跳转到内容
- Graph (V,E): V vertices, E 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,v adjacent (neighbours) ⇔ some edge has endpoints u,v; that edge is incident with u,v; N(v) = all neighbours, N(A)=⋃v∈AN(v).
- In an undirected graph: deg(v)(度)= number of incident edges, a loop counts twice.
- Handshaking(握手定理): finite undirected ⇒ 2∣E∣=∑v∈Vdeg(v) (proof: swap summation order over v and e). ⇒ number of odd-degree vertices is even.
- Directed edge u→v: u adjacent to v, v adjacent from u; u initial, v terminal vertex; deg−(v) in-degree, deg+(v) out-degree; finite directed ⇒ ∣E∣=∑deg+(v)=∑deg−(v).
- Path of length n⩾0 from u to v: edges e1,…,en with vertices u=x0,…,xn=v, endpoints of ei are xi−1,xi (directed: ei from xi−1 to xi); simple = no duplicate edges; circuit = path of positive length u to u.
- u,v connected ⇔ path from u to v; connectivity holds to itself, is symmetric and transfers along chains; connected graph(连通图) ⇔ every pair connected.
- Subgraph(子图): V′⊆V, E′⊆E; proper if =G; induced(导出子图) by W: all vertices of W + all edges with both endpoints in W.
- 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}.
- 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}; mutual reachability holds reflexively, symmetrically, transitively.
- Between two strongly-connected components reachability is uniform (v1 reachable from u1 iff v2 from u2); a circuit's edges and vertices lie in one strongly-connected component.
- Adding edge e0 (u–v): never destroys connectivity; if u,v already connected, connectivity unchanged; if not: x connected to u in G′ ⇔ to v in G′ ⇔ to one of u,v in G; any newly connected x,y become connected together with u,v in G′.
- Tree = connected nonempty undirected graph with no simple circuits; add edge between existing vertices ⇒ simple circuit; remove edge ⇒ disconnected; leaf (unrooted) = degree-1 vertex; ⩾2 vertices ⇒ ⩾2 leaves; n vertices ⇒ n−1 edges.
- Six equivalent characterizations of finite G: ① tree; ② connected ∧ ∣E∣=∣V∣−1; ③ no simple circuits ∧ ∣E∣=∣V∣−1; ④ connected ∧ every edge is a cut edge; ⑤ no simple circuits ∧ adding any edge between vertices of G 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 T0; repeatedly add the minimum-weight edge keeping Tn+e′ a tree (edge crosses Vn to V\Vn, vertex side added); after ∣V∣−1 steps, MST.
- Kruskal: for a finite connected weighted graph, start from (V,∅); repeatedly add the minimum-weight edge that creates no simple circuit; after ∣V∣−1 steps, MST.
- Correctness pattern (both): induction — there is always an MST T∗ containing the current partial graph; Prim's induction step is the edge exchange: a T∗-path between en+1's endpoints must contain an edge e∗ leaving Vn; w(e∗)⩾w(en+1) (choice) and w(e∗)⩽w(en+1) (T∗ is minimum), so swapping keeps an MST; Kruskal's idea: en is "necessary" — lighter edges cannot connect its endpoints without a simple circuit.
- Rooted tree = tree + designated root r; level of v = length of unique simple path r→v; height = max level; parent of v=r = unique neighbour on the r–v path, v its child; siblings = same parent; ancestors of v=r = vertices on the r–v path excluding v, including r; descendants of v = vertices with v as ancestor.
- Ancestor/descendant relations are transitive; u is v's ancestor ⇔ a parent chain w0=u,…,wk=v exists; the unique simple path between descendants of u stays within u's descendants and u.
- Rooted-tree leaf = no children (≠ unrooted notion: degree 1), otherwise internal vertex; subtree at v = induced subgraph of v + descendants (it is a tree).
- m-ary tree(m 叉树): every internal vertex has ⩽m children (binary = 2-ary); height h ⇒ at most mh leaves.
- 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 (k-th step vk−1→vk via ek, start u): v0=u; if an unvisited neighbour of vk−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−1, ek=ei).
- 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=u is a forward step's terminal exactly once and a backward step's start exactly once; with n=∣V∣, total: n−1 forward + n−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→vk uses only forward edges and passes exactly through the start and the not-yet-left vertices.
- Between two visits of u all visited vertices are u's descendants or u itself; a back edge always joins a vertex to an ancestor, a descendant, or itself.
- Tarjan bridges: DFS computing dfn(u) (visit time) and low(u)=min of own time, children's low, and dfn of other neighbours (entering edge e0 excluded); after recursing into child v: edge u–v is reported as a bridge when low(v)=dfn(v).