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
Implement node rank in graph definition files (ipspace#2711)
The 'graph.rank' node attribute allows you to group nodes into layers
in GraphViz graphs, and to ensure the node positioning is more closely
aligned with the network topology in D2 graphs (D2 does not have a
shape rank concept)
Copy file name to clipboardExpand all lines: docs/outputs/d2.md
+11-4Lines changed: 11 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,12 +26,21 @@ You can use the **d2** link and node attributes to change the style of individua
26
26
***d2.fill** -- fill color (*fill* in D2 lingo)
27
27
***d2.width** -- line width (*stroke-width* in D2 lingo)
28
28
29
-
You can also use the **d2.linkorder** link attribute to change the order of links in the D2 graph description file, which can sometimes improve the diagrams' appearance. Links with lower **d2.linkorder** values (default: 100) appear earlier in the list of links.
30
-
31
29
```{tip}
32
30
The generic link- and node attributes can also be specified as **graph._attribute_** (for example, **graph.color**) values to use the same settings for GraphViz and D2 graphs.
33
31
```
34
32
33
+
(outputs-d2-layout)=
34
+
## Influencing the Graph Layout
35
+
36
+
_netlab_ uses the node **graph.rank** attribute to sort nodes in link definitions to ensure the graph edges are always defined as going from nodes with a lower rank to nodes with a higher rank. The order of nodes in the graph edges influences the D2 layout engine.
37
+
38
+
The default value of the **graph.rank** attribute is 100, allowing you to push some nodes (with rank below 100) toward the top of the graph and others (with rank above 100) toward the bottom.
39
+
40
+
You can also use the **graph.rank** on links to influence how GraphViz draws multi-access links.
41
+
42
+
Finally, the link/interface **graph.linkorder** attribute allows you to specify the node order in individual links. The default **graph.linkorder** value is 50 for interfaces and 100 for subnets (multi-access links), resulting in subnets being "below" nodes unless you change the link- or interface **graph.linkorder** value.
43
+
35
44
(outputs-d2-graph-appearance)=
36
45
## Modifying Graph Appearance
37
46
@@ -116,8 +125,6 @@ vrf:
116
125
_netlab_ releases 25.07 and older specified D2 style attributes in the **defaults.outputs.d2** dictionary. The style attributes recognized by those releases are automatically migrated into the **defaults.outputs.d2.styles** dictionary.
117
126
```
118
127
119
-
## Specifying D2 Attributes
120
-
121
128
You could specify D2 attributes in your [topology file](defaults-topology) (where you would have to prefix them with **defaults**), in [per-user topology defaults](defaults-user-file), or with [environment variables](defaults-env) (even [more details](../defaults.md)). You could also specify them with the `-s` parameter of the **[netlab create](netlab-create)** command, yet again prefixed with **defaults** ([more details](netlab-create-set)).
122
129
123
130
Use the **netlab show defaults outputs.d2**[command](netlab-show-defaults) to show the current D2 defaults, including topology file defaults and user defaults.
Copy file name to clipboardExpand all lines: docs/outputs/graph.md
+15-3Lines changed: 15 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ The *graph* output module is invoked with the **[netlab graph](netlab-graph)** c
9
9
10
10
A single formatting modifier can be used to specify the graph type:
11
11
12
-
***topology** (default) -- Display inter-node links, multi-access- and stub subnets. When the network topology contains BGP information, the graph groups nodes into autonomous systems. Alternatively, you could set **defaults.outputs.graph.groups** attribute to use topology **[groups](topo-groups)** to group graph nodes.
12
+
***topology** (default) -- Display inter-node links, multi-access-, and stub subnets. When the network topology contains BGP information, the graph groups nodes into autonomous systems. Alternatively, you could set **defaults.outputs.graph.groups** attribute to use topology **[groups](topo-groups)** to group graph nodes.
13
13
***bgp** -- Include autonomous systems, nodes, and BGP sessions. The formatting modifier can include [BGP formatting parameters](outputs-graph-bgp-parameters). For example, `netlab create -o graph:bgp:rr` draws RR-client sessions as directed arrows.
14
14
***isis** -- Create a diagram of IS-IS routing, including areas, color-coded circuit types, and edge subnets (does not work with IS-IS running over VLANs)
15
15
@@ -24,10 +24,22 @@ You can use the **graph** link and node attributes to change the style of indivi
24
24
***graph.fill** -- fill color (*fillcolor* GraphViz attribute)
25
25
***graph.width** -- line width (*penwidth* GraphViz attribute)
26
26
27
-
You can also use the **graph.linkorder** link attribute to change the order of links in the D2 graph description file, which can sometimes improve the diagrams' appearance. Links with lower **graph.linkorder** values (default: 100) appear earlier in the list of links.
28
-
29
27
[^XS]: You can extend the GraphViz styling capabilities and add new **graph** attributes. See [](outputs-d2-styles) for details.
30
28
29
+
(outputs-graph-layout)=
30
+
## Influencing the Graph Layout
31
+
32
+
_netlab_ uses the node **graph.rank** attribute to:
33
+
34
+
1. Tell GraphViz that nodes with the same **graph.rank** should be at the same rank (vertical position) in the graph
35
+
2. Sort nodes in link definitions to ensure the graph edges are always defined as going from nodes with a lower rank to nodes with a higher rank. The order of nodes in the graph edges influences the GraphViz layout engine.
36
+
37
+
The default value of the **graph.rank** attribute is 100, allowing you to push some nodes (with rank below 100) toward the top of the graph and others (with rank above 100) toward the bottom.
38
+
39
+
You can also use the **graph.rank** on links to influence how GraphViz draws multi-access links.
40
+
41
+
Finally, the link/interface **graph.linkorder** attribute allows you to specify the node order in individual links. The default **graph.linkorder** value is 50 for interfaces and 100 for subnets (multi-access links), resulting in subnets being "below" nodes unless you change the link- or interface **graph.linkorder** value.
0 commit comments