From 59e17d09da40d60fa1ec94d27702a8649965a5b2 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 6 Jun 2012 16:01:13 +0100 Subject: Boogie: add /printCFG command line option, which prints each implementation's CFG in Graphviz format --- Source/Graph/Graph.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Source/Graph') 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 NodeLabel = null, Func 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 { -- cgit v1.2.3