目 录CONTENT

文章目录

关于图的构建

小磊
2023-04-25 / 0 评论 / 0 点赞 / 604 阅读 / 139 字 / 正在检测是否收录...

图的节点描述类

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;
    }
}
0

评论区