Create GraphViz DOT graph with dotnet (compatible with .NET Standard 2.0 and higher).
vargraph=newDotGraph().WithIdentifier("MyGraph");vardirectedGraph=newDotGraph().WithIdentifier("MyDirectedGraph").Directed();varmyNode=newDotNode().WithIdentifier("MyNode").WithShape(DotNodeShape.Ellipse).WithLabel("My node!").WithFillColor(DotColor.Coral).WithFontColor(DotColor.Black).WithStyle(DotNodeStyle.Dotted).WithWidth(0.5).WithHeight(0.5).WithPenWidth(1.5);// Add the node to the graphgraph.Add(myNode);// Create an edge with identifiersvarmyEdge=newDotEdge().From("Node1").To("Node2");// Or with nodes and attributesvarmyEdge=newDotEdge().From(node1).To(node2).WithArrowHead(DotEdgeArrowType.Box).WithArrowTail(DotEdgeArrowType.Diamond).WithColor(DotColor.Red).WithFontColor(DotColor.Black).WithLabel("My edge!").WithStyle(DotEdgeStyle.Dashed).WithPenWidth(1.5);// Add the edge to the graphgraph.Add(myEdge);// Subgraph identifier need to start with "cluster" to be identified as a clustervarmySubgraph=newDotSubgraph().WithIdentifier("cluster_0");// Create a subgraph with attributes (only used for cluster)varmySubgraph2=newDotSubgraph().WithIdentifier("cluster_1").WithColor(DotColor.Red).WithStyle(DotSubGraphStyle.Dashed).WithLabel("My subgraph!");// Add node, edge, subgraphsubGraph.Add(myNode);subGraph.Add(myEdge);subGraph.Add(mySubgraph2);// Add subgraph to main graphgraph.Add(mySubgraph);awaitusingvarwriter=newStringWriter();varcontext=newCompilationContext(writer,newCompilationOptions());awaitgraph.CompileAsync(context);varresult=writer.GetStringBuilder().ToString();// Save it to a fileFile.WriteAllText("graph.dot",result);