Added Graph Algorithms handout
This commit is contained in:
91
Advanced/Graph Algorithms/parts/00 review.tex
Executable file
91
Advanced/Graph Algorithms/parts/00 review.tex
Executable file
@ -0,0 +1,91 @@
|
||||
\documentclass[../main.tex]{subfiles}
|
||||
|
||||
|
||||
\begin{document}
|
||||
|
||||
\section{Review}
|
||||
|
||||
\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{weighted graph} is a graph that features weights on its edges. \\
|
||||
A weighted directed graph is shown below.
|
||||
|
||||
\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] node[label] {$4$} (B)
|
||||
(B) edge node[label] {$2$} (C)
|
||||
(C) edge node[label] {$2$} (A)
|
||||
(B) edge[bend right] node[label] {$1$} (A)
|
||||
;
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
\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:
|
||||
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
% Nodes
|
||||
\begin{scope}
|
||||
\node[main] (A) at (0mm, 0mm) {$A$};
|
||||
\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$};
|
||||
\end{scope}
|
||||
|
||||
% Edges
|
||||
\draw
|
||||
(A) edge (D)
|
||||
(A) edge (E)
|
||||
(B) edge (F)
|
||||
(C) edge (E)
|
||||
(C) edge (D)
|
||||
;
|
||||
\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
|
||||
|
||||
\end{document}
|
Reference in New Issue
Block a user