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() {
}
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() {