Some graph work before I had to go out, will continue later today
This commit is contained in:
parent
13b43a3d29
commit
28d7216096
2 changed files with 57 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
package com.pahimar.ee3.emc.graph;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
||||
|
||||
public class WeightedDirectedGraph<T, E> implements Iterable<T> {
|
||||
|
||||
private final Map<T, SortedSet<E>> graph = new HashMap<T, SortedSet<E>>();
|
||||
private List<T> orderedNodes = new ArrayList<T>();
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
|
||||
return orderedNodes.iterator();
|
||||
}
|
||||
|
||||
}
|
35
ee3_common/com/pahimar/ee3/emc/graph/WeightedEdge.java
Normal file
35
ee3_common/com/pahimar/ee3/emc/graph/WeightedEdge.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package com.pahimar.ee3.emc.graph;
|
||||
|
||||
|
||||
|
||||
public class WeightedEdge<T> {
|
||||
|
||||
private int weight;
|
||||
private T target;
|
||||
|
||||
public WeightedEdge(int weight, T target) {
|
||||
|
||||
this.weight = weight;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
|
||||
return weight;
|
||||
}
|
||||
|
||||
public T getTarget() {
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setWeight(int weight) {
|
||||
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public void setTarget(T target) {
|
||||
|
||||
this.target = target;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue