Some more DynEMC work - lots still to do!

This commit is contained in:
pahimar 2013-06-03 13:06:13 -04:00
parent e2b9869c0e
commit 27fab71f64
3 changed files with 78 additions and 20 deletions

View file

@ -56,6 +56,7 @@ public class DynEMC {
}
private void populateItemList() {
ArrayList<ItemStack> subItems = new ArrayList<ItemStack>();
/*
@ -192,11 +193,59 @@ public class DynEMC {
}
}
@Override
// TODO Make this an actual toString and take out the logging into a debug method
public String toString() {
public int size() {
StringBuilder stringBuilder = new StringBuilder();
return graph.size();
}
public List<CustomWrappedStack> getAllNodes() {
ArrayList<CustomWrappedStack> allNodes = new ArrayList<CustomWrappedStack>();
Iterator<CustomWrappedStack> nodeIter = graph.iterator();
while (nodeIter.hasNext()) {
allNodes.add(nodeIter.next());
}
return allNodes;
}
public List<CustomWrappedStack> getCriticalNodes() {
ArrayList<CustomWrappedStack> criticalNodes = new ArrayList<CustomWrappedStack>();
Iterator<CustomWrappedStack> nodeIter = graph.iterator();
while (nodeIter.hasNext()) {
CustomWrappedStack currentNode = nodeIter.next();
if (graph.edgesFrom(currentNode).size() == 0) {
criticalNodes.add(currentNode);
}
}
return criticalNodes;
}
public List<CustomWrappedStack> getOrphanNodes() {
ArrayList<CustomWrappedStack> criticalNodes = new ArrayList<CustomWrappedStack>();
Iterator<CustomWrappedStack> nodeIter = graph.iterator();
while (nodeIter.hasNext()) {
CustomWrappedStack currentNode = nodeIter.next();
if ((graph.edgesFrom(currentNode).size() == 0) && (graph.edgesTo(currentNode).size() == 0)) {
criticalNodes.add(currentNode);
}
}
return criticalNodes;
}
public void printDebugDump() {
LogHelper.log(Level.INFO, "***** START NODES *****");
Iterator<CustomWrappedStack> nodeIter = graph.iterator();
@ -235,6 +284,14 @@ public class DynEMC {
}
}
LogHelper.log(Level.INFO, "***** END EDGES TO *****");
}
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(String.format("DynEMC Node Count: %s", graph.size()));
return stringBuilder.toString();
}

View file

@ -119,6 +119,7 @@ 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 o1.hashCode() - o2.hashCode();
}
});