aiSee
» Examples
» Download
» Purchase
» Help
   » GDL
      » Lesson 1
» aiSee.com

» About us
» Products
» WCET
» Press center
» Contact

»  Sitemap
» 

Lesson 1: My First Graph

A graph is specified as follows:

graph: {     }

Nodes, edges, graph attributes etc. are specified inside the graph, i.e. between the curly brackets.

A node is specified as follows:

node: { title: "the node's title" }

All node titles have to be unique. The titles are case-sensitive and whitespace-sensitive. For example, the names "a", "A" and "a " refer to three different nodes.

An edge is specified as follows:

edge: { source: "source node title"
        target: "target node title"
}

Example of a simple graph:

graph: {

node: { title: "mom" }
node: { title: "dad" }
node: { title: "son" }

edge: { source: "mom" target: "son" }
edge: { source: "dad" target: "son" }

}

By default, nodes are labeled with their titles. To specify a different label for a node, use the attribute "label".

node: { title: "dad" 
        label: "John Smith"
}

Labels may contain the special characters "\n" (new line), "\t" (tab), and "\"" (double quotes).

node: { title: "dad" 
        label: "John\n\"Rambo\"\nSmith"
}

The graph specification may contain comments in C style (a comment is enclosed between "/*" and "*/") and in C++ style (a comment starts with a "//" and continues until the end of the line):

// This is a comment
// in C++ style 

/* And this is a 
   comment in C style */

Example graph:

graph: {

// Nodes:

node: { title: "mom" }
node: { title: "dad" }
node: { title: "son 1" label: "son\n(James)" }
node: { title: "son 2" label: "son\n(Jim)" }

// Edges:

edge: { source: "mom" target: "son 1" }
edge: { source: "mom" target: "son 2" }
edge: { source: "dad" target: "son 1" }
edge: { source: "dad" target: "son 2" }

}

Top


Note:

  • There is always only one top-level graph.

  • The colon may not be separated from the keywords "graph:", "node:" and "edge:".

  • Edge labels will be discussed in a separate lesson.

» Next lesson: node shapes and border styles