drasys.or.graph.color
Class WelshPowell

java.lang.Object
  |
  +--drasys.or.graph.color.WelshPowell

public class WelshPowell
extends java.lang.Object
implements ColoringI

An implementation of the Welsh and Powell graph coloring algorithm.


Constructor Summary
WelshPowell(GraphI graph)
           
 
Method Summary
 int colorEdges()
          Colors the edges of the graph.
 int colorVertices()
          Colors the vertices of the graph.
 int getEdgeColor(EdgeI edge)
          Returns the color assigned to the edge.
 int[] getEdgeColors()
          Returns an array containing the edge color assignments.
 int getVertexColor(VertexI vertex)
          Returns the color assigned to the vertex.
 int[] getVertexColors()
          Returns an array containing the vertex color assignments.
 int sizeOfEdgeColors()
          Returns the number of unique colors used to color the edges.
 int sizeOfVertexColors()
          Returns the number of unique colors used to color the vertices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WelshPowell

public WelshPowell(GraphI graph)
Method Detail

colorVertices

public int colorVertices()
Colors the vertices of the graph. The colors are numbered sequentially starting at zero
Specified by:
colorVertices in interface ColoringI
Returns:
the number of unique colors used.

colorEdges

public int colorEdges()
Colors the edges of the graph. The colors are numbered sequentially starting at zero
Specified by:
colorEdges in interface ColoringI
Returns:
the number of unique colors used.

sizeOfVertexColors

public int sizeOfVertexColors()
                       throws GraphException
Returns the number of unique colors used to color the vertices.
Specified by:
sizeOfVertexColors in interface ColoringI
Throws:
GraphException - if the edges have not been colored.
InvalidGraphError - if the graph has changed since the vertices were colored.

sizeOfEdgeColors

public int sizeOfEdgeColors()
                     throws GraphException
Returns the number of unique colors used to color the edges.
Specified by:
sizeOfEdgeColors in interface ColoringI
Throws:
GraphException - if the edges have not been colored.
InvalidGraphError - if the graph has changed since the edges were colored.

getVertexColor

public int getVertexColor(VertexI vertex)
                   throws GraphException
Returns the color assigned to the vertex.
Specified by:
getVertexColor in interface ColoringI
Throws:
GraphException - if the vertices have not been colored.
GraphError - if the vertex is not owned by the graph.
InvalidGraphError - if the graph has changed since the vertices were colored.

getEdgeColor

public int getEdgeColor(EdgeI edge)
                 throws GraphException
Returns the color assigned to the edge.
Specified by:
getEdgeColor in interface ColoringI
Throws:
GraphException - if the edges have not been colored.
GraphError - if the edge is not owned by the graph.
InvalidGraphError - if the graph has changed since the edges were colored.

getVertexColors

public int[] getVertexColors()
                      throws GraphException
Returns an array containing the vertex color assignments. The colors are sequentially numbered starting at zero.
Specified by:
getVertexColors in interface ColoringI
Returns:
an integer array indexed by VertexI.getIndex().
Throws:
GraphException - if the vertices have not been colored.
InvalidGraphError - if the graph has changed since the vertices were colored.

getEdgeColors

public int[] getEdgeColors()
                    throws GraphException
Returns an array containing the edge color assignments. The colors are sequentially numbered starting at zero.
Specified by:
getEdgeColors in interface ColoringI
Returns:
an integer array indexed by EdgeI.getIndex().
Throws:
GraphException - if the edges have not been colored.
InvalidGraphError - if the graph has changed since the edges were colored.


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com