public override string ToString() { var Indentation = 0; var sb = new StringBuilder(); sb.AppendFormat("digraph {0}\n", ID); sb.AppendLine("{"); var graphAttributes = GraphAttributes.ToString(); var defaultNodeAttributes = DefaultNodeAttributes.ToString(); var defaultEdgeAttributes = DefaultEdgeAttributes.ToString(); if (graphAttributes.Length > 4) { sb.AppendFormat("{0}graph {1}", new String('\t', Indentation + 1), graphAttributes); } if (defaultNodeAttributes.Length > 4) { sb.AppendFormat("{0}node {1}", new String('\t', Indentation + 1), defaultNodeAttributes); } if (defaultEdgeAttributes.Length > 4) { sb.AppendFormat("{0}edge {1}", new String('\t', Indentation + 1), defaultEdgeAttributes); } sb.AppendLine(""); foreach (var node in Nodes) { node.Indentation = 1; sb.Append(node.ToString()); } if (Nodes.Count > 0) { sb.AppendLine(); } foreach (var subgraph in Subgraphs) { subgraph.Indentation = 1; sb.Append(subgraph.ToString()); } if (Subgraphs.Count > 0) { sb.AppendLine(); } foreach (var edge in Edges) { edge.Indentation = 1; sb.Append(edge.ToString()); } sb.AppendLine("}"); return(sb.ToString()); }
public override string ToString() { var sb = new StringBuilder(); sb.AppendFormat("{0}subgraph {1} {{\n", new string('\t', Indentation), ID); var subgraphAttributes = SubgraphAttributes.ToString(); var defaultNodeAttributes = DefaultNodeAttributes.ToString(); var defaultEdgeAttributes = DefaultEdgeAttributes.ToString(); if (subgraphAttributes.Length > 4) { sb.AppendFormat("{0}graph {1}", new String('\t', Indentation + 1), subgraphAttributes); } if (defaultNodeAttributes.Length > 4) { sb.AppendFormat("{0}node {1}", new String('\t', Indentation + 1), defaultNodeAttributes); } if (defaultEdgeAttributes.Length > 4) { sb.AppendFormat("{0}edge {1}", new String('\t', Indentation + 1), defaultEdgeAttributes); } foreach (var node in Nodes) { node.Indentation = Indentation + 1; sb.Append(node.ToString()); } foreach (var edge in Edges) { edge.Indentation = Indentation + 1; sb.Append(edge.ToString()); } foreach (var subgraph in Subgraphs) { subgraph.Indentation = Indentation + 1; sb.Append(subgraph.ToString()); } sb.AppendFormat("{0}}}\n", new string('\t', Indentation)); return(sb.ToString()); }
public override string ToString() { var sb = new StringBuilder(); sb.AppendFormat("{0}{1} {2}", new string('\t', Indentation), string.Join(" -> ", Connections), EdgeAttributes.ToString()); return(sb.ToString()); }