net.xqhs.graphs.representation.linear
Class LinearGraphRepresentation.PathComparator

java.lang.Object
  extended by net.xqhs.graphs.representation.linear.LinearGraphRepresentation.PathComparator
All Implemented Interfaces:
java.util.Comparator<PathElement>
Enclosing class:
LinearGraphRepresentation

static class LinearGraphRepresentation.PathComparator
extends java.lang.Object
implements java.util.Comparator<PathElement>

A Comparator for PathElement instances that sorts the element with the longer distance to a leaf first. In case both elements have the same distance to the farthest leaf, a LinearGraphRepresentation.NodeInAlphaComparator is used on the graph nodes corresponding to the path elements.

Author:
Andrei Olaru

Field Summary
protected  Graph theGraph
          The graph containing the paths to be compared.
 
Constructor Summary
LinearGraphRepresentation.PathComparator(Graph graph)
          Default constructor.
 
Method Summary
 int compare(PathElement el1, PathElement el2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

theGraph

protected Graph theGraph
The graph containing the paths to be compared.

Constructor Detail

LinearGraphRepresentation.PathComparator

public LinearGraphRepresentation.PathComparator(Graph graph)
Default constructor. The graph is needed to calculate the in-degree of nodes in path elements.

Parameters:
graph - - the graph to which the paths to compare belong.
Method Detail

compare

public int compare(PathElement el1,
                   PathElement el2)
Specified by:
compare in interface java.util.Comparator<PathElement>