Weak component

From testwiki
Revision as of 16:12, 7 February 2025 by imported>Matt Deres (Reverted 1 edit by 46.210.30.175 (talk): Unclear what is meant with this change)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Short description Template:Use dmy dates Template:Use list-defined references 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 Template:Nowrap

In more detail, Template:Harvtxt defines the weak components through a combination of four symmetric relations on the vertices of any directed graph, denoted here as Template:Nowrap Template:Nowrap Template:Nowrap Template:Nowrap

  • For any two vertices u and v of the graph, uv if and only if each vertex is reachable from the other: there exist paths in the graph from u to v and from v Template:Nowrap 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 u and v of the graph, uv if and only if neither vertex is reachable from the other: there do not exist paths in the graph in either direction between u Template:Nowrap
  • For any two vertices u and v of the graph, uv if and only if either uv Template:Nowrap 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 Template:Nowrap That is, uv when there is a sequence uv of vertices, starting with u and ending Template:Nowrap such that each consecutive pair in the sequence is related Template:Nowrap

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 Template:Nowrap 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 Template:Nowrap

The original definition by Graham, Knuth, and Motzkin is equivalent but formulated somewhat differently. Given a directed Template:Nowrap they first construct another graph G^ as the complement graph of the transitive closure Template:Nowrap As Template:Harvtxt describes, the edges in G^ represent Template:Em, pairs of vertices that are not connected by a path Template:Nowrap Then, two vertices belong to the same weak component when either they belong to the same strongly connected component of G or Template:Nowrap As Graham, Knuth, and Motzkin show, this condition defines an equivalence Template:Nowrap the same one defined above Template:Nowrap

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 Template:Nowrap

Properties

If X and Y are two weak components of a directed graph, then either all vertices in X can reach all vertices in Y by paths in the graph, or all vertices in Y can reach all vertices Template:Nowrap 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 X<Y when all vertices in X can reach all vertices Template:Nowrap By definition, Template:Nowrap This is an asymmetric relation (two elements can only be related in one direction, not the other) and it inherits the property of being a transitive relation from the transitivity of reachability. Therefore, it defines a total ordering on the weak components. It is the finest possible partition of the vertices into a totally ordered set of vertices consistent with Template:Nowrap

This ordering on the weak components can alternatively be interpreted as a weak ordering on the vertices themselves, with the property that when u<v in the weak ordering, there necessarily exists a path from u Template:Nowrap but not from v Template:Nowrap However, this is not a complete characterization of this weak ordering, because two vertices u and v could have this same reachability ordering while belonging to the same weak component as each Template:Nowrap

Every weak component is a union of strongly connected Template:Nowrap If the strongly connected components of any given graph are contracted to single vertices, producing a directed acyclic graph (the Template:Em 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 Template:Nowrap

Algorithms

An algorithm for computing the weak components of a given directed graph in linear time was described by Template:Harvtxt, and subsequently simplified by Template:Harvtxt and Template:Nowrap 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 Template:Nowrap

It is convenient to maintain the current partition into weak components in a stack, with each weak component maintaining additionally a list of its Template:Em, 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 Template:Nowrap

Thus, the algorithm performs the following Template:Nowrap

  • 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 Template:Nowrap again pop that component from the stack.
    • Construct a new weak Template:Nowrap containing as sources S and all of the unhit sources from the top component that was popped, and push W onto the stack.

Each test for whether any edges from S hit a weak component can be performed in constant time once we find an edge from S to the most recently generated earlier strongly connected component, by comparing the target component of that edge to the first source of the second-to-top component on the stack.

References

Template:Reflist