|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.algo.Bipartitions
public class Bipartitions
This class provides methods to determine whether a graph is bipartite and to obtain the corresponding partitions.
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
.
Field Summary | |
---|---|
static java.lang.Object |
BLUE
A constant for marking a node that belongs to the blue partition. |
static java.lang.Object |
RED
A constant for marking a node that belongs to the red partition. |
Method Summary | |
---|---|
static boolean |
getBipartition(Graph graph,
NodeMap 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Object RED
public static final java.lang.Object BLUE
Method Detail |
---|
public static boolean isBipartite(Graph graph)
O(graph.N() + graph.E())
graph
- the given graph
true
if the graph is bipartite, false
otherwisepublic static boolean getBipartition(Graph graph, NodeMap markMap)
If the graph is bipartite, then for all nodes of the given graph either RED
or BLUE
objects will be set in the given NodeMap
, depending on the partition to which each node belongs.
O(graph.N() + graph.E())
graph
- the given graphmarkMap
- the NodeMap
that will be filled during the BFS execution and returns the partition (either
RED
or BLUE
) to which each node belongs
true
if the graph is bipartite, false
otherwise
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |