Graph theory
- Handshake lemma
- Σ deg(v) = 2|E|
- Complete graphs
- |E(Kn)| = n(n − 1)/2, |E(Km,n)| = m·n
- Regular graph
- |E| = n·k/2
- Tree and forest
- |E| = n − 1, |E| = n − c
- Leaves of a tree
- L = 2 + Σ (deg(v) − 2) over deg(v) ≥ 3
- Euler
- circuit: all degrees even; path: exactly 2 odd degrees
- Hamilton circuits in Kn
- (n − 1)!/2
- Dijkstra update
- d(v) = min(d(v), d(u) + w(u, v))
- Walks of length L
- (Mᴸ)ij
Method
- Write down the degree of every vertex; the degrees add up to twice the number of edges.
- For Euler questions, check that the graph is connected and count the vertices with odd degree.
- For trees, use n − 1 edges and the handshake lemma.
- For Dijkstra, keep a table of tentative distances and settle the smallest unsettled vertex each round.
- For a minimum spanning tree, sort the edges by weight and skip every edge that closes a cycle (Kruskal), or grow one tree from a start vertex (Prim).