% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. % Last built with version 1.1.0 \documentclass[ solutions ]{ormc_handout} \usepackage{subfiles} \usetikzlibrary{arrows.meta} \usetikzlibrary{shapes.geometric} % We put nodes in a separate layer, so we can % slightly overlap with paths for a perfect fit \pgfdeclarelayer{nodes} \pgfdeclarelayer{path} \pgfsetlayers{main,nodes} % Layer settings \tikzset{ % Layer hack, lets us write % later = * in scopes. layer/.style = { execute at begin scope={\pgfonlayer{#1}}, execute at end scope={\endpgfonlayer} }, % % Arrowhead tweaks >={Latex[ width=2mm, length=2mm ]}, label/.style = { circle, % For automatic red background in solutions fill = \ORMCbgcolor, draw = none }, % % Nodes main/.style = { draw, circle, fill = white }, % % Flow annotations flow/.style = { opacity = 1, thin, inner xsep = 2.5mm, inner ysep = 2.5mm }, % % Paths path/.style = { line width = 4mm, draw = black, % Lengthen paths so they're % completely under nodes. line cap = rect, opacity = 0.3 } } \begin{document} \maketitle {Algorithms on Graphs: Flow} {Prepared by Mark on \today} \subfile{parts/00 review} \subfile{parts/01 flow} \subfile{parts/02 residual} \subfile{parts/03 fulkerson} \problem{Maximum Cardinality Matching} A \textit{matching} is a subset of edges in a bipartite graph. Nodes in a matching must not have more than one edge connected to them. \\ A matching is \textit{maximal} if it has more edges than any other matching. \vspace{5mm} \begin{minipage}[t]{0.48\textwidth} \begin{center} Initial Graph \\ \vspace{2mm} \begin{tikzpicture} % Nodes \begin{scope}[layer = nodes] \node[main] (A1) at (0mm, 24mm) {}; \node[main] (A2) at (0mm, 18mm) {}; \node[main] (A3) at (0mm, 12mm) {}; \node[main] (A4) at (0mm, 6mm) {}; \node[main] (A5) at (0mm, 0mm) {}; \node[main] (B1) at (20mm, 24mm) {}; \node[main] (B2) at (20mm, 18mm) {}; \node[main] (B3) at (20mm, 12mm) {}; \node[main] (B4) at (20mm, 6mm) {}; \node[main] (B5) at (20mm, 0mm) {}; \end{scope} % Edges \draw (A1) edge (B2) (A1) edge (B3) (A2) edge (B1) (A2) edge (B4) (A4) edge (B3) (A2) edge (B3) (A5) edge (B3) (A5) edge (B4) ; \end{tikzpicture} \end{center} \end{minipage} \hfill \begin{minipage}[t]{0.48\textwidth} \begin{center} Maximal Matching \\ \vspace{2mm} \begin{tikzpicture} % Nodes \begin{scope}[layer = nodes] \node[main] (A1) at (0mm, 24mm) {}; \node[main] (A2) at (0mm, 18mm) {}; \node[main] (A3) at (0mm, 12mm) {}; \node[main] (A4) at (0mm, 6mm) {}; \node[main] (A5) at (0mm, 0mm) {}; \node[main] (B1) at (20mm, 24mm) {}; \node[main] (B2) at (20mm, 18mm) {}; \node[main] (B3) at (20mm, 12mm) {}; \node[main] (B4) at (20mm, 6mm) {}; \node[main] (B5) at (20mm, 0mm) {}; \end{scope} % Edges \draw[opacity = 0.4] (A1) edge (B2) (A1) edge (B3) (A2) edge (B1) (A2) edge (B4) (A4) edge (B3) (A4) edge (B3) (A5) edge (B3) (A5) edge (B4) ; \draw (A1) edge (B2) (A2) edge (B1) (A4) edge (B3) (A5) edge (B4) ; \end{tikzpicture} \end{center} \end{minipage} \vspace{5mm} Devise an algorithm to find a maximal matching in any bipartite graph. \\ Find an upper bound for its runtime. \begin{solution} Turn this into a maximum flow problem and use FF. \\ Connect a node $S$ to all nodes in the left group and a node $T$ to all nodes in the right group. All edges have capacity 1. \vspace{2ex} Just like FF, this algorithm will take at most $\min(\# \text{ left nodes}, \# \text{ right nodes})$ iterations. \end{solution} \end{document}