Drawing graphs with Graphviz Emden R. Gansner 22 November 2004 1 GraphvizDrawin

Drawing graphs with Graphviz Emden R. Gansner 22 November 2004 1 GraphvizDrawing Library Manual, 22 November 2004 2 Contents 1 Introduction 3 1.1 String-based layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.1.1 dot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.1.2 xdot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1.3 plain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1.4 plain-ext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1.5 GXL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2 Graphviz as a library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2 Basic graph drawing 6 2.1 Creating the graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.1.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.1.2 Cleaning up a graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.2 Laying out the graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.3 Getting layout information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.4 Drawing nodes and edges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3 Inside the layouts 16 3.1 dot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.2 neato . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.3 fdp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.4 twopi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.5 circo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4 Using the output drivers 21 5 Graphics code generators 22 5.1 Style information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 5.2 Color information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 5.3 Using codegen t to draw nodes and edges . . . . . . . . . . . . . . . . . . . . . . . . . 28 6 Unconnected graphs 28 A Compiling and linking 34 A.1 Finer-grained usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 A.2 Application-specific data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 B A sample program: simple.c 36 C A sample program: dot.c 37 D A sample program: demo.c 38 E String representations of types 39 GraphvizDrawing Library Manual, 22 November 2004 3 1 Introduction The Graphviz package consists of a variety of software for drawing attributed graphs. It implements a handful of common graph layout algorithms. These are: dot A Sugiyama-style hierarchical layout[STT81, GKNV93]. neato An implementation of the Kamada-Kawai algorithm[KK89] for “symmetric” layouts. This is a vari- ation of multidimensional scaling[KS80, Coh87]. fdp An implementation of the Fruchterman-Reingold algorithm[FR91] for “symmetric” layouts. This lay- out is similar to neato, but there are performance and feature differences. twopi A radial layout as described by Wills[Wil97]. circo A circular layout combining aspects of the work of Six and Tollis[ST99, ST00] and Kaufmann and Wiese[KW]. In addition, Graphviz provides an assortment of more general-purpose graph algorithms, such as transitive reduction, which have proven useful in the context of graph drawing. The package was designed[GN00] to rely on the “program-as-filter” model of software, in which dis- tinct graph operations or transformations are embodied as programs. Graph drawing and manipulation are achieved by using the output of one filter as the input of another, with each filter recognizing a common, text-based graph format. One thus has an algebra of graphs, using a scripting language to provide the base language with variables and function application and composition. Despite the simplicity and utility of this approach, some applications need or desire to use the software as a library with bindings in a non-scripting language, rather than as primitives composed using a scripting language. The Graphviz software provides a variety of ways to achieve this, running a spectrum from very simple but somewhat inflexible to fairly complex but offering a good deal of application control. 1.1 String-based layouts The simplest mechanism for doing this consists of using the filter approach in disguise. The application, perhaps using the libgraph or libagraph library, constructs a representation of a graph in the DOT language. The application can then invoke the desired layout program, e.g., using system or popen on a Unix system, passing the graph using an intermediate file or a pipe. The layout program computes position information for the graph, attaches this as attributes, and delivers the graph back to the application through another file or pipe. The application can then read in the graph, and apply the geometric information as necessary. This is the approach used by many applications, e.g., dotty[KN94] and grappa[LBM97], which rely on Graphviz. There are several Graphviz output formats which can be used in this approach. They are specified by using a -T flag when invoking the layout program. The input to the uploads/s3/ graphviz-guide.pdf

  • 94
  • 0
  • 0
Afficher les détails des licences
Licence et utilisation
Gratuit pour un usage personnel Attribution requise
Partager