Class mxTraversal


  • public class mxTraversal
    extends java.lang.Object
    Implements a collection of utility methods for traversing the graph structure. This does not include tree traversal methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      mxTraversal()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.util.Map<java.lang.Object,​java.lang.Object>> bellmanFord​(mxAnalysisGraph aGraph, java.lang.Object startVertex)
      Implements the Bellman-Ford shortest path from startVertex to all vertices.
      static void bfs​(mxAnalysisGraph aGraph, java.lang.Object startVertex, mxGraph.mxICellVisitor visitor)
      Implements a recursive breadth first search starting from the specified cell.
      static void dfs​(mxAnalysisGraph aGraph, java.lang.Object startVertex, mxGraph.mxICellVisitor visitor)
      Implements a recursive depth first search starting from the specified cell.
      static void dijkstra​(mxAnalysisGraph aGraph, java.lang.Object startVertex, java.lang.Object endVertex, mxGraph.mxICellVisitor visitor)
      Implements the Dijkstra's shortest path from startVertex to endVertex.
      static java.util.ArrayList<java.lang.Object[][]> floydRoyWarshall​(mxAnalysisGraph aGraph)
      Implements the Floyd-Roy-Warshall (aka WFI) shortest path algorithm between all vertices.
      static java.lang.Object[] getWFIPath​(mxAnalysisGraph aGraph, java.util.ArrayList<java.lang.Object[][]> FWIresult, java.lang.Object startVertex, java.lang.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,
                               java.lang.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,
                               java.lang.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,
                                    java.lang.Object startVertex,
                                    java.lang.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 java.util.List<java.util.Map<java.lang.Object,​java.lang.Object>> bellmanFord​(mxAnalysisGraph aGraph,
                                                                                                         java.lang.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 java.util.ArrayList<java.lang.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 java.lang.Object[] getWFIPath​(mxAnalysisGraph aGraph,
                                                    java.util.ArrayList<java.lang.Object[][]> FWIresult,
                                                    java.lang.Object startVertex,
                                                    java.lang.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