Overview
SHA1 Hash: | 86f3319041f2b26b6121b35001cb4bb7bdf3e1e2 |
---|---|
Date: | 2007-11-23 05:41:21 |
User: | aku |
Comment: | Extended the dot graph exporter to allow the export of a subgraph specified through a set of nodes. Default is the export of the whole graph, as before. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified tools/cvs2fossil/lib/dot.tcl from [405d093d08] to [5248549660].
@@ -25,43 +25,36 @@ snit::type ::vc::tools::dot { # # ## ### ##### ######## ############# ## Public API, Methods - typemethod format {g name} { + typemethod format {g name {subgraph {}}} { lappend lines "digraph \"$name\" \{" - foreach n [$g nodes] { - set cmd "\"$n\"" - set sep " " - set head " \[" - set tail "" - foreach {gattr nodekey} { - label label - shape shape - } { - if {![$g node keyexists $n $nodekey]} continue - append cmd "$head$sep${gattr}=\"[$g node get $n $nodekey]\"" - - set sep ", " - set head "" - set tail " \]" - } - - append cmd ${tail} ";" - lappend lines $cmd + if {![llength $subgraph]} { + set nodes [$g nodes] + set arcs [$g arcs] + } else { + set nodes $subgraph + set arcs [eval [linsert $subgraph 0 $g arcs -inner]] + } + + foreach n $nodes { + set style [Style $g node $n {label label shape shape}] + lappend lines "\"$n\" ${style};" } - foreach a [$g arcs] { - lappend lines "\"[$g arc source $a]\" -> \"[$g arc target $a]\";" + foreach a $arcs { + set style [Style $g arc $a {color color}] + lappend lines "\"[$g arc source $a]\" -> \"[$g arc target $a]\" ${style};" } lappend lines "\}" return [join $lines \n] } - typemethod write {g name file} { - fileutil::writeFile $file [$type format $g $name] + typemethod write {g name file {subgraph {}}} { + fileutil::writeFile $file [$type format $g $name $subgraph] return } typemethod layout {format g name file} { set f [fileutil::tempfile c2fdot_] @@ -71,10 +64,27 @@ return } # # ## ### ##### ######## ############# ## Internal, state + + proc Style {graph x y dict} { + set sep " " + set head " \[" + set tail "" + set style "" + foreach {gattr key} $dict { + if {![$graph $x keyexists $y $key]} continue + append style "$head$sep${gattr}=\"[$graph $x get $y $key]\"" + set sep ", " + set head "" + set tail " \]" + } + + append style ${tail} + return $style + } # # ## ### ##### ######## ############# ## Internal, helper methods (formatting, dispatch) # # ## ### ##### ######## #############