graphviz: Update this nightmare :p

modern-harvey2
Doug Coleman 2017-08-27 13:34:41 -05:00
parent c9d2ed1458
commit 1771fbb909
5 changed files with 210 additions and 243 deletions

View File

@ -1,25 +1,10 @@
! Copyright (C) 2011 Alex Vondrak. ! Copyright (C) 2011 Alex Vondrak.
! See http://factorcode.org/license.txt for BSD license ! See http://factorcode.org/license.txt for BSD license
USING: accessors compiler.cfg compiler.cfg.builder
USING: accessors fry io io.directories io.pathnames compiler.cfg.debugger compiler.cfg.finalization compiler.cfg.rpo
io.streams.string kernel math math.parser namespaces graphviz graphviz.notation graphviz.render io.directories
prettyprint sequences splitting strings tools.annotations io.pathnames io.streams.string kernel math math.parser
namespaces sequences splitting ;
compiler.cfg
compiler.cfg.builder
compiler.cfg.debugger
compiler.cfg.linearization
compiler.cfg.finalization
compiler.cfg.optimizer
compiler.cfg.rpo
compiler.cfg.value-numbering
compiler.cfg.value-numbering.graph
graphviz
graphviz.notation
graphviz.render
;
FROM: compiler.cfg.linearization => number-blocks ; FROM: compiler.cfg.linearization => number-blocks ;
IN: compiler.cfg.graphviz IN: compiler.cfg.graphviz
@ -48,8 +33,8 @@ IN: compiler.cfg.graphviz
: cfgviz ( cfg -- graph ) : cfgviz ( cfg -- graph )
<digraph> <digraph>
[graph "t" =labelloc ]; graph[ "t" =labelloc ]
[node "box" =shape "Courier" =fontname 10 =fontsize ]; node[ "box" =shape "Courier" =fontname 10 =fontsize ]
swap [ swap [
[ add-cfg-vertex ] [ add-cfg-edges ] bi [ add-cfg-vertex ] [ add-cfg-edges ] bi
] each-basic-block ; ] each-basic-block ;

View File

@ -607,8 +607,8 @@ $nl
"" ""
": K_n ( n -- )" ": K_n ( n -- )"
" <graph>" " <graph>"
" [node \"point\" =shape ]; " " node[ \"point\" =shape ]"
" [graph \"t\" =labelloc \"circo\" =layout ];" " graph[ \"t\" =labelloc \"circo\" =layout ]"
"" ""
" over number>string \"K \" prepend =label" " over number>string \"K \" prepend =label"
"" ""
@ -636,15 +636,15 @@ $nl
":: partite-set ( n color -- cluster )" ":: partite-set ( n color -- cluster )"
" color <cluster>" " color <cluster>"
" color =color" " color =color"
" [node color =color ];" " node[ color =color ]"
" n <iota> [" " n <iota> ["
" number>string color prepend add-node" " number>string color prepend add-node"
" ] each ;" " ] each ;"
"" ""
":: K_n,m ( n m -- )" ":: K_n,m ( n m -- )"
" <graph>" " <graph>"
" [node \"point\" =shape ];" " node[ \"point\" =shape ]"
" [graph \"t\" =labelloc \"dot\" =layout \"LR\" =rankdir ];" " graph[ \"t\" =labelloc \"dot\" =layout \"LR\" =rankdir ]"
"" ""
" n \"#FF0000\" partite-set" " n \"#FF0000\" partite-set"
" m \"#0000FF\" partite-set" " m \"#0000FF\" partite-set"
@ -678,8 +678,8 @@ $nl
"" ""
": C_n ( n -- )" ": C_n ( n -- )"
" <graph>" " <graph>"
" [graph \"t\" =labelloc \"circo\" =layout ];" " graph[ \"t\" =labelloc \"circo\" =layout ]"
" [node \"point\" =shape ];" " node[ \"point\" =shape ]"
" over number>string \"C \" prepend =label" " over number>string \"C \" prepend =label"
" swap add-cycle" " swap add-cycle"
" preview ;" " preview ;"
@ -707,8 +707,8 @@ $nl
"" ""
": W_n ( n -- )" ": W_n ( n -- )"
" <graph>" " <graph>"
" [graph \"t\" =labelloc \"twopi\" =layout ];" " graph[ \"t\" =labelloc \"twopi\" =layout ]"
" [node \"point\" =shape ];" " node[ \"point\" =shape ]"
" over number>string \"W \" prepend =label" " over number>string \"W \" prepend =label"
" over add-node" " over add-node"
" over 1 - add-cycle" " over 1 - add-cycle"
@ -736,13 +736,13 @@ $nl
" 0 <cluster>" " 0 <cluster>"
" \"filled\" =style" " \"filled\" =style"
" \"lightgrey\" =color" " \"lightgrey\" =color"
" [node \"filled\" =style \"white\" =color ];" " node[ \"filled\" =style \"white\" =color ]"
" { \"a0\" \"a1\" \"a2\" \"a3\" } ~->" " { \"a0\" \"a1\" \"a2\" \"a3\" } ~->"
" \"process #1\" =label" " \"process #1\" =label"
" add" " add"
"" ""
" 1 <cluster>" " 1 <cluster>"
" [node \"filled\" =style ];" " node[ \"filled\" =style ]"
" { \"b0\" \"b1\" \"b2\" \"b3\" } ~->" " { \"b0\" \"b1\" \"b2\" \"b3\" } ~->"
" \"process #2\" =label" " \"process #2\" =label"
" \"blue\" =color" " \"blue\" =color"
@ -756,8 +756,8 @@ $nl
" \"a3\" \"end\" ->" " \"a3\" \"end\" ->"
" \"b3\" \"end\" ->" " \"b3\" \"end\" ->"
"" ""
" \"start\" [add-node \"Mdiamond\" =shape ];" " \"start\" add-node[ \"Mdiamond\" =shape ]"
" \"end\" [add-node \"Msquare\" =shape ];" " \"end\" add-node[ \"Msquare\" =shape ]"
"preview" "preview"
} }
{ $image "resource:extra/graphviz/gallery/cluster.png" } { $image "resource:extra/graphviz/gallery/cluster.png" }
@ -777,16 +777,16 @@ $nl
" [ 16 * \"#%2x0000\" sprintf =fillcolor ] tri ;" " [ 16 * \"#%2x0000\" sprintf =fillcolor ] tri ;"
"" ""
"<graph>" "<graph>"
" [graph \"3,3\" =size \"circo\" =layout ];" " graph[ \"3,3\" =size \"circo\" =layout ]"
"" ""
" [node \"filled\" =style" " node[ \"filled\" =style"
" \"circle\" =shape" " \"circle\" =shape"
" \"true\" =fixedsize" " \"true\" =fixedsize"
" \"\" =label ];" " \"\" =label ]"
"" ""
" [edge \"invis\" =style ];" " edge[ \"invis\" =style ]"
"" ""
" 0 [add-node \"invis\" =style \"none\" =shape ];" " 0 add-node[ \"invis\" =style \"none\" =shape ]"
"" ""
" 16 <iota> [" " 16 <iota> ["
" [ 0 -- ] [ colored-circle add ] bi" " [ 0 -- ] [ colored-circle add ] bi"
@ -805,23 +805,23 @@ $nl
"<digraph>" "<digraph>"
" \"LR\" =rankdir" " \"LR\" =rankdir"
" \"8,5\" =size" " \"8,5\" =size"
" [node \"doublecircle\" =shape ];" " node[ \"doublecircle\" =shape ]"
" { \"LR_0\" \"LR_3\" \"LR_4\" \"LR_8\" } add-nodes" " { \"LR_0\" \"LR_3\" \"LR_4\" \"LR_8\" } add-nodes"
" [node \"circle\" =shape ];" " node[ \"circle\" =shape ]"
" \"LR_0\" \"LR_2\" [-> \"SS(B)\" =label ];" " \"LR_0\" \"LR_2\" ->[ \"SS(B)\" =label ]"
" \"LR_0\" \"LR_1\" [-> \"SS(S)\" =label ];" " \"LR_0\" \"LR_1\" ->[ \"SS(S)\" =label ]"
" \"LR_1\" \"LR_3\" [-> \"S($end)\" =label ];" " \"LR_1\" \"LR_3\" ->[ \"S($end)\" =label ]"
" \"LR_2\" \"LR_6\" [-> \"SS(b)\" =label ];" " \"LR_2\" \"LR_6\" ->[ \"SS(b)\" =label ]"
" \"LR_2\" \"LR_5\" [-> \"SS(a)\" =label ];" " \"LR_2\" \"LR_5\" ->[ \"SS(a)\" =label ]"
" \"LR_2\" \"LR_4\" [-> \"S(A)\" =label ];" " \"LR_2\" \"LR_4\" ->[ \"S(A)\" =label ]"
" \"LR_5\" \"LR_7\" [-> \"S(b)\" =label ];" " \"LR_5\" \"LR_7\" ->[ \"S(b)\" =label ]"
" \"LR_5\" \"LR_5\" [-> \"S(a)\" =label ];" " \"LR_5\" \"LR_5\" ->[ \"S(a)\" =label ]"
" \"LR_6\" \"LR_6\" [-> \"S(b)\" =label ];" " \"LR_6\" \"LR_6\" ->[ \"S(b)\" =label ]"
" \"LR_6\" \"LR_5\" [-> \"S(a)\" =label ];" " \"LR_6\" \"LR_5\" ->[ \"S(a)\" =label ]"
" \"LR_7\" \"LR_8\" [-> \"S(b)\" =label ];" " \"LR_7\" \"LR_8\" ->[ \"S(b)\" =label ]"
" \"LR_7\" \"LR_5\" [-> \"S(a)\" =label ];" " \"LR_7\" \"LR_5\" ->[ \"S(a)\" =label ]"
" \"LR_8\" \"LR_6\" [-> \"S(b)\" =label ];" " \"LR_8\" \"LR_6\" ->[ \"S(b)\" =label ]"
" \"LR_8\" \"LR_5\" [-> \"S(a)\" =label ];" " \"LR_8\" \"LR_5\" ->[ \"S(a)\" =label ]"
"preview" "preview"
} }
{ $image "resource:extra/graphviz/gallery/fsm.png" } { $image "resource:extra/graphviz/gallery/fsm.png" }
@ -836,66 +836,66 @@ $nl
"USING: graphviz graphviz.notation graphviz.render ;" "USING: graphviz graphviz.notation graphviz.render ;"
"" ""
"<digraph>" "<digraph>"
" [graph \"LR\" =rankdir \"8,8\" =size ];" " graph[ \"LR\" =rankdir \"8,8\" =size ]"
" [node 8 =fontsize \"record\" =shape ];" " node[ 8 =fontsize \"record\" =shape ]"
"" ""
" \"node0\" [add-node" " \"node0\" add-node["
" \"<f0> 0x10ba8| <f1>\" =label" " \"<f0> 0x10ba8| <f1>\" =label"
" ];" " ]"
" \"node1\" [add-node" " \"node1\" add-node["
" \"<f0> 0xf7fc4380| <f1> | <f2> |-1\" =label" " \"<f0> 0xf7fc4380| <f1> | <f2> |-1\" =label"
" ];" " ]"
" \"node2\" [add-node" " \"node2\" add-node["
" \"<f0> 0xf7fc44b8| | |2\" =label" " \"<f0> 0xf7fc44b8| | |2\" =label"
" ];" " ]"
" \"node3\" [add-node" " \"node3\" add-node["
" \"<f0> 3.43322790286038071e-06|44.79998779296875|0\" =label" " \"<f0> 3.43322790286038071e-06|44.79998779296875|0\" =label"
" ];" " ]"
" \"node4\" [add-node" " \"node4\" add-node["
" \"<f0> 0xf7fc4380| <f1> | <f2> |2\" =label" " \"<f0> 0xf7fc4380| <f1> | <f2> |2\" =label"
" ];" " ]"
" \"node5\" [add-node" " \"node5\" add-node["
" \"<f0> (nil)| | |-1\" =label" " \"<f0> (nil)| | |-1\" =label"
" ];" " ]"
" \"node6\" [add-node" " \"node6\" add-node["
" \"<f0> 0xf7fc4380| <f1> | <f2> |1\" =label" " \"<f0> 0xf7fc4380| <f1> | <f2> |1\" =label"
" ];" " ]"
" \"node7\" [add-node" " \"node7\" add-node["
" \"<f0> 0xf7fc4380| <f1> | <f2> |2\" =label" " \"<f0> 0xf7fc4380| <f1> | <f2> |2\" =label"
" ];" " ]"
" \"node8\" [add-node" " \"node8\" add-node["
" \"<f0> (nil)| | |-1\" =label" " \"<f0> (nil)| | |-1\" =label"
" ];" " ]"
" \"node9\" [add-node" " \"node9\" add-node["
" \"<f0> (nil)| | |-1\" =label" " \"<f0> (nil)| | |-1\" =label"
" ];" " ]"
" \"node10\" [add-node" " \"node10\" add-node["
" \"<f0> (nil)| <f1> | <f2> |-1\" =label" " \"<f0> (nil)| <f1> | <f2> |-1\" =label"
" ];" " ]"
" \"node11\" [add-node" " \"node11\" add-node["
" \"<f0> (nil)| <f1> | <f2> |-1\" =label" " \"<f0> (nil)| <f1> | <f2> |-1\" =label"
" ];" " ]"
" \"node12\" [add-node" " \"node12\" add-node["
" \"<f0> 0xf7fc43e0| | |1\" =label" " \"<f0> 0xf7fc43e0| | |1\" =label"
" ];" " ]"
"" ""
" \"node0\" \"node1\" [-> \"f0\" =tailport \"f0\" =headport ];" " \"node0\" \"node1\" ->[ \"f0\" =tailport \"f0\" =headport ]"
" \"node0\" \"node2\" [-> \"f1\" =tailport \"f0\" =headport ];" " \"node0\" \"node2\" ->[ \"f1\" =tailport \"f0\" =headport ]"
" \"node1\" \"node3\" [-> \"f0\" =tailport \"f0\" =headport ];" " \"node1\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ]"
" \"node1\" \"node4\" [-> \"f1\" =tailport \"f0\" =headport ];" " \"node1\" \"node4\" ->[ \"f1\" =tailport \"f0\" =headport ]"
" \"node1\" \"node5\" [-> \"f2\" =tailport \"f0\" =headport ];" " \"node1\" \"node5\" ->[ \"f2\" =tailport \"f0\" =headport ]"
" \"node4\" \"node3\" [-> \"f0\" =tailport \"f0\" =headport ];" " \"node4\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ]"
" \"node4\" \"node6\" [-> \"f1\" =tailport \"f0\" =headport ];" " \"node4\" \"node6\" ->[ \"f1\" =tailport \"f0\" =headport ]"
" \"node4\" \"node10\" [-> \"f2\" =tailport \"f0\" =headport ];" " \"node4\" \"node10\" ->[ \"f2\" =tailport \"f0\" =headport ]"
" \"node6\" \"node3\" [-> \"f0\" =tailport \"f0\" =headport ];" " \"node6\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ]"
" \"node6\" \"node7\" [-> \"f1\" =tailport \"f0\" =headport ];" " \"node6\" \"node7\" ->[ \"f1\" =tailport \"f0\" =headport ]"
" \"node6\" \"node9\" [-> \"f2\" =tailport \"f0\" =headport ];" " \"node6\" \"node9\" ->[ \"f2\" =tailport \"f0\" =headport ]"
" \"node7\" \"node3\" [-> \"f0\" =tailport \"f0\" =headport ];" " \"node7\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ]"
" \"node7\" \"node1\" [-> \"f1\" =tailport \"f0\" =headport ];" " \"node7\" \"node1\" ->[ \"f1\" =tailport \"f0\" =headport ]"
" \"node7\" \"node8\" [-> \"f2\" =tailport \"f0\" =headport ];" " \"node7\" \"node8\" ->[ \"f2\" =tailport \"f0\" =headport ]"
" \"node10\" \"node11\" [-> \"f1\" =tailport \"f0\" =headport ];" " \"node10\" \"node11\" ->[ \"f1\" =tailport \"f0\" =headport ]"
" \"node10\" \"node12\" [-> \"f2\" =tailport \"f0\" =headport ];" " \"node10\" \"node12\" ->[ \"f2\" =tailport \"f0\" =headport ]"
" \"node11\" \"node1\" [-> \"f2\" =tailport \"f0\" =headport ];" " \"node11\" \"node1\" ->[ \"f2\" =tailport \"f0\" =headport ]"
"preview" "preview"
} }
{ $image "resource:extra/graphviz/gallery/record.png" } { $image "resource:extra/graphviz/gallery/record.png" }

View File

@ -55,23 +55,23 @@ SYMBOLS: supported-layouts supported-formats ;
: K_n ( n -- graph ) : K_n ( n -- graph )
<graph> <graph>
[node "point" =shape ]; node[ "point" =shape ]
[graph "t" =labelloc "circo" =layout ]; graph[ "t" =labelloc "circo" =layout ]
over number>string "K " prepend =label over number>string "K " prepend =label
swap <iota> 2 [ first2 add-edge ] each-combination ; swap <iota> 2 [ first2 add-edge ] each-combination ;
:: partite-set ( n color -- cluster ) :: partite-set ( n color -- cluster )
color <cluster> color <cluster>
color =color color =color
[node color =color ]; node[ color =color ]
n <iota> [ n <iota> [
number>string color prepend add-node number>string color prepend add-node
] each ; ] each ;
:: K_n,m ( n m -- graph ) :: K_n,m ( n m -- graph )
<graph> <graph>
[node "point" =shape ]; node[ "point" =shape ]
[graph "t" =labelloc "dot" =layout "LR" =rankdir ]; graph[ "t" =labelloc "dot" =layout "LR" =rankdir ]
n "#FF0000" partite-set n "#FF0000" partite-set
m "#0000FF" partite-set m "#0000FF" partite-set
add-edge add-edge
@ -82,15 +82,15 @@ SYMBOLS: supported-layouts supported-formats ;
: C_n ( n -- graph ) : C_n ( n -- graph )
<graph> <graph>
[graph "t" =labelloc "circo" =layout ]; graph[ "t" =labelloc "circo" =layout ]
[node "point" =shape ]; node[ "point" =shape ]
over number>string "C " prepend =label over number>string "C " prepend =label
swap add-cycle ; swap add-cycle ;
: W_n ( n -- graph ) : W_n ( n -- graph )
<graph> <graph>
[graph "t" =labelloc "twopi" =layout ]; graph[ "t" =labelloc "twopi" =layout ]
[node "point" =shape ]; node[ "point" =shape ]
over number>string "W " prepend =label over number>string "W " prepend =label
over add-node over add-node
over 1 - add-cycle over 1 - add-cycle
@ -102,12 +102,12 @@ SYMBOLS: supported-layouts supported-formats ;
0 <cluster> 0 <cluster>
"filled" =style "filled" =style
"lightgrey" =color "lightgrey" =color
[node "filled" =style "white" =color ]; node[ "filled" =style "white" =color ]
{ "a0" "a1" "a2" "a3" } ~-> { "a0" "a1" "a2" "a3" } ~->
"process #1" =label "process #1" =label
add add
1 <cluster> 1 <cluster>
[node "filled" =style ]; node[ "filled" =style ]
{ "b0" "b1" "b2" "b3" } ~-> { "b0" "b1" "b2" "b3" } ~->
"process #2" =label "process #2" =label
"blue" =color "blue" =color
@ -119,8 +119,8 @@ SYMBOLS: supported-layouts supported-formats ;
"a3" "a0" -> "a3" "a0" ->
"a3" "end" -> "a3" "end" ->
"b3" "end" -> "b3" "end" ->
"start" [add-node "Mdiamond" =shape ]; "start" add-node[ "Mdiamond" =shape ]
"end" [add-node "Msquare" =shape ]; "end" add-node[ "Msquare" =shape ]
; ;
: colored-circle ( i -- node ) : colored-circle ( i -- node )
@ -131,13 +131,13 @@ SYMBOLS: supported-layouts supported-formats ;
: colored-circles-example ( -- graph ) : colored-circles-example ( -- graph )
<graph> <graph>
[graph "3,3" =size "circo" =layout ]; graph[ "3,3" =size "circo" =layout ]
[node "filled" =style node[ "filled" =style
"circle" =shape "circle" =shape
"true" =fixedsize "true" =fixedsize
"" =label ]; "" =label ]
[edge "invis" =style ]; edge[ "invis" =style ]
0 [add-node "invis" =style "none" =shape ]; 0 add-node[ "invis" =style "none" =shape ]
16 <iota> [ 16 <iota> [
[ 0 -- ] [ colored-circle add ] bi [ 0 -- ] [ colored-circle add ] bi
] each ; ] each ;
@ -146,87 +146,87 @@ SYMBOLS: supported-layouts supported-formats ;
<digraph> <digraph>
"LR" =rankdir "LR" =rankdir
"8,5" =size "8,5" =size
[node "doublecircle" =shape ]; node[ "doublecircle" =shape ]
{ "LR_0" "LR_3" "LR_4" "LR_8" } add-nodes { "LR_0" "LR_3" "LR_4" "LR_8" } add-nodes
[node "circle" =shape ]; node[ "circle" =shape ]
"LR_0" "LR_2" [-> "SS(B)" =label ]; "LR_0" "LR_2" ->[ "SS(B)" =label ]
"LR_0" "LR_1" [-> "SS(S)" =label ]; "LR_0" "LR_1" ->[ "SS(S)" =label ]
"LR_1" "LR_3" [-> "S($end)" =label ]; "LR_1" "LR_3" ->[ "S($end)" =label ]
"LR_2" "LR_6" [-> "SS(b)" =label ]; "LR_2" "LR_6" ->[ "SS(b)" =label ]
"LR_2" "LR_5" [-> "SS(a)" =label ]; "LR_2" "LR_5" ->[ "SS(a)" =label ]
"LR_2" "LR_4" [-> "S(A)" =label ]; "LR_2" "LR_4" ->[ "S(A)" =label ]
"LR_5" "LR_7" [-> "S(b)" =label ]; "LR_5" "LR_7" ->[ "S(b)" =label ]
"LR_5" "LR_5" [-> "S(a)" =label ]; "LR_5" "LR_5" ->[ "S(a)" =label ]
"LR_6" "LR_6" [-> "S(b)" =label ]; "LR_6" "LR_6" ->[ "S(b)" =label ]
"LR_6" "LR_5" [-> "S(a)" =label ]; "LR_6" "LR_5" ->[ "S(a)" =label ]
"LR_7" "LR_8" [-> "S(b)" =label ]; "LR_7" "LR_8" ->[ "S(b)" =label ]
"LR_7" "LR_5" [-> "S(a)" =label ]; "LR_7" "LR_5" ->[ "S(a)" =label ]
"LR_8" "LR_6" [-> "S(b)" =label ]; "LR_8" "LR_6" ->[ "S(b)" =label ]
"LR_8" "LR_5" [-> "S(a)" =label ]; "LR_8" "LR_5" ->[ "S(a)" =label ]
; ;
: record-example ( -- graph ) : record-example ( -- graph )
<digraph> <digraph>
[graph "LR" =rankdir "8,8" =size ]; graph[ "LR" =rankdir "8,8" =size ]
[node 8 =fontsize "record" =shape ]; node[ 8 =fontsize "record" =shape ]
"node0" [add-node "node0" add-node[
"<f0> 0x10ba8| <f1>" =label "<f0> 0x10ba8| <f1>" =label
]; ]
"node1" [add-node "node1" add-node[
"<f0> 0xf7fc4380| <f1> | <f2> |-1" =label "<f0> 0xf7fc4380| <f1> | <f2> |-1" =label
]; ]
"node2" [add-node "node2" add-node[
"<f0> 0xf7fc44b8| | |2" =label "<f0> 0xf7fc44b8| | |2" =label
]; ]
"node3" [add-node "node3" add-node[
"<f0> 3.43322790286038071e-06|44.79998779296875|0" =label "<f0> 3.43322790286038071e-06|44.79998779296875|0" =label
]; ]
"node4" [add-node "node4" add-node[
"<f0> 0xf7fc4380| <f1> | <f2> |2" =label "<f0> 0xf7fc4380| <f1> | <f2> |2" =label
]; ]
"node5" [add-node "node5" add-node[
"<f0> (nil)| | |-1" =label "<f0> (nil)| | |-1" =label
]; ]
"node6" [add-node "node6" add-node[
"<f0> 0xf7fc4380| <f1> | <f2> |1" =label "<f0> 0xf7fc4380| <f1> | <f2> |1" =label
]; ]
"node7" [add-node "node7" add-node[
"<f0> 0xf7fc4380| <f1> | <f2> |2" =label "<f0> 0xf7fc4380| <f1> | <f2> |2" =label
]; ]
"node8" [add-node "node8" add-node[
"<f0> (nil)| | |-1" =label "<f0> (nil)| | |-1" =label
]; ]
"node9" [add-node "node9" add-node[
"<f0> (nil)| | |-1" =label "<f0> (nil)| | |-1" =label
]; ]
"node10" [add-node "node10" add-node[
"<f0> (nil)| <f1> | <f2> |-1" =label "<f0> (nil)| <f1> | <f2> |-1" =label
]; ]
"node11" [add-node "node11" add-node[
"<f0> (nil)| <f1> | <f2> |-1" =label "<f0> (nil)| <f1> | <f2> |-1" =label
]; ]
"node12" [add-node "node12" add-node[
"<f0> 0xf7fc43e0| | |1" =label "<f0> 0xf7fc43e0| | |1" =label
]; ]
"node0" "node1" [-> "f0" =tailport "f0" =headport ]; "node0" "node1" ->[ "f0" =tailport "f0" =headport ]
"node0" "node2" [-> "f1" =tailport "f0" =headport ]; "node0" "node2" ->[ "f1" =tailport "f0" =headport ]
"node1" "node3" [-> "f0" =tailport "f0" =headport ]; "node1" "node3" ->[ "f0" =tailport "f0" =headport ]
"node1" "node4" [-> "f1" =tailport "f0" =headport ]; "node1" "node4" ->[ "f1" =tailport "f0" =headport ]
"node1" "node5" [-> "f2" =tailport "f0" =headport ]; "node1" "node5" ->[ "f2" =tailport "f0" =headport ]
"node4" "node3" [-> "f0" =tailport "f0" =headport ]; "node4" "node3" ->[ "f0" =tailport "f0" =headport ]
"node4" "node6" [-> "f1" =tailport "f0" =headport ]; "node4" "node6" ->[ "f1" =tailport "f0" =headport ]
"node4" "node10" [-> "f2" =tailport "f0" =headport ]; "node4" "node10" ->[ "f2" =tailport "f0" =headport ]
"node6" "node3" [-> "f0" =tailport "f0" =headport ]; "node6" "node3" ->[ "f0" =tailport "f0" =headport ]
"node6" "node7" [-> "f1" =tailport "f0" =headport ]; "node6" "node7" ->[ "f1" =tailport "f0" =headport ]
"node6" "node9" [-> "f2" =tailport "f0" =headport ]; "node6" "node9" ->[ "f2" =tailport "f0" =headport ]
"node7" "node3" [-> "f0" =tailport "f0" =headport ]; "node7" "node3" ->[ "f0" =tailport "f0" =headport ]
"node7" "node1" [-> "f1" =tailport "f0" =headport ]; "node7" "node1" ->[ "f1" =tailport "f0" =headport ]
"node7" "node8" [-> "f2" =tailport "f0" =headport ]; "node7" "node8" ->[ "f2" =tailport "f0" =headport ]
"node10" "node11" [-> "f1" =tailport "f0" =headport ]; "node10" "node11" ->[ "f1" =tailport "f0" =headport ]
"node10" "node12" [-> "f2" =tailport "f0" =headport ]; "node10" "node12" ->[ "f2" =tailport "f0" =headport ]
"node11" "node1" [-> "f2" =tailport "f0" =headport ]; "node11" "node1" ->[ "f2" =tailport "f0" =headport ]
; ;
:: with-global-value ( value variable quot -- ) :: with-global-value ( value variable quot -- )

View File

@ -4,13 +4,13 @@ USING: graphviz graphviz.attributes help.markup help.syntax
kernel present sequences ; kernel present sequences ;
IN: graphviz.notation IN: graphviz.notation
{ add-edge [add-edge -- ~-- [-- } related-words { add-edge \ \add-edge[ \ \-- \ \~-- \ \--[ } related-words
{ add-edge [add-edge -> ~-> [-> } related-words { add-edge \ \add-edge[ \ \-> \ \~-> \ \->[ } related-words
{ {
[add-node [add-edge [-- [-> [node [edge [graph ]; \ \add-node[ \ \add-edge[ \ \--[ \ \->[ \ \node[ \ \edge[ \ \graph[
} related-words } related-words
HELP: -- HELP: \--
{ $values { $values
{ "graph" { $or graph subgraph } } { "graph" { $or graph subgraph } }
{ "tail" object } { "tail" object }
@ -78,13 +78,13 @@ HELP: ->
} }
; ;
HELP: [-- HELP: \--[
{ $values { $values
{ "tail" object } { "tail" object }
{ "head" object } { "head" object }
{ "edge" edge } { "edge" edge }
} }
{ $description "Shorthand for " { $link <edge> } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that undirected " { $link graph } "s read more like graphs in the DOT language." } { $description "Shorthand for " { $link <edge> } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that undirected " { $link graph } "s read more like graphs in the DOT language." }
{ $examples { $examples
"Instead of writing" "Instead of writing"
{ $code { $code
@ -94,7 +94,7 @@ HELP: [--
"it looks better to write" "it looks better to write"
{ $code { $code
"<graph>" "<graph>"
" 1 2 [-- \"red\" =color ];" " 1 2 --[ \"red\" =color ]"
} }
"Compare this with the DOT language, where you'd write" "Compare this with the DOT language, where you'd write"
{ $code { $code
@ -105,13 +105,13 @@ HELP: [--
} }
; ;
HELP: [-> HELP: \->[
{ $values { $values
{ "tail" object } { "tail" object }
{ "head" object } { "head" object }
{ "edge" edge } { "edge" edge }
} }
{ $description "Shorthand for " { $link <edge> } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that directed " { $link graph } "s read more like digraphs in the DOT language." } { $description "Shorthand for " { $link <edge> } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that directed " { $link graph } "s read more like digraphs in the DOT language." }
{ $examples { $examples
"Instead of writing" "Instead of writing"
{ $code { $code
@ -121,7 +121,7 @@ HELP: [->
"it looks better to write" "it looks better to write"
{ $code { $code
"<digraph>" "<digraph>"
" 1 2 [-> \"red\" =color ];" " 1 2 ->[ \"red\" =color ]"
} }
"Compare this with the DOT language, where you'd write" "Compare this with the DOT language, where you'd write"
{ $code { $code
@ -132,23 +132,13 @@ HELP: [->
} }
; ;
HELP: ]; HELP: \add-edge[
{ $values
{ "graph" { $or graph subgraph } }
{ "statement" object }
{ "graph'" { $or graph subgraph } }
}
{ $description "Synonym for " { $link add } " meant to be the \"other half\" of various " { $vocab-link "graphviz.notation" } " words like " { $links [add-edge [add-node [graph } ", etc." }
{ $examples "Refer to the documentation for the complementary words listed below." }
;
HELP: [add-edge
{ $values { $values
{ "tail" object } { "tail" object }
{ "head" object } { "head" object }
{ "edge" edge } { "edge" edge }
} }
{ $description "Shorthand for " { $link <edge> } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that setting an " { $link edge } "'s " { $slot "attributes" } " reads more like the equivalent in the DOT language." } { $description "Shorthand for " { $link <edge> } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that setting an " { $link edge } "'s " { $slot "attributes" } " reads more like the equivalent in the DOT language." }
{ $examples { $examples
"Instead of writing" "Instead of writing"
{ $code { $code
@ -158,7 +148,7 @@ HELP: [add-edge
"it looks better to write" "it looks better to write"
{ $code { $code
"<graph>" "<graph>"
" 1 2 [add-edge \"red\" =color ];" " 1 2 add-edge[ \"red\" =color ]"
} }
"Compare this with the DOT language, where you'd write" "Compare this with the DOT language, where you'd write"
{ $code { $code
@ -167,16 +157,16 @@ HELP: [add-edge
"}" "}"
} }
$nl $nl
"This has the advantage over " { $link [-- } " and " { $link [-> } " of reading nicely for both directed " { $emphasis "and" } " undirected " { $link graph } "s." "This has the advantage over " { $link \ --[ } " and " { $link \ ->[ } " of reading nicely for both directed " { $emphasis "and" } " undirected " { $link graph } "s."
} }
; ;
HELP: [add-node HELP: \add-node[
{ $values { $values
{ "id" object } { "id" object }
{ "node" node } { "node" node }
} }
{ $description "Shorthand for " { $link <node> } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that setting a " { $link node } "'s " { $slot "attributes" } " reads more like the equivalent in the DOT language." } { $description "Shorthand for " { $link <node> } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that setting a " { $link node } "'s " { $slot "attributes" } " reads more like the equivalent in the DOT language." }
{ $examples { $examples
"Instead of writing" "Instead of writing"
{ $code { $code
@ -186,7 +176,7 @@ HELP: [add-node
"it looks better to write" "it looks better to write"
{ $code { $code
"<graph>" "<graph>"
" \"foo\" [add-node \"red\" =color ];" " \"foo\" add-node[ \"red\" =color ]"
} }
"Compare this with the DOT language, where you'd write" "Compare this with the DOT language, where you'd write"
{ $code { $code
@ -197,11 +187,11 @@ HELP: [add-node
} }
; ;
HELP: [edge HELP: \edge[
{ $values { $values
{ "attrs" edge-attributes } { "attrs" edge-attributes }
} }
{ $description "Shorthand for " { $link <edge-attributes> } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link edge-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." } { $description "Shorthand for " { $link <edge-attributes> } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link edge-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." }
{ $examples { $examples
"Instead of writing" "Instead of writing"
{ $code { $code
@ -211,22 +201,22 @@ HELP: [edge
"it looks better to write" "it looks better to write"
{ $code { $code
"<graph>" "<graph>"
" [edge \"red\" =color ];" " edge[ \"red\" =color ]"
} }
"Compare this with the DOT language, where you'd write" "Compare this with the DOT language, where you'd write"
{ $code { $code
"graph {" "graph {"
" [edge color=\"red\" ];" " edge[ color=\"red\" ]"
"}" "}"
} }
} }
; ;
HELP: [graph HELP: \graph[
{ $values { $values
{ "attrs" graph-attributes } { "attrs" graph-attributes }
} }
{ $description "Shorthand for " { $link <graph-attributes> } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link graph-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." } { $description "Shorthand for " { $link <graph-attributes> } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link graph-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." }
{ $notes "This word is rendered redundant by the " { $link graph } " and " { $link subgraph } " methods defined by " { $vocab-link "graphviz.notation" } " for setting attributes. Sometimes it still might look better to delineate certain attribute-setting code." } { $notes "This word is rendered redundant by the " { $link graph } " and " { $link subgraph } " methods defined by " { $vocab-link "graphviz.notation" } " for setting attributes. Sometimes it still might look better to delineate certain attribute-setting code." }
{ $examples { $examples
"Instead of writing" "Instead of writing"
@ -237,12 +227,12 @@ HELP: [graph
"it looks better to write" "it looks better to write"
{ $code { $code
"<graph>" "<graph>"
" [graph \"LR\" =rankdir \"blah\" =label ];" " [graph \"LR\" =rankdir \"blah\" =label ]"
} }
"Compare this with the DOT language, where you'd write" "Compare this with the DOT language, where you'd write"
{ $code { $code
"graph {" "graph {"
" [graph rankdir=\"LR\" label=\"blah\" ];" " [graph rankdir=\"LR\" label=\"blah\" ]"
"}" "}"
} }
$nl $nl
@ -262,11 +252,11 @@ HELP: [graph
} }
; ;
HELP: [node HELP: \node[
{ $values { $values
{ "attrs" node-attributes } { "attrs" node-attributes }
} }
{ $description "Shorthand for " { $link <node-attributes> } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link node-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." } { $description "Shorthand for " { $link <node-attributes> } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link node-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." }
{ $examples { $examples
"Instead of writing" "Instead of writing"
{ $code { $code
@ -276,12 +266,12 @@ HELP: [node
"it looks better to write" "it looks better to write"
{ $code { $code
"<graph>" "<graph>"
" [node \"red\" =color ];" " node[ \"red\" =color ]"
} }
"Compare this with the DOT language, where you'd write" "Compare this with the DOT language, where you'd write"
{ $code { $code
"graph {" "graph {"
" [node color=\"red\" ];" " node[ color=\"red\" ]"
"}" "}"
} }
} }
@ -425,20 +415,16 @@ $nl
} }
"Notation for nodes/edges with local attributes:" "Notation for nodes/edges with local attributes:"
{ $subsections { $subsections
[add-node \ \add-node[
[add-edge \ \add-edge[
[-- \ \--[
[-> \ \->[
} }
"Notation for global attributes:" "Notation for global attributes:"
{ $subsections { $subsections
[node \ \node[
[edge \ \edge[
[graph \ \graph[
}
"Word to \"close off\" notation for attributes:"
{ $subsections
];
} }
; ;

View File

@ -1,10 +1,8 @@
! Copyright (C) 2011 Alex Vondrak. ! Copyright (C) 2011 Alex Vondrak.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors fry generic generic.parser generic.standard USING: accessors fry generic generic.parser generic.standard
kernel present quotations sequences slots words graphviz graphviz.attributes kernel parser present quotations
graphviz sequences slots words ;
graphviz.attributes
;
IN: graphviz.notation IN: graphviz.notation
<< <<
@ -74,16 +72,14 @@ ALIAS: -- add-edge
ALIAS: ~-> add-path ALIAS: ~-> add-path
ALIAS: ~-- add-path ALIAS: ~-- add-path
ALIAS: [graph <graph-attributes> SYNTAX: \graph[ parse-quotation '[ <graph-attributes> @ add ] append! ;
ALIAS: [node <node-attributes> SYNTAX: \node[ parse-quotation '[ <node-attributes> @ add ] append! ;
ALIAS: [edge <edge-attributes> SYNTAX: \edge[ parse-quotation '[ <edge-attributes> @ add ] append! ;
ALIAS: [add-node <node> SYNTAX: \add-node[ parse-quotation '[ <node> @ add ] append! ;
ALIAS: [add-edge <edge> SYNTAX: \add-edge[ parse-quotation '[ <edge> @ add ] append! ;
ALIAS: [-> <edge> SYNTAX: \->[ parse-quotation '[ <edge> @ add ] append! ;
ALIAS: [-- <edge> SYNTAX: \--[ parse-quotation '[ <edge> @ add ] append! ;
ALIAS: ]; add
! Can't really do add-path[ & add-nodes[ this way, since they ! Can't really do add-path[ & add-nodes[ this way, since they
! involve multiple objects. ! involve multiple objects.