美文网首页算法
本文集用到的自定义数据结构

本文集用到的自定义数据结构

作者: 一凡呀 | 来源:发表于2017-12-07 15:15 被阅读0次

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<>();
    }
}

相关文章

网友评论

    本文标题:本文集用到的自定义数据结构

    本文链接:https://www.haomeiwen.com/subject/vhndixtx.html