1.算法模板:
public class GraphTrverse {
final static int undiscoeverd=0;
final static int discovered=1;
final static int visited=2;
final static int unknown=0;
final static int tree=1;
final static int CROSS=2;
final static int forward=3;
final static int backward=4;
//变量
protected Graph G;
public GraphTrverse(Graph g) {
G = g;
}
protected void reset(Vertex s){
for(Iterator it=G.vertices();it.hasNext()){
Vertex v=(Vertex) it.Next();
v.setStatus(UNDISCOVERED);
v.setDistance(Inter.MAX_VALUE);
}
for(Iterator it=G.edges();it.hasNext()){
((Edge) it.getNext()).setType(UNKNOWN);
}
}
//遍历过程中对定点的v 的具体操作的模板,取决与,服务于就见图的算法algorithm()
protected abstract Object algorithm(Vertex s,Object info);
//遍历算法模板
protected abstract Object traverse(Vertex v,Object info);
//遍历算法模板
protected abstract Object traverse(Vertex v,Object info);
}