edu.hawaii.ics.yucheng
Class GraphSolution

java.lang.Object
  extended by edu.hawaii.ics.yucheng.GraphSolution
All Implemented Interfaces:
java.lang.Iterable<Edge>

final class GraphSolution
extends java.lang.Object
implements java.lang.Iterable<Edge>

A solution, or partial solution, for a graph. This class is immutable.


Field Summary
private  java.util.ArrayList<Edge> myEdges
           
private  int myRoot
           
private  float myWeight
           
static int NO_ROOT
           
static float NO_WEIGHT
           
 
Constructor Summary
GraphSolution(java.util.Collection<Edge> edges)
          Initializes a new instance of the class.
GraphSolution(java.util.Collection<Edge> edges, int root)
          Initializes a new instance of the class.
GraphSolution(java.util.Collection<Edge> edges, int root, float weight)
          Initializes a new instance of the class.
 
Method Summary
 boolean hasRoot()
          Returns true if the solution has a root specified.
 boolean hasWeight()
          Returns true if the solution has a weight specified.
private static boolean isDuplicateEdge(java.util.Collection<Edge> edges, Edge edge)
          Returns true if the edge is a duplicate in a collection.
 java.util.Iterator<Edge> iterator()
          Returns an iterator for the edges in the solution.
 int root()
          Returns the root vertex.
 float weight()
          Returns the calculated weight.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ROOT

public static final int NO_ROOT
See Also:
Constant Field Values

NO_WEIGHT

public static final float NO_WEIGHT
See Also:
Constant Field Values

myEdges

private final java.util.ArrayList<Edge> myEdges

myRoot

private final int myRoot

myWeight

private final float myWeight
Constructor Detail

GraphSolution

public GraphSolution(java.util.Collection<Edge> edges)
Initializes a new instance of the class.

Parameters:
edges - The edges.

GraphSolution

public GraphSolution(java.util.Collection<Edge> edges,
                     int root)
Initializes a new instance of the class.

Parameters:
edges - The edges.
root - The root edge.

GraphSolution

public GraphSolution(java.util.Collection<Edge> edges,
                     int root,
                     float weight)
Initializes a new instance of the class.

Parameters:
edges - The edges.
root - The root edge.
weight - The calculated weight.
Method Detail

isDuplicateEdge

private static boolean isDuplicateEdge(java.util.Collection<Edge> edges,
                                       Edge edge)
Returns true if the edge is a duplicate in a collection.

Parameters:
edges - The collection of edges.
edge - The edge to find.
Returns:
True indicates the edge is a duplicate.

hasRoot

public boolean hasRoot()
Returns true if the solution has a root specified.

Returns:
True if the solution has a root specified and false otherwise.

hasWeight

public boolean hasWeight()
Returns true if the solution has a weight specified.

Returns:
True if the solution has a weight specified and false otherwise.

iterator

public java.util.Iterator<Edge> iterator()
Returns an iterator for the edges in the solution.

Specified by:
iterator in interface java.lang.Iterable<Edge>
Returns:
An edge iterator.

root

public int root()
Returns the root vertex.

Returns:
The root vertex.

weight

public float weight()
Returns the calculated weight.

Returns:
The calculated weight.