Edge:
/**
* Created by wang on 2017/11/27.
*/
public class Edge {
public Node from;
public Node to;
public int weight;
public Edge(Node to,Node from,int weight){
this.from = from;
this.to = to;
this.weight = weight;
}
}
Node:
import java.util.ArrayList;
/**
* Created by wang on 2017/11/27.
*/
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;
in = 0;
out = 0;
nexts = new ArrayList<Node>();
edges = new ArrayList<Edge>();
}
}
Graph:
import java.util.HashMap;
import java.util.HashSet;
/**
* Created by wang on 2017/11/27.
*/
public class Graph {
public HashMap<Integer,Node> nodes;
public HashSet<Edge> edges;
public Graph(){
nodes = new HashMap<>();
edges = new HashSet<>();
}
}