You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also use `Node.CreateNew(...)` to automatically generate a GUID node ID, but being explicit about identifiers may make your diagrams more readable.
69
+
You can also use the generic `Node.Create<TNodeText>` overload to specify the type of node text to be used.
70
+
By default, using the non-generic overload uses Unicode (`MermaidUnicodeText`) but another option is Markdown (`MarkdownText`).
71
+
72
+
### Scope of adding links
73
+
74
+
You may only add links on a flowchart or a subgraph (more about them later) when both link nodes exist within the scope of the flowchart or the subgraph.
75
+
If one of the nodes cannot be found inside the flowchart or subgraph or its nested descendants, then adding the link will fail.
76
+
77
+
#### Some examples
78
+
79
+
Adding a link with a newly defined node is technically allowed in Mermaid itself, but using `Mermaid.Net.Flowcharts` you must first add both nodes explicitly.
80
+
81
+
```cs
82
+
Flowchartflowchart=new();
83
+
Nodea=Node.Create("a", "A");
84
+
Nodeb=Node.Create("b", "B");
85
+
Linkab=Link.Create(a, b);
86
+
87
+
flowchart
88
+
.AddNode(a) // Add both a and b!
89
+
.AddNode(b)
90
+
.AddLink(ab);
91
+
```
92
+
93
+
The correct output looks like this:
94
+
95
+
```diff
96
+
flowchart TD
97
+
a["A"]
98
+
+ b["B"]
99
+
a ---> b
100
+
```
101
+
102
+
When defining links that connects a node to nested node, the link must be defined outside to ensure correctness.
103
+
When a node from outside a subgraph is linked inside a subgraph, the node is incorrectly duplicated and treated as a node inside the subgraph.
0 commit comments