java.lang.Object
org.jgrapht.alg.partition.BipartitePartitioning<V,E>
- Type Parameters:
V
- the graph vertex typeE
- the graph edge type
- All Implemented Interfaces:
PartitioningAlgorithm<V>
Algorithm for computing bipartite partitions thus checking whether a graph is bipartite or not.
The algorithm runs in linear time in the number of vertices and edges.
- Author:
- Dimitrios Michail, Alexandru Valeanu
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapht.alg.interfaces.PartitioningAlgorithm
PartitioningAlgorithm.Partitioning<V>, PartitioningAlgorithm.PartitioningImpl<V>
-
Constructor Summary
ConstructorDescriptionBipartitePartitioning
(Graph<V, E> graph) Constructs a new bipartite partitioning. -
Method Summary
Modifier and TypeMethodDescriptionComputes a vertex partitioning.boolean
Test whether the input graph is bipartite.boolean
isValidPartitioning
(PartitioningAlgorithm.Partitioning<V> partitioning) Check if the given vertex partitioning is valid.
-
Constructor Details
-
BipartitePartitioning
Constructs a new bipartite partitioning.- Parameters:
graph
- the input graph;
-
-
Method Details
-
isBipartite
public boolean isBipartite()Test whether the input graph is bipartite.- Returns:
- true if the input graph is bipartite, false otherwise
-
getPartitioning
Computes a vertex partitioning.- Specified by:
getPartitioning
in interfacePartitioningAlgorithm<V>
- Returns:
- a vertex partitioning
-
isValidPartitioning
Check if the given vertex partitioning is valid.- Specified by:
isValidPartitioning
in interfacePartitioningAlgorithm<V>
- Parameters:
partitioning
- the input vertex partitioning- Returns:
- true if the input partitioning is valid, false otherwise
-