mxGraph 2.3.0.0


com.mxgraph.analysis
Class mxTraversal

java.lang.Object
  extended by com.mxgraph.analysis.mxTraversal

public class mxTraversal
extends Object

Implements a collection of utility methods for traversing the graph structure. This does not include tree traversal methods.


Constructor Summary
mxTraversal()
           
 
Method Summary
static List<Map<Object,Object>> bellmanFord(mxAnalysisGraph aGraph, Object startVertex)
          Implements the Bellman-Ford shortest path from startVertex to all vertices.
static void bfs(mxAnalysisGraph aGraph, Object startVertex, mxGraph.mxICellVisitor visitor)
          Implements a recursive breadth first search starting from the specified cell.
static void dfs(mxAnalysisGraph aGraph, Object startVertex, mxGraph.mxICellVisitor visitor)
          Implements a recursive depth first search starting from the specified cell.
static void dijkstra(mxAnalysisGraph aGraph, Object startVertex, Object endVertex, mxGraph.mxICellVisitor visitor)
          Implements the Dijkstra's shortest path from startVertex to endVertex.
static ArrayList<Object[][]> floydRoyWarshall(mxAnalysisGraph aGraph)
          Implements the Floyd-Roy-Warshall (aka WFI) shortest path algorithm between all vertices.
static Object[] getWFIPath(mxAnalysisGraph aGraph, ArrayList<Object[][]> FWIresult, Object startVertex, Object targetVertex)
          This method helps the user to get the desired data from the result of the Floyd-Roy-Warshall algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

mxTraversal

public mxTraversal()
Method Detail

dfs

public static void dfs(mxAnalysisGraph aGraph,
                       Object startVertex,
                       mxGraph.mxICellVisitor visitor)
Implements a recursive depth first search starting from the specified cell. Process on the cell is performing by the visitor class passed in. The visitor has access to the current cell and the edge traversed to find this cell. Every cell is processed once only.
 mxTraversal.bfs(analysisGraph, startVertex, new mxICellVisitor()
 {
        public boolean visit(Object vertex, Object edge)
        {
                // perform your processing on each cell here
                return false;
        }
 });
 

Parameters:
aGraph - the graph
startVertex -
visitor -

bfs

public static void bfs(mxAnalysisGraph aGraph,
                       Object startVertex,
                       mxGraph.mxICellVisitor visitor)
Implements a recursive breadth first search starting from the specified cell. Process on the cell is performing by the visitor class passed in. The visitor has access to the current cell and the edge traversed to find this cell. Every cell is processed once only.
 mxTraversal.bfs(analysisGraph, startVertex, new mxICellVisitor()
 {
        public boolean visit(Object vertex, Object edge)
        {
                // perform your processing on each cell here
                return false;
        }
 });
 

Parameters:
aGraph - the graph
startVertex -
visitor -

dijkstra

public static void dijkstra(mxAnalysisGraph aGraph,
                            Object startVertex,
                            Object endVertex,
                            mxGraph.mxICellVisitor visitor)
                     throws StructuralException
Implements the Dijkstra's shortest path from startVertex to endVertex. Process on the cell is performing by the visitor class passed in. The visitor has access to the current cell and the edge traversed to find this cell. Every cell is processed once only.
 mxTraversal.dijkstra(analysisGraph, startVertex, endVertex, new mxICellVisitor()
 {
        public boolean visit(Object vertex, Object edge)
        {
                // perform your processing on each cell here
                return false;
        }
 });
 

Parameters:
aGraph -
startVertex -
endVertex -
visitor -
Throws:
StructuralException - - The current Dijkstra algorithm only works for connected graphs

bellmanFord

public static List<Map<Object,Object>> bellmanFord(mxAnalysisGraph aGraph,
                                                   Object startVertex)
                                            throws StructuralException
Implements the Bellman-Ford shortest path from startVertex to all vertices.

Parameters:
aGraph -
startVertex -
Returns:
a List where List(0) is the distance map and List(1) is the parent map. See the example in GraphConfigDialog.java
Throws:
StructuralException - - The Bellman-Ford algorithm only works for graphs without negative cycles

floydRoyWarshall

public static ArrayList<Object[][]> floydRoyWarshall(mxAnalysisGraph aGraph)
                                              throws StructuralException
Implements the Floyd-Roy-Warshall (aka WFI) shortest path algorithm between all vertices.

Parameters:
aGraph -
Returns:
an ArrayList where ArrayList(0) is the distance map and List(1) is the path map. See the example in GraphConfigDialog.java
Throws:
StructuralException - - The Floyd-Roy-Warshall algorithm only works for graphs without negative cycles

getWFIPath

public static Object[] getWFIPath(mxAnalysisGraph aGraph,
                                  ArrayList<Object[][]> FWIresult,
                                  Object startVertex,
                                  Object targetVertex)
                           throws StructuralException
This method helps the user to get the desired data from the result of the Floyd-Roy-Warshall algorithm.

Parameters:
aGraph -
FWIresult - - the result of the Floyd-Roy-Warhall algorithm
startVertex -
targetVertex -
Returns:
returns the shortest path from startVertex to endVertex
Throws:
StructuralException - - The Floyd-Roy-Warshall algorithm only works for graphs without negative cycles

mxGraph 2.3.0.0


Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.