Graph Theory Reference
Reference 为图 theory: types, traversal, connectivity, 和 algorithms.
Graph Types and Properties
A graph G = (V, E) has vertices V and edges E. Directed graphs have ordered edges; undirected have unordered. Weighted graphs assign values to edges. Simple graphs have no loops or multi-edges. The degree of a vertex is its edge count. A path is a sequence of connected vertices; a cycle returns to the start. Connectivity: a graph is connected if every pair has a path. Trees are connected acyclic graphs with |V|-1 edges. Bipartite graphs partition into two independent sets. Complete graphs have all possible edges.
- directed
- Ordered edges
- tree
- Connected acyclic
- bipartite
- Two independent sets
digraph |V|-1 edges 2-colorable Graph Algorithms
BFS (breadth-first search) explores level by level, finds shortest paths in unweighted graphs. DFS (depth-first search) goes deep first, used for connectivity, cycles, and topological sort. Dijkstra's algorithm finds shortest paths with non-negative weights. Bellman-Ford handles negative weights. A* uses heuristics for faster pathfinding. Kruskal's and Prim's algorithms find minimum spanning trees. Ford-Fulkerson finds max flow. Graph coloring assigns colors with no adjacent same. Eulerian paths use every edge once; Hamiltonian paths visit every vertex once. Many graph problems are NP-hard (Hamiltonian, coloring, clique).
- BFS
- Level-order
- Dijkstra
- Shortest path
- MST
- Min spanning tree
shortest unweighted non-negative weights Kruskal, Prim