跳转到内容

离散数学 · 图论 · 速览

  • Graph (V,E)(V,E): VV vertices, EE edges; each edge has two endpoints (possibly identical) and connects them.
  • Three classification axes: directed/undirected; multiple edges(重边/平行边)or not; loops(自环)or not.
  • In an undirected graph: u,vu,v adjacent (neighbours) ⇔ some edge has endpoints u,vu,v; that edge is incident with u,vu,v; N(v)\mathcal{N}(v) = all neighbours, N(A)=⋃v∈AN(v)\mathcal{N}(A)=\bigcup_{v\in A}\mathcal{N}(v).
  • In an undirected graph: deg⁡(v)\deg(v)(度)= number of incident edges, a loop counts twice.
  • Handshaking(握手定理): finite undirected ⇒ 2∣E∣=∑v∈Vdeg⁡(v)2|E| = \sum_{v\in V}\deg(v) (proof: swap summation order over vv and ee). ⇒ number of odd-degree vertices is even.
  • Directed edge u→vu \to v: uu adjacent to vv, vv adjacent from uu; uu initial, vv terminal vertex; deg⁡−(v)\deg^-(v) in-degree, deg⁡+(v)\deg^+(v) out-degree; finite directed ⇒ ∣E∣=∑deg⁡+(v)=∑deg⁡−(v)|E| = \sum\deg^+(v) = \sum\deg^-(v).
  • Path of length n⩾0n\geqslant 0 from uu to vv: edges e1,…,ene_1,\ldots,e_n with vertices u=x0,…,xn=vu=x_0,\ldots,x_n=v, endpoints of eie_i are xi−1,xix_{i-1},x_i (directed: eie_i from xi−1x_{i-1} to xix_i); simple = no duplicate edges; circuit = path of positive length uu to uu.
  • u,vu,v connected ⇔ path from uu to vv; connectivity holds to itself, is symmetric and transfers along chains; connected graph(连通图) ⇔ every pair connected.
  • Subgraph(子图): V′⊆VV'\subseteq V, E′⊆EE'\subseteq E; proper if ≠G\neq G; induced(导出子图) by WW: all vertices of WW + all edges with both endpoints in WW.
  • A path induces a connected subgraph; two connected subgraphs sharing a vertex have a connected union.
  • Connected component(连通块) = connected subgraph not a proper subgraph of another connected subgraph; each is an induced subgraph of {v:v connected to u}\{v : v \text{ connected to } u\}.
  • Strongly connected(强连通) directed graph: paths both ways for every pair; strongly-connected component(强连通块) = strongly-connected subgraph not a proper subgraph of another one, each an induced subgraph of {v:v mutually reachable from u}\{v : v \text{ mutually reachable from } u\}; mutual reachability holds reflexively, symmetrically, transitively.
  • Between two strongly-connected components reachability is uniform (v1v_1 reachable from u1u_1 iff v2v_2 from u2u_2); a circuit's edges and vertices lie in one strongly-connected component.
  • Adding edge e0e_0 (uu–vv): never destroys connectivity; if u,vu,v already connected, connectivity unchanged; if not: xx connected to uu in G′G' ⇔ to vv in G′G' ⇔ to one of u,vu,v in GG; any newly connected x,yx,y become connected together with u,vu,v in G′G'.
  • Tree = connected nonempty undirected graph with no simple circuits; add edge between existing vertices ⇒ simple circuit; remove edge ⇒ disconnected; leaf (unrooted) = degree-11 vertex; ⩾2\geqslant 2 vertices ⇒ ⩾2\geqslant 2 leaves; nn vertices ⇒ n−1n-1 edges.
  • Six equivalent characterizations of finite GG: ① tree; ② connected ∧ ∣E∣=∣V∣−1|E|=|V|-1; ③ no simple circuits ∧ ∣E∣=∣V∣−1|E|=|V|-1; ④ connected ∧ every edge is a cut edge; ⑤ no simple circuits ∧ adding any edge between vertices of GG creates one; ⑥ unique simple path between any two vertices.
  • Spanning tree: subgraph that is a tree containing every vertex; graph connected ⇔ spanning tree exists (connected ⇒ exists: repeatedly delete one edge of a simple circuit until vertices = edges + 1).
  • Weighted graph: each edge gets a (real) number; MST: spanning tree with minimum total weight (finite connected weighted graph).
  • Prim: for a finite connected weighted graph, start from a singleton vertex T0T_0; repeatedly add the minimum-weight edge keeping Tn+e′T_n + e' a tree (edge crosses VnV_n to V\VnV\backslash V_n, vertex side added); after ∣V∣−1|V|-1 steps, MST.
  • Kruskal: for a finite connected weighted graph, start from (V,∅)(V,\varnothing); repeatedly add the minimum-weight edge that creates no simple circuit; after ∣V∣−1|V|-1 steps, MST.
  • Correctness pattern (both): induction — there is always an MST T∗T^* containing the current partial graph; Prim's induction step is the edge exchange: a T∗T^*-path between en+1e_{n+1}'s endpoints must contain an edge e∗e^* leaving VnV_n; w(e∗)⩾w(en+1)w(e^*)\geqslant w(e_{n+1}) (choice) and w(e∗)⩽w(en+1)w(e^*)\leqslant w(e_{n+1}) (T∗T^* is minimum), so swapping keeps an MST; Kruskal's idea: ene_n is "necessary" — lighter edges cannot connect its endpoints without a simple circuit.
  • Rooted tree = tree + designated root rr; level of vv = length of unique simple path r→vr \to v; height = max level; parent of v≠rv\neq r = unique neighbour on the rr–vv path, vv its child; siblings = same parent; ancestors of v≠rv \neq r = vertices on the rr–vv path excluding vv, including rr; descendants of vv = vertices with vv as ancestor.
  • Ancestor/descendant relations are transitive; uu is vv's ancestor ⇔ a parent chain w0=u,…,wk=vw_0=u,\ldots,w_k=v exists; the unique simple path between descendants of uu stays within uu's descendants and uu.
  • Rooted-tree leaf = no children (≠ unrooted notion: degree 11), otherwise internal vertex; subtree at vv = induced subgraph of vv + descendants (it is a tree).
  • mm-ary tree(mm 叉树): every internal vertex has ⩽m\leqslant m children (binary = 2-ary); height hh ⇒ at most mhm^h leaves.

Depth-First Search(深度优先搜索)

跳转到:Depth-First Search(深度优先搜索)
  • Procedure: fix a start vertex; augment a simple path until stuck; trace back to the deepest vertex with an augmentable edge; repeat. Moves are forward / backward steps; edge used by a forward move = tree edge, otherwise back edge.
  • Formal DFS conditions (kk-th step vk−1→vkv_{k-1}\to v_k via eke_k, start uu): v0=uv_0=u; if an unvisited neighbour of vk−1v_{k-1} exists, the move must be forward; forward steps reach only unvisited vertices; a backward step retraces the forward edge that first entered the current vertex (vk=vi−1v_k=v_{i-1}, ek=eie_k=e_i).
  • Tree edges of a DFS on a connected graph form a spanning tree (rooted at the start vertex); a forward step goes to a child.
  • Each v≠uv \neq u is a forward step's terminal exactly once and a backward step's start exactly once; with n=∣V∣n=|V|, total: n−1n-1 forward + n−1n-1 backward steps.
  • Visited vertices split into three categories: the start vertex / entered (one forward terminal) but not yet left / entered and left (one backward start); a simple path v0→vkv_0 \to v_k uses only forward edges and passes exactly through the start and the not-yet-left vertices.
  • Between two visits of uu all visited vertices are uu's descendants or uu itself; a back edge always joins a vertex to an ancestor, a descendant, or itself.
  • Tarjan bridges: DFS computing dfn(u)\mathrm{dfn}(u) (visit time) and low(u)=min⁡\mathrm{low}(u) = \min of own time, children's low\mathrm{low}, and dfn\mathrm{dfn} of other neighbours (entering edge e0e_0 excluded); after recursing into child vv: edge uu–vv is reported as a bridge when low(v)=dfn(v)\mathrm{low}(v) = \mathrm{dfn}(v).