Class PureLinkGraphConnectedComponents
- All Implemented Interfaces:
BigraphDecompositionStrategy<PureBigraph>
This implementation is suited for hypergraphs (i.e., link graphs). See the note below for trees and forests. Each hyperedge is treated as a set of vertices that are "unioned" together in the algorithm.
Complexity: O(E * α(V)), where E is the number of hyperedges, V is the number of vertices, and α the inverse of the Ackermann function.
Note: A tree is a connected, acyclic graph, which means every pair of nodes in a tree is connected by exactly one path, and there are no cycles. Given these properties, we do not have to handle connected components in trees. For forests, we just need to identify and count each tree as a connected component.
- Author:
- Dominik Grzelak
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Generic subclass that solves the connectedness problem of a graph.Nested classes/interfaces inherited from interface org.bigraphs.framework.core.analysis.BigraphDecompositionStrategy
BigraphDecompositionStrategy.DecompositionStrategy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
decompose
(PureBigraph linkGraph) Entrypoint of the algorithm.getChildrenForRoot
(Map<Integer, Integer> idMap, int rootIndex) Get the connected component as disjoint bigraphs.Map<BigraphEntity<?>,
Integer> getIdMap()
Get the map fromBigraphEntity
to simple Integer labels.Map<Integer,
List<BigraphEntity<?>>> Returns a map of partitions and their entities (which can be nodes and inner names).Returns the abstract data structure to solve the Union-Find problem.
-
Constructor Details
-
PureLinkGraphConnectedComponents
public PureLinkGraphConnectedComponents()
-
-
Method Details
-
getDecompositionStrategyType
- Specified by:
getDecompositionStrategyType
in interfaceBigraphDecompositionStrategy<PureBigraph>
-
decompose
Entrypoint of the algorithm. Computes the number of connected components of a link graph. It can be used to determine whether it is connected or not.- Specified by:
decompose
in interfaceBigraphDecompositionStrategy<PureBigraph>
- Parameters:
linkGraph
- the bigraph
-
getPartitions
Returns a map of partitions and their entities (which can be nodes and inner names). Methoddecompose(PureBigraph)
must be called before.The unique key signifies not only that it's a unique partition, but the integer value also refers to the "representative" of this partition as determined by the Union-Find algorithm. It can be identified via the
idMap
.- Returns:
- partitions
-
getConnectedComponents
Get the connected component as disjoint bigraphs. They can be composed from left to right. Therefore, a linked list is returned that determines the order. Otherwise, the interfaces have to be checked manually.The bigraphs are separated according to the link graph structure. If the bigraph is just a tree, or if there is a single path through all nodes w.r.t. the link graph, then the tree will be returned. That is, the number of connected components is 1.
- Returns:
- the connected components as bigraphs
-
getChildrenForRoot
-
getIdMap
Get the map fromBigraphEntity
to simple Integer labels. For the Union-Find algorithm, the original bigraph nodes and edges are assigned a simple integer label for identification.- Returns:
- the map from bigraph entities to simple integer labels
-
getUnionFindDataStructure
Returns the abstract data structure to solve the Union-Find problem.- Returns:
- the data structure
-
vertexLabelSupplier
-
edgeLabelSupplier
-