@@ -64,17 +64,17 @@ public class Tutorial
6464 [Test , Order (1 )]
6565 public void GraphConstruction ()
6666 {
67- // You can programmatically construct graphs as follows
67+ // You can programmatically construct graphs as follows.
6868 RootGraph root = RootGraph .CreateNew (GraphType .Directed , " Some Unique Identifier" );
6969 // The graph name is optional, and can be omitted. The name is not interpreted by Graphviz,
7070 // except it is recorded and preserved when the graph is written as a file.
7171
72- // The node names are unique identifiers within a graph in Graphviz
72+ // The node names are unique identifiers within a graph in Graphviz.
7373 Node nodeA = root .GetOrAddNode (" A" );
7474 Node nodeB = root .GetOrAddNode (" B" );
7575 Node nodeC = root .GetOrAddNode (" C" );
7676
77- // The edge name is only unique between two nodes
77+ // The edge name is only unique between two nodes.
7878 Edge edgeAB = root .GetOrAddEdge (nodeA , nodeB , " Some edge name" );
7979 Edge edgeBC = root .GetOrAddEdge (nodeB , nodeC , " Some edge name" );
8080 Edge anotherEdgeBC = root .GetOrAddEdge (nodeB , nodeC , " Another edge name" );
@@ -87,8 +87,8 @@ public class Tutorial
8787
8888 // We can attach attributes to nodes, edges and graphs to store information and instruct
8989 // Graphviz by specifying layout parameters. At the moment we only support string
90- // attributes. Cgraph assumes that all objects of a given kind (graphs/subgraphs, nodes,
91- // or edges) have the same attributes. An attribute has to be introduced with a default value
90+ // attributes. Cgraph assumes that all objects of a given kind (graphs/subgraphs, nodes, or
91+ // edges) have the same attributes. An attribute has to be introduced with a default value
9292 // first for a certain kind, before we can use it.
9393 Node .IntroduceAttribute (root , " my attribute" , " defaultvalue" );
9494 nodeA .SetAttribute (" my attribute" , " othervalue" );
@@ -98,17 +98,18 @@ public class Tutorial
9898 Edge .IntroduceAttribute (root , " my attribute" , " defaultvalue" );
9999 edgeAB .SetAttribute (" my attribute" , " othervalue" );
100100
101- // To introduce and set an attribute at the same time, there are convenience wrappers
101+ // To introduce and set an attribute at the same time, there are convenience wrappers.
102102 edgeBC .SafeSetAttribute (" arrowsize" , " 2.0" , " 1.0" );
103- // If we set an unintroduced attribute, the attribute will be introduced with an empty default value.
103+ // If we set an unintroduced attribute, the attribute will be introduced with an empty
104+ // default value.
104105 edgeBC .SetAttribute (" new attr" , " value" );
105106
106- // Some attributes - like "label" - accept HTML strings as value
107- // To tell Graphviz that a string should be interpreted as HTML use the designated methods
107+ // Some attributes - like "label" - accept HTML strings as value.
108+ // To tell Graphviz that a string should be interpreted as HTML use the designated methods.
108109 Node .IntroduceAttribute (root , " label" , " defaultlabel" );
109110 nodeB .SetAttributeHtml (" label" , " <b>Some HTML string</b>" );
110111
111- // We can simply export this graph to a text file in dot format
112+ // We can simply export this graph to a text file in dot format.
112113 root .ToDotFile (TestContext .CurrentContext .TestDirectory + " /out.dot" );
113114
114115 // A word of advice, Graphviz doesn't play very well with empty strings.
@@ -118,20 +119,21 @@ public class Tutorial
118119 [Test , Order (2 )]
119120 public void Layouting ()
120121 {
121- // If we have a given dot file (in this case the one we generated above), we can also read it back in
122+ // If we have a given dot file (in this case the one we generated above), we can also read
123+ // it back in.
122124 RootGraph root = RootGraph .FromDotFile (TestContext .CurrentContext .TestDirectory + " /out.dot" );
123125
124- // We can ask Graphviz to compute a layout and render it to svg
126+ // We can ask Graphviz to compute a layout and render it to svg.
125127 root .ToSvgFile (TestContext .CurrentContext .TestDirectory + " /dot_out.svg" );
126128
127- // We can use layout engines other than dot by explicitly passing the engine we want
129+ // We can use layout engines other than dot by explicitly passing the engine we want.
128130 root .ToSvgFile (TestContext .CurrentContext .TestDirectory + " /neato_out.svg" , LayoutEngines .Neato );
129131
130- // Or we can ask Graphviz to compute the layout and programatically read out the layout attributes
131- // This will create a copy of our original graph with layout information attached to it in the form
132- // of attributes. Graphviz outputs coordinates in a bottom-left originated coordinate system.
133- // But since many applications require rendering in a top-left originated coordinate system,
134- // we provide a way to translate the coordinates.
132+ // Or we can ask Graphviz to compute the layout and programatically read out the layout
133+ // attributes This will create a copy of our original graph with layout information attached
134+ // to it in the form of attributes. Graphviz outputs coordinates in a bottom-left originated
135+ // coordinate system. But since many applications require rendering in a top-left originated
136+ // coordinate system, we provide a way to translate the coordinates.
135137 RootGraph layout = root .CreateLayout (coordinateSystem : CoordinateSystem .TopLeft );
136138
137139 // There are convenience methods available that parse these attributes for us and give
@@ -143,7 +145,7 @@ public class Tutorial
143145 RectangleD nodeboundingbox = nodeA .GetBoundingBox ();
144146 Utils .AssertPattern (RectPattern , nodeboundingbox .ToString ());
145147
146- // Or splines between nodes
148+ // Or splines between nodes.
147149 Node nodeB = layout .GetNode (" B" )! ;
148150 Edge edge = layout .GetEdge (nodeA , nodeB , " Some edge name" )! ;
149151 PointD [] spline = edge .GetFirstSpline ();
@@ -202,10 +204,10 @@ public class Tutorial
202204
203205 // COMPOUND EDGES
204206 // Graphviz does not really support edges from and to clusters. However, by adding an
205- // invisible dummynode and setting the ltail or lhead attributes of an edge this
206- // behavior can be faked. Graphviz will then draw an edge to the dummy node but clip it
207- // at the border of the cluster. We provide convenience methods for this.
208- // To enable this feature, Graphviz requires us to set the "compound" attribute to "true".
207+ // invisible dummynode and setting the ltail or lhead attributes of an edge this behavior
208+ // can be faked. Graphviz will then draw an edge to the dummy node but clip it at the border
209+ // of the cluster. We provide convenience methods for this. To enable this feature, Graphviz
210+ // requires us to set the "compound" attribute to "true".
209211 Graph .IntroduceAttribute (root , " compound" , " true" ); // Allow lhead/ltail
210212 // The boolean indicates whether the dummy node should take up any space. When you pass
211213 // false and you have a lot of edges, the edges may start to overlap a lot.
@@ -228,12 +230,13 @@ public class Tutorial
228230 RootGraph root = RootGraph .CreateNew (GraphType .Directed , " Graph with records" );
229231 Node nodeA = root .GetOrAddNode (" A" );
230232 nodeA .SetAttribute (" shape" , " record" );
231- // New line characters are not supported by record labels, and will be ignored by Graphviz
233+ // New line characters are not supported by record labels, and will be ignored by Graphviz.
232234 nodeA .SetAttribute (" label" , " 1|2|3|{4|5}|6|{7|8|9}" );
233235
234236 var layout = root .CreateLayout ();
235237
236- // The order of the list matches the order in which the labels occur in the label string above.
238+ // The order of the list matches the order in which the labels occur in the label string
239+ // above.
237240 var rects = layout .GetNode (" A" )! .GetRecordRectangles ().ToList ();
238241 var rectLabels = layout .GetNode (" A" )! .GetRecordRectangleLabels ().Select (l => l .Text ).ToList ();
239242 Assert .AreEqual (9 , rects .Count );
@@ -248,19 +251,21 @@ public class Tutorial
248251 Node nodeA = root .GetOrAddNode (" A" );
249252
250253 // Several characters and character sequences can have special meanings in labels, like \N.
251- // When you want to have a literal string in a label, we provide a convenience function for you to do just that.
254+ // When you want to have a literal string in a label, we provide a convenience function for
255+ // you to do just that.
252256 nodeA .SetAttribute (" label" , CGraphThing .EscapeLabel (" Some string literal \\ N \\ n |}>" ));
253257
254- // When defining portnames, some characters, like ':' and '|', are not allowed and they can't be escaped either.
255- // This can be troubling if you have an externally defined ID for such a port.
256- // We provide a function that maps strings to valid portnames.
258+ // When defining portnames, some characters, like ':' and '|', are not allowed and they
259+ // can't be escaped either. This can be troubling if you have an externally defined ID for
260+ // such a port. We provide a function that maps strings to valid portnames.
257261 var somePortId = " port id with :| special characters" ;
258262 var validPortName = Edge .ConvertUidToPortName (somePortId );
259263 Node nodeB = root .GetOrAddNode (" B" );
260264 nodeB .SetAttribute (" shape" , " record" );
261265 nodeB .SetAttribute (" label" , $" <{validPortName }>1|2" );
262266
263- // The conversion function makes sure different strings don't accidentally map onto the same portname
267+ // The conversion function makes sure different strings don't accidentally map onto the same
268+ // portname.
264269 Assert .AreNotEqual (Edge .ConvertUidToPortName (" :" ), Edge .ConvertUidToPortName (" |" ));
265270 }
266271}
0 commit comments