Cartesian product G×H=(V(G)×V(H),E′),((u,v),(x,y))∈E′ if u=x,vy∈E(H) or v=y,ux∈E
multigraph: E is a multiset
parallel edges: join the same pair of vertices
pseudograph: (u,u)∈E
oriented graph: if (u,v)∈E, (v,u)∈/E
oritentation of G
Storage
adjacent matrix
edge set(可以链式前向星实现)
Digraph
digraph (directed graph): (v,u)=(u,v)
(u,v): u adjacent to v, v adjacent from u
symmetric: (u,v)∈E⟺(v,u)∈E
underlying graph: replace direction and parallel edges
tournament: orientation of complete graph
transitive: (u,v),(v,w)∈T,(u,w)∈T
every tournament contains a Hamiltonian path
Hamiltonian iff strong
weakly connected: underlying graph is connected
strongly connected: ∀u,v,∃P from u to v and vice versa
strongly connected component (SCC)
Semiconnected Digraph: u∼v or v∼u
Toposort + edges (vi,vi+1) exsits
Isomorphism
isomorphic G≅H: ∃ 1-1 ϕ:V(G)→V(H) such that uv∈E(G)⇒ϕ(u)ϕ(v)∈E(H)
self-complementary: G≅G
isomorphism is an equivalence relation of the set of all graphs
automorphism: isomorphism from G to G
Aut(H): automorphism group of G (under composition)
u and v are similar: they are in same orbit
vertex-transitive: G contains a single orbit
Frucht's Theorem: For every finite group A, there exists a graph G such that Aut(G) is isomorphic to A
recognizable: a parameter of G can be determined from G−v,v∈V(G)
∣V∣
∣E∣ for ∣V∣≥3
degree sequence for ∣V∣≥3
reconstructible: G can be uniquely determined (up to isomorphism) from subgraphs G−vi
Reconstruction Conjecture: G is reconstructible for ∣V∣≥3
Trees
bridge e: G is connected, G−{e} is disconnected
bridge ⟺!∃n,Cn⊆G,e∈Cn
nontrivial connected graph has a strong orientation ⟺ no bridges in G
acyclic graph(forests): !∃n,Cn⊆G
tree: acyclic graph + connected
spanning tree of G
cycle property
cut property
weight: w(H)=sume∈E(H)w(e)
Kruskal's Algorithm: O(ElgV)
sort G.E # into nondecreasing order by weightfor e in E: if find_set(u) != find_set(v): ans += {u,v} merge(u,v)
Prim's Algorithm: O(E+VlgV)
for u in G.V: u.key = inf u.pi = NILs.key = 0Q = G.Vwhile Q: u = Extract_Min(Q) for v in G.Adj[u]: if v in Q and w(u,v) < v.key: v.pi = u v.key = w(u,v)
Carley's Theorem: the spanning tree of Kn of order n is nn−2
Matrix Tree Theorem: The spanning tree of an arbitrary graph is any cofactor of matrix
Havel-Hakimi Theorem: non-increaing sequence s:d1,d2,...,dn where d1≥1 is graphical iff s1:d2−1,d3−1,...,dd1+1−1,dd1+2,...,dn is graphical.
irregular graph: ∀u,v∈V,degu=degv
The Party Theorem: At any party, there is a pair of people who have the same number of friends present
No nontrivial graph is irregular
F-degree of v: number of copies of F in G contain v
G contain m copies of F, then ∑u∈V(G)degFv=km
F-(ir)regular
adjacency matrix A: V×V
incidence matrix B: V×B
Connectivity
Vertex
cut-vertex: G is connected and G−{v} is disconnected
nonseparable graph (biconnected): a nontrivial connected graph with no cut-vertices
block (bicomponent)
maximal nonseparable subgraph of G
equivalence class defined by R,eRf if e,f lie on a common cycle
vertex-cut: a set U of vertices of G such that G−U is disconnected
minimum vertex-cut
vertex-connectivity: κ(G)=min∣U∣,G−U disconnected
equals maxu∼v∣{disjoint u-v path}∣
k-connected: κ(G)≥k
2-connected: no vertex-cut
Edge
edge-cut: G is connected and G−{e} is disconnected
minimum edge-cut
edge-connectivity: λ(G)
k-edge-connected
κ(G)≤λ(G)≤δ(G)
cubic graph: κ(G)=λ(G)
Menger's Theorem
u-v separating set S: u∼v and belong to seperate components of G−S
minimum u-v separating set
internal vertex of u-v path P: w∈P,w=v,w=u
internally disjoint paths: A collection of u-v paths that every two of them have no vertices in common other than u and v
Menger's Theorem: minimum cardinality of u-v separating set = maximum number of internally disjoint u-v paths in G
induction on the size of graph, discussion on the property of separating set
Whitney's Theorem: k-connected ⟺∀u,v there are at least k internally disjoint u-v paths
Traversability
Eulerian circuit: a circuit contains every edge of G
Eulerian graph: graph G contians an Eulerian circuit
A nontrivial connected graph G is Eulerian iff every vertex of G has even degree
(directed) odv=idu
Eulerian trail: an open trail that contains every edge of G
Ko¨nigsberg Bridge Problem
A connected graph G contains an Eulerian trail iff exactly two vertices of G have odd degree.
Hamiltonian cycle: a cycle in a graph G that contains every vertex of G
Hamiltonian graph
Hamiltonian path: a path in G contains every vertex of G
k(G): number of components in G
(neccessary) Hamiltonian Graph: ∀S,k(G−S)≤∣S∣
(sufficient) n≥3,∀u∼v,degu+degv≥n, then G is Hamiltonian
closure C(G): the graph obtained from G(order n) by recursively joining pairs of nonadjacent vertices whose degree sum ≥n until no such pair remains
(neccessary) Hamiltonian Graph: C(G) is Hamiltonian
Search
BFS: Θ(V+E)
for u in vertices: u.pi = NIL u.visited = Falses.visited = TrueQ = {s}while Q: u = Q.pop() for v in G.Adj[u]: if not u.visitied: v.pi = u v.visited = True Q.push(u)
DFS: Θ(V+E)
# all colored whitedef dfs(u): u.visited = True # color gray for v in G.Adj[v]: if not v.visited: v.pi = u v.visited = True dfs(v)# color black
DFS properties
Parenthesis theorem
Nesting of descendant's intervals
White-path theorem
Classification of Edges
Tree edge: edge in Gπ (white)
Back edge: ancestor (gray)
Forward edge: descendant (black)
Cross edge (black)
There is no Forward edges and Cross edge in undirected graphs
directed acyclic graph(DAG): no back edge
Toposort on dag: sort vertices in descending order of their finish times
component graph: dag of its SCCs
Kosaraju's Algorithm: Θ(V+E)
dfs(G) # compute u.f for each vertex udfs(G^T) # in order of decreasing u.f in main loop# SCC is trees in depth-first forest
Tarjan's Algorithm: Θ(V+E)
cut-vertex(undirected): ∃v son of u, low[v] ≥ dnf[u]
bridge(undirected): ∃v son of u, low[v] > dnf[u]
directed: SCC
def tarjan_dfs(u): t += 1 dfn[u] = low[u] = t Stack.push(u) for v in G.Adj[u]: if not v.visited: tarjan_dfs(v) low[u] = min(low[u], low[v]) elif v in Stack: low[u] = min(low[u], dfn[v]) if dfn[u] == low[u]: while v != Stack.top(): Stack.pop()
Distance
distance
positive
reflexivity
symmetric
triangle inequatity
metric space: (V(G),d)
eccentricity: e(v)=maxu∈V(G)d(u,v)
radius: rad(G)=minv∈V(G)e(v)
center: Cen(G)={v:e(v)=rad(G)}
self-centered: Cen(G)=G
center is subgraph of block
diameter: diam(G)=maxv∈V(G)e(v)
periphery: Per(G)={v:e(v)=diam(G)}
rad(G)≤diam(G)≤2rad(G)
eccentric vertex of u={v:d(u,v)=e(u)}
Ecc(G)={v:∃u,d(u,v)=e(u)}
boundary vertex of a vertex u={v:∀w∼v,d(u,w)≤d(u,v)}
peripheral ⇒ eccentric ⇒ boundary
complete vertex (extrem or simplicial vertex): the subgraph of G induced by the neighbors of v is complete
complete ⇒ boundary
interior vertex: ∀u,∃w,d(u,w)=d(u,v)+d(v,w)
Int(G): subgraph induced by interior vertices
boundary ⇒ not interior (connected graph)
Shortest Path
simple path -> path
path -> walk
in DAG or only positive edges: path = simple path
shortest path: walk
single source shortest path(sssp):
all pair shortest path(assp)
longest path: simple path, NP
relaxation
def relax(u,v,w): if v.d > u.d + w(u,v): v.d = u.d + w(u,v) v.pi = u
Properties
Triangle inequality
Upper-bound property
No-path property
Convergence property
Path-relaxation property
Predecessor-subgraph property
Bellman-Ford Algorithm: Θ(VE)
s.d = 0for i in range(|G.V|): for e in G.E: relax(e.u, e.v, w)for i in range(|G.V|): if v.d > u.d + w(u,v): return Falsereturn True
DAG shortest path: Θ(V+E)
critical path: longest path through dag
for u in G.topo: for v in G.Adj[u]: relax(u,v,w)
Dijkstra Algorithm: all edges are nonnegative
Array: O(V2)
Min-heap: O(ElgV) for sparse graph E=o(lgVV2)
Fib-heap: O(E+VlgV)
Q = G.Vwhile Q: u = Extract_Min(Q) for v in G.Adj[u]: relax(u, v, w)
matrix multiplication and repeated squaring: Θ(n3lgn)
Floyed-Warshall Algorithm: Θ(V3)
dynamic programming on first k vertices as intermediate vertices
for k in range(n): for i in range(n): for j in range(n): d[i][j] = min(d[i][j], d[i][k] + d[k][j])
Johnson's Algorithm: Θ(V2lgV+VE)
reweighting: ω^(u,v)=ω(u,v)+h(u)−h(v)
Matching
independent set(matching) F: ∀e1,e2∈F,e1∩e2=∅
Theorem: partite graph G has partite sets U and W such that r=∣U∣≤∣W∣. Then G contains a matching of cardinality r iff G satisfies Hall's condition.
augmentation: f′ is flow of residual network, if (u,v)∈E, (f↑f′)(u,v)=f(u,v)+f′(u,v)−f′(v,u)
∣f↑f′∣=∣f∣+∣f′∣
augmentation path: simple path from s to t in residual network
# initial flow f to 0while augmenting_path in residual_network: augment(f,augmenting_path)return f
Basic Ford-Fulkerson Algorithm: O(∣f∗∣E) arbitrary with integer
while augmenting_path in residual_network: c_f(p) = min([c_f(u,v) for (u,v) in p]) for (u,v) in p: if (u,v) in E (u,v).f += c_f(p) else: (v,u).f -= c_f(p)
Edmonds-Karp Algorithm: O(VE2)
search augmenting path by BFS in residual network, where each edge has unit distance
Push-relabeled algorithms: O(V2E)
relabel-to-front algorithm: O(V3)
Factorization
ko(G): number of odd components of G
factor F: spanning subgraph of G
factorable: E(G)=⨆i=1kE(Fi)
F-factorable: factorable and Fi≅F
r-factorable: factorable and Fi is r-regular graph
1-factorable: perfect matching
Tutte's Theorem: ∀S∈V(G),k0(G−S)≤∣S∣, then G contains a 1-factor
Petersen's Theorem: Every 3-regular bridgeless graph contains a 1-factor
Every r-regular bipartite graph is 1-factorable
2-factorable: cyclic factorization
G is 2-factorable iff G is r-regular, r is positive even integer
Hamiltonian-factorization
∀k≥1, K2k+1 is Hamiltonian-factorable
∀k≥1, K2k can be factored into k−1 Hamiltonian-cycles and a 1-factor
Kirkman's Schoolgirl Problem: Is there a 5K3-factorization of K15
Decomposition
decomposable: E(G)=⨆i=1kE(Hi)
if H is spanning subgraph, then it is factorization
H-decomposable: Hi≅H
graceful labeling f:V(G)→Zm:
one-to-one
f′(e)=∣f(u)−f(v)∣ is one-to-one.
graceful graph: G possessing a graceful labeling
Conjecture: Every tree is graceful
girth: minCn⊆Gn
g-cage: minimal 3-regular graph that has girth g≥3
g=3,K4
g=4,K3,3
g=5 Petersen
g=6 Heawoo
g=7 McGee
g=8 Tutte-Coxeter
g≤8, the g-cages are all sole
Embedding
Plane
plane graph: G is drawed on(embeded into) a plane with no edge crossing
regions R: connected area divied by plane graph
exterior regions: a region without bounding
boundary of R: subgraph corresponding to a region
planar graph: ∃P is a plane graph, G≅P
Euler Identity: a connected plane graph of order n, number of edge m and r regions, n−m+r=2
a planar graph of order n≥3 then m≤3n−6 (2m≥3r)
every planar graph contains a vertex of degree 5 or less
maximal planar: planar but any addition of an edge results in nonplanar graph
Kuratowski Theorem: G is planar ⟺ it does not contain a subgraph of K5,K3,3 or subdivision of K5,K3,3
subdivision: inserting vertex of degree 2 into G
Surface
Sk surface of genus k: a surface with k handle
S0: sphere
planar graph can be embedded into a sphere
S1: torus
γ(G): minimal integer k that G can be embedded into Sk
A and A′ are in the same region if there is a line connecting there without crossing edges or vertices of G
2-cell embedding: every region is 2-cell embedding
2-cell: a region in which any closed curves can shrink into a node continuously
Theorem: If G is 2-cell embedded into Sk then n−m+r=2−2k
n≥3,γ(G)≥6m−2n+1
γ(Kn)=⌈12(n−3)(n−4)⌉
Minor
G′ is got from G by contracting edge e (or identifying the vertices u,v)
minor: H can be got be a series of edge contraction from G
G is a subdivision of H⇒H is a minor of G
H is a minor of G⇒γ(H)≤γ(G)
Wagner Theorem: G is planar ⟺K5,K3,3 is not a minor of G
The Graph Minor Theorem: For any infinite set S of graphs, there are two distinct graph in S that one is a minor of the other
Coloring
clique: a complete subgraph of graph
clique number ω(G): the largest order of clique in G
color class: the independet set division corresponding to a coloring
χ(G): chromatic number, the minimal number of color to color G
k-colorable: χ(G)≤k
χ(G)=1⟺G has no edges
χ(G)=2⟺G is a nonempty partite graph
χ(C2n+1)=3
χ(G)=4 for triangle-free graph (Grotzsch graph)
Four Color Theorem: For every planar graph G, χ(G)≤4
χ(G) inequality
χ(G)≥ω(G)
χ(G)≥β(G)n
χ(G)≤1+Δ(G)
Brook Theorem: G is odd circle or complete graph, then χ(G)≤Δ(G)
χ(G)≤1+max(δ(H)), H is all possible induced subgraph
perfect: ∀H⊆G,χ(H)=ω(H)
perfect iff complement is perfect
edge coloring c:E(G)→N,∀e1∩e2=∅,c(e1)=c(e2)
χ′(G): edge chromatic number(chromatic index)
Divide G into minimum number of 1-regulation graph
Vizing Theorem: χ′(G)=ΔG or =ΔG+1
If m>2(n−1)ΔG then χ′(G)=1+Δ(G)
Konig Theorem: For nonempty partite graph, χ′(X)=Δ(G)
Ramsey Numbers
Ramsey's Theorem: ∀k+1≥3 positive integers t,n1,n2,⋯,nk,∃n>0,∀S⊆Zn,∣S∣=t is colored with one of k colors, then ∃S containing ni elements such that every t-element subset of S is colored i
(t=2) ∀k≥2,n1,n2,⋯,nk,∃n>0,E(Kn) is colored by k colors that ∃i, complete subgraph Kni is colored i
Ramsey's number r(F1,F2): the smallest positive integer n such that if every edge of Kn is colored red or blue in any manner whatsoever, then either a red F1 or a blue F2 is produced