GraphvizDocument Class
A graph read from the DOT language of Graphviz, drawn as a FlowchartDiagram: the nodes, the edges and the clusters, with their shapes, styles, colors and labels. The layout is the layered layout of the flowcharts, close to the dot engine of Graphviz.
public sealed class GraphvizDocumentExample
var text = """
digraph Orders {
rankdir=LR;
node [shape=box, style=rounded];
start [label="Order received", shape=ellipse];
check [label="Payment valid?", shape=diamond];
subgraph cluster_fulfillment {
label="Fulfillment";
ship [label="Ship the order"];
notify [label="Notify the customer"];
}
cancel [label="Cancel the order", color=red];
start -> check;
check -> ship [label="yes"];
ship -> notify;
check -> cancel [label="no", style=dashed];
}
""";
var document = GraphvizDocument.Parse(text);
var flowchart = document.Diagram;
var svg = flowchart.ToSvg();Properties
| Name | Description |
|---|---|
| Diagram | Gets the flowchart of the graph. The clusters (the subgraphs whose name starts with cluster) are its subgraphs. |
| IsDirected | Gets a value that indicates whether the graph is directed (digraph). The edges of an undirected graph have no arrowheads. |
| IsStrict | Gets a value that indicates whether the graph is strict: the edges between the same nodes are merged. |
| Name | Gets the name of the graph (digraph name { }), or null when it has none. |
| Warnings | Gets the parts of the text that are valid DOT but are not supported, and are ignored or approximated. |
Diagram
GraphvizDocument.csGets the flowchart of the graph. The clusters (the subgraphs whose name starts with cluster) are its subgraphs.
public FlowchartDiagram Diagram { get; }Property value
IsDirected
GraphvizDocument.csIsStrict
GraphvizDocument.csWarnings
GraphvizDocument.csGets the parts of the text that are valid DOT but are not supported, and are ignored or approximated.
public IReadOnlyList<GraphvizWarning> Warnings { get; }Property value
Methods
| Name | Description |
|---|---|
| Parse(string, GraphvizParseOptions?) | Reads a DOT text. Only its first graph is read. |
| TryParse(string?, GraphvizDocument?) | Tries to read a DOT text. |
| TryParse(string?, GraphvizParseOptions?, GraphvizDocument?, GraphvizParseError) | Tries to read a DOT text. |
Parse(string, GraphvizParseOptions?)
GraphvizDocument.csReads a DOT text. Only its first graph is read.
public static GraphvizDocument Parse(string text, GraphvizParseOptions? options = null)Parameters
textstring- The text.
optionsGraphvizParseOptions?- The options, or
nullforGraphvizParseOptions.Default.
Returns
GraphvizDocument The document.
Exceptions
GraphvizParseException- The text is not valid, or it exceeds a limit of the options.
TryParse overloads
TryParse(string?, GraphvizDocument?)
GraphvizDocument.csTries to read a DOT text.
public static bool TryParse(string? text, out GraphvizDocument? document)Parameters
textstring?- The text.
documentGraphvizDocument?- The document, when the method returns
true.
Returns
bool true when the text is valid.
TryParse(string?, GraphvizParseOptions?, GraphvizDocument?, GraphvizParseError)
GraphvizDocument.csTries to read a DOT text.
public static bool TryParse(string? text, GraphvizParseOptions? options, out GraphvizDocument? document, out GraphvizParseError error)Parameters
textstring?- The text.
optionsGraphvizParseOptions?- The options, or
nullforGraphvizParseOptions.Default. documentGraphvizDocument?- The document, when the method returns
true. errorGraphvizParseError- The error, when the method returns
false.
Returns
bool true when the text is valid.