edu.hawaii.ics.yucheng
Class JadeSolver

java.lang.Object
  extended by edu.hawaii.ics.yucheng.GraphSolver
      extended by edu.hawaii.ics.yucheng.JadeSolver

 class JadeSolver
extends GraphSolver

A graph solver that runs in O(V*E) time.


Nested Class Summary
(package private)  class JadeSolver.GraphData
          A class that encapsulates the graph file conveniently for the algorithm.
(package private)  class JadeSolver.Queue
          A queue used to hold a collection of vertex nodes.
(package private)  class JadeSolver.SolutionMatrix
          A solution matrix, which is a matrix with v rows and v columns that holds booleans indicating whether or not vertices are connected.
(package private)  class JadeSolver.VertexNode
          Implementation of a vertex node.
 
Field Summary
private static int INFINITE_HOPS
           
private static float INFINITE_WEIGHT
           
 
Constructor Summary
JadeSolver()
           
 
Method Summary
private  void animate(JadeSolver.SolutionMatrix solution)
          Animates a partial solution.
(package private) static GraphSolution getSolution(float bestWeight, JadeSolver.VertexNode bestRoot, JadeSolver.SolutionMatrix bestSolution)
          Static methods cannot be declared in inner classes due to a java limitation, so this method is implemented here instead of the SolutionMatrix class.
 GraphSolution solve(Graph g)
          Solves a graph or returns null if there is no solution.
 
Methods inherited from class edu.hawaii.ics.yucheng.GraphSolver
addGraphListener, isAnimating, publish, removeGraphListener, startAnimation, startAnimation, stopAnimation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFINITE_HOPS

private static final int INFINITE_HOPS
See Also:
Constant Field Values

INFINITE_WEIGHT

private static final float INFINITE_WEIGHT
See Also:
Constant Field Values
Constructor Detail

JadeSolver

JadeSolver()
Method Detail

getSolution

static GraphSolution getSolution(float bestWeight,
                                 JadeSolver.VertexNode bestRoot,
                                 JadeSolver.SolutionMatrix bestSolution)
Static methods cannot be declared in inner classes due to a java limitation, so this method is implemented here instead of the SolutionMatrix class. This method returns the GraphSolution for a SolutionMatrix, VertexNode, and a weight.

Parameters:
bestWeight - The best weight.
bestRoot - The best root index.
bestSolution - The best solution.
Returns:
A GraphSolution object understood by the rest of the package.

animate

private void animate(JadeSolver.SolutionMatrix solution)
Animates a partial solution.

Parameters:
solution - The partial solution.

solve

public GraphSolution solve(Graph g)
Solves a graph or returns null if there is no solution.

Specified by:
solve in class GraphSolver
Parameters:
g - The graph.
Returns:
The solution.