All Downloads are FREE. Search and download functionalities are using the official Maven repository.

poussecafe.doc.graph.UndirectedGraphNodesAndEdges Maven / Gradle / Ivy

There is a newer version: 0.29.0
Show newest version
package poussecafe.doc.graph;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class UndirectedGraphNodesAndEdges implements NodesAndEdges {

    private Map nodes = new HashMap<>();

    private Set edges = new HashSet<>();

    @Override
    public void addEdge(Edge edge) {
        edges.add((UndirectedEdge) edge);
    }

    public List edges() {
        return new ArrayList<>(edges);
    }

    public List nodes() {
        return new ArrayList<>(nodes.values());
    }

    @Override
    public void addNode(Node node) {
        nodes.put(node.getName(), node);
    }

    public Node getNode(String name) {
        return nodes.get(name);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy