图的节点描述类
public class Node {
public Integer value;
public ArrayList<Node> next;
public Integer in;
public Integer out;
public ArrayList<Edge> edges;
public Node() {
}
public Node(Integer val) {
this.value = val;
this.next = new ArrayList<Node>();
this.in = 0;
this.out = 0;
this.edges = new ArrayList<Edge>();
}
}
图的边描述类
public class Edge {
public Integer weight;
public Node from;
public Node to;
public Edge() {
}
public Edge(Integer 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() {
}
public Graph(HashMap<Integer, Node> nodes, HashSet<Edge> edges) {
this.nodes = nodes;
this.edges = edges;
}
}
评论区