<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Graph::Easy - Manual - Tutorial - Inline edge labels</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta http-equiv="imagetoolbar" content="no">
<link rel="stylesheet" type="text/css" href="../base.css">
<link rel="stylesheet" type="text/css" href="manual.css">
<link rel="Start" href="index.html">
<link href="http://bloodgate.com/mail.html" rev="made">
<!-- compliance patch for microsoft browsers -->
<!--[if lt IE 7]><script src="http://bloodgate.com/ie7/ie7-standard-p.js" type="text/javascript"></script><![endif]-->
</head>
<body bgcolor=white text=black>
<a name="top"></a>
<div class="menu">
<a class="menubck" href="index.html" title="Back to the index">Index</a>
<p style="height: 0.2em"> </p>
<a class="menuext" href="overview.html" title="How everything fits together">Overview</a>
<a class="menuext" href="layouter.html" title="How the layouter works">Layouter</a>
<a class="menuext" href="hinting.html" title="Generating specific layouts">Hinting</a>
<a class="menuext" href="output.html" title="Output formats and their limitations">Output</a>
<a class="menuext" href="syntax.html" title="Syntax rules for the text format">Syntax</a>
<a class="menuext" href="attributes.html" title="All possible attributes for graphs, nodes and edges">Attributes</a>
<a class="menuext" href="faq.html" title="Frequently Asked Questions and their answers">F.A.Q.</a>
<a class="menucur" href="tutorial.html" title="Tutorials for often used graph types and designs">Tutorials</a>
<a class="menuind" href="tutorial_bypass.html" title="A bypass">Bypass</a>
<a class="menucin" href="tutorial_edges.html" title="Inline edge labels">Edge labels</a>
<a class="menuind" href="tutorial_tree.html" title="Tree-like layouts">Trees</a>
<a class="menuext" href="editor.html" title="The interactive interface">Editor</a>
</div>
<div class="right">
<h1>Graph::Easy - Manual</h2>
<h2>Tutorials - Inline Edge Labels</h2>
<div class="text">
<h3>The goal</h3>
<p>
The goal of that tutorial is to show you how to create the following
layout:
</p>
<pre class="graph" style="min-width: 50em;">
+------+ +-----+ car +-----+
| Bonn | --- train --> | Ulm | ----------------> | Hof |
+------+ +-----+ +-----+
^ ^
| buy | rent
| |
</pre>
<h3 class="clear">Solution</h3>
<pre class="graphtxt">
[ Bonn ] <em>--</em> [ train ] --> [ Ulm ] <em>--</em> [ car ] --> [ Hof ]
[ ] -- buy --> [ train ] { <em>shape: none;</em> }
[ ] -- rent --> [ car ] { <em>shape: edge;</em> }
</pre>
<h3 class="clear">Explanation</h3>
<p>
For a normal edge between two nodes, the edge label will be put above the edge line:
</p>
<pre class="graphtxt">
[ Koblenz ] -- train --> [ Frankfurt ]
</pre>
<pre class="graph">
+---------+ train +-----------+
| Koblent | -------> | Frankfurt |
+---------+ +-----------+
</pre>
<p class="clear">
But if you want to have the edge label <b>inside</b> 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 <code>shape: none;</code> to remove
the border and an eventual fill color from the node:
</p>
<pre class="graphtxt">
[ ] --> [ Bonn ] <em>--</em> [ train ] --> [ Ulm ] <em>--</em> [ car ] --> [ Hof ]
[ ] -- buy --> [ train ] { <em>shape: none;</em> }
[ ] -- rent --> [ car ] { <em>shape: none;</em> }
</pre>
<pre class="graph">
+------+ +-----+ +-----+
| Bonn | --- train --> | Ulm | --- car --> | Hof |
+------+ +-----+ +-----+
^ ^
| bye | rent
| |
</pre>
<p class="clear">
To make the second part look like the arrow points to the <b>edge</b>,
we set the node shape to <i>edge</i>:
</p>
<pre class="graphtxt">
[ ] --> [ Bonn ] -- [ train ] --> [ Ulm ] -- [ car ] --> [ Hof ]
[ ] -- buy --> [ train ] { shape: none; }
[ ] -- rent --> [ car ] { <em>shape: edge;</em> }
</pre>
<pre class="graph">
+------+ +-----+ car +-----+
| Bonn | --- train --> | Ulm | ----------------> | Hof |
+------+ +-----+ +-----+
^ ^
| buy | rent
| |
</pre>
<p class="clear">
<p>
Here is how that looks as SVG:
</p>
<object width="529" height="149" data="svg/inline.svg" type="image/svg+xml">
<embed width="529" height="149" src="svg/inline.svg" type="image/svg+xml" />
<span class="warning">
If you read this text, your browser does not yet support Scalable Vector graphics (SVG).
</span>
</object>
<h3>Contact and Bugreports</h3>
<p>
If you have questions, feel free to send me an <a href="http://bloodgate.com/mail.html">email</a>
<small>(<a href="http://bloodgate.com/tels.asc">Gnupg key</a>)</small>.
<b>Bugreports</b> should go to <a href="http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Graph-Easy">rt.cpan.org</a>.
</p>
</div>
<div class="footer">
Page created <span class="date">2006-08-17</span> by <a href="http://bloodgate.com/mail.html">Tels</a>.
Last update: <span class="date">2006-08-20</span>
</div>
</div> <!-- end of right cell -->
</body>
</html>