//结点,按照有向图完整定义
public class Node{
public int value;
public int in; //入度
public int out; //出度
public ArrayList<Node> nexts;
public ArrayList<Edge> edges;
public Node(int value){
this.value = value;
this.in = 0;
this.out = 0;
nexts = new ArrayList();
edges = new ArrayList();
}
}
//边
public class Edge{
public int weight;
public Node from;
public Node to;
public Edge(int weight,Node from,Node to){
this.weight = weight;
this.from =from;
this.to = to;
}
}
public class Graph{
public HashMap<Integer,Node> nodes;
public HashSet<Edge> edges;
public Graph(){
nodes = new HashMap();
edges = new HashSet();
}
}