Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
ds2-notes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
datovky
ds2-notes
Commits
d737c1ba
Commit
d737c1ba
authored
3 years ago
by
Ondřej Mička
Browse files
Options
Downloads
Patches
Plain Diff
Graphs: Dinic picture and code
parent
56200b30
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
om-graphs/Makefile
+1
-1
1 addition, 1 deletion
om-graphs/Makefile
om-graphs/graphs.tex
+26
-4
26 additions, 4 deletions
om-graphs/graphs.tex
with
27 additions
and
5 deletions
om-graphs/Makefile
+
1
−
1
View file @
d737c1ba
...
...
@@ -2,7 +2,7 @@ TOP=..
include
../Makerules
IMAGES
=
range-tree lazy-update heavy-light expose-idea middle-sons expose-real expose-phases
IMAGES
=
range-tree lazy-update heavy-light expose-idea middle-sons expose-real expose-phases
level-network
$(MAIN).pdf
:
images
...
...
This diff is collapsed.
Click to expand it.
om-graphs/graphs.tex
+
26
−
4
View file @
d737c1ba
...
...
@@ -78,7 +78,7 @@ from $x$ to $z$. The node~$x$ is marked, with $\delta = +4$, so we need to incre
stored in~
$
x
$
by~4 and transfer mark to both children of~
$
x
$
. Then we can visit~
$
x
$
and
move along to~
$
y
$
. Node~
$
y
$
is also marked now, so we update~
$
y
$
and transfer mark to both
children. Left child of~
$
y
$
was already marked by
$
+
3
$
, so we have change the mark to
$
+
7
$
.
\TODO
shorter caption
}
$
+
7
$
.
}
\qed
...
...
@@ -110,7 +110,7 @@ linear time.
\figure
[]
{
heavy-light.pdf
}{}{
Example of heavy-light decomposition. Top part shows a tree
with heavy paths marked by thick lines. Numbers in parenthesis show the value of
$
s
(
v
)
$
(ones are omitted). Bottom part shows the tree after compression of non-trivial heavy
paths.
\TODO
shorter caption
}
paths.
}
\subsection
{
Lowest common ancestor
}
A simple application of heavy-light decomposition is a data structure to answer lowest
...
...
@@ -464,9 +464,12 @@ from~$s$ to~$t$ in the residual network\footnote{Residual network is a network c
the edges with non-zero residual capacity, that is, difference between capacity and a
flow. Capacity of each edge in residual network is exactly the residual capacity.
}
. The
important property of level graph is that it is acyclic and it can be decomposed into
levels such that there are no edges between vertices in each level, see Figure~
\TODO
level
levels such that there are no edges between vertices in each level, see
Figure~
\figref
{
level-network
}
level
graph.
\figure
[level-network]
{
level-network.pdf
}{}{
Example of a level network.
}
Dinic's algorithm starts with a zero flow and in each iteration it finds a blocking flow
in the level graph and augments the flow with the blocking flow. It can be shown that we
need~
$
n
$
iterations to find the maximum flow in~
$
G
$
.
...
...
@@ -495,6 +498,15 @@ $s \to t$ and perform a path update that decreases costs on $s\to t$ by $\Cost(e
This corresponds to increasing the flow on
$
s
\to
t
$
by
$
\Cost
(
e
)
$
. If
$
\Cost
(
e
)
=
0
$
we
simply cut~
$
e
$
and remove it from
$
F
$
.
\proc
{
Augment step
}
\:
If
$
\Root
(
s
)
=
t
$
, then:
\:
:
$
e
\=
\op
{
PathMin
}
(
s
)
$
\:
:If
$
\Cost
(
e
)
=
0
$
:
\:
::
$
\op
{
Cut
}
(
e
)
$
\:
:else:
\:
::
$
\op
{
PathUpdate
}
(
s,
-
\Cost
(
e
))
$
\endalgo
The other step is expand step which is performed when
$
\Root
(
s
)
=
r
\neq
t
$
. If
$
r
$
has an unmarked outgoing edge~
$
e
$
we simply add~
$
e
$
to~
$
F
$
using
$
\op
{
Link
}
(
e
)
$
and we
mark~
$
e
$
. However, if there is no such edge, all
$
s
\to
t
$
paths via~
$
r
$
are already
...
...
@@ -502,7 +514,17 @@ blocked and we may remove~$r$ from~$F$ for good. That is, we remove all edges th
to~
$
r
$
. Marked edges still present in~
$
F
$
are cut and deleted from~
$
F
$
, unmarked edges are
marked but not added to~
$
F
$
.
\TODO
algorithm pseudocode
\proc
{
Expand step
}
\:
$
r
\=
\Root
(
s
)
$
\:
If
$
r
\neq
t
$
:
\:
:If exists unmarked edge~
$
e
$
going from
$
r
$
:
\:
::
$
\op
{
Mark
}
(
e
)
$
\:
::
$
\op
{
Link
}
(
e
)
$
\:
:else:
\:
:: For each edge
$
e
=
(
u,r
)
$
:
\:
:::
$
\op
{
Mark
}
(
e
)
$
\:
:::
$
\op
{
Cut
}
(
e
)
$
\cmt
{
Cut does nothing if
$
e
$
is not in the tree
}
\endalgo
We repeat these steps until
$
\Root
(
s
)
=
s
$
and all edges going out from~
$
s
$
are marked.
That is, we stop when
$
s
$
would be removed from~
$
F
$
during expand step. Using simple
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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