public final class Bipartitions extends Object
A bipartite graph is a graph whose nodes can be partitioned into two sets such that each edges connects two nodes of different sets. In other words, there are no edges connecting nodes that belong to the same partition.
The two sets/partitions are represented by two Object
constants i.e., RED
or BLUE
.
Example of a bipartite graph. Circular and rectangular nodes represent the two partitions.
Modifier and Type | Field and Description |
---|---|
static Object |
BLUE
A constant for marking a node that belongs to the blue partition.
|
static Object |
RED
A constant for marking a node that belongs to the red partition.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
getBipartition(Graph graph,
INodeMap markMap)
Calculates a bipartition of the given graph, if one exists.
|
static boolean |
isBipartite(Graph graph)
Determines whether or not the given graph is bipartite.
|
public static final Object BLUE
public static final Object RED
public static final boolean isBipartite(Graph graph)
O(graph.N() + graph.E())
graph
- the given graphtrue
if the graph is bipartite, false
otherwise