You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jv...@apache.org on 2001/11/29 15:24:23 UTC

cvs commit: jakarta-commons-sandbox/graph/src/java/org/apache/commons/graph/visualize DaVinciVisualizer.java GMLVisualizer.java GraphVisualizer.java VCGVisualizer.java

jvanzyl     01/11/29 06:24:23

  Added:       graph/src/java/org/apache/commons/graph/visualize
                        DaVinciVisualizer.java GMLVisualizer.java
                        GraphVisualizer.java VCGVisualizer.java
  Removed:     graph/src/java/org/apache/commons/graph
                        DaVinciVisualizer.java GMLVisualizer.java
                        GraphVisualizer.java VCGVisualizer.java
  Log:
  - creating a visualize package for better organization before some
    refactoring.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/graph/src/java/org/apache/commons/graph/visualize/DaVinciVisualizer.java
  
  Index: DaVinciVisualizer.java
  ===================================================================
  package org.apache.commons.graph.visualize;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache BCEL" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache BCEL", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.io.OutputStream;
  
  import org.apache.commons.graph.Constants;
  import org.apache.commons.graph.Edge;
  import org.apache.commons.graph.Graph;
  import org.apache.commons.graph.Sequential;
  import org.apache.commons.graph.Vertex;
  
  /**
   * Visualizes directed graphs into the
   * <A HREF="http://www.informatik.uni-bremen.de/~inform/forschung/daVinci/daVinci.html">
   * DaVinci</A> format. It can only be used for directed graphs and does not support
   * labeled edges very well, unfortunately. They have to be simulated via dummy vertices.
   *
   * Traverses graph with the Sequential visitor, since it uses invariants of that algorithm.
   *
   * @version $Id: DaVinciVisualizer.java,v 1.1 2001/11/29 14:24:23 jvanzyl Exp $
   * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
   */
  public class DaVinciVisualizer extends GraphVisualizer implements Constants {
    private Graph        graph;
    private int          no_edges, edges;
    private int          no_vertices, vertices;
  
    /**
     * @param out stream to print output to
     * @param verbose toggle verbosity of output
     */
    public DaVinciVisualizer(OutputStream out, int verbose) {
      super(out, verbose);
    }
  
    public void discoverGraph(Graph g) {
      graph = g;
  
      no_vertices = g.getNoVertices();
      vertices    = 0;
      out.println("[");
    }
  
    public void finishGraph(Graph g) {
      out.println("]");
      out.close();
    }
  
    public void discoverVertex(Vertex v) {
      String label = convertString(v.toString(verbose));
      //System.out.println("vertex:" + v.getIdent() + ":" + v);
      
      println(1, "l(\"" + v.getIdent() + "\",");
      println(1, "n(\"anything\", [");
      println(2, "a(\"OBJECT\", \"" + label + "\"),");
      println(2, "a(\"FONTSTYLE\", \"bold\"),");
      println(2, "a(\"FONTFAMILY\", \"courier\")],");
      println(1, "["); // array of successor nodes
  
      no_edges = graph.getNoEdges(v);
      edges    = 0;
    }
  
    public void finishVertex(Vertex v) {
      String str = (vertices < no_vertices - 1)? "]))," : "]))";
      println(1, str);
      vertices++;
    }
  
    private static int label_counter=0;
  
    private final String getEdgeAttribute() {
      if(graph.isDirected())
        return "";
      else
        return "a(\"_DIR\", \"none\"";
    }
  
    public void discoverEdge(Edge e) {
      int    u     = graph.getSource(e).getIdent();
      int    v     = graph.getTarget(e).getIdent();
      String label = convertString(e.toString(verbose));
  
      if(label.equals("")) {
        print(2, "l(\"" + u + "->" + v + "\", e(\"\", [" + getEdgeAttribute() +
  	    "], r(\"" + v + "\")))");
      } else { // Simulate labeled edge with intermediate node
        String dummy = "label" + label_counter++; // Dummy name for intermediate node
  
        print(2, "l(\"" + u + "->" + dummy + "\", e(\"\", [a(\"_DIR\", \"none\")], " +
  	    "l(\"" + dummy + "\", n(\"anything\",[a(\"OBJECT\", \"" + label +
  	    "\"), a(\"_GO\", \"text\")], [l(\"" + dummy + "->" + v +
  	    "\", e(\"\",[" + getEdgeAttribute() + "], r(\"" + v + "\")))]))))");
        //System.out.println(graph.getTarget(e).getIdent() + ":" + graph.getTarget(e));
      }
    }
  
    public void finishEdge(Edge e) {
      if(edges < no_edges - 1)
        out.println(", ");
      else
        out.print('\n');
  
      edges++;
    }
  
    /**
     * Visualize graph g with this Visualizer.
     *
     * @param g graph to visualize
     * @param start node to start at
     */
    public void visualize(Graph g, Vertex start) {
      new Sequential(this).start(g);
    }
  }
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/graph/src/java/org/apache/commons/graph/visualize/GMLVisualizer.java
  
  Index: GMLVisualizer.java
  ===================================================================
  package org.apache.commons.graph.visualize;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache BCEL" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache BCEL", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.io.OutputStream;
  
  import org.apache.commons.graph.Constants;
  import org.apache.commons.graph.DFS;
  import org.apache.commons.graph.Edge;
  import org.apache.commons.graph.Graph;
  import org.apache.commons.graph.Vertex;
  
  /**
   * Visualizes graphs into the <A HREF="http://www.fmi.uni-passau.de/Graphlet/">GML</A>
   * format.
   *
   * @version $Id: GMLVisualizer.java,v 1.1 2001/11/29 14:24:23 jvanzyl Exp $
   * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
   */
  public class GMLVisualizer extends GraphVisualizer {
    private Graph graph;
  
    /**
     * @param out stream to print output to
     * @param verbose toggle verbosity of output
     */
    public GMLVisualizer(OutputStream out, int verbose) {
      super(out, verbose);
    }
  
    public void discoverGraph(Graph g) {
      String d = g.isDirected()? "1" : "0";
  
      graph = g;
  
      println(0, "graph [");
      println(1, "Creator\t \"GMLVisualizer\"");
      println(1, "id\t " + Vertex.getCounter()); // Make sure this is a unique number
      println(1, "directed\t " + d + "\n");
    }
  
    public void finishGraph(Graph g) {
      println(0, "]\n");
      out.close();
    }
  
    public void discoverVertex(Vertex v) {
      println(1, "node [");
      println(2, "id\t " + v.getIdent());
      println(2, "label");
      
      out.println("\"" + v.toString(verbose) + "\"");
      
      println(2, "graphics [");
      println(3, "type\t\t \"rectangle\"");
      println(3, "fill\t\t \"white\"");
      println(3, "outline\t\t \"black\"");
      println(3, "background\t \"blue\"");
      println(3, "foreground\t \"green\"");
      println(2, "]\n");
      
      println(2, "LabelGraphics [");
      println(3, "type\t \"text\"");
      println(3, "fill\t \"black\"");
      println(3, "justify\t \"left\"");
      println(2, "]\n");
      
      println(1, "]\n");
    }
  
    public void finishVertex(Vertex v) {}
  
    public void discoverEdge(Edge e) {
      int src    = graph.getSource(e).getIdent();
      int target = graph.getTarget(e).getIdent();
  
      println(1, "edge [");
      println(2, "source\t " + src);
      println(2, "target\t " + target);
  
      println(2, "label");
      out.println("\"" + e.toString(verbose) + "\"");
  
      println(2, "graphics [");
  
      println(3, "fill\t \"black\"");
      //println(3, "fill\t\t \"white\"");
  
      println(3, "arrow\t \"last\"");
      println(2, "]\n");
      
      println(2, "LabelGraphics [");
      println(3, "type\t \"text\"");
      println(3, "fill\t \"black\"");
      println(2, "]\n");
      
      println(1, "]\n");  
    }
  
    public void finishEdge(Edge e) {}
  
    /**
     * Visualize graph g with this Visualizer.
     *
     * @param g graph to visualize
     * @param start node to start at
     */
    public void visualize(Graph g, Vertex start) {
      new DFS(this).start(g, start);
    }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/graph/src/java/org/apache/commons/graph/visualize/GraphVisualizer.java
  
  Index: GraphVisualizer.java
  ===================================================================
  package org.apache.commons.graph.visualize;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache BCEL" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache BCEL", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  import java.io.*;
  import java.util.StringTokenizer;
  
  import org.apache.commons.graph.Constants;
  import org.apache.commons.graph.Edge;
  import org.apache.commons.graph.Graph;
  import org.apache.commons.graph.Vertex;
  import org.apache.commons.graph.visitor.Visitor;
  
  /**
   * Abstract super class for drivers that visualize graphs
   * in different graph formats such as 
   * <A HREF="http://www.fmi.uni-passau.de/Graphlet/">GML</A> or
   * <A HREF="http://www.informatik.uni-bremen.de/~inform/forschung/daVinci/daVinci.html">
   * daVinci</A> or <A HREF="http://www.cs.uni-sb.de/RW/users/sander/html/gsvcg1.html">
   * VCG</A>.
   *
   * By default graphs are dumped in the native Java format, i.e. by using the
   * Serialization feature.
   *
   * @version $Id: GraphVisualizer.java,v 1.1 2001/11/29 14:24:23 jvanzyl Exp $
   * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
   * @see DaVinciVisualizer
   * @see GMLVisualizer
   * @see VCGVisualizer
   */
  public class GraphVisualizer implements Visitor {
    protected OutputStream orig_out;
    protected PrintWriter  out;
    protected int          verbose;
  
    /**
     * @param out stream to print output to
     * @param verbose toggle verbosity
     */
    public GraphVisualizer(OutputStream out, int verbose) {
      orig_out     = out;
      this.out     = new PrintWriter(out, true);
      this.verbose = verbose;
    }
  
    /**
     * Print string using ident tab as prefix, used for nested calls
     *
     * @param indent how many tabs
     * @param s string to print
     */
    protected final void print(int indent, String s) {
      for(int i=0; i < indent; i++)
        out.print('\t');
  
      out.print(s);
    }
  
    /**
     * Print string using ident tab as prefix, used for nested calls
     *
     * @param indent how many tabs
     * @param s string to print
     */
    protected final void println(int indent, String s) {
      print(indent, s);
      out.print('\n');
    }
  
  
    /**
     * Escape all occurences of newline chars '\n' and quotes \"
     */
    protected static final String convertString(String label) {
      char[] ch = label.toCharArray();
      StringBuffer    buf = new StringBuffer();
  
      for(int i=0; i < ch.length; i++) {
        switch(ch[i]) {
        case '\n':
  	buf.append("\\n"); break;
        case '\"':
  	buf.append("\\\""); break;
        case '\\':
  	buf.append("\\\\"); break;
        default:
  	buf.append(ch[i]); break;
        }
      }
  
      return buf.toString();
    }
  
    /**
     * Visualize graph g with this Visualizer.
     *
     * @param g graph to visualize
     * @param start node to start at
     */
    public void visualize(Graph g, Vertex start) {
      try {
        g.dump(orig_out);
      } catch(IOException e) {
        System.err.println(e);
      }
  
      out.close();
    }
  
    public void discoverGraph(Graph g) {}
    public void finishGraph(Graph g) {}
    public void discoverVertex(Vertex v) {}
    public void finishVertex(Vertex v) {}
    public void discoverEdge(Edge e) {}
    public void finishEdge(Edge e) {}
  
    public void visit(Graph g, Vertex start) {
      visualize(g, start);
    }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/graph/src/java/org/apache/commons/graph/visualize/VCGVisualizer.java
  
  Index: VCGVisualizer.java
  ===================================================================
  package org.apache.commons.graph.visualize;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache BCEL" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache BCEL", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  import java.io.OutputStream;
  
  import org.apache.commons.graph.Constants;
  import org.apache.commons.graph.DFS;
  import org.apache.commons.graph.Edge;
  import org.apache.commons.graph.Graph;
  import org.apache.commons.graph.Vertex;
  
  /**
   * Visualizes graphs into the <A
   * HREF="http://www.cs.uni-sb.de/RW/users/sander/html/gsvcg1.html">VCG</A>
   * format.
   *
   * @version $Id: VCGVisualizer.java,v 1.1 2001/11/29 14:24:23 jvanzyl Exp $
   * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
   */
  public class VCGVisualizer extends GraphVisualizer {
    private Graph graph;
  
    /**
     * @param out stream to print output to
     * @param verbose toggle verbosity of output
     */
    public VCGVisualizer(OutputStream out, int verbose) {
      super(out, verbose);
    }
  
    public void discoverGraph(Graph g) {
      String d = g.isDirected()? "1" : "0";
  
      graph = g;
      
      println(0, "/* Created by VCGVisualizer */\n");
      println(0, "graph: {");
      println(1, "display_edge_labels: yes");
      println(1, "port_sharing: no");
      println(1, "manhattan_edges: yes");
      println(1, "straight_phase: yes");
      println(1, "priority_phase: yes");
      println(1, "node.color: white");
      println(1, "node.bordercolor: black");
      println(1, "node.textcolor: black");
      println(1, "node.shape: box");
      println(1, "node.textmode: left_justify");
      println(1, "edge.textcolor: black");
      println(1, "edge.color: black\n");
    }
  
    public void finishGraph(Graph g) {
      println(0, "}");
      out.close();
    }
  
    public void discoverVertex(Vertex v) {
      String label = convertString(v.toString(verbose));
  
      println(1, "node: {");
      println(2, "title: \"" + v.getIdent() + "\"");
      println(2, "label: \"" + label + "\"");
      println(1, "}");
    }
  
    public void finishVertex(Vertex v) {}
  
    public void discoverEdge(Edge e) {
      int src      = graph.getSource(e).getIdent();
      int target   = graph.getTarget(e).getIdent();
      String label = convertString(e.toString(verbose));
  
      println(1, "edge: {");
      println(2, "sourcename: \"" + src + "\"");
      println(2, "targetname: \"" + target + "\"");
      if(!label.equals(""))
        println(2, "label: \"" + label + "\"");
      println(1, "}");
    }
  
    public void finishEdge(Edge e) {}
  
    /**
     * Visualize graph g with this Visualizer.
     *
     * @param g graph to visualize
     * @param start node to start at
     */
    public void visualize(Graph g, Vertex start) {
      new DFS(this).start(g, start);
    }
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>