graphtraversal.java

来自「OpenJGraph是一个开源的Java库」· Java 代码 · 共 56 行

JAVA
56
字号
package salvo.jesus.graph.algorithm;import salvo.jesus.graph.*;import java.util.*;import java.io.*;/** * Abstract class for an algorithm implementing graph traversal. * Classes implementing the Graph interface uses the Strategy * pattern to allow different implementations of the graph traversal * algorithm to be used. * * Concrete implementations of this class must never modify the Graph itself. */public abstract class GraphTraversal implements Serializable {  static final public int   TERMINATEDBYVISITOR = -1;  static final public int   OK = 1;  /**   * The Graph on which graph traversal will be performed.   */  Graph   graph;  public GraphTraversal( Graph graph ) {    this.graph = graph;  }  /**   * Abstract traversal method to be implemented by subclasses.   *   * @param startat The vertex from which traversal will start.   * @param visitor Visitor object controlling if and when traversal will stop,   *                apart from having visited all the vertices.   * @param visited A List of vertices that has been visited in sequence by the traversal   */  public abstract int traverse( Vertex startat, List visited, Visitor visitor );  /**   * Abstract traversal method to be implemented by subclasses.   *   * @param startat The vertex from which traversal will start.   * @return  A VList of vertices that has been visited in sequence by the traversal   */  public abstract List traverse( Vertex startat );  /**   * Abstract traversal method to be implemented by subclasses.   *   * @param startat The vertex from which traversal will start.   * @param visitor Visitor object controlling if and when traversal will stop,   *                apart from having visited all the vertices.   * @return  A List of vertices that has been visited in sequence by the traversal   */  public abstract List traverse( Vertex startat, Visitor visitor );}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?