checkpoint
[sbp.git] / src / edu / berkeley / sbp / util / GraphViz.java
index 13899bb..bfef2f6 100644 (file)
@@ -23,11 +23,13 @@ public class GraphViz {
         public boolean directed = false;
         public String color="black";
         public ArrayList<Node> edges = new ArrayList<Node>();
+        public ArrayList<Object> labels = new ArrayList<Object>();
         public ArrayList<Node> inbound = new ArrayList<Node>();
-        public void edge(ToGraphViz o) {
+        public void edge(ToGraphViz o, Object label) {
             Node n = o.toGraphViz(GraphViz.this);
             if (n==null) return;
             edges.add(n);
+            labels.add(label);
             n.inbound.add(this);
         }
         public String name() {
@@ -37,8 +39,11 @@ public class GraphViz {
         }
         public void edges(PrintWriter pw) {
             if (simple()) return;
-            for(Node n : edges)
-                pw.println("    "+name()+" -> " + n.name() + " [color="+color+"];\n");
+            for(int i=0; i<edges.size(); i++) {
+                Node n = edges.get(i);
+                Object label = labels.get(i);
+                pw.println("    "+name()+" -> " + n.name() + " [color="+color+" " +(label==null?"":("label=\""+label+"\""))+ "];\n");
+            }
         }
         public int numEdges() { return edges.size(); }
         public boolean simple() {