public class Graphic {
public static class Vertex{
public int num;//节点编号
public int weight;//边的权重
public Vertex next;//指向顶点的下一个弧尾,即下一条边
public Vertex(int num,int weight,Vertex next)
{
this.num=num;
this.weight=weight;
this.next=next;
}
}
private int size;//图的顶点数
private boolean isDirection;//是否为有向图true,
private boolean visit[];
private Vertex p[];//存放每个顶点的前驱
private int distance[];//广度优先遍历时存放与根节点的距离
private Vertex adj[];
public int startT[];//深度优先遍历的开始时间
public int endT[];//深度优先遍历的结束时间 用于拓扑排序
int time;//深度优先遍历时记录每个节点的开始和结束时间的计时器
LinkedList<Vertex>topologicalSort=new LinkedList<Vertex>();//存放拓扑排序的数组