Fixed a derp in my edgesTo implementation
This commit is contained in:
parent
d8e80366e1
commit
e3079cbfef
|
@ -207,19 +207,21 @@ public class DynEMC {
|
|||
}
|
||||
LogHelper.log(Level.INFO, "***** END EDGES FROM *****");
|
||||
|
||||
// LogHelper.log(Level.INFO, "***** START EDGES TO *****");
|
||||
// nodeIter = graph.iterator();
|
||||
// while (nodeIter.hasNext()) {
|
||||
// CustomStackWrapper node = nodeIter.next();
|
||||
// Set<WeightedEdge<CustomStackWrapper>> edgesTo = graph.edgesTo(node);
|
||||
// for (WeightedEdge<CustomStackWrapper> edge : edgesTo) {
|
||||
// LogHelper.log(Level.INFO, "From: " + node);
|
||||
// LogHelper.log(Level.INFO, "To: " + edge.getTarget());
|
||||
// LogHelper.log(Level.INFO, "Weight: " + edge.getWeight());
|
||||
// LogHelper.log(Level.INFO, "");
|
||||
// }
|
||||
// }
|
||||
// LogHelper.log(Level.INFO, "***** END EDGES TO *****");
|
||||
LogHelper.log(Level.INFO, "***** START EDGES TO *****");
|
||||
nodeIter = graph.iterator();
|
||||
while (nodeIter.hasNext()) {
|
||||
CustomWrappedStack node = nodeIter.next();
|
||||
Set<WeightedEdge<CustomWrappedStack>> edgesTo = graph.edgesTo(node);
|
||||
Iterator<WeightedEdge<CustomWrappedStack>> edgeIter = edgesTo.iterator();
|
||||
while (edgeIter.hasNext()) {
|
||||
WeightedEdge<CustomWrappedStack> edge = edgeIter.next();
|
||||
LogHelper.log(Level.INFO, "From: " + node);
|
||||
LogHelper.log(Level.INFO, "To: " + edge.getTarget());
|
||||
LogHelper.log(Level.INFO, "Weight: " + edge.getWeight());
|
||||
LogHelper.log(Level.INFO, "");
|
||||
}
|
||||
}
|
||||
LogHelper.log(Level.INFO, "***** END EDGES TO *****");
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
|
|
@ -119,17 +119,18 @@ public class WeightedDirectedGraph<T> implements Iterable<T> {
|
|||
Set<WeightedEdge<T>> edgesTo = new TreeSet<WeightedEdge<T>>(new Comparator<WeightedEdge<T>>() {
|
||||
|
||||
public int compare(WeightedEdge<T> o1, WeightedEdge<T> o2) {
|
||||
|
||||
return orderedNodes.indexOf(o1.getTarget()) - orderedNodes.indexOf(o2.getTarget());
|
||||
return o1.hashCode() - o2.hashCode();
|
||||
}
|
||||
});
|
||||
|
||||
for (T node : graph.keySet()) {
|
||||
Set<WeightedEdge<T>> edgesFrom = edgesFrom(node);
|
||||
|
||||
for (WeightedEdge<T> fromEdge : edgesFrom) {
|
||||
if (fromEdge.getTarget().equals(to)) {
|
||||
edgesTo.add(fromEdge);
|
||||
if (!node.equals(to)) {
|
||||
Set<WeightedEdge<T>> edgesFrom = edgesFrom(node);
|
||||
|
||||
for (WeightedEdge<T> fromEdge : edgesFrom) {
|
||||
if (fromEdge.getTarget().equals(to)) {
|
||||
edgesTo.add(new WeightedEdge<T>(fromEdge.getWeight(), node));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue