diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2012-06-06 16:01:13 +0100 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2012-06-06 16:01:13 +0100 |
commit | 59e17d09da40d60fa1ec94d27702a8649965a5b2 (patch) | |
tree | 6eed6624c5dbff94d15ea040365246ba3fb0b0e1 /Source/Graph/Graph.cs | |
parent | 8d4d34942bd9eb87989fbcace836851d1e4880d2 (diff) |
Boogie: add /printCFG command line option, which prints each implementation's CFG in Graphviz format
Diffstat (limited to 'Source/Graph/Graph.cs')
-rw-r--r-- | Source/Graph/Graph.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/Graph/Graph.cs b/Source/Graph/Graph.cs index e5e8444c..b5590865 100644 --- a/Source/Graph/Graph.cs +++ b/Source/Graph/Graph.cs @@ -843,6 +843,19 @@ namespace Graphing { }
return dag.TopologicalSort();
}
+
+ public string ToDot(Func<Node, string> NodeLabel = null, Func<Node, string> NodeStyle = null) {
+ NodeLabel = NodeLabel ?? (n => n.ToString());
+ NodeStyle = NodeStyle ?? (n => "[shape=box]");
+ var s = new StringBuilder();
+ s.AppendLine("digraph G {");
+ foreach (var n in Nodes)
+ s.AppendLine(" \"" + NodeLabel(n) + "\" " + NodeStyle(n) + ";");
+ foreach (var e in Edges)
+ s.AppendLine(" \"" + NodeLabel(e.Item1) + "\" -> \"" + NodeLabel(e.Item2) + "\";");
+ s.AppendLine("}");
+ return s.ToString();
+ }
} // end: class Graph
public class GraphProgram {
|