The goal
The goal of that tutorial is to show you how to create the following layout:
+------+ +-----+ car +-----+ | Bonn | --- train --> | Ulm | ----------------> | Hof | +------+ +-----+ +-----+ ^ ^ | buy | rent | |
Solution
[ Bonn ] -- [ train ] --> [ Ulm ] -- [ car ] --> [ Hof ] [ ] -- buy --> [ train ] { shape: none; } [ ] -- rent --> [ car ] { shape: edge; }
Explanation
For a normal edge between two nodes, the edge label will be put above the edge line:
[ Koblenz ] -- train --> [ Frankfurt ]
+---------+ train +-----------+ | Koblent | -------> | Frankfurt | +---------+ +-----------+
But if you want to have the edge label inside the edge, there is
not yet a way to specify this directly. So one needs to use a trick
to achive the desired layout. First, we convert the edge label
into a normal node and then we use shape: none;
to remove
the border and an eventual fill color from the node:
[ ] --> [ Bonn ] -- [ train ] --> [ Ulm ] -- [ car ] --> [ Hof ] [ ] -- buy --> [ train ] { shape: none; } [ ] -- rent --> [ car ] { shape: none; }
+------+ +-----+ +-----+ | Bonn | --- train --> | Ulm | --- car --> | Hof | +------+ +-----+ +-----+ ^ ^ | bye | rent | |
To make the second part look like the arrow points to the edge, we set the node shape to edge:
[ ] --> [ Bonn ] -- [ train ] --> [ Ulm ] -- [ car ] --> [ Hof ] [ ] -- buy --> [ train ] { shape: none; } [ ] -- rent --> [ car ] { shape: edge; }
+------+ +-----+ car +-----+ | Bonn | --- train --> | Ulm | ----------------> | Hof | +------+ +-----+ +-----+ ^ ^ | buy | rent | |
Here is how that looks as SVG:
Contact and Bugreports
If you have questions, feel free to send me an email (Gnupg key). Bugreports should go to rt.cpan.org.