Package org.graph4j.support
Class BipartiteGraphSupport
java.lang.Object
org.graph4j.SimpleGraphAlgorithm
org.graph4j.support.BipartiteGraphSupport
Support class for bipartite graphs. A graph is bipartite if its
vertices can be partitioned in two disjoint stable sets.
A bipartite graph is 2-colorable.
A graph is bipartite if and only if it has no odd-length cycle.
- Author:
- Cristian Frăsinaru
-
Field Summary
Fields inherited from class org.graph4j.SimpleGraphAlgorithm
graph -
Constructor Summary
ConstructorsConstructorDescriptionBipartiteGraphSupport(Graph graph) Creates an instance of the support class. -
Method Summary
Modifier and TypeMethodDescriptionDetermines an odd cycle, if the graph is not bipartite.Created a 2-coloring of the bipartite graph.Returns the left side of the bipartition.Determines a maximum matching in a bipartite graph, usingHopcroftKarpMaximumMatchingalgorithm.Determines a maximum stable set in a bipartite graph, usingHopcroftKarpMaximumMatchingalgorithm.Determines a minimum vertex cover in a bipartite graph, usingHopcroftKarpMaximumMatchingalgorithm.Returns the right side of the bipartition.getSide(int v) Determines the stable set of the partition where a specified vertex belongs to.booleanMethods inherited from class org.graph4j.SimpleGraphAlgorithm
getGraph
-
Constructor Details
-
BipartiteGraphSupport
Creates an instance of the support class.- Parameters:
graph- the input graph.
-
-
Method Details
-
isBipartite
public boolean isBipartite()- Returns:
trueif the graph is bipartite,falseotherwise.
-
getLeftSide
Returns the left side of the bipartition.- Returns:
- the left side of the graph, if the graph is bipartite.
- Throws:
NotBipartiteException- if the graph is not bipartite.
-
getRightSide
Returns the right side of the bipartition.- Returns:
- the right side of the graph, if the graph is bipartite.
- Throws:
NotBipartiteException- if the graph is not bipartite.
-
getSide
Determines the stable set of the partition where a specified vertex belongs to.- Parameters:
v- a vertex number- Returns:
- the partition set
vbelongs to, if the graph is bipartite. - Throws:
NotBipartiteException- if the graph is not bipartite.
-
findOddCycle
Determines an odd cycle, if the graph is not bipartite.- Returns:
- an odd cycle, if the graph is not bipartite, otherwise it returns
null.
-
getColoring
Created a 2-coloring of the bipartite graph.- Returns:
- a 2-coloring of the bipartite graph.
- Throws:
NotBipartiteException- if the graph is not bipartite.
-
getMaximumMatching
Determines a maximum matching in a bipartite graph, usingHopcroftKarpMaximumMatchingalgorithm.- Returns:
- a maximum stable set in a bipartite graph.
- Throws:
NotBipartiteException- if the graph is not bipartite.- See Also:
-
getMaximumStableSet
Determines a maximum stable set in a bipartite graph, usingHopcroftKarpMaximumMatchingalgorithm.- Returns:
- a maximum stable set in a bipartite graph.
- Throws:
NotBipartiteException- if the graph is not bipartite.- See Also:
-
getMinimumVertexCover
Determines a minimum vertex cover in a bipartite graph, usingHopcroftKarpMaximumMatchingalgorithm.- Returns:
- a maximum stable set in a bipartite graph.
- Throws:
NotBipartiteException- if the graph is not bipartite.- See Also:
-