This chapter of the Graph::Easy manual covers the basic syntax and elements of the graph description language.
This chapter of the Graph::Easy manual covers the basic syntax and elements of the graph description language.
A node is enclosed in square brackets,
[ ]
.
The text between the brackets will be the unique name of the node and is also what will usually displayed:
[ Bonn ] [ Berlin ]
Bonn | |||
Berlin | |||
[ Bonn and Berlin ] [ Bonn and Berlin ] [Bonn and Berlin]
Bonn and Berlin | |||
Note that spaces at the front and end, as well as double spaces are stripped out. Thus the following are all equivalent and the resulting graph will only have one node:
[ Bonn\n and\n Berlin ]
Bonn and Berlin |
|||
You can embed linebreaks into the node text by using \n
:
See also the section on Escaping.
When describing graphs,
a few characters are used to start/end special features.
These markers,
like <[
>,
<]
> or <#
>,
cannot appear in names,
labels,
texts etc,
without being escaped.
The escape character is <\
> (backslash).
Here is an example:
[ \[ Bonn\n and\n Berlin are \#0 (really!) \] ]
Comments in the source start with a #
and always comment out anything to the end of the line:
[ Bonn ] -> [ Berlin ]
Bonn | ------> | Berlin | |||||
Note that the color definition does not start a comment, this is a special case that should be automatically handled right by the parser.
If you want to embed a literal #
into a node name,
use \#
.
Edges connect nodes with each other.
[ Bonn ] --> [ Berlin ] [ A ] ==> [ B ] [ B ] ..> [ C ] [ B ] - > [ D ] [ F ] -This is a label-> [ E ]
Bonn | ------> | Berlin | |||||||||
A | ======> | B | - - - > | D | |||||||
| | v |
|||||||||||
F | C | ||||||||||
| | vThis is a label |
|||||||||||
E | |||||||||||
[ F ] =This is a label=> [ E ]
F | This is a label ==============================> |
E | |||||
You can also combine different styles and labels:
graph { background: white; color: green; } [ Bonn ] { color: red; } -> { color: blue; } [ Berlin ]
Bonn | ------> | Berlin | |||||
Attributes can appear either as global class definitions, or specifically on Nodes (and Edges):
If you want two nodes with the same text, or name a node different from what text is displayed, you need to use a node label:
[ Bonn ] -> [ Berlin ] -> [ Bonn1 ] { label: Bonn; }
Bonn | ------> | Berlin | ------> | Bonn | |||||||