1 ! Copyright (C) 2011 Alex Vondrak.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays graphviz.attributes help.markup
4 help.syntax kernel present sequences strings ;
7 { subgraph <subgraph> <anon> <cluster> } related-words
8 { graph <graph> <digraph> <strict-graph> <strict-digraph> } related-words
9 { node <node> add-node add-nodes } related-words
10 { edge <edge> add-edge add-path } related-words
11 { add add-node add-edge add-nodes add-path } related-words
15 { "subgraph" subgraph }
18 "Constructs an empty, anonymous " { $link subgraph } " by automatically generating a (somewhat) unique " { $slot "id" } "."
21 "Each " { $slot "id" } " has the form " { $snippet "\"_anonymous_n\"" } ", where " { $snippet "n" } " is a counter incremented by 1 each time an anonymous " { $slot "id" } " is generated (e.g., each time you call " { $link <anon> } " or " { $link <graph> } "). This is also how the Graphviz DOT parser internally handles anonymous graphs and subgraphs."
23 "Thus, while it's possible to manually create a " { $link subgraph } " whose " { $slot "id" } " conflicts with an " { $link <anon> } "'s , in practice it's unlikely to happen by accident."
26 "Each " { $link <anon> } " will generate a " { $link subgraph } " with a new " { $slot "id" } ", such as:"
28 "USING: graphviz prettyprint ;"
30 "T{ subgraph { id \"_anonymous_5\" } { statements V{ } } }\nT{ subgraph { id \"_anonymous_6\" } { statements V{ } } }"
33 "More generally, the following should always be the case:"
35 "USING: accessors graphviz kernel prettyprint ;"
36 "<anon> <anon> [ id>> ] bi@ = ."
45 { "subgraph" subgraph }
48 "Constructs a cluster, which is a " { $link subgraph } " whose " { $slot "id" } " begins with the word " { $emphasis "\"cluster\"" } "."
50 { $snippet "id" } " must be an object supported by the " { $link present } " word. The string " { $snippet "\"cluster_\"" } " is automatically prefixed to the " { $slot "id" } " of the resulting " { $link subgraph } "."
53 "Clusters are just a syntactic convention. Not all Graphviz layout engines treat clusters any differently from regular subgraphs. See the Graphviz documentation (" { $url "http://graphviz.org/Documentation.php" } ") for more information."
57 "USING: graphviz prettyprint ;"
59 "T{ subgraph { id \"cluster_foo\" } { statements V{ } } }"
63 "USING: accessors graphviz prettyprint ;"
75 "Constructs an empty, non-strict, directed " { $link graph } "."
78 "Because it's rare for " { $link graph } " " { $slot "id" } "s to be meaningful or useful, " { $link <digraph> } " automatically generates one, just as in " { $link <anon> } "."
82 "If you want, you can still give the resulting " { $link graph } " a specific " { $slot "id" } " using standard words like " { $link >>id } ". For example,"
83 { $code "<digraph> \"G\" >>id" }
86 { $example "USING: graphviz prettyprint ;" "<digraph> graph? ." "t" }
88 { $example "USING: accessors graphviz prettyprint sequences ;" "<digraph> statements>> empty? ." "t" }
90 { $example "USING: accessors graphviz prettyprint ;" "<digraph> strict?>> ." "f" }
92 { $example "USING: accessors graphviz prettyprint ;" "<digraph> directed?>> ." "t" }
103 "Constructs an " { $link edge } " with the given " { $slot "tail" } " and " { $slot "head" } ", each of which must be either:"
105 { "an " { $link array } " of objects supported by the " { $link present } " word, which is treated as an anonymous " { $link subgraph } " of " { $link node } "s with corresponding " { $slot "id" } "s;" }
106 { "a " { $link subgraph } "; or" }
107 { "any object supported by the " { $link present } " word, which is taken to be the " { $slot "id" } " of a " { $link node } "." }
111 "There is more detailed information about how different " { $slot "tail" } " and " { $slot "head" } " types interact in the documentation for " { $link edge } "."
115 "USING: accessors graphviz kernel prettyprint ;"
117 "[ tail>> . ] [ head>> . ] bi"
122 "USING: accessors classes graphviz kernel prettyprint strings ;"
124 "[ tail>> class-of . ] [ head>> class-of . ] bi"
129 "USING: accessors graphviz kernel prettyprint ;"
130 "<anon> <anon> <edge>"
131 "[ tail>> id>> ] [ head>> id>> ] bi = ."
142 "Constructs an empty, non-strict, undirected " { $link graph } "."
145 "Because it's rare for " { $link graph } " " { $slot "id" } "s to be meaningful or useful, " { $link <graph> } " automatically generates one, just as in " { $link <anon> } "."
149 "If you want, you can still give the resulting " { $link graph } " a specific " { $slot "id" } " using standard words like " { $link >>id } ". For example,"
150 { $code "<graph> \"G\" >>id" }
153 { $example "USING: graphviz prettyprint ;" "<graph> graph? ." "t" }
155 { $example "USING: accessors graphviz prettyprint sequences ;" "<graph> statements>> empty? ." "t" }
157 { $example "USING: accessors graphviz prettyprint ;" "<graph> strict?>> ." "f" }
159 { $example "USING: accessors graphviz prettyprint ;" "<graph> directed?>> ." "f" }
169 "Constructs a " { $link node } " with the given " { $slot "id" } ", which must be an object supported by the " { $link present } " word."
173 "USING: graphviz prettyprint ;"
175 "T{ node { id \"foo\" } }"
179 "USING: accessors graphviz prettyprint ;"
186 HELP: <strict-digraph>
191 "Constructs an empty, strict, directed " { $link graph } "."
194 "Because it's rare for " { $link graph } " " { $slot "id" } "s to be meaningful or useful, " { $link <strict-digraph> } " automatically generates one, just as in " { $link <anon> } "."
198 "If you want, you can still give the resulting " { $link graph } " a specific " { $slot "id" } " using standard words like " { $link >>id } ". For example,"
199 { $code "<strict-digraph> \"G\" >>id" }
203 "In " { $emphasis "strict" } " " { $link graph } "s, there is at most one " { $link edge } " between any two " { $link node } "s, so duplicates are ignored while rendering. See " { $vocab-link "graphviz.render" } " for more information."
206 { $example "USING: graphviz prettyprint ;" "<strict-digraph> graph? ." "t" }
208 { $example "USING: accessors graphviz prettyprint sequences ;" "<strict-digraph> statements>> empty? ." "t" }
210 { $example "USING: accessors graphviz prettyprint ;" "<strict-digraph> strict?>> ." "t" }
212 { $example "USING: accessors graphviz prettyprint ;" "<strict-digraph> directed?>> ." "t" }
221 "Constructs an empty, strict, undirected " { $link graph } "."
224 "Because it's rare for " { $link graph } " " { $slot "id" } "s to be meaningful or useful, " { $link <strict-graph> } " automatically generates one, just as in " { $link <anon> } "."
228 "If you want, you can still give the resulting " { $link graph } " a specific " { $slot "id" } " using standard words like " { $link >>id } ". For example,"
229 { $code "<strict-digraph> \"G\" >>id" }
233 "In " { $emphasis "strict" } " " { $link graph } "s, there is at most one " { $link edge } " between any two " { $link node } "s, so duplicates are ignored while rendering. See " { $vocab-link "graphviz.render" } " for more information."
236 { $example "USING: graphviz prettyprint ;" "<strict-graph> graph? ." "t" }
238 { $example "USING: accessors graphviz prettyprint sequences ;" "<strict-graph> statements>> empty? ." "t" }
240 { $example "USING: accessors graphviz prettyprint ;" "<strict-graph> strict?>> ." "t" }
242 { $example "USING: accessors graphviz prettyprint ;" "<strict-graph> directed?>> ." "f" }
249 { "subgraph" subgraph }
252 "Constructs an empty " { $link subgraph } " with the given " { $slot "id" } ", which must be an object supported by the " { $link present } " word."
255 "The empty string, " { $snippet "\"\"" } ", counts as a distinct " { $slot "id" } ". To create an anonymous " { $link subgraph } ", use " { $link <anon> } "."
259 "USING: graphviz prettyprint ;"
260 "\"subg\" <subgraph> subgraph? ."
265 "USING: accessors graphviz prettyprint ;"
266 "3.14 <subgraph> id>> ."
271 "USING: accessors graphviz prettyprint sequences ;"
272 "\"foo\" <subgraph> statements>> empty? ."
280 { "graph" { $or graph subgraph } }
281 { "statement" object }
282 { "graph'" { $or graph subgraph } }
285 "Adds an arbitrary object to the " { $slot "statements" } " slot of a " { $link graph } " or " { $link subgraph } ", leaving the updated tuple on the stack. This is the most basic way to construct a " { $link graph } "."
288 { $link add } " does not check the type of " { $snippet "statement" } ". You should ensure that " { $link graph } "s and " { $link subgraph } "s only contain instances of:"
293 { $link graph-attributes }
294 { $link node-attributes }
295 { $link edge-attributes }
300 "USING: accessors graphviz prettyprint sequences ;"
303 "statements>> [ id>> . ] each"
308 "USING: accessors graphviz prettyprint sequences ;"
312 "statements>> [ id>> . ] each"
317 "USING: accessors classes graphviz prettyprint sequences ;"
322 "statements>> [ class-of . ] each"
330 { "graph" { $or graph subgraph } }
333 { "graph'" { $or graph subgraph } }
336 "Adds an " { $link edge } " in " { $snippet "graph" } " from " { $slot "tail" } " to " { $slot "head" } ". That is,"
337 { $code "X Y add-edge" }
339 { $code "X Y <edge> add" }
343 "USING: accessors graphviz io kernel sequences ;"
347 " 1 2 add-edge ! duplicate"
349 "statements>> [ dup tail>> write \"--\" write head>> print ] each"
350 "1--2\n3--4\n1--2\n5--6"
354 "USING: accessors graphviz io kernel math.combinatorics"
358 " 2 [ first2 add-edge ] each-combination"
359 "statements>> [ dup tail>> write \"--\" write head>> print ] each"
367 { "graph" { $or graph subgraph } }
369 { "graph'" { $or graph subgraph } }
372 "Adds a " { $link node } " with the given " { $slot "id" } " to " { $snippet "graph" } ". That is,"
373 { $code "X add-node" }
375 { $code "X <node> add" }
379 "USING: accessors graphviz prettyprint sequences ;"
384 "statements>> [ id>> . ] each"
385 "\"foo\"\n\"bar\"\n\"baz\""
389 "USING: accessors graphviz prettyprint sequences ;"
391 " 5 iota [ add-node ] each"
392 "statements>> [ id>> . ] each"
393 "\"0\"\n\"1\"\n\"2\"\n\"3\"\n\"4\""
400 { "graph" { $or graph subgraph } }
402 { "graph'" { $or graph subgraph } }
405 "Adds a " { $link node } " to " { $snippet "graph" } " for each element in " { $snippet "nodes" } ", which must be a " { $link sequence } " of objects that are supported by the " { $link present } " word. Thus, the following two lines are equivalent:"
407 "{ X Y Z } add-nodes"
408 "X add-node Y add-node Z add-node"
413 "USING: accessors graphviz prettyprint sequences ;"
415 " { 8 6 7 5 3 0 9 \"Jenny\" \"Jenny\" } add-nodes"
416 "statements>> length ."
421 "USING: accessors graphviz kernel math prettyprint sequences ;"
423 " 100 [ \"spam\" ] replicate add-nodes"
424 "statements>> [ id>> \"spam\" = ] all? ."
432 { "graph" { $or graph subgraph } }
434 { "graph'" { $or graph subgraph } }
437 "Adds " { $link edge } "s to " { $snippet "graph" } " corresponding to a path through " { $snippet "nodes" } "."
441 "That is, an " { $link edge } " is added between each object and the one immediately following it in " { $snippet "nodes" } ". Thus, the following two lines are equivalent:"
443 "{ A B C D E } add-path"
444 "A B add-edge B C add-edge C D add-edge D E add-edge"
449 "USING: accessors graphviz prettyprint sequences ;"
452 "statements>> empty? ."
457 "USING: accessors graphviz prettyprint sequences ;"
459 " { \"the cheese stands alone\" } add-path"
460 "statements>> empty? ."
465 "USING: accessors graphviz io kernel sequences ;"
467 " { 1 2 3 4 5 } add-path"
468 "statements>> [ dup tail>> write \" -> \" write head>> print ] each"
469 "1 -> 2\n2 -> 3\n3 -> 4\n4 -> 5"
473 "USING: accessors graphviz io kernel sequences ;"
475 " { \"cycle\" \"cycle\" } add-path"
476 "statements>> [ dup tail>> write \" -> \" write head>> print ] each"
484 "Represents a Graphviz edge. Each " { $link edge } " is defined by its " { $slot "tail" } " slot and its " { $slot "head" } " slot. Each slot must be either"
486 { { $instance string } " representing the " { $slot "id" } " of a " { $link node } " or" }
487 { { $instance subgraph } ", which is a convenient way to represent multiple Graphviz edges." }
490 "In particular, using " { $link subgraph } "s gives us shorthand forms for the following cases:"
496 { { $slot "head" } " is a " { $link string } "..." }
497 { { $slot "head" } " is a " { $link subgraph } "..." }
500 { { $slot "tail" } " is a " { $link string } "..." }
501 { "edge from " { $slot "tail" } " node\nto " { $slot "head" } " node" }
502 { "edge from " { $slot "tail" } " node\nto each node in " { $slot "head" } }
505 { { $slot "tail" } " is a " { $link subgraph } "..." }
506 { "edge from each node in " { $slot "tail" } "\nto " { $slot "head" } " node" }
507 { "edge from each node in " { $slot "tail" } "\nto each node in " { $slot "head" } }
510 "For more details, see " { $vocab-link "graphviz.render" } "."
512 "In addition, an " { $link edge } " may store local attributes in its " { $slot "attributes" } " slot (" { $instance edge-attributes } " tuple)."
515 "By convention, an " { $link edge } " orders its endpoints \"from\" " { $slot "tail" } " \"to\" " { $slot "head" } ", even if it belongs to an undirected " { $link graph } ", where such a distinction is generally meaningless. See the Graphviz documentation (" { $url "http://graphviz.org/Documentation.php" } "), and specifically the notes about ambiguous attributes (in " { $url "http://graphviz.org/content/attrs" } ") for more information."
520 "Represents the top-level (or " { $emphasis "root" } ") graph used in Graphviz. Its structure is modeled after the DOT language (see " { $url "http://graphviz.org/Documentation.php" } "):"
524 { $strong "Slot name" }
526 { $strong "Meaning in DOT" }
531 { "the reference name of a graph, as in " { $strong "graph" } " " { $slot "id" } " " { $strong "{" } " ... " { $strong "}" } }
535 { $instance boolean }
536 { "indicates strictness, as in " { $strong "strict graph {" } " ... " { $strong "}" } }
539 { $slot "directed?" }
540 { $instance boolean }
541 { "corresponds to " { $strong "digraph {" } " ... " { $strong "}" } " vs. " { $strong "graph {" } " ... " { $strong "}" } }
544 { $slot "statements" }
545 { $instance sequence }
546 { "the defining \"body\", as in " { $strong "graph {" } " ... " { $slot "statements" } " ... " { $strong "}" } }
550 "In particular, " { $slot "statements" } " should be a " { $link sequence } " containing only instances of:"
555 { $link graph-attributes }
556 { $link node-attributes }
557 { $link edge-attributes }
563 "Represents a single Graphviz node. Each " { $link node } " is uniquely determined by an " { $slot "id" } " (" { $instance string } ") and may have per-node attributes stored in its " { $slot "attributes" } " slot (" { $instance node-attributes } " tuple)." ! TODO see graphviz.attributes
568 "Represents a logical grouping of nodes and edges within a Graphviz graph. See " { $url "http://graphviz.org/Documentation.php" } " for more information."
570 "Its structure is largely similar to " { $link graph } ", except " { $link subgraph } " only has two slots: " { $slot "id" } " (" { $instance string } ") and " { $slot "statements" } " (" { $instance sequence } "). The " { $slot "strict?" } " and " { $slot "directed?" } " slots of the parent " { $link graph } " are implicitly inherited by a " { $link subgraph } "."
572 { $slot "id" } " and " { $slot "statements" } " correspond to the name and defining \"body\" of a subgraph in the DOT language, as in " { $strong "subgraph" } " " { $slot "id" } " " { $strong "{" } " ... " { $slot "statements" } " ... " { $strong "}" } "."
574 "In particular, " { $slot "statements" } " should be a " { $link sequence } " containing only instances of:"
579 { $link graph-attributes }
580 { $link node-attributes }
581 { $link edge-attributes }
585 ARTICLE: { "graphviz" "data" } "Graphviz data structures"
586 "To use the " { $vocab-link "graphviz" } " vocabulary, we construct Factor objects that can be converted to data understood by Graphviz (specifically, that " { $emphasis "libgraph" } " and " { $emphasis "libgvc" } " can understand; see " { $vocab-link "graphviz.ffi" } ")."
588 "The following classes are used to represent their equivalent Graphviz structures:"
589 { $subsections node edge subgraph graph }
590 "Several constructor variations exist to make building graphs convenient."
592 "To construct different sorts of graphs:"
593 { $subsections <graph> <digraph> <strict-graph> <strict-digraph> }
594 "To construct different sorts of subgraphs:"
595 { $subsections <subgraph> <anon> <cluster> }
596 "To construct nodes and edges:"
597 { $subsections <node> <edge> }
598 "Finally, use the following words to combine these objects into a single " { $link graph } ":"
599 { $subsections add add-node add-edge add-nodes add-path }
602 ARTICLE: { "graphviz" "gallery" "complete" } "Complete graphs"
603 "In graph theory, a " { $emphasis "complete graph" } " is one in which there is an edge between each pair of distinct nodes."
606 "USING: kernel math.combinatorics math.parser sequences"
607 "graphviz graphviz.notation graphviz.render ;"
611 " node[ \"point\" =shape ]; "
612 " graph[ \"t\" =labelloc \"circo\" =layout ];"
614 " over number>string \"K \" prepend =label"
616 " swap iota 2 [ first2 add-edge ] each-combination"
621 { $image "resource:extra/graphviz/gallery/k5.png" }
624 { $image "resource:extra/graphviz/gallery/k6.png" }
627 { $image "resource:extra/graphviz/gallery/k7.png" }
630 ARTICLE: { "graphviz" "gallery" "bipartite" } "Complete bipartite graphs"
631 "In graph theory, a " { $emphasis "bipartite graph" } " is one in which the nodes can be divided into exactly two independent sets (i.e., there are no edges between nodes in the same set)."
634 "USING: formatting locals math.parser sequences"
635 "graphviz graphviz.notation graphviz.render ;"
637 ":: partite-set ( n color -- cluster )"
640 " node[ color =color ];"
642 " number>string color prepend add-node"
645 ":: K_n,m ( n m -- )"
647 " node[ \"point\" =shape ];"
648 " graph[ \"t\" =labelloc \"dot\" =layout \"LR\" =rankdir ];"
650 " n \"#FF0000\" partite-set"
651 " m \"#0000FF\" partite-set"
653 " add-edge ! between clusters"
655 " ! set label last so that clusters don't inherit it"
656 " n m \"K %d,%d\" sprintf =label"
660 { $code "3 3 K_n,m" }
661 { $image "resource:extra/graphviz/gallery/k33.png" }
663 { $code "3 4 K_n,m" }
664 { $image "resource:extra/graphviz/gallery/k34.png" }
666 { $code "5 4 K_n,m" }
667 { $image "resource:extra/graphviz/gallery/k54.png" }
670 ARTICLE: { "graphviz" "gallery" "cycle" } "Cycle graphs"
671 "In graph theory, a " { $emphasis "cycle graph" } " is one in which all the nodes are connected in a single circle."
674 "USING: kernel math math.parser sequences"
675 "graphviz graphviz.notation graphviz.render ;"
677 ": add-cycle ( graph n -- graph' )"
678 " [ iota add-path ] [ 1 - 0 add-edge ] bi ;"
682 " graph[ \"t\" =labelloc \"circo\" =layout ];"
683 " node[ \"point\" =shape ];"
684 " over number>string \"C \" prepend =label"
690 { $image "resource:extra/graphviz/gallery/c5.png" }
693 { $image "resource:extra/graphviz/gallery/c6.png" }
696 { $image "resource:extra/graphviz/gallery/c7.png" }
699 ARTICLE: { "graphviz" "gallery" "wheel" } "Wheel graphs"
700 "In graph theory, a " { $emphasis "wheel graph" } " on " { $emphasis "n" } " nodes is composed of a single node connected to each node of a cycle of " { $emphasis "n-1" } " nodes."
703 "USING: arrays kernel math math.parser sequences"
704 "graphviz graphviz.notation graphviz.render ;"
706 ": add-cycle ( graph n -- graph' )"
707 " [ iota add-path ] [ 1 - 0 add-edge ] bi ;"
711 " graph[ \"t\" =labelloc \"twopi\" =layout ];"
712 " node[ \"point\" =shape ];"
713 " over number>string \"W \" prepend =label"
715 " over 1 - add-cycle"
716 " swap [ ] [ 1 - iota >array ] bi add-edge"
721 { $image "resource:extra/graphviz/gallery/w6.png" }
723 { $image "resource:extra/graphviz/gallery/w7.png" }
725 { $image "resource:extra/graphviz/gallery/w8.png" }
728 ARTICLE: { "graphviz" "gallery" "cluster" } "Cluster example"
729 "This example is adapted from " { $url "http://graphviz.org/content/cluster" } "."
732 "USING: graphviz graphviz.notation graphviz.render ;"
739 " \"lightgrey\" =color"
740 " node[ \"filled\" =style \"white\" =color ];"
741 " { \"a0\" \"a1\" \"a2\" \"a3\" } ~->"
742 " \"process #1\" =label"
746 " node[ \"filled\" =style ];"
747 " { \"b0\" \"b1\" \"b2\" \"b3\" } ~->"
748 " \"process #2\" =label"
752 " \"start\" \"a0\" ->"
753 " \"start\" \"b0\" ->"
760 " \"start\" add-node[ \"Mdiamond\" =shape ];"
761 " \"end\" add-node[ \"Msquare\" =shape ];"
764 { $image "resource:extra/graphviz/gallery/cluster.png" }
767 ARTICLE: { "graphviz" "gallery" "circles" } "Colored circles example"
768 "This example was adapted from the \"star\" example in PyGraphviz (" { $url "http://networkx.lanl.gov/pygraphviz/" } ") and modified slightly."
771 "USING: formatting kernel math sequences"
772 "graphviz graphviz.notation graphviz.render ;"
774 ": colored-circle ( i -- node )"
776 " [ 16.0 / 0.5 + =width ]"
777 " [ 16.0 / 0.5 + =height ]"
778 " [ 16 * \"#%2x0000\" sprintf =fillcolor ] tri ;"
781 " graph[ \"3,3\" =size \"circo\" =layout ];"
783 " node[ \"filled\" =style"
785 " \"true\" =fixedsize"
788 " edge[ \"invis\" =style ];"
790 " 0 add-node[ \"invis\" =style \"none\" =shape ];"
793 " [ 0 -- ] [ colored-circle add ] bi"
797 { $image "resource:extra/graphviz/gallery/circles.png" }
800 ARTICLE: { "graphviz" "gallery" "fsm" } "Finite state machine example"
801 "This example is adapted from " { $url "http://graphviz.org/content/fsm" } "."
804 "USING: graphviz graphviz.notation graphviz.render ;"
809 " node[ \"doublecircle\" =shape ];"
810 " { \"LR_0\" \"LR_3\" \"LR_4\" \"LR_8\" } add-nodes"
811 " node[ \"circle\" =shape ];"
812 " \"LR_0\" \"LR_2\" ->[ \"SS(B)\" =label ];"
813 " \"LR_0\" \"LR_1\" ->[ \"SS(S)\" =label ];"
814 " \"LR_1\" \"LR_3\" ->[ \"S($end)\" =label ];"
815 " \"LR_2\" \"LR_6\" ->[ \"SS(b)\" =label ];"
816 " \"LR_2\" \"LR_5\" ->[ \"SS(a)\" =label ];"
817 " \"LR_2\" \"LR_4\" ->[ \"S(A)\" =label ];"
818 " \"LR_5\" \"LR_7\" ->[ \"S(b)\" =label ];"
819 " \"LR_5\" \"LR_5\" ->[ \"S(a)\" =label ];"
820 " \"LR_6\" \"LR_6\" ->[ \"S(b)\" =label ];"
821 " \"LR_6\" \"LR_5\" ->[ \"S(a)\" =label ];"
822 " \"LR_7\" \"LR_8\" ->[ \"S(b)\" =label ];"
823 " \"LR_7\" \"LR_5\" ->[ \"S(a)\" =label ];"
824 " \"LR_8\" \"LR_6\" ->[ \"S(b)\" =label ];"
825 " \"LR_8\" \"LR_5\" ->[ \"S(a)\" =label ];"
828 { $image "resource:extra/graphviz/gallery/fsm.png" }
831 ARTICLE: { "graphviz" "gallery" "record" } "Record example"
832 "This example is adapted (and slightly altered) from " { $url "http://graphviz.org/content/datastruct" } "."
834 "As it shows, special label syntax is still parsed, like escape sequences (see " { $url "http://graphviz.org/content/attrs#kescString" } ") or, in this case, record syntax (see " { $url "http://graphviz.org/content/node-shapes#record" } "). However, there is no equivalent to Graphviz's headport/tailport syntax, so we set the " { $link edge } " attributes explicitly."
837 "USING: graphviz graphviz.notation graphviz.render ;"
840 " graph[ \"LR\" =rankdir \"8,8\" =size ];"
841 " node[ 8 =fontsize \"record\" =shape ];"
843 " \"node0\" add-node["
844 " \"<f0> 0x10ba8| <f1>\" =label"
846 " \"node1\" add-node["
847 " \"<f0> 0xf7fc4380| <f1> | <f2> |-1\" =label"
849 " \"node2\" add-node["
850 " \"<f0> 0xf7fc44b8| | |2\" =label"
852 " \"node3\" add-node["
853 " \"<f0> 3.43322790286038071e-06|44.79998779296875|0\" =label"
855 " \"node4\" add-node["
856 " \"<f0> 0xf7fc4380| <f1> | <f2> |2\" =label"
858 " \"node5\" add-node["
859 " \"<f0> (nil)| | |-1\" =label"
861 " \"node6\" add-node["
862 " \"<f0> 0xf7fc4380| <f1> | <f2> |1\" =label"
864 " \"node7\" add-node["
865 " \"<f0> 0xf7fc4380| <f1> | <f2> |2\" =label"
867 " \"node8\" add-node["
868 " \"<f0> (nil)| | |-1\" =label"
870 " \"node9\" add-node["
871 " \"<f0> (nil)| | |-1\" =label"
873 " \"node10\" add-node["
874 " \"<f0> (nil)| <f1> | <f2> |-1\" =label"
876 " \"node11\" add-node["
877 " \"<f0> (nil)| <f1> | <f2> |-1\" =label"
879 " \"node12\" add-node["
880 " \"<f0> 0xf7fc43e0| | |1\" =label"
883 " \"node0\" \"node1\" ->[ \"f0\" =tailport \"f0\" =headport ];"
884 " \"node0\" \"node2\" ->[ \"f1\" =tailport \"f0\" =headport ];"
885 " \"node1\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ];"
886 " \"node1\" \"node4\" ->[ \"f1\" =tailport \"f0\" =headport ];"
887 " \"node1\" \"node5\" ->[ \"f2\" =tailport \"f0\" =headport ];"
888 " \"node4\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ];"
889 " \"node4\" \"node6\" ->[ \"f1\" =tailport \"f0\" =headport ];"
890 " \"node4\" \"node10\" ->[ \"f2\" =tailport \"f0\" =headport ];"
891 " \"node6\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ];"
892 " \"node6\" \"node7\" ->[ \"f1\" =tailport \"f0\" =headport ];"
893 " \"node6\" \"node9\" ->[ \"f2\" =tailport \"f0\" =headport ];"
894 " \"node7\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ];"
895 " \"node7\" \"node1\" ->[ \"f1\" =tailport \"f0\" =headport ];"
896 " \"node7\" \"node8\" ->[ \"f2\" =tailport \"f0\" =headport ];"
897 " \"node10\" \"node11\" ->[ \"f1\" =tailport \"f0\" =headport ];"
898 " \"node10\" \"node12\" ->[ \"f2\" =tailport \"f0\" =headport ];"
899 " \"node11\" \"node1\" ->[ \"f2\" =tailport \"f0\" =headport ];"
902 { $image "resource:extra/graphviz/gallery/record.png" }
905 ARTICLE: { "graphviz" "gallery" } "Graphviz gallery"
906 "Below are some examples of the typical usage of the " { $vocab-link "graphviz" } " vocabulary."
908 "The images in the gallery were pre-compiled using Graphviz version 2.26.3. Depending on your particular Graphviz installation, these examples may not actually work for you, especially if you have a non-standard installation."
910 "Also, while most of the images have a reasonable size, some of these examples may be slow to load in the UI listener."
913 { "graphviz" "gallery" "complete" }
914 { "graphviz" "gallery" "bipartite" }
915 { "graphviz" "gallery" "cycle" }
916 { "graphviz" "gallery" "wheel" }
917 { "graphviz" "gallery" "cluster" }
918 { "graphviz" "gallery" "circles" }
919 { "graphviz" "gallery" "fsm" }
920 { "graphviz" "gallery" "record" }
924 ARTICLE: "graphviz" "Graphviz"
925 "The " { $vocab-link "graphviz" } " vocabulary provides an interface to your existing Graphviz installation, thus allowing you to create, edit, and render Graphviz graphs using Factor. For more information about Graphviz, see " { $url "http://graphviz.org" } "."
927 "This vocabulary provides the basic tools to construct Factor representations of graphs. For more details, see:"
928 { $subsections { "graphviz" "data" } }
929 "Other vocabularies let you change a graph's look & feel, write cleaner code to represent it, and (of course) generate its Graphviz output:"
930 { $vocab-subsection "Graphviz attributes" "graphviz.attributes" }
931 { $vocab-subsection "Graphviz notation" "graphviz.notation" }
932 { $vocab-subsection "Rendering Graphviz output" "graphviz.render" }
934 "After reading the above, you can see several examples in action:"
935 { $subsections { "graphviz" "gallery" } }