From 24219bdf084b45273e869cd19382d1640b396566 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 4 Nov 2007 21:39:15 -0500 Subject: [PATCH] rename Node->StateNode darcs-hash:20071105023915-5007d-a1bdc50cb5c65bb1ca10dd55f93c4aef2ad01f82.gz --- src/edu/berkeley/sbp/Forest.java | 14 +++--- src/edu/berkeley/sbp/GSS.java | 28 ++++++------ src/edu/berkeley/sbp/ParseFailed.java | 22 +++++----- src/edu/berkeley/sbp/Parser.java | 12 ++--- src/edu/berkeley/sbp/Reduction.java | 4 +- src/edu/berkeley/sbp/Result.java | 33 +++++++------- src/edu/berkeley/sbp/{Node.java => StateNode.java} | 18 ++++---- src/edu/berkeley/sbp/util/GraphViz.java | 46 ++++++++++---------- src/edu/berkeley/sbp/util/PrintableTree.java | 4 +- 9 files changed, 91 insertions(+), 90 deletions(-) rename src/edu/berkeley/sbp/{Node.java => StateNode.java} (90%) diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java index e39a8f6..636ad4f 100644 --- a/src/edu/berkeley/sbp/Forest.java +++ b/src/edu/berkeley/sbp/Forest.java @@ -37,7 +37,7 @@ public abstract class Forest implements GraphViz.ToGraphViz { abstract void expand(HashSet> ht, HashSet> ignore, Tree bogus); abstract void gather(HashSet> ignore); - abstract void edges(GraphViz.Node n); + abstract void edges(GraphViz.StateNode n); boolean ambiguous() { return false; } // One ////////////////////////////////////////////////////////////////////////////// @@ -97,16 +97,16 @@ public abstract class Forest implements GraphViz.ToGraphViz { public boolean isTransparent() { return false; } public boolean isHidden() { return false; } - public GraphViz.Node toGraphViz(GraphViz gv) { + public GraphViz.StateNode toGraphViz(GraphViz gv) { if (gv.hasNode(this)) return gv.createNode(this); - GraphViz.Node n = gv.createNode(this); + GraphViz.StateNode n = gv.createNode(this); n.label = headToString()==null?"":headToString(); n.directed = true; edges(n); return n; } boolean edges = false; // FIXME ?? - public void edges(GraphViz.Node n) { + public void edges(GraphViz.StateNode n) { if (edges) return; edges = true; for(int i=0; i implements GraphViz.ToGraphViz { public boolean isTransparent() { return hp.size()==1; } public boolean isHidden() { return hp.size()==0; } - public void edges(GraphViz.Node n) { + public void edges(GraphViz.StateNode n) { if (hp.size()==1) { hp.iterator().next().edges(n); return; } for(Forest f : hp) f.edges(n); } - public GraphViz.Node toGraphViz(GraphViz gv) { + public GraphViz.StateNode toGraphViz(GraphViz gv) { if (hp.size()==1) return hp.iterator().next().toGraphViz(gv); if (gv.hasNode(this)) return gv.createNode(this); - GraphViz.Node n = gv.createNode(this); + GraphViz.StateNode n = gv.createNode(this); n.label = "?"; n.color = "red"; for(Forest f : hp) n.edge(f, null); diff --git a/src/edu/berkeley/sbp/GSS.java b/src/edu/berkeley/sbp/GSS.java index 7626b4e..db833b9 100644 --- a/src/edu/berkeley/sbp/GSS.java +++ b/src/edu/berkeley/sbp/GSS.java @@ -27,7 +27,7 @@ class GSS { int numReductions = 0; /** corresponds to a positions between tokens the input stream; same as Tomita's U_i's */ - class Phase implements Invokable, IntegerMappable, GraphViz.ToGraphViz, Iterable { + class Phase implements Invokable, IntegerMappable, GraphViz.ToGraphViz, Iterable { // FIXME: right now, these are the performance bottleneck private HashMapBag performed = new HashMapBag(); @@ -42,7 +42,7 @@ class GSS { reductionQueue.add(r); } - public void invoke(State st, Node pred, Forest f) { + public void invoke(State st, StateNode pred, Forest f) { parser.spin(); good |= next.newNode(f, null, pred, st, false); } @@ -50,7 +50,7 @@ class GSS { /** the token immediately after this phase */ final Tok token; final int pos; - public IntPairMap hash = new IntPairMap(); /* ALLOC */ + public IntPairMap hash = new IntPairMap(); /* ALLOC */ private boolean good = false; private Phase next = null; private Phase prev; @@ -125,13 +125,13 @@ class GSS { this.next = next; // this massively improves GC performance if (prev != null) { - IntPairMap h = prev.hash; + IntPairMap h = prev.hash; prev.hash = null; prev.performed = null; - for(Node n : h) n.check(); + for(StateNode n : h) n.check(); } numOldNodes = hash.size(); - for(Node n : hash.values()) { + for(StateNode n : hash.values()) { if (token == null && n.state().isAccepting()) { if (finalResult==null) finalResult = new Forest.Many(); for(Result r : n) @@ -160,14 +160,14 @@ class GSS { if (token==null && finalResult==null) ParseFailed.error("unexpected end of file", this, null, getLocation().createRegion(getLocation())); - for(Node n : hash) n.check(); + for(StateNode n : hash) n.check(); } Input.Region getRegionFromThisToNext() { return getLocation().createRegion(getNextLocation()); } - void newNodeFromReduction(Forest f, Pos reduction, Node pred) { + void newNodeFromReduction(Forest f, Pos reduction, StateNode pred) { int pos = pred.phase().pos; for(int s : reduction.hates()) if (performed.contains(pos, s)) @@ -189,8 +189,8 @@ class GSS { * @param fromEmptyReduction true iff this node is being created as a result of a reduction of length zero (see GRMLR paper) * @param start the earliest part of the input contributing to this node (used to make merging decisions) */ - private boolean newNode(Forest f, Pos reduction, Node pred, State state, boolean fromEmptyReduction) { - Node p = pred==null ? null : hash.get(state, pred.phase()); + private boolean newNode(Forest f, Pos reduction, StateNode pred, State state, boolean fromEmptyReduction) { + StateNode p = pred==null ? null : hash.get(state, pred.phase()); if (p != null) { p.addResult(f, reduction, pred); return !state.doomed(); @@ -201,7 +201,7 @@ class GSS { if (token==null) break; if (!state.canReduce(token)) return false; } while(false); - Node n = new Node(Phase.this, f, reduction, pred, state, fromEmptyReduction); // ALLOC + StateNode n = new StateNode(Phase.this, f, reduction, pred, state, fromEmptyReduction); // ALLOC /** FIXME: this null-result can be used to notice bogus/dead states */ for(Object s : state.conjunctStates) newNode(null, null, n, (State)s, fromEmptyReduction); @@ -212,12 +212,12 @@ class GSS { public int size() { return hash==null ? 0 : hash.size(); } public int pos() { return pos; } public Tok getToken() { return token; } - public Iterator iterator() { return hash.iterator(); } + public Iterator iterator() { return hash.iterator(); } public GSS getGSS() { return GSS.this; } // GraphViz ////////////////////////////////////////////////////////////////////////////// - public GraphViz.Node toGraphViz(GraphViz gv) { + public GraphViz.StateNode toGraphViz(GraphViz gv) { if (gv.hasNode(this)) return gv.createNode(this); GraphViz.Group g = gv.createGroup(this); g.label = "Phase " + pos; @@ -233,7 +233,7 @@ class GSS { PrintWriter p = new PrintWriter(new OutputStreamWriter(fos)); GraphViz gv = new GraphViz(); for(Object n : this) - ((Node)n).toGraphViz(gv); + ((StateNode)n).toGraphViz(gv); gv.dump(p); p.flush(); p.close(); diff --git a/src/edu/berkeley/sbp/ParseFailed.java b/src/edu/berkeley/sbp/ParseFailed.java index 7a3416e..872ffac 100644 --- a/src/edu/berkeley/sbp/ParseFailed.java +++ b/src/edu/berkeley/sbp/ParseFailed.java @@ -5,7 +5,7 @@ import edu.berkeley.sbp.*; import edu.berkeley.sbp.Sequence.Pos; import edu.berkeley.sbp.Sequence.Pos; import edu.berkeley.sbp.GSS.Phase; -import edu.berkeley.sbp.Node; +import edu.berkeley.sbp.StateNode; import edu.berkeley.sbp.util.*; import java.io.*; import java.util.*; @@ -47,23 +47,23 @@ public class ParseFailed extends Exception { return (c >= 'A' && c <= 'Z'); } - static void barf(HashMap sb, Node n, int indent, boolean skip, int count, Input.Location loc) { + static void barf(HashMap sb, StateNode n, int indent, boolean skip, int count, Input.Location loc) { if (count <= 0) { barf(sb, n, indent, skip, loc); } else { /* FIXME: removed - for(Node nn : (Iterable)n.parents()) + for(StateNode nn : (Iterable)n.parents()) barf(sb, nn, indent, skip, count-1, n.phase().getLocation()); */ } } - static void barf(HashMap sb, Node n, int indent, boolean skip, Input.Location loc) { + static void barf(HashMap sb, StateNode n, int indent, boolean skip, Input.Location loc) { if (touched.contains(n)) return; touched.add(n); String s = ""; for(int i=0; i< indent; i++) s += " "; - Node parent = n; + StateNode parent = n; boolean done = false; boolean alldone = false; boolean go = false; @@ -102,8 +102,8 @@ public class ParseFailed extends Exception { // FIXME - private static HashSet touched = new HashSet(); - static void complain(Node n, HashMap> errors, boolean force, int indent) { + private static HashSet touched = new HashSet(); + static void complain(StateNode n, HashMap> errors, boolean force, int indent) { if (touched.contains(n)) return; touched.add(n); for(Pos p : (Iterable)n.state()) { @@ -112,7 +112,7 @@ public class ParseFailed extends Exception { !important(p)) { /* FIXME: removed - for(Node n2 : n.parents()) + for(StateNode n2 : n.parents()) complain(n2, errors, force //| p.isFirst() , indent); @@ -150,7 +150,7 @@ public class ParseFailed extends Exception { } private static void error(String message, Object token, - Iterable nodes, + Iterable nodes, Input.Region region, Input input, GSS gss) throws ParseFailed{ @@ -184,7 +184,7 @@ public class ParseFailed extends Exception { */ } HashMap hm = new HashMap(); - for(Node no : nodes) + for(StateNode no : nodes) barf(hm, no, 0, false, region.getStart()); ret.append("\n expected: "); Set hs = hm.keySet(); @@ -207,7 +207,7 @@ public class ParseFailed extends Exception { /* ret.append("\n The author of SBP apologizes for the these nearly-useless error messages:\n\n"); HashMap> errors = new HashMap>(); - for(Node n : nodes) { + for(StateNode n : nodes) { //System.out.println(n.state); complain(n, errors, false, 0); } diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 95e3ba5..e5cd67c 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -296,7 +296,7 @@ public abstract class Parser implements Serializable { * possible from it * * A state corresponds to a set of Sequence.Pos's. Each - * Node in the GSS has a State; the Node represents a set of + * StateNode in the GSS has a State; the StateNode represents a set of * possible parses, one for each Pos in the State. * * Every state is either "doomed" or "normal". If a Pos @@ -311,10 +311,10 @@ public abstract class Parser implements Serializable { * Nodes with non-doomed states represent nodes which * contribute to actual valid parses. Nodes with doomed * States exist for no other purpose than to enable/disable - * some future reduction from a non-doomed Node. Because of + * some future reduction from a non-doomed StateNode. Because of * this, we "garbage-collect" Nodes with doomed states if * there are no more non-doomed Nodes which they could - * affect (see Result, Reduction, and Node for details). + * affect (see Result, Reduction, and StateNode for details). * * Without this optimization, many seemingly-innocuous uses * of positive and negative conjuncts can trigger O(n^2) @@ -347,14 +347,14 @@ public abstract class Parser implements Serializable { Iterable positions() { return hs; } boolean canShift(Token t) { return oshifts!=null && oshifts.contains(t); } - void invokeShifts(Token t, GSS.Phase phase, Node pred, Forest f) { oshifts.invoke(t, phase, pred, f); } + void invokeShifts(Token t, GSS.Phase phase, StateNode pred, Forest f) { oshifts.invoke(t, phase, pred, f); } boolean canReduce(Token t) { return oreductions != null && (t==null ? eofReductions.size()>0 : oreductions.contains(t)); } - void invokeEpsilonReductions(Token t, Node node) { + void invokeEpsilonReductions(Token t, StateNode node) { if (t==null) for(Pos r : eofReductions) node.invoke(r, null, null); else oreductions.invoke(t, node, null, null); } - void invokeReductions(Token t, Node node, Result b) { + void invokeReductions(Token t, StateNode node, Result b) { if (t==null) for(Pos r : eofReductions) node.invoke(r, b, null); else oreductions.invoke(t, node, b, null); } diff --git a/src/edu/berkeley/sbp/Reduction.java b/src/edu/berkeley/sbp/Reduction.java index 222a168..0266782 100644 --- a/src/edu/berkeley/sbp/Reduction.java +++ b/src/edu/berkeley/sbp/Reduction.java @@ -9,9 +9,9 @@ final class Reduction implements Comparable { private Pos reduction; private GSS.Phase phase; private Forest forest; - private Node pred; + private StateNode pred; - public Reduction(Node pred, Pos reduction, Forest forest, GSS.Phase target) { + public Reduction(StateNode pred, Pos reduction, Forest forest, GSS.Phase target) { this.reduction = reduction; this.forest = forest; this.phase = target; diff --git a/src/edu/berkeley/sbp/Result.java b/src/edu/berkeley/sbp/Result.java index c91ab76..dfe12bb 100644 --- a/src/edu/berkeley/sbp/Result.java +++ b/src/edu/berkeley/sbp/Result.java @@ -6,20 +6,21 @@ import edu.berkeley.sbp.Sequence.Pos; import edu.berkeley.sbp.Sequence.Pos; import java.util.*; -final class Result implements GraphViz.ToGraphViz { +final class Result + implements GraphViz.ToGraphViz { private Forest.Many f = new Forest.Many(); - //private HashSet predecessors = new HashSet(); - //private HashSet successors = new HashSet(); - private FastSet predecessors = new FastSet(); - private FastSet successors = new FastSet(); + //private HashSet predecessors = new HashSet(); + //private HashSet successors = new HashSet(); + private FastSet predecessors = new FastSet(); + private FastSet successors = new FastSet(); private boolean destroyed = false; private boolean primordeal; private int usedByNonDoomedNode = 0; private Pos reduction; private GSS.Phase predPhase; - public boolean predecessorsContains(Node n) { + public boolean predecessorsContains(StateNode n) { return predecessors.contains(n); } public Pos reduction() { return reduction; } @@ -37,14 +38,14 @@ final class Result implements GraphViz.ToGraphViz { public GSS.Phase phase() { return predPhase; } public Forest getForest() { return f; } - public Iterable getPreds() { return predecessors; } - public void addSucc(Node succ) { + public Iterable getPreds() { return predecessors; } + public void addSucc(StateNode succ) { if (successors.contains(succ)) return; successors.add(succ); usedByNonDoomedNode += succ.state().doomed ? 0 : 1; if (predecessors.size() > 1) throw new Error(); } - public void removeSucc(Node succ) { + public void removeSucc(StateNode succ) { if (!successors.contains(succ)) return; successors.remove(succ); usedByNonDoomedNode -= succ.state().doomed ? 0 : 1; @@ -65,14 +66,14 @@ final class Result implements GraphViz.ToGraphViz { if (primordeal) return; // never destroy the "primordeal" result destroyed = true; while(predecessors.size() > 0) - for(Node pred : predecessors) { + for(StateNode pred : predecessors) { removePred(pred); pred.removeSucc(this); break; } predecessors = null; while(successors.size() > 0) - for(Node succ : successors) { + for(StateNode succ : successors) { removeSucc(succ); succ.removeResult(this); break; @@ -80,13 +81,13 @@ final class Result implements GraphViz.ToGraphViz { successors = null; } - public void removePred(Node pred) { + public void removePred(StateNode pred) { if (!predecessors.contains(pred)) return; predecessors.remove(pred); check(); } - public void addPred(Node pred) { + public void addPred(StateNode pred) { if (predPhase==null) predPhase = pred.phase(); if (predPhase != pred.phase()) throw new Error(); predecessors.add(pred); @@ -98,7 +99,7 @@ final class Result implements GraphViz.ToGraphViz { this(null, null, null); this.primordeal = true; } - public Result(Forest f, Pos reduction, Node pred) { + public Result(Forest f, Pos reduction, StateNode pred) { this.f.merge(f); this.reduction = reduction; if (pred != null) addPred(pred); @@ -106,9 +107,9 @@ final class Result implements GraphViz.ToGraphViz { // GraphViz ////////////////////////////////////////////////////////////////////////////// - public GraphViz.Node toGraphViz(GraphViz gv) { + public GraphViz.StateNode toGraphViz(GraphViz gv) { if (gv.hasNode(this)) return gv.createNode(this); - GraphViz.Node n = gv.createNode(this); + GraphViz.StateNode n = gv.createNode(this); n.label = ""+f; n.shape = "rectangle"; //if (pred()!=null) n.edge(pred, ""); diff --git a/src/edu/berkeley/sbp/Node.java b/src/edu/berkeley/sbp/StateNode.java similarity index 90% rename from src/edu/berkeley/sbp/Node.java rename to src/edu/berkeley/sbp/StateNode.java index 8353384..8fb1fd7 100644 --- a/src/edu/berkeley/sbp/Node.java +++ b/src/edu/berkeley/sbp/StateNode.java @@ -11,13 +11,13 @@ import java.util.*; import java.lang.reflect.*; /** a node in the GSS */ -final class Node +final class StateNode implements Invokable, IntegerMappable, GraphViz.ToGraphViz, Iterable { - /** which GSS.Phase this Node belongs to */ + /** which GSS.Phase this StateNode belongs to */ public GSS.Phase phase() { return phase; } public Iterator iterator() { return results.iterator(); } public Parser.Table.State state() { return state; } @@ -85,11 +85,11 @@ final class Node private void reduce(Pos r, int pos, GSS.Phase target, Result only) { for(Result res : results) if (only == null || res == only) - for(Node pred : res.getPreds()) + for(StateNode pred : res.getPreds()) reduce2(r, pos, target, pred, res.getForest()); } - void reduce2(Pos r, int pos, GSS.Phase target, Node pred, Forest f) { + void reduce2(Pos r, int pos, GSS.Phase target, StateNode pred, Forest f) { Forest[] holder = r.holder; Forest old = pos >= holder.length ? null : holder[pos]; if (pos < holder.length) holder[pos] = f; @@ -101,10 +101,10 @@ final class Node if (pos < holder.length) holder[pos] = old; } - Node(GSS.Phase phase, Forest f, Pos reduction, Node pred, State state, boolean fromEmptyReduction) { + StateNode(GSS.Phase phase, Forest f, Pos reduction, StateNode pred, State state, boolean fromEmptyReduction) { this(phase, new Result(f, reduction, pred), state, fromEmptyReduction); } - Node(GSS.Phase phase, Result pred, State state, boolean fromEmptyReduction) { + StateNode(GSS.Phase phase, Result pred, State state, boolean fromEmptyReduction) { this.phase = phase; this.state = state; this.fromEmptyReduction = fromEmptyReduction; @@ -133,7 +133,7 @@ final class Node public void addSucc(Result succ) { successors.add(succ); } - public void addResult(Forest f, Pos reduction, Node pred) { + public void addResult(Forest f, Pos reduction, StateNode pred) { for(Result r : results) if (r.predecessorsContains(pred)) { r.merge(f); @@ -147,10 +147,10 @@ final class Node // GraphViz ////////////////////////////////////////////////////////////////////////////// - public GraphViz.Node toGraphViz(GraphViz gv) { + public GraphViz.StateNode toGraphViz(GraphViz gv) { if (results.size()==0) return null; if (gv.hasNode(this)) return gv.createNode(this); - GraphViz.Node n = gv.createNode(this); + GraphViz.StateNode n = gv.createNode(this); n.label = "state["+state.toInt()+"]"; n.shape = "rectangle"; boolean haspreds = false; diff --git a/src/edu/berkeley/sbp/util/GraphViz.java b/src/edu/berkeley/sbp/util/GraphViz.java index 44b47fc..1d85e11 100644 --- a/src/edu/berkeley/sbp/util/GraphViz.java +++ b/src/edu/berkeley/sbp/util/GraphViz.java @@ -10,18 +10,18 @@ import java.lang.ref.*; public class GraphViz { - IdentityHashMap ihm = new IdentityHashMap(); - HashMap groups = new HashMap(); + IdentityHashMap ihm = new IdentityHashMap(); + HashMap groups = new HashMap(); - public class Group extends Node { + public class Group extends StateNode { private final int idx = master_idx++; public boolean cluster = false; public boolean primary = true; public Group() { } - public void add(Node n) { groups.put(n, this); } + public void add(StateNode n) { groups.put(n, this); } public String name() { return cluster?("cluster_"+idx):("subgraph_"+idx); } public boolean simple() { return false; } - public void dump(PrintWriter pw, IdentityHashMap done) { + public void dump(PrintWriter pw, IdentityHashMap done) { Group g = this; if (done.get(g)!=null) return; done.put(g,g); @@ -29,7 +29,7 @@ public class GraphViz { pw.println(" label=\""+StringUtil.escapify(label.toString(), "\\\"\r\n")+"\";\n"); pw.println(" color="+g.color+";\n"); pw.println(" shape="+g.shape+";\n"); - for(Node n : groups.keySet()) + for(StateNode n : groups.keySet()) if (groups.get(n)==g) n.dump(pw, done); pw.println(" }\n"); @@ -38,7 +38,7 @@ public class GraphViz { private static int master_idx=0; - public class Node { + public class StateNode { private final int idx = master_idx++; public String label; public String comment; @@ -46,11 +46,11 @@ public class GraphViz { public String color="black"; public String fill="white"; public String shape="ellipse"; - public ArrayList edges = new ArrayList(); + public ArrayList edges = new ArrayList(); public ArrayList labels = new ArrayList(); - public ArrayList inbound = new ArrayList(); + public ArrayList inbound = new ArrayList(); public void edge(ToGraphViz o, Object label) { - Node n = o.toGraphViz(GraphViz.this); + StateNode n = o.toGraphViz(GraphViz.this); if (n==null) return; edges.add(n); labels.add(label); @@ -69,7 +69,7 @@ public class GraphViz { public void edges(PrintWriter pw) { if (simple()) return; for(int i=0; i " + n.name() + " [color="+color+" " +(label==null?"":("label=\""+StringUtil.escapify(label.toString(), "\\\"\r\n")+"\""))+ "];\n"); @@ -80,17 +80,17 @@ public class GraphViz { boolean simple = true; if (label!=null && !label.equals("")) simple = false; if (simple) - for(Node n : edges) + for(StateNode n : edges) //if (n.numEdges()>0) { simple = false; break; } if (n.inbound.size() > 1) { simple = false; break; } return simple; } - public void dump(PrintWriter pw, IdentityHashMap done) { + public void dump(PrintWriter pw, IdentityHashMap done) { if (done.get(this)!=null) return; done.put(this, this); if (inbound.size() > 0) { boolean good = false; - for(Node n : inbound) + for(StateNode n : inbound) if (!n.simple()) { good = true; break; } if (!good) return; @@ -102,12 +102,12 @@ public class GraphViz { pw.print(" shape=record "); pw.print(" label=\""); boolean complex = false; - for(Node n : edges) + for(StateNode n : edges) if (n.edges.size()>0) complex = true; if (!complex) pw.print("{"); boolean first = true; - for(Node n : edges) { + for(StateNode n : edges) { if (!first) pw.print("|"); first = false; pw.print(""); @@ -130,10 +130,10 @@ public class GraphViz { return ihm.get(o)!=null; } - public Node createNode(ToGraphViz o) { - Node n = ihm.get(o); + public StateNode createNode(ToGraphViz o) { + StateNode n = ihm.get(o); if (n!=null) return n; - n = new Node(); + n = new StateNode(); ihm.put(o, n); return n; } @@ -147,7 +147,7 @@ public class GraphViz { } public static interface ToGraphViz { - Node toGraphViz(GraphViz gv); + StateNode toGraphViz(GraphViz gv); boolean isTransparent(); boolean isHidden(); } @@ -158,17 +158,17 @@ public class GraphViz { public void dump(OutputStream os) { dump(new PrintWriter(new OutputStreamWriter(os))); } public void dump(PrintWriter pw) { - IdentityHashMap done = new IdentityHashMap(); + IdentityHashMap done = new IdentityHashMap(); pw.println("digraph G { rankdir=LR; ordering=out; compound=true; \n"); for(Group g : groups.values()) if (g.primary) g.dump(pw, done); - for(Node n : ihm.values()) { + for(StateNode n : ihm.values()) { if (done.get(n)!=null) continue; if (n instanceof Group) continue; n.dump(pw, done); } - for(Node n : ihm.values()) n.edges(pw); + for(StateNode n : ihm.values()) n.edges(pw); pw.println("}\n"); pw.flush(); } diff --git a/src/edu/berkeley/sbp/util/PrintableTree.java b/src/edu/berkeley/sbp/util/PrintableTree.java index ba26a58..802296d 100644 --- a/src/edu/berkeley/sbp/util/PrintableTree.java +++ b/src/edu/berkeley/sbp/util/PrintableTree.java @@ -87,9 +87,9 @@ public abstract class PrintableTree implements Iterable // this is here to keep it out of the javadoc for Tree - public GraphViz.Node toGraphViz(GraphViz gv) { + public GraphViz.StateNode toGraphViz(GraphViz gv) { if (gv.hasNode(this)) return gv.createNode(this); - GraphViz.Node n = gv.createNode(this); + GraphViz.StateNode n = gv.createNode(this); n.label = head()==null ? "" : head().toString(); for(T t : this) n.edge(t, null); return n; -- 1.7.10.4