weak component
{{Short description|Partition of vertices of a directed graph}}
{{Use dmy dates|cs1-dates=ly|date=January 2022}}
{{Use list-defined references|date=January 2022}}
In graph theory, the weak components of a directed graph partition the vertices of the graph into subsets that are totally ordered by reachability. They form the finest partition of the set of vertices that is totally ordered in this way.
Definition
The weak components were defined in a 1972 paper by Ronald Graham, Donald Knuth, and (posthumously) Theodore Motzkin, by analogy to the strongly connected components of a directed graph, which form the finest possible partition of the graph's vertices into subsets that are partially ordered by reachability. Instead, they defined the weak components to be the finest partition of the vertices into subsets that are totally ordered by {{nowrap|reachability.{{r|gkm|knuth}}}}
In more detail, {{harvtxt|Knuth|2022}} defines the weak components through a combination of four symmetric relations on the vertices of any directed graph, denoted here as {{nowrap|,}} {{nowrap|,}} {{nowrap|,}} {{nowrap|and :}}
- For any two vertices and of the graph, if and only if each vertex is reachable from the other: there exist paths in the graph from to and from {{nowrap|to .}} The relation is an equivalence relation, and its equivalence classes are used to define the strongly connected components of the graph.
- For any two vertices and of the graph, if and only if neither vertex is reachable from the other: there do not exist paths in the graph in either direction between {{nowrap|and .}}
- For any two vertices and of the graph, if and only if either {{nowrap|or .}} That is, there may be a two-way connection between these vertices, or they may be mutually unreachable, but they may not have a one-way connection.
- The relation is defined as the transitive closure {{nowrap|of .}} That is, when there is a sequence of vertices, starting with and ending {{nowrap|with ,}} such that each consecutive pair in the sequence is related {{nowrap|by .}}
Then is an equivalence relation: every vertex is related to itself by (because it can reach itself in both directions by paths of length zero), any two vertices that are related by can be swapped for each other without changing this relation (because is built out of the symmetric relations {{nowrap|and ),}} and is a transitive relation (because it is a transitive closure). As with any equivalence relation, it can be used to partition the vertices of the graph into equivalence classes, subsets of the vertices such that two vertices are related by if and only if they belong to the same equivalence class. These equivalence classes are the weak components of the given {{nowrap|graph.{{r|knuth}}}}
The original definition by Graham, Knuth, and Motzkin is equivalent but formulated somewhat differently. Given a directed {{nowrap|graph ,}} they first construct another graph as the complement graph of the transitive closure {{nowrap|of .}} As {{harvtxt|Tarjan|1974}} describes, the edges in represent {{em|non-paths}}, pairs of vertices that are not connected by a path {{nowrap|in .{{r|tarjan}}}} Then, two vertices belong to the same weak component when either they belong to the same strongly connected component of or {{nowrap|of .{{r|gkm|tarjan}}}} As Graham, Knuth, and Motzkin show, this condition defines an equivalence {{nowrap|relation,{{r|gkm}}}} the same one defined above {{nowrap|as .{{sfnp|Knuth|2022|loc=Exercise 81, p. 21}}}}
Corresponding to these definitions, a directed graph is called weakly connected if it has exactly one weak component. This means that its vertices cannot be partitioned into two subsets, such that all of the vertices in the first subset can reach all of the vertices in the second subset, but such that none of the vertices in the second subset can reach any of the vertices in the first subset. It differs from other notions of weak connectivity in the literature, such as connectivity and components in the underlying undirected graph, for which Knuth suggests the alternative terminology {{nowrap|{{em|undirected components}}.{{r|knuth}}}}
Properties
If and are two weak components of a directed graph,
then either all vertices in can reach all vertices in by paths in the graph, or all vertices in can reach all vertices {{nowrap|in .}} However, there cannot exist reachability relations in both directions between these two components. Therefore, we can define an ordering on the weak components, according to which
This ordering on the weak components can alternatively be interpreted as a weak ordering on the vertices themselves, with the property that when
Every weak component is a union of strongly connected {{nowrap|components.{{r|knuth}}}} If the strongly connected components of any given graph are contracted to single vertices, producing a directed acyclic graph (the {{em|condensation}} of the given graph), and then this condensation is topologically sorted, then each weak component necessarily appears as a consecutive subsequence of the topological order of the strong {{nowrap|components.{{r|tarjan}}}}
Algorithms
An algorithm for computing the weak components of a given directed graph in linear time was described by {{harvtxt|Pacault|1974}}, and subsequently simplified by {{harvtxt|Tarjan|1974}} and {{nowrap|{{harvtxt|Knuth|2022}}.{{r|knuth|tarjan|pacault}}}} As Tarjan observes, Tarjan's strongly connected components algorithm based on depth-first search will output the strongly connected components in (the reverse of) a topologically sorted order. The algorithm for weak components generates the strongly connected components in this order, and maintains a partition of the components that have been generated so far into the weak components of their induced subgraph. After all components are generated, this partition will describe the weak components of the whole {{nowrap|graph.{{r|knuth|tarjan}}}}
It is convenient to maintain the current partition into weak components in a stack, with each weak component maintaining additionally a list of its {{em|sources}}, strongly connected components that have no incoming edges from other strongly connected components in the same weak component, with the most recently generated source first. Each newly generated strongly connected component may form a new weak component on its own, or may end up merged with some of the previously constructed weak components near the top of the stack, the ones for which it cannot reach all {{nowrap|sources.{{r|knuth|tarjan}}}}
Thus, the algorithm performs the following {{nowrap|steps:{{r|knuth|tarjan}}}}
- Initialize an empty stack of weak components, each associated with a list of its source components.
- Use Tarjan's strongly connected components algorithm to generate the strongly connected components of the given graph in the reverse of a topological order. When each strongly connected component
S is generated, perform the following steps with it: - While the stack is non-empty and
S has no edges to the top weak component of the stack, pop that component from the stack. - If the stack is still non-empty, and some sources of its top weak component are not hit by edges {{nowrap|from
S ,}} again pop that component from the stack. - Construct a new weak {{nowrap|component
W ,}} containing as sourcesS and all of the unhit sources from the top component that was popped, and pushW onto the stack.
Each test for whether any edges from
References
{{reflist|refs=
| last1 = Graham | first1 = R. L. | author1-link = Ronald Graham
| last2 = Knuth | first2 = D. E. | author2-link = Donald Knuth
| last3 = Motzkin | first3 = T. S. | author3-link = Theodore Motzkin
| doi = 10.1016/0012-365X(72)90057-X
| journal = Discrete Mathematics
| mr = 323577
| pages = 17–29
| title = Complements and transitive closures
| url = https://mathweb.ucsd.edu/~fan/ron/papers/72_08_complements.pdf
| volume = 2
| year = 1972}}
| last = Knuth | first = Donald E. | author-link = Donald Knuth
| contribution = Weak components
| date = January 15, 2022
| pages = 11–14
| title = The Art of Computer Programming, Volume 4, Pre-Fascicle 12A: Components and Traversal
| url = https://cs.stanford.edu/~knuth/fasc12a+.pdf}}
| last = Pacault | first = Jean François
| doi = 10.1137/0203005
| journal = SIAM Journal on Computing
| mr = 376418
| pages = 56–61
| title = Computing the weak components of a directed graph
| volume = 3
| year = 1974}}
| last = Tarjan | first = Robert Endre | author-link = Robert Tarjan
| date = July 1974
| doi = 10.1016/0020-0190(74)90040-4
| issue = 1
| journal = Information Processing Letters
| pages = 13–15
| title = A new algorithm for finding weak components
| volume = 3}}
}}
External links
- {{citation
| last = Knuth | first = Donald E. | author-link = Donald Knuth
| title = Strong Components and Weak Components
| department = Annual Christmas Lecture
| type = video
| url = https://www.youtube.com/watch?v=au26uZfuxVY
| publisher = Stanford University
| date = 2024-12-05
}}