Skip to main content
Mathematics LibreTexts

5.11: Directed Graphs

  • Page ID
    7209
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    A directed graph, also called a digraph, is a graph in which the edges have a direction. This is usually indicated with an arrow on the edge; more formally, if \(v\) and \(w\) are vertices, an edge is an unordered pair \(\{v,w\}\), while a directed edge, called an arc, is an ordered pair \((v,w)\) or \((w,v)\). The arc \((v,w)\) is drawn as an arrow from \(v\) to \(w\). If a graph contains both arcs \((v,w)\) and \((w,v)\), this is not a "multiple edge'', as the arcs are distinct. It is possible to have multiple arcs, namely, an arc \((v,w)\) may be included multiple times in the multiset of arcs. As before, a digraph is called simple if there are no loops or multiple arcs.

    We denote by \(E\strut_v^-\) the set of all arcs of the form \((w,v)\), and by \(E_v^+\) the set of arcs of the form \((v,w)\). The indegree of \(v\), denoted \(\text{d}^-(v)\), is the number of arcs in \(E\strut_v^-\), and the outdegree, \(\text{d}^+(v)\), is the number of arcs in \(E_v^+\). If the vertices are \(v_1,v_2,\ldots,v_n\), the degrees are usually denoted \(d^-_1,d^-_2,\ldots,d^-_n\) and \(d^+_1,d^+_2,\ldots,d^+_n\). Note that both \(\sum_{i=0}^n \text{d}^-_i\) and \(\sum_{i=0}^n \text{d}^+_i\) count the number of arcs exactly once, and of course \(\sum_{i=0}^n \text{d}^-_i=\sum_{i=0}^n \text{d}^+_i\). A walk in a digraph is a sequence \(v_1,e_1,v_2,e_2,\ldots,v_{k-1},e_{k-1},v_k\) such that \(e_k=(v_i,v_{i+1})\); if \(v_1=v_k\), it is a closed walk or a circuit. A path in a digraph is a walk in which all vertices are distinct. It is not hard to show that, as for graphs, if there is a walk from \(v\) to \(w\) then there is a path from \(v\) to \(w\).

    Many of the topics we have considered for graphs have analogues in digraphs, but there are many new topics as well. We will look at one particularly important result in the latter category.

    Definition \(\PageIndex{1}\): Network

    A network is a digraph with a designated source \(s\) and target \(t\not=s\). In addition, each arc \(e\) has a positive capacity, \(c(e)\).

    Networks can be used to model transport through a physical network, of a physical quantity like oil or electricity, or of something more abstract, like information.

    Definition \(\PageIndex{2}\): Flow

    A flow in a network is a function \(f\) from the arcs of the digraph to \(\mathbb{R}\), with \(0\le f(e)\le c(e)\) for all \(e\), and such that \[\sum_{e\in E_v^+}f(e)=\sum_{e\in E_v^-}f(e),\nonumber\] for all \(v\) other than \(s\) and \(t\).

    We wish to assign a value to a flow, equal to the net flow out of the source. Since the substance being transported cannot "collect'' or "originate'' at any vertex other than \(s\) and \(t\), it seems reasonable that this value should also be the net flow into the target.

    Before we prove this, we introduce some new notation. Suppose that \(U\) is a set of vertices in a network, with \(s\in U\) and \(t\notin U\). Let \(\overset{\longrightarrow}{U}\) be the set of arcs \((v,w)\) with \(v\in U\), \(w\notin U\), and \(\overset{\longleftarrow}{U}\) be the set of arcs \((v,w)\) with \(v\notin U\), \(w\in U\).

    Theorem \(\PageIndex{1}\)

    For any flow \(f\) in a network, the net flow out of the source is equal to the net flow into the target, namely, \[\sum_{e\in E_s^+} f(e)-\sum_{e\in E_s^-}f(e)= \sum_{e\in E_t^-} f(e)-\sum_{e\in E_t^+}f(e).\nonumber\]

    Proof

    We will show first that for any \(U\) with \(s\in U\) and \(t\notin U\), \[\sum_{e\in E_s^+} f(e)-\sum_{e\in E_s^-}f(e)= \sum_{e\in\overset{\longrightarrow}{U}} f(e)-\sum_{e\in\overset{\longleftarrow}{U}}f(e).\nonumber\]

    Consider the following: \[S=\sum_{v\in U}\left(\sum_{e\in E_v^+}f(e)-\sum_{e\in E_v^-}f(e)\right).\nonumber\] The quantity \[\sum_{e\in E_v^+}f(e)-\sum_{e\in E_v^-}f(e)\nonumber\] is zero except when \(v=s\), by the definition of a flow. Thus, the entire sum \(S\) has value \[\sum_{e\in E_s^+} f(e)-\sum_{e\in E_s^-}f(e).\nonumber\] On the other hand, we can write the sum \(S\) as \[ \sum_{v\in U}\sum_{e\in E_v^+}f(e)- \sum_{v\in U}\sum_{e\in E_v^-}f(e). \nonumber\] Every arc \(e=(x,y)\) with both \(x\) and \(y\) in \(U\) appears in both sums, that is, in \[\sum_{v\in U}\sum_{e\in E_v^+}f(e),\nonumber\] when \(v=x\), and in \[\sum_{v\in U}\sum_{e\in E_v^-}f(e),\nonumber\] when \(v=y\), and so the flow in such arcs contributes \(0\) to the overall value. Thus, only arcs with exactly one endpoint in \(U\) make a non-zero contribution, so the entire sum reduces to \[\sum_{e\in \overset{\longrightarrow}{U} } f(e)-\sum_{e\in \overset{\longleftarrow}{U} }f(e).\nonumber\] Thus \[\sum_{e=(s,v)} f(e)-\sum_{e=(v,s)}f(e)=S= \sum_{e\in \overset{\longrightarrow}{U} } f(e)-\sum_{e\in \overset{\longleftarrow}{U} }f(e),\nonumber\] as desired.

    Now let \(U\) consist of all vertices except \(t\). Then \[ \sum_{e\in E_s^+} f(e)-\sum_{e\in E_s^-}f(e)= \sum_{e\in \overset{\longrightarrow}{U} } f(e)-\sum_{e\in \overset{\longleftarrow}{U} }f(e)= \sum_{e\in E_t^-} f(e)-\sum_{e\in E_t^+}f(e), \nonumber\] finishing the proof.

    Definition \(\PageIndex{3}\): Value

    The value of a flow, denoted \(\text{val}(f)\), is \(\sum_{e\in E_s^+} f(e)-\sum_{e\in E_s^-}f(e)\). A maximum flow in a network is any flow \(f\) whose value is the maximum among all flows.

    We next seek to formalize the notion of a "bottleneck'', with the goal of showing that the maximum flow is equal to the amount that can pass through the smallest bottleneck.

    Definition \(\PageIndex{4}\): Cut

    A cut in a network is a set \(C\) of arcs with the property that every path from \(s\) to \(t\) uses an arc in \(C\), that is, if the arcs in \(C\) are removed from the network there is no path from \(s\) to \(t\). The capacity of a cut, denoted \(c(C)\), is \[\sum_{e\in C} c(e).\nonumber\] A minimum cut is one with minimum capacity. A cut \(C\) is minimal if no cut is properly contained in \(C\).

    Note that a minimum cut is a minimal cut. Clearly, if \(U\) is a set of vertices containing \(s\) but not \(t\), then \(\overset{\longrightarrow}{U}\) is a cut.

    Lemma \(\PageIndex{1}\)

    Suppose \(C\) is a minimal cut. Then there is a set \(U\) containing \(s\) but not \(t\) such that \(C=\overset{\longrightarrow}{U}\).

    Proof

    Let \(U\) be the set of vertices \(v\) such that there is a path from \(s\) to \(v\) using no arc in \(C\).

    Suppose that \(e=(v,w)\in C\). Since \(C\) is minimal, there is a path \(P\) from \(s\) to \(t\) using \(e\) but no other arc in \(C\). Thus, there is a path from \(s\) to \(v\) using no arc of \(C\), so \(v\in U\). If there is a path from \(s\) to \(w\) using no arc of \(C\), then this path followed by the portion of \(P\) that begins with \(w\) is a walk from \(s\) to \(t\) using no arc in \(C\). This implies there is a path from \(s\) to \(t\) using no arc in \(C\), a contradiction. Thus \(w\notin U\) and so \(e\in \overset{\longrightarrow}{U}\). Hence, \(C\subseteq \overset{\longrightarrow}{U}\).

    Suppose that \(e=(v,w)\in \overset{\longrightarrow}{U}\). Then \(v\in U\) and \(w\notin U\), so every path from \(s\) to \(w\) uses an arc in \(C\). Since \(v\in U\), there is a path from \(s\) to \(v\) using no arc of \(C\), and this path followed by \(e\) is a path from \(s\) to \(w\). Hence the arc \(e\) must be in \(C\), so \(\overset{\longrightarrow}{U}\subseteq C\).

    We have now shown that \(C=\overset{\longrightarrow}{U}\).

    Now we can prove a version of the important max-flow, min cut theorem.

    Theorem \(\PageIndex{2}\)

    Suppose in a network all arc capacities are integers. Then the value of a maximum flow is equal to the capacity of a minimum cut. Moreover, there is a maximum flow \(f\) for which all \(f(e)\) are integers.

    Proof

    First we show that for any flow \(f\) and cut \(C\), \(\text{val}(f)\le c(C)\). It suffices to show this this for a minimum cut \(C\), and by Lemma \(\PageIndex{1}\) we know that \(C=\overset{\longrightarrow}{U}\) for some \(U\). Using the proof of Theorem \(\PageIndex{1}\) we have: \[ \text{val}(f) = \sum_{e\in\overset{\longrightarrow}{U}} f(e)-\sum_{e\in\overset{\longleftarrow}{U}}f(e) \le \sum_{e\in\overset{\longrightarrow}{U}} f(e) \le \sum_{e\in\overset{\longrightarrow}{U}} c(e) = c(\overset{\longrightarrow}{U}). \nonumber\] Now if we find a flow \(f\) and cut \(C\) with \(\text{val}(f)=c(C)\), it follows that \(f\) is a maximum flow and \(C\) is a minimum cut. We present an algorithm that will produce such an \(f\) and \(C\).

    Given a flow \(f\), which may initially be the zero flow, \(f(e)=0\) for all arcs \(e\), do the following:

    1. Let \(U=\{s\}\).
      Repeat the next two steps until no new vertices are added to \(U\).
    2. If there is an arc \(e=(v,w)\) with \(v\in U\) and \(w\notin U\), and \(f(e)< c(e)\), add \(w\) to \(U\).
    3. If there is an arc \(e=(v,w)\) with \(v\notin U\) and \(w\in U\), and \(f(e)>0\), add \(v\) to \(U\).

    When this terminates, either \(t\in U\) or \(t\notin U\). If \(t\in U\), there is a sequence of distinct vertices \(s=v_1,v_2,v_3,\ldots,v_k=t\) such that for each \(i\), \(1\le i< k\), either \(e=(v_i,v_{i+1})\) is an arc with \(f(e)< c(e)\) or \(e=(v_{i+1},v_i)\) is an arc with \(f(e)>0\). Update the flow by adding \(1\) to \(f(e)\) for each of the former, and subtracting \(1\) from \(f(e)\) for each of the latter. This new flow \(f'\) is still a flow: In the first case, since \(f(e)< c(e)\), \(f'(e)\le c(e)\), and in the second case, since \(f(e)>0\), \(f'(e)\ge 0\). It is straightforward to check that for each vertex \(v_i\), \(1< i< k\), that \[\sum_{e\in E_{v_i}^+}f'(e)=\sum_{e\in E_{v_i}^-}f'(e).\nonumber\] In addition, \(\text{val}(f')=\text{val}(f)+1\). Now rename \(f'\) to \(f\) and repeat the algorithm.

    Eventually, the algorithm terminates with \(t\notin U\) and flow \(f\). This implies that for each \(e=(v,w)\) with \(v\in U\) and \(w\notin U\), \(f(e)=c(e)\), and for each \(e=(v,w)\) with \(v\notin U\) and \(w\in U\), \(f(e)=0\). The capacity of the cut \(\overset{\longrightarrow}{U}\) is \[\sum_{e\in\overset{\longrightarrow}{U}} c(e).\nonumber\] The value of the flow \(f\) is \[ \sum_{e\in\overset{\longrightarrow}{U}} f(e)-\sum_{e\in\overset{\longleftarrow}{U}}f(e)= \sum_{e\in\overset{\longrightarrow}{U}} c(e)-\sum_{e\in\overset{\longleftarrow}{U}}0= \sum_{e\in\overset{\longrightarrow}{U}} c(e). \nonumber\] Thus we have found a flow \(f\) and cut \(\overset{\longrightarrow}{U}\) such that \[ \text{val}(f) = c(\overset{\longrightarrow}{U}), \nonumber\] as desired.

    The max-flow, min-cut theorem is true when the capacities are any positive real numbers, though of course the maximum value of a flow will not necessarily be an integer in this case. It is somewhat more difficult to prove, requiring a proof involving limits.

    We have already proved that in a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover, Theorem 4.6.4. This turns out to be essentially a special case of the max-flow, min-cut theorem.

    Corollary \(\PageIndex{1}\)

    In a bipartite graph \(G\), the size of a maximum matching is the same as the size of a minimum vertex cover.

    Proof

    Suppose the parts of \(G\) are \(X=\{x_1,x_2,\ldots,x_k\}\) and \(Y=\{y_1,y_2,\ldots,y_l\}\). Create a network as follows: introduce two new vertices \(s\) and \(t\) and arcs \((s,x_i)\) for all \(i\) and \((y_i,t)\) for all \(i\). For each edge \(\{x_i,y_j\}\) in \(G\), let \((x_i,y_j)\) be an arc. Let \(c(e)=1\) for all arcs \(e\). Now the value of a maximum flow is equal to the capacity of a minimum cut.

    Let \(C\) be a minimum cut. If \((x_i,y_j)\) is an arc of \(C\), replace it by arc \((s,x_i)\). This is still a cut, since any path from \(s\) to \(t\) including \((x_i,y_j)\) must include \((s,x_i)\). Thus, we may suppose that \(C\) contains only arcs of the form \((s,x_i)\) and \((y_i,t)\). Now it is easy to see that \[K=\{x_i\vert (s,x_i)\in C\}\cup\{y_i\vert (y_i,t)\in C\}\nonumber\] is a vertex cover of \(G\) with the same size as \(C\).

    Let \(f\) be a maximum flow such that \(f(e)\) is an integer for all \(e\), which is possible by the max-flow, min-cut theorem. Consider the set of edges \[M=\{\{x_i,y_j\}\vert f((x_i,y_j))=1\}.\nonumber\] If \(\{x_i,y_j\}\) and \(\{x_i,y_m\}\) are both in this set, then the flow out of vertex \(x_i\) is at least 2, but there is only one arc into \(x_i\), \((s,x_i)\), with capacity 1, contradicting the definition of a flow. Likewise, if \(\{x_i,y_j\}\) and \(\{x_m,y_j\}\) are both in this set, then the flow into vertex \(y_j\) is at least 2, but there is only one arc out of \(y_j\), \((y_j,t)\), with capacity 1, also a contradiction. Thus \(M\) is a matching. Moreover, if \(U=\{s,x_1,\ldots,x_k\}\) then the value of the flow is \[ \sum_{e\in\overset{\longrightarrow}{U}}f(e)-\sum_{e\in\overset{\longleftarrow}{U}}f(e)= \sum_{e\in\overset{\longrightarrow}{U}}f(e)=|M|\cdot1=|M|. \nonumber\] Thus \(|M|=\text{val}(f)=c(C)=|K|\), so we have found a matching and a vertex cover with the same size. This implies that \(M\) is a maximum matching and \(K\) is a minimum vertex cover.


    This page titled 5.11: Directed Graphs is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by David Guichard via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.