net.amygdalum.util.graph.Graph Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compilerutils Show documentation
Show all versions of compilerutils Show documentation
Utility classes needed for search and compiler applications
The newest version!
package net.amygdalum.util.graph;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
public class Graph> {
private Map> nodes;
public Graph() {
this.nodes = new LinkedHashMap>();
}
public GraphNode getNode(K key) {
return nodes.get(key);
}
public GraphNode createNode(K key) {
GraphNode node = nodes.get(key);
if (node == null) {
node = new GraphNode(key);
nodes.put(key, node);
}
return node;
}
public Collection> getNodes() {
return nodes.values();
}
public void connectNodes(K from, K to) {
GraphNode toNode = nodes.get(to);
GraphNode fromNode = nodes.get(from);
fromNode.addSuccessor(toNode);
toNode.addPredecessor(fromNode);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy