diff --git a/Advanced/Graph Algorithms/parts/00 review.tex b/Advanced/Graph Algorithms/parts/00 review.tex index 3781dae..db4e0f4 100755 --- a/Advanced/Graph Algorithms/parts/00 review.tex +++ b/Advanced/Graph Algorithms/parts/00 review.tex @@ -2,7 +2,7 @@ \definition{} A \textit{graph} consists of a set of \textit{nodes} $\{A, B, ...\}$ and a set of edges $\{ (A,B), (A,C), ...\}$ connecting them. -A \textit{directed graph} is a graph where edges have direction. In such a graph, $(A, B)$ and $(B, A)$ are distinct edges. +A \textit{directed graph} is a graph where edges have direction. In such a graph, edges $(A, B)$ and $(B, A)$ are distinct. A \textit{weighted graph} is a graph that features weights on its edges. \\ A weighted directed graph is shown below. @@ -28,8 +28,7 @@ A weighted directed graph is shown below. \vfill \definition{} -We say a graph is \textit{bipartite} if its nodes can be split into two groups $L$ and $R$ so that no two nodes in the same group are connected by an edge. \\ -The following graph is bipartite: +We say a graph is \textit{bipartite} if its nodes can be split into two groups $L$ and $R$, where no two nodes in the same group are connected by an edge: \\ \begin{center} \begin{tikzpicture} @@ -39,9 +38,9 @@ The following graph is bipartite: \node[main] (B) at (0mm, -10mm) {$B$}; \node[main] (C) at (0mm, -20mm) {$C$}; - \node[main] (D) at (20mm, 0mm) {$D$}; - \node[main] (E) at (20mm, -10mm) {$E$}; - \node[main] (F) at (20mm, -20mm) {$F$}; + \node[main, hatch] (D) at (20mm, 0mm) {$D$}; + \node[main, hatch] (E) at (20mm, -10mm) {$E$}; + \node[main, hatch] (F) at (20mm, -20mm) {$F$}; \end{scope} % Edges @@ -55,30 +54,5 @@ The following graph is bipartite: \end{tikzpicture} \end{center} -\vfill - -\definition{} -We say two nodes $A$ ane $B$ are \textit{connected} if we can reach $A$ from $B$ and $B$ from $A$ by walking along (possibly directed) edges. We say a graph is connected if all its nodes are connected to each other.\\ - -The bipartite graph above and the directed graph below are not connected. - -\begin{center} - \begin{tikzpicture}[node distance = 20mm] - % Nodes - \begin{scope} - \node[main] (A) {$A$}; - \node[main] (B) [below right of = A] {$B$}; - \node[main] (C) [below left of = A] {$C$}; - \end{scope} - - % Edges - \draw[->] - (A) edge[bend right] (B) - (B) edge[bend right] (A) - (B) edge (C) - ; - \end{tikzpicture} -\end{center} - \vfill \pagebreak \ No newline at end of file diff --git a/Advanced/Graph Algorithms/parts/01 flow.tex b/Advanced/Graph Algorithms/parts/01 flow.tex index 07b1361..538f83b 100755 --- a/Advanced/Graph Algorithms/parts/01 flow.tex +++ b/Advanced/Graph Algorithms/parts/01 flow.tex @@ -1,23 +1,23 @@ \section{Network Flow} \generic{Networks} -Say have a network: a sequence of pipes, a set of cities and highways, an electrical circuit, server infrastructure, etc. +Say have a network: a sequence of pipes, a set of cities and highways, an electrical circuit, etc. \vspace{1ex} -We'll represent our network with a connected directed weighted graph. If we take a city, edges will be highways and cities will be nodes. There are a few conditions for a valid network graph: +We can draw this network as a directed weighted graph. If we take a transporation network, for example, edges will represent highways and nodes will be cities. There are a few conditions for a valid network graph: \begin{itemize} - \item The weight of each edge represents its capacity, the number of lanes in the highway. + \item The weight of each edge represents its capacity, e.g, the number of lanes in the highway. \item Edge capacities are always positive integers.\hspace{-0.5ex}\footnotemark{} \item Node $S$ is a \textit{source}: it produces flow. \item Node $T$ is a \textit{sink}: it consumes flow. - \item All other nodes \textit{conserve} flow. In other words, the sum of flow coming in must equal the sum of flow going out. + \item All other nodes \textit{conserve} flow. The sum of flow coming in must equal the sum of flow going out. \end{itemize} \footnotetext{An edge with capacity zero is equivalent to an edge that does not exist; An edge with negative capacity is equivalent to an edge in the opposite direction.} -Here is an example of a such a graph: +Here is an example of such a graph: \begin{center} \begin{tikzpicture} @@ -43,7 +43,7 @@ Here is an example of a such a graph: \hrule{} \generic{Flow} -In our city example, cars represent \textit{flow}. Let's send one unit of cars along the topmost highway: +In our city example, traffic represents \textit{flow}. Let's send one unit of traffic along the topmost highway: \vspace{2ex} @@ -89,11 +89,9 @@ In our city example, cars represent \textit{flow}. Let's send one unit of cars a \vspace{1ex} -The \textit{magnitude} of a flow\footnotemark{} is the number of \say{flow-units} that go from $S$ to $T$. \\ +The \textit{magnitude} of a flow is the number of \say{flow-units} that go from $S$ to $T$. \\ -We are interested in the \textit{maximum flow} through this network: what is the greatest amount of flow we can push from $S$ to $T$? - -\footnotetext{you could also think of \say{flow} as a directed weighted graph on top of our network.} +We are interested in the \textit{maximum flow} through this network: what is the greatest amount of flow we can get from $S$ to $T$? \problem{} What is the magnitude of the flow above? @@ -156,7 +154,8 @@ Find a maximal flow on the graph below. \\ \pagebreak \section{Combining Flows} -It is fairly easy to combine two flows on a graph. All we need to do is add the flows along each edge. For example, consider the following flows: +It is fairly easy to combine two flows on a graph. All we need to do is add the flows along each edge. \\ +Consider the following flows: \vspace{2ex} @@ -266,11 +265,7 @@ It is fairly easy to combine two flows on a graph. All we need to do is add the \vspace{1ex} - For example, we could not add these graphs if the magnitude of flow in the right graph above was 2. - - \vspace{1ex} - - This is because the capacity of the top-right edge is 2, and $2 + 1 > 2$. + For example, we could not add these graphs if the magnitude of flow in the right graph above was 2, since the capacity of the top-right edge is 2, and $2 + 1 > 2$. \end{minipage} \vspace{2ex} @@ -278,7 +273,7 @@ It is fairly easy to combine two flows on a graph. All we need to do is add the \vspace{2ex} \problem{} -Combine the following flows and ensure that the flow along all edges remains within capacity. +Combine the flows below, ensuring that the flow along each edge remains within capacity. \vspace{2ex} diff --git a/Advanced/Graph Algorithms/parts/02 residual.tex b/Advanced/Graph Algorithms/parts/02 residual.tex index f8ff5c6..f37e946 100755 --- a/Advanced/Graph Algorithms/parts/02 residual.tex +++ b/Advanced/Graph Algorithms/parts/02 residual.tex @@ -1,9 +1,10 @@ \section{Residual Graphs} -As our network gets bigger, finding a maximum flow by hand becomes much more difficult. It will be convenient to have an algorithm that finds a maximal flow in any network. +It is hard to find a maximum flow for a large network by hand. \\ +We need to create an algorithm to accomplish this task. \vspace{1ex} -The first thing we'll need to construct such an algorithm is a \textit{residual graph}. +The first thing we'll is the notion of a \textit{residual graph}. \vspace{2ex} \hrule @@ -202,11 +203,9 @@ If it isn't, find a maximal flow. \\ \problem{} Show that... \begin{enumerate} - \item A maximal flow exists in every network with integral\footnotemark{} edge weights. + \item A maximal flow exists in every network with integral edge weights. \item Every edge in this flow carries an integral amount of flow \end{enumerate} -\footnotetext{Integral = \say{integer} as an adjective.} - \vfill \pagebreak \ No newline at end of file diff --git a/Advanced/Graph Algorithms/parts/03 fulkerson.tex b/Advanced/Graph Algorithms/parts/03 fulkerson.tex index f1524c1..cf837bc 100755 --- a/Advanced/Graph Algorithms/parts/03 fulkerson.tex +++ b/Advanced/Graph Algorithms/parts/03 fulkerson.tex @@ -108,7 +108,7 @@ There is extra space on the next page. \pagebreak \problem{} -You are given a large network. How would you quickly find an upper bound for the number of iterations the Ford-Fulkerson algorithm will need to find a maximum flow? +You are given a large network. How can you quickly find an upper bound for the number of iterations the Ford-Fulkerson algorithm will need to find a maximum flow? \begin{solution} Each iteration adds at least one unit of flow. So, we will find a maximum flow in at most $\min(\text{flow out of } S,~\text{flow into } T)$ iterations. diff --git a/Advanced/Graph Algorithms/parts/04 applications.tex b/Advanced/Graph Algorithms/parts/04 applications.tex index 883db36..e648a24 100755 --- a/Advanced/Graph Algorithms/parts/04 applications.tex +++ b/Advanced/Graph Algorithms/parts/04 applications.tex @@ -86,8 +86,9 @@ A matching is \textit{maximal} if it has more edges than any other matching. \vspace{5mm} -Devise an algorithm to find a maximal matching in any bipartite graph. \\ -Find an upper bound for its runtime. +Create an algorithm that finds a maximal matching in any bipartite graph. \\ +Find an upper bound for its runtime. \\ +\hint{Can you modify an algorithm we already know?} \begin{solution} Turn this into a maximum flow problem and use FF. \\ @@ -101,7 +102,7 @@ Find an upper bound for its runtime. \vfill \pagebreak -\problem{Circulations with Demand} +\problem{Supply and Demand} Say we have a network of cities and power stations. Stations produce power; cities consume it. @@ -146,7 +147,7 @@ We'll represent station capacity with a negative number, since they \textit{cons \end{tikzpicture} \end{center} -We'd like to know if there exists a \textit{feasible circulation} in this network---that is, can we supply our cities with the energy they need without exceeding the capacity of power plants or transmission lines? +We'd like to know if there exists a \textit{feasible circulation} in this network---that is, can we supply our cities with the energy they need without exceeding the capacity of our power plants and transmission lines? \vspace{2ex} diff --git a/Advanced/Graph Algorithms/parts/05 reductions.tex b/Advanced/Graph Algorithms/parts/05 reductions.tex index 9376b27..0ad1859 100755 --- a/Advanced/Graph Algorithms/parts/05 reductions.tex +++ b/Advanced/Graph Algorithms/parts/05 reductions.tex @@ -8,11 +8,7 @@ An \textit{independent set} is a set of vertices\footnotemark{} in which no two \begin{center} \begin{tikzpicture}[ - node distance = 12mm, - hatch/.style = { - pattern=north west lines, - pattern color=gray - } + node distance = 12mm ] % Nodes \begin{scope}[layer = nodes] @@ -48,11 +44,7 @@ A \textit{vertex cover} is a set of vertices that includes at least one endpoint \begin{center} \begin{tikzpicture}[ - node distance = 12mm, - hatch/.style = { - pattern=north west lines, - pattern color=gray - } + node distance = 12mm ] % Nodes \begin{scope}[layer = nodes] diff --git a/Advanced/Graph Algorithms/parts/06 bonus.tex b/Advanced/Graph Algorithms/parts/06 bonus.tex index 83d5438..be94bae 100644 --- a/Advanced/Graph Algorithms/parts/06 bonus.tex +++ b/Advanced/Graph Algorithms/parts/06 bonus.tex @@ -1,6 +1,6 @@ -\section{Crosses (Bonus Problem)} +\section{Crosses} -You are given an $n \times n$ grid. Some of its squares are white, and some are gray. Your goal is to place $n$ crosses on white cells so that each row and each column contains exactly one cross. +You are given an $n \times n$ grid. Some of its squares are white, some are gray. Your goal is to place $n$ crosses on white cells so that each row and each column contains exactly one cross. \vspace{2ex} diff --git a/Advanced/Graph Algorithms/tikxset.tex b/Advanced/Graph Algorithms/tikxset.tex index 9c0d794..4991f1d 100644 --- a/Advanced/Graph Algorithms/tikxset.tex +++ b/Advanced/Graph Algorithms/tikxset.tex @@ -49,5 +49,9 @@ % completely under nodes. line cap = rect, opacity = 0.3 + }, + hatch/.style = { + pattern=north west lines, + pattern color=gray } } \ No newline at end of file