This page provides an overview of several concepts in graph theory. Not all of them are commonly encountered in OI; for OIers, mastering the basic material in this page is sufficient. If you encounter a concept you do not understand while studying, you can return here for reference.
Warning
Definitions in graph theory often differ between textbooks, so their meaning should be determined from the context in which they occur.
Graphs
A graph (graph) is an ordered pair . Here, is a nonempty set called the vertex set. Each element of is called a vertex (vertex) or node (node), or simply a vertex; is the set of edges between vertices of , called the edge set.
A graph is commonly written as .
When both are finite sets, is called a finite graph.
When or is an infinite set, is called an infinite graph.
There are several kinds of graphs, including undirected graphs (undirected graph), directed graphs (directed graph), and mixed graphs (mixed graph).
If is an undirected graph, each element of is an unordered pair , called an undirected edge (undirected edge), or simply an edge (edge), where . If , then and are called the endpoints (endpoint) of .
If is a directed graph, each element of is an ordered pair , sometimes written as , called a directed edge (directed edge) or an arc (arc). When there is no risk of confusion, it may also be called an edge (edge). If , then is called the tail (tail) of , and is the head (head) of ; the tail and head are also called the endpoints (endpoint) of . We also say that is the immediate predecessor of , and is the immediate successor of .
Why is the tail the tail and the endpoint the head?
Edges are usually represented by arrows, and an arrow points from its tail to its head.
If is a mixed graph, contains both directed edges and undirected edges.
If has every edge assigned a number as its weight, then is called a weighted graph. If all these weights are positive real numbers, is called a positive-weight graph.
The number of vertices in graph , , is also called the order (order) of graph .
In intuitive terms, a graph consists of several vertices together with edges connecting vertices to one another.
Adjacency
In an undirected graph , if vertex is an endpoint of edge , then and are incident (incident) or adjacent (adjacent). For two vertices and , if an edge exists, then and are adjacent (adjacent).
The neighborhood (neighborhood) of a vertex is the set of all vertices adjacent to it, denoted by .
The neighborhood of a vertex set is the set of all vertices adjacent to at least one vertex in , denoted by ; that is:
Simple graphs
Loop (loop): For an edge in , if , then is called a loop.
Multiple edge (multiple edge): If contains two identical elements (edges) , they are called a set of multiple edges.
Simple graph (simple graph): A graph with no loops or multiple edges is called a simple graph. Every simple undirected graph with at least two vertices contains two vertices with the same degree. (Pigeonhole principle)
If a graph has a loop or a multiple edge, it is called a multigraph (multigraph).
Warning
In an undirected graph, and count as a set of multiple edges, whereas in a directed graph, and are not multiple edges.
Warning
Unless a problem explicitly says otherwise, loops and multiple edges may exist in a graph, and they must be handled carefully when solving the problem.
Degrees
The number of edges incident to a vertex is called its degree (degree), denoted by . In particular, for an edge , each such edge contributes to .
For a simple undirected graph, .
The handshake lemma, also called the fundamental theorem of graph theory, states that for every undirected graph , .
Corollary: In every graph, the number of vertices with odd degree is even.
If , then is called an isolated vertex (isolated vertex).
If , then is called a leaf vertex (leaf vertex)/pendant vertex (pendant vertex).
If , then is called an even vertex (even vertex).
If , then is called an odd vertex (odd vertex). The number of odd vertices in a graph is even.
If , then is called a universal vertex (universal vertex).
For a graph, the minimum degree among all its vertices is called the minimum degree (minimum degree) of and denoted by ; the maximum is called the maximum degree (maximum degree) and denoted by . That is, and .
In a directed graph , the number of edges starting at a vertex is called its out-degree (out-degree), denoted by . The number of edges ending at a vertex is called its in-degree (in-degree), denoted by . Clearly, .
For every directed graph , we have:
If every vertex of an undirected graph has the same fixed degree , then is called a -regular graph (-regular graph).
If, given a sequence a, there exists a graph G whose degree sequence is a, then a is called graphical.
If, given a sequence a, there exists a simple graph G whose degree sequence is a, then a is called simply graphical.
Paths
Walk (walk): A walk is a sequence of edges joining a sequence of vertices, and may have finite or infinite length. Formally, a finite walk is a sequence of edges for which there exists a vertex sequence satisfying for . Such a walk can be abbreviated as . In general, the number of edges is called the length of the walk (if the edges are weighted, length usually means the sum of the edge weights along the walk, though a problem may define it differently).
Trail (trail): For a walk , if are pairwise distinct, then is called a trail.
Path (path) (also called a simple path (simple path)): For a trail , if the vertices in its vertex sequence are pairwise distinct, then is called a path.
Circuit (circuit): For a trail , if , then is called a circuit.
Cycle (cycle) (also called a simple circuit/simple cycle (simple circuit)): For a circuit , if is the only pair of vertices repeated in the vertex sequence, then is called a cycle.
Warning
The definitions of path-related terms may differ from place to place. For example, ‘path’ may refer to the ‘walk’ defined in this article, and ‘cycle’ may refer to the ‘circuit’ defined here. When you encounter similar terminology in a problem without a special qualification such as ‘simple path’/‘non-simple path’ (that is, a ‘walk’ here), it is best to ask exactly which meaning is intended.
Subgraphs
For a graph , if there is another graph satisfying and , then is called a subgraph (subgraph) of , written .
For , if for every , whenever , we also have , then is called an induced subgraph (induced subgraph) of .
It is easy to see that an induced subgraph is determined solely by the vertex set of the subgraph. Therefore, the induced subgraph with vertex set () is called the subgraph induced by , denoted by .
If and , then is called a spanning subgraph (spanning subgraph) of .
Clearly, is its own subgraph, spanning subgraph, and induced subgraph; the edgeless graph is a spanning subgraph of . The original graph and the edgeless graph are both trivial subgraphs of .
If a spanning subgraph of an undirected graph is a -regular graph, then is called a -factor (-factor) of .
If an induced subgraph of a directed graph satisfies , we have , then is called a closed subgraph (closed subgraph) of .
Connectivity
Undirected graphs
For an undirected graph and , if there is a walk with , then and are connected (connected). By definition, every vertex is connected to itself, and the two endpoints of every edge are connected.
If every pair of vertices in an undirected graph is connected, then is called a connected graph (connected graph), and this property of is called connectivity (connectivity).
If is a connected subgraph of and there is no satisfying such that is connected, then is a connected component (connected component) of (a maximal connected subgraph).
Directed graphs
For a directed graph and , if there is a walk with , then can reach . By definition, every vertex can reach itself, and the tail of every edge can reach its head. (Connectivity in an undirected graph can also be viewed as mutual reachability.)
If every pair of vertices in a directed graph can reach each other, then the graph is strongly connected (strongly connected).
If replacing every edge of a directed graph by an undirected edge produces a connected graph, then the original directed graph is weakly connected (weakly connected).
As with connected components, there are weakly connected components (weakly connected component) (maximal weakly connected subgraphs) and strongly connected components (strongly connected component) (maximal strongly connected subgraphs).
For related algorithms, see strongly connected components.
Cuts
For related algorithms, see cut vertices and bridges and biconnected components.
In this section, ‘connected’ for directed graphs generally means ‘strongly connected’.
For a connected graph , if and (that is, the graph obtained by deleting the vertices in from ) is not connected, then is a vertex cut (vertex cut/separating set) of . A vertex cut of size one is also called a cut vertex (cut vertex).
For a connected graph and an integer , if and has no vertex cut of size , then is -vertex-connected (-vertex-connected). The largest for which this holds is called the vertex connectivity (vertex connectivity) of , denoted by . (For a non-complete graph, vertex connectivity is the size of the smallest vertex cut, while the vertex connectivity of the complete graph is .)
For a graph and satisfying , with and nonadjacent and able to reach , if , , and and are disconnected in , then is called a vertex cut from to . The size of the smallest vertex cut from to is called the local connectivity (local connectivity) between and , denoted by .
A similar definition can be made for edges:
For a connected graph , if and (that is, the graph obtained by deleting the edges in from ) is not connected, then is an edge cut (edge cut) of . An edge cut of size one is also called a bridge (bridge).
For a connected graph and an integer , if has no edge cut of size , then is -edge-connected (-edge-connected). The largest for which this holds is called the edge connectivity (edge connectivity) of , denoted by . (For any graph, edge connectivity is the size of the smallest edge cut.)
For a graph and satisfying , with able to reach , if and and are disconnected in , then is called an edge cut from to . The size of the smallest edge cut from to is called the local edge-connectivity (local edge-connectivity) between and , denoted by .
Biconnected (biconnected) is almost exactly the same as -vertex-connected, except that a graph consisting of two vertices joined by one edge is biconnected but is not -vertex-connected. In other words, a connected graph with no cut vertex is biconnected.
Edge-biconnected (-edge-connected) is exactly the same as -edge-connected. In other words, a connected graph with no bridge is edge-biconnected.
As with connected components, there are biconnected components (biconnected component) (maximal biconnected subgraphs) and Edge-biconnected components (-edge-connected component) (maximal edge-biconnected subgraphs).
Whitney's theorem: For any graph , . (The three quantities in the inequality are vertex connectivity, edge connectivity, and minimum degree, respectively.)
Sparse and dense graphs
If a graph has far fewer edges than the square of its number of vertices, it is a sparse graph (sparse graph).
If a graph has a number of edges close to the square of its number of vertices, it is a dense graph (dense graph).
These two concepts have no strict definitions. They are generally used to discuss the efficiency difference between algorithms with time complexity and algorithms with complexity (the two algorithms have comparable efficiency on dense graphs, whereas the algorithm is significantly more efficient on sparse graphs).
Complement graphs
For an undirected simple graph , its complement graph (complement graph) is the graph, denoted by , satisfying and, for every pair of vertices , if and only if .
Transpose graphs
For a directed graph , its transpose graph (transpose graph) is the graph with the same vertex set and every edge reversed. In other words, if the transpose of is , then .
Special graphs
If an undirected simple graph has an edge between every pair of distinct vertices, then is a complete graph (complete graph); the complete graph of order is denoted by . If a directed graph has two oppositely directed edges between every pair of distinct vertices, then is a complete digraph (complete digraph).
A graph with an empty edge set is called an edgeless graph (edgeless graph), an empty graph (empty graph), or a null graph (null graph). An edgeless graph of order is denoted by or . and are complements of each other.
Warning
Null graph (null graph) may also refer to an order-zero graph (order-zero graph) , whose vertex and edge sets are both empty.
If a simple directed graph has exactly one directed edge between every pair of distinct vertices, then is called a tournament graph (tournament graph).
If all edges of an undirected simple graph form exactly one cycle, then is called a cycle graph (cycle graph). A cycle graph of order () is denoted by . It is easy to see that a graph is a cycle graph if and only if it is a connected -regular graph.
If an undirected simple graph has a vertex that is universal and no edges between any of the other vertices, then is called a star graph (star graph). A star graph of order () is denoted by .
If an undirected simple graph has a vertex that is universal and the other vertices form a cycle, then is called a wheel graph (wheel graph). A wheel graph of order () is denoted by .
If all edges of an undirected simple graph form exactly one simple path, then is called a chain/path graph (chain/path graph). A chain of order is denoted by . It is easy to see that a chain is obtained by deleting one edge from a cycle graph.
If an undirected connected graph contains no cycle, then it is a tree (tree). For related content, see Basic tree algorithms.
If an undirected connected graph contains exactly one cycle, then it is a pseudotree (pseudotree).
If every vertex of a directed weakly connected graph has in-degree , then it is an outward-oriented pseudotree.
If every vertex of a directed weakly connected graph has out-degree , then it is an inward-oriented pseudotree.
Several trees can form a forest (forest); several pseudotrees can form a pseudoforest (pseudoforest); several outward-oriented pseudotrees can form a forest of outward-oriented pseudotrees; and several inward-oriented pseudotrees can form a forest of inward-oriented pseudotrees (functional graph).
If every edge of an undirected connected graph belongs to at most one cycle, then it is a cactus (cactus). Several cacti can form a desert.
If the vertex set of a graph can be divided into two parts with no edges within either part, then the graph is a bipartite graph (bipartite graph). If every pair of vertices in different parts of a bipartite graph is connected by an edge, then it is a complete bipartite graph (complete bipartite graph/biclique). A complete bipartite graph whose two parts contain and vertices is denoted by . For related content, see Bipartite graphs.
If a graph can be drawn on a plane with no two edges intersecting away from their endpoints, then it is a planar graph (planar graph). For a simple connected planar graph with , .
Kuratowski's theorem: A graph is planar if and only if it has no subgraph homeomorphic to or . Graphs and are homeomorphic if both can be transformed into the same graph by adding several degree- vertices1 on edges.
Isomorphism
For two graphs and , if there is a bijection satisfying if and only if , then is an isomorphism (isomorphism) from to , and graphs and are isomorphic (isomorphic), written .
It follows from the definition that if , then all of the following must hold:
- and have the same nonincreasing sequence of vertex degrees
- and have isomorphic induced subgraphs
Binary operations on undirected simple graphs
For undirected simple graphs, we can define the following binary operations:
Intersection (intersection): For graphs , their intersection is defined as .
It is easy to prove that the intersection of two undirected simple graphs is still an undirected simple graph.
Union (union): For graphs , their union is defined as .
Sum (sum)/direct sum (direct sum): For , construct any such that ( may be equal to ). Then any graph isomorphic to is called the sum/direct sum/disjoint union of and , denoted by or .
If the vertex sets of and are already disjoint, then .
For example, a forest can be defined as the sum of several trees.
Difference between union and sum
The ‘union’ can be understood as merging vertices and edges with the same names in the two graphs, whereas the ‘sum’ does not.
Special vertex and edge sets
Dominating sets
For an undirected graph , if and there is an edge with , then is a dominating set (dominating set) of .
The size of a smallest dominating set of an undirected graph is denoted by . Finding a minimum dominating set of a graph is NP-hard.
For a directed graph , if and there is an edge with , then is an out-dominating set (out-dominating set) of . Similarly, an in-dominating set (in-dominating set) can be defined for directed graphs.
The minimum size of an out-dominating set of a directed graph is denoted by , and the minimum size of an in-dominating set is denoted by .
Edge-dominating sets
For a graph , if and there is an edge in sharing an endpoint with it, then is an edge-dominating set (edge dominating set) of .
Finding a minimum edge-dominating set of a graph is NP-hard.
Independent sets
For a graph , if and no two vertices in are adjacent, then is an independent set (independent set) of .
The size of a largest independent set of graph is denoted by . Finding a maximum independent set of a graph is NP-hard.
Matchings
For a graph , if , every two distinct edges in have no common endpoint, and no edge in is a loop, then is a matching (matching) of , also called an independent edge set (independent edge set). If a vertex is an endpoint of an edge in the matching, it is called matched (matched)/saturated (saturated); otherwise, it is called unmatched (unmatched).
A matching with the largest number of edges is called a maximum-cardinality matching (maximum-cardinality matching) of a graph. The size of a maximum matching in graph is denoted by .
If the edges are weighted, a matching with the largest total weight is called a maximum-weight matching (maximum-weight matching) of a graph.
If adding any edge to a matching makes it no longer a matching, then the matching is a maximal matching (maximal matching). A largest maximal matching is a maximum matching, and every maximum matching is maximal. Every maximal matching is an edge-dominating set, but an edge-dominating set need not be a matching. A minimum maximal matching and a minimum edge-dominating set have the same size, but a minimum edge-dominating set need not be a matching. Finding a minimum maximal matching is NP-hard.
If every vertex is matched in a matching, then the matching is a perfect matching (perfect matching). If exactly one vertex is unmatched in a matching, then the matching is a near-perfect matching (near-perfect matching).
Counting the matchings or perfect matchings of an ordinary graph or a bipartite graph is #P-complete.
For a matching , if a path starts at an unmatched vertex and each pair of consecutive edges consists of one edge in the matching and one edge outside the matching, then the path is called an alternating path (alternating path); an alternating path that ends at an unmatched vertex is called an augmenting path (augmenting path).
Tutte's theorem: An undirected graph of order has a perfect matching if and only if, for every , , where denotes the number of connected components of odd order.
Tutte's theorem (corollary): Every bridgeless 3-regular graph has a perfect matching.
Vertex covers
For a graph , if and at least one endpoint of belongs to , then is a vertex cover (vertex cover) of .
Every vertex cover is a dominating set, but a minimal vertex cover need not be a minimal dominating set.
A vertex set is a vertex cover if and only if its complement is an independent set; therefore, the complement of a minimum vertex cover is a maximum independent set. Finding a minimum vertex cover of a graph is NP-hard.
The size of any matching in a graph is no greater than the size of any vertex cover of that graph. In the complete bipartite graph , both the maximum matching size and the minimum vertex cover size are .
Edge covers
For a graph , if and , is adjacent to at least one edge in , then is an edge cover (edge cover) of .
The size of a minimum edge cover is denoted by . It can be obtained by greedily extending a maximum matching: for every unmatched vertex, add one incident edge to the maximum matching; the result is a minimum edge cover.
A maximum matching can also be obtained from a minimum edge cover: for every pair of edges in the minimum edge cover that share a vertex, delete one of them.
For a graph, the size of a minimum edge cover plus the size of a maximum matching equals the number of vertices, namely .
For a graph, the size of a maximum matching is no greater than the size of a minimum edge cover, namely . In particular, a perfect matching is always a minimum edge cover, and it is the only case in which equality holds in the formula above.
The size of any independent set in a graph is no greater than the size of any edge cover of that graph. In the complete bipartite graph , both the maximum independent set size and the minimum edge cover size are .
Cliques
For a graph , if and every two distinct vertices in are adjacent, then is a clique (clique) of . The subgraph induced by a clique is a complete graph.
If adding any vertex to a clique makes it no longer a clique, then the clique is a maximal clique (maximal clique).
The size of a maximum clique in a graph is denoted by . It equals the size of a maximum independent set in its complement, namely . Finding a maximum clique in a graph is NP-hard.
References
OI Graph Transit Station - A review of graph theory concepts
Wikipedia (and the corresponding entries for related concepts)
Discrete Mathematics (Revised Edition), compiled by Tian Wencheng and Zhou Luxin, Tianjin Literature Press, pp. 184–187
Dai Yiqi, Hu Guanzhang, and Chen Wei. Graph Theory and Algebraic Structures [M]. Beijing: Tsinghua University Press, 1995.
Footnotes
-
This operation is also called a subdivision (subdivision). ↩