Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
datovky
ds2notes
Commits
d737c1ba
Commit
d737c1ba
authored
Aug 25, 2021
by
Ondřej Mička
Browse files
Graphs: Dinic picture and code
parent
56200b30
Changes
2
Hide whitespace changes
Inline
Sidebyside
omgraphs/Makefile
View file @
d737c1ba
...
...
@@ 2,7 +2,7 @@ TOP=..
include
../Makerules
IMAGES
=
rangetree lazyupdate heavylight exposeidea middlesons exposereal exposephases
IMAGES
=
rangetree lazyupdate heavylight exposeidea middlesons exposereal exposephases
levelnetwork
$(MAIN).pdf
:
images
...
...
omgraphs/graphs.tex
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
[]
{
heavylight.pdf
}{}{
Example of heavylight 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 nontrivial heavy
paths.
\TODO
shorter caption
}
paths.
}
\subsection
{
Lowest common ancestor
}
A simple application of heavylight 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 nonzero 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
{
levelnetwork
}
level
graph.
\figure
[levelnetwork]
{
levelnetwork.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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment