Class BipartiteGraph

java.lang.Object
  |
  +--BipartiteGraph

public class BipartiteGraph
extends java.lang.Object

A repręsentation of a bipartite graph. The graph is represented only by the nodes - the edges are not stored explicit in the graph. The nodes are put into two lists, V1 and V2.


Constructor Summary
BipartiteGraph()
           
 
Method Summary
 java.lang.String getMatches()
          Get a string representation of the edges that are part of the matching.
 void loadDataFromFile(java.lang.String filename)
          Loads an input graph from a file Input data are read from a file and the corresponding graph is constructed.
 void removeColors()
          Colors the nodes white All the nodes composing the graph are run through.
 Node runTransitionSystem()
          Run the graph coloring algorithm.
 void toLaTeX(java.lang.String filename)
          Produces a graphical LaTeX output of a graph.
 void toLaTeX(java.lang.String filename, boolean only_pairs)
          Produces a graphical LaTeX output of a graph.
 java.lang.String toString()
          Returns a string representation of the graph.
 void turnEdges(Node v0)
          Turns the edges around.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BipartiteGraph

public BipartiteGraph()
Method Detail

runTransitionSystem

public Node runTransitionSystem()
Run the graph coloring algorithm. The graph is colored by application of the coloring transition system. The algorithm runs in O(|m| + |n|), where m and n are the edges and nodes from the graph which nodes are those from V1 and V2.
Returns:
a random terminal node

turnEdges

public void turnEdges(Node v0)
Turns the edges around. The edges are reorientated along a random path leading back from the terminal node v0 to an initial node. It runs in O(|m'|) where m' are the edges that lie on the path. The terminal node v0 must come from a call to runTransitionSystem() because that method also stores information needed to find a path back to an initial node.
Parameters:
v0 - a terminal node as returned by runTransitionSystem()
See Also:
runTransitionSystem()

removeColors

public void removeColors()
Colors the nodes white All the nodes composing the graph are run through. The color of the nodes is systematically changed to white. The algorithm runs in O(|n|), where n are the nodes listed in V1 and V2 (which means the total amount of nodes in the graph).

loadDataFromFile

public void loadDataFromFile(java.lang.String filename)
Loads an input graph from a file Input data are read from a file and the corresponding graph is constructed. The algorithm runs in O(|n| + |m|) where m are the edges listed in the input file and |n| the number of nodes composing the graph.
Parameters:
filename - an input data file describing a graph.

toLaTeX

public void toLaTeX(java.lang.String filename)
Produces a graphical LaTeX output of a graph. The output is an Xy-pic matrix which can be included in another LaTeX document.
Parameters:
filename - the LaTeX output will be saved here.

toLaTeX

public void toLaTeX(java.lang.String filename,
                    boolean only_pairs)
Produces a graphical LaTeX output of a graph. The output is an Xy-pic matrix which can be included in another LaTeX document.
Parameters:
filename - the LaTeX output will be saved here.
only_pairs - boolean that indicates whether the produced graph should contain all the edges or only the pair edges.

toString

public java.lang.String toString()
Returns a string representation of the graph. This should only be used when debugging.
Overrides:
toString in class java.lang.Object
Returns:
an enumeration of the nodes in V1 and V2.

getMatches

public java.lang.String getMatches()
Get a string representation of the edges that are part of the matching. This is done by finding the edges that goes from V2 to V1. It is done in O(|V1|) since we only have to ask each node in V1 once to find out if there is an incoming edge. If so, then it takes a constant amount of time to acquire the edge.
Returns:
a string representation of the edges in the matching, or the empty string if the matching is the empty set.