File: SimpleGraph.java

package info (click to toggle)
graphviz 14.1.2-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 139,476 kB
  • sloc: ansic: 142,288; cpp: 11,975; python: 7,883; makefile: 4,044; yacc: 3,030; xml: 2,972; tcl: 2,495; sh: 1,391; objc: 1,159; java: 560; lex: 423; perl: 243; awk: 156; pascal: 139; php: 58; ruby: 49; cs: 31; sed: 1
file content (86 lines) | stat: -rw-r--r-- 2,667 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// Time-stamp: <30.10.2003 14:33:38h liekweg>
//
// This library is distributed under the BSD license.
// See license.txt for more information.
//
// $Id$
//

package example;

import dot.*;

/**
   <P>Use the dot package to create a simple graph.</P>

   @version     $Id$
   @since   Thu Oct 30 09:53:40 2003
   @author  Florian Liekweg <TT>&lt;liekweg@ipd.info.uni-karlsruhe.de&gt;</TT>, Universitt Karlsruhe (TH), Germany
 */

public class SimpleGraph
  implements DotAttributes // 'import' the attribute names
{
  public static void main (String [] args)
  {
    DotGraph dot = new DotGraph ("Sample Graph", // Graph Title
                                 "sample.gv", // Output file name
                                 GRAPH_DEFAULT, // Graph (default) attributes
                                 NODE_DEFAULT, // node defaults
                                 EDGE_DEFAULT); // edge defaults

    // add some nodes with no special attributes
    dot.add_node ("start",      // node name
                  "Start Node"); // node label

    dot.add_node ("one",
                  "First Node");

    // start a new cluster:
    DotCluster cluster = dot.get_cluster ();
    cluster.add_node ("two",
                      "Second Node\\nFirst Node in Cluster");
    cluster.add_node ("three",
                      "Third Node\\nSecond Node in Cluster");


    dot.add_node ("four",
                  "Fourth Node", RED_NODE);
    dot.add_node ("five",
                  "Fifth Node");

    // now, add some edges:
    dot.add_edge ("start", "one");
    dot.add_edge ("one", "two");
    dot.add_edge ("two", "three");
    dot.add_edge ("three", "four");
    dot.add_edge ("four", "five");

    // write it to disk:
    dot.write ();
  }

  private static DotGraphAttr [] GRAPH_DEFAULT = {GRAPH_TD,
                                                  new DotCommentedAttr
                                                  (GRAPH_A4_LANDSCAPE)};

  private static DotNodeAttr [] NODE_DEFAULT = {NODE_NORMAL, NODE_RECORD,
                                                new DotStringAttr (FONTSIZE, "12"),
                                                new DotStringAttr (STYLE,
                                                                   STYLE_FILLED),
                                                new DotColorAttr ("lightblue")};

  private static DotNodeAttr [] RED_NODE = {NODE_RED};

  private static DotEdgeAttr [] EDGE_DEFAULT = {EDGE_NORMAL,
                                                new DotStringAttr (FONTSIZE, "10"),
                                                EDGE_BLACK};
}


/*
  Local Variables:
  c-basic-offset: 2
  End:
*/