### Graphs: Dinic picture and code

parent 56200b30
 ... ... @@ -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 ... ...  ... ... @@ -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 ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!