Some graph work before I had to go out, will continue later today

This commit is contained in:
pahimar 2013-05-29 06:45:30 -04:00
parent 13b43a3d29
commit 28d7216096
2 changed files with 57 additions and 0 deletions

View file

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

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