6da20bc6b4fd

cl-digraph: Update site.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 07 Nov 2016 00:01:29 +0000
parents e9e8c7460182
children ed6e2187a5fa
branches/tags (none)
files cl-digraph/usage/index.html

Changes

--- a/cl-digraph/usage/index.html	Sun Nov 06 23:49:33 2016 +0000
+++ b/cl-digraph/usage/index.html	Mon Nov 07 00:01:29 2016 +0000
@@ -34,6 +34,7 @@
 <li><a href="#topological-sorting">Topological Sorting</a></li>
 </ul>
 </li>
+<li><a href="#drawing">Drawing</a></li>
 </ul></div>
 <h2 id="package">Package</h2>
 <p>All core cl-digraph functions are in the <code>digraph</code> package.  You can <code>:use</code> that
@@ -337,6 +338,25 @@
 <span class="p">(</span><span class="nv">C</span> <span class="nv">B</span> <span class="nv">A</span> <span class="nv">D</span><span class="p">)</span>
 <span class="p">(</span><span class="nv">B</span> <span class="nv">C</span> <span class="nv">A</span> <span class="nv">D</span><span class="p">)</span>
 </pre></div>
+
+
+<p>An error will be signaled if the digraph contains a cycle.</p>
+<h2 id="drawing">Drawing</h2>
+<p>If you have <a href="http://www.graphviz.org/">Graphviz</a> installed, you can draw digraph objects to images with
+the <a href="https://github.com/michaelw/cl-dot">cl-dot</a> library by loading the optional <code>cl-digraph.dot</code> system:</p>
+<div class="codehilite"><pre><span class="p">(</span><span class="nv">ql:quickload</span> <span class="ss">'cl-digraph.dot</span><span class="p">)</span>
+
+<span class="p">(</span><span class="nb">defparameter</span> <span class="vg">*d*</span>
+  <span class="p">(</span><span class="nv">digraph:make-digraph</span> <span class="ss">:initial-vertices</span> <span class="o">'</span><span class="p">(</span><span class="nv">a</span> <span class="nv">b</span> <span class="nv">c</span> <span class="nv">d</span> <span class="nv">foo</span> <span class="nv">bar</span><span class="p">)))</span>
+
+<span class="p">(</span><span class="nb">loop</span> <span class="ss">:for</span> <span class="p">(</span><span class="nv">from</span> <span class="nv">to</span><span class="p">)</span> <span class="ss">:in</span> <span class="o">'</span><span class="p">((</span><span class="nv">a</span> <span class="nv">b</span><span class="p">)</span> <span class="p">(</span><span class="nv">a</span> <span class="nv">c</span><span class="p">)</span> <span class="p">(</span><span class="nv">b</span> <span class="nv">d</span><span class="p">)</span> <span class="p">(</span><span class="nv">foo</span> <span class="nv">bar</span><span class="p">)</span> <span class="p">(</span><span class="nv">bar</span> <span class="nv">bar</span><span class="p">))</span>
+      <span class="ss">:do</span> <span class="p">(</span><span class="nv">digraph:insert-edge</span> <span class="vg">*d*</span> <span class="nv">from</span> <span class="nv">to</span><span class="p">))</span>
+
+<span class="p">(</span><span class="nv">digraph.dot:draw</span> <span class="vg">*d*</span> <span class="ss">:filename</span> <span class="s">"digraph.png"</span> <span class="ss">:format</span> <span class="ss">:png</span><span class="p">)</span>
+</pre></div>
+
+
+<p><img alt="Digraph PNG" src="http://i.imgur.com/TtyGQfM.png"/></p>
                 </div>
             <footer><p><i>Made with Lisp and love by <a href="http://stevelosh.com/">Steve Losh</a> in Reykjavík, Iceland.</i></p>
 <script>