X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FNode.java;h=09718afdce0d970fc521ba769c670ce7025b4460;hp=7a5c38d72ab5a00c44e0b7f87dd4db4df50aa974;hb=c404939a6dfed4dcfdca5ede08db99b3e5ef0c91;hpb=5d881ff49c40eacd47314a400dc69cc88edc9156 diff --git a/src/edu/berkeley/sbp/Node.java b/src/edu/berkeley/sbp/Node.java index 7a5c38d..09718af 100644 --- a/src/edu/berkeley/sbp/Node.java +++ b/src/edu/berkeley/sbp/Node.java @@ -10,6 +10,43 @@ import java.io.*; import java.util.*; import java.lang.reflect.*; -class Node { +class Node + implements IntegerMappable, + GraphViz.ToGraphViz { + + protected FastSet predecessors = new FastSet(); + protected FastSet successors = new FastSet(); + //private HashSet predecessors = new HashSet(); + //private HashSet successors = new HashSet(); + + // GraphViz ////////////////////////////////////////////////////////////////////////////// + + public GraphViz.StateNode toGraphViz(GraphViz gv) { + if (gv.hasNode(this)) return gv.createNode(this); + GraphViz.StateNode n = gv.createNode(this); + /* + n.label = ""+f; + n.shape = "rectangle"; + //if (pred()!=null) n.edge(pred, ""); + n.color = "blue"; + if (phase() != null) + ((GraphViz.Group)phase().toGraphViz(gv)).add(n); + n.label = "state["+state.toInt()+"]"; + n.shape = "rectangle"; + boolean haspreds = false; + for(ResultNode r : results) n.edge(r, ""); + n.color = state.doomed ? "red" : "green"; + ((GraphViz.Group)phase().toGraphViz(gv)).add(n); + */ + return n; + } + public boolean isTransparent() { return false; } + public boolean isHidden() { return false; } + + // IntegerMappable //////////////////////////////////////////////////////////// + + private static int node_idx = 0; + private final int idx = node_idx++; + public int toInt() { return idx; } } \ No newline at end of file