Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
psco-2019-gp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Scherzer
psco-2019-gp
Commits
36a4904b
Commit
36a4904b
authored
5 years ago
by
Lukas Garbas
Committed by
p-hamann
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Push-relabel adjacency as reference
parent
f9af5a80
Branches
Branches containing commit
1 merge request
!7
Incremental bfs
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bnb/push_relabel.cpp
+6
-4
6 additions, 4 deletions
bnb/push_relabel.cpp
include/gp-bnb/push_relabel.hpp
+5
-6
5 additions, 6 deletions
include/gp-bnb/push_relabel.hpp
with
11 additions
and
10 deletions
bnb/push_relabel.cpp
+
6
−
4
View file @
36a4904b
...
...
@@ -5,6 +5,9 @@
push_relabel
::
push_relabel
(
const
graph
&
g
,
std
::
vector
<
node_id
>
sources
,
std
::
vector
<
node_id
>
sinks
)
:
g_
(
g
),
sources_
(
sources
),
sinks_
(
sinks
)
{
// Initial flow value
flow_value_
=
0
;
int
num_nodes
=
g_
.
num_nodes
();
// Initialize all vectors
...
...
@@ -41,7 +44,7 @@ void push_relabel::relabel(node_id u) {
int
d
=
std
::
numeric_limits
<
int
>::
max
();
std
::
vector
<
node_id
>
neighbors
=
g_
.
get_adjacency
(
u
);
const
std
::
vector
<
node_id
>
&
neighbors
=
g_
.
get_adjacency
(
u
);
for
(
auto
v
:
neighbors
)
{
if
(
1
-
flow_
[
u
][
v
]
>
0
)
...
...
@@ -58,7 +61,7 @@ void push_relabel::discharge(node_id u) {
while
(
excess_
[
u
]
>
0
)
{
std
::
vector
<
node_id
>
neighbors
=
g_
.
get_adjacency
(
u
);
const
std
::
vector
<
node_id
>
&
neighbors
=
g_
.
get_adjacency
(
u
);
bool
push_possible
=
false
;
for
(
auto
v
:
neighbors
)
{
...
...
@@ -87,7 +90,7 @@ void push_relabel::preflow() {
}
for
(
node_id
s
:
sources_
)
{
std
::
vector
<
node_id
>
neighbors
=
g_
.
get_adjacency
(
s
);
const
std
::
vector
<
node_id
>
&
neighbors
=
g_
.
get_adjacency
(
s
);
for
(
auto
n
:
neighbors
)
{
if
(
sources_and_sinks_
[
n
]
!=
1
)
// if n is not a source node
push
(
s
,
n
);
...
...
@@ -109,7 +112,6 @@ void push_relabel::run() {
}
// Flow value is the sum of excesses in sinks
flow_value_
=
0
;
for
(
node_id
t
:
sinks_
)
flow_value_
+=
excess_
[
t
];
...
...
This diff is collapsed.
Click to expand it.
include/gp-bnb/push_relabel.hpp
+
5
−
6
View file @
36a4904b
...
...
@@ -30,22 +30,21 @@ private:
public:
/**
* Constructs an instance of the
EdmondsKarp
algorithm for the given graph, source and sink
* Constructs an instance of the
Push-Realbel
algorithm for the given graph, source
s
and sink
s
* @param graph The graph.
* @param source
The
source node.
* @param sink
The
sink node.
* @param source
s Vector of
source node
s
.
* @param sink
s Vector of
sink node
s
.
*/
push_relabel
(
const
graph
&
g
,
std
::
vector
<
node_id
>
sources
,
std
::
vector
<
node_id
>
sinks
);
/**
* Computes the maximum flow, executes the
EdmondsKarp algorithm
.
* Computes the maximum flow, executes the
Peush-Relabel algorithm with discharge
.
* For unweighted, undirected Graphs.
*/
void
run
();
/**
* Returns the value of the maximum flow from source to sink.
*
* Returns the value of the maximum flow from sources to sinks.
* @return The maximum flow value
*/
int
get_max_flow
()
const
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment