Edit and Customize Dependency Graphs
You can edit dependency graphs without affecting the underlying code. This is useful when you want to focus on key items or communicate ideas about the code. For example, to highlight interesting areas, you can select nodes and filter them, change the style of nodes and links, hide or delete nodes, and organize nodes using properties, categories, or groups.
You can customize a graph even further by editing the graph's Directed Graph Markup Language (.dgml) file. For example, you can edit elements to specify custom styles, assign properties and categories to nodes and links, or link nodes to items, such as documents, URLs, or other graphs.
Note
Visual Studio cleans up any unused DGML elements and attributes by deleting them when you save the .dgml file. It also creates node elements automatically when you manually add new links. When you save the .dgml file, any attributes that you added to an element might rearrange themselves in alphabetical order. For more information about DGML elements, see Understanding Directed Graph Markup Language (DGML).
Requirements
Visual Studio Ultimate, Visual Studio Premium, or Visual Studio Professional
To create dependency graphs, you must have Visual Studio Ultimate. See Visualize Code Dependencies on Dependency Graphs.
In this topic
Select nodes or links
Rename nodes or links
Hide or show nodes and links
Add nodes and links
Add comments to the graph
Delete nodes
Group nodes
Merge graphs
Change the style of the graph
Change the node or link style
Copy styles from one graph to another graph
Assign properties to nodes and links
Assign categories to nodes and links
Link items to nodes or links
Create aliases for commonly-used paths
Select nodes or links
To |
Perform these steps |
---|---|
Select all unselected nodes |
Open the shortcut menu for the selected nodes. Choose Select, Invert Selection. |
Select additional nodes that link to the selected ones |
Open the shortcut menu for the selected nodes. Choose Select and one of the following:
|
Rename nodes or links
Select the node or the link. Press F2. When the edit box appears, rename the node or the link.
If the label is visible, select the label.
Hide or show nodes and links
Hiding nodes keeps them from participating in layout algorithms. By default, cross-group links are hidden. Cross-group links are individual links that connect nodes across groups. When groups are collapsed, the graph aggregates all cross-group links into single links between groups. When you expand a group and select nodes inside the group, cross-group links appear and show the dependencies in that group.
Warning
Before you share a graph that was created in Visual Studio Ultimate with those who use Visual Studio Premium or Visual Studio Professional, make sure to unhide any nodes or cross-group links that you want others to see. Otherwise, those users won't be able to unhide those items.
To hide or show nodes
To |
Perform these steps |
---|---|
Hide selected nodes |
|
Hide unselected nodes |
|
Show hidden nodes |
|
Hide nodes by editing the .dgml file |
|
To show or hide links
To |
On the graph toolbar, open the Change how links are rendered on the graph list or open the graph shortcut menu. Choose: |
---|---|
Show cross-group links at all times |
Show All Cross-Group Links This hides aggregated links between groups. |
Show only cross-group links for selected nodes |
Show Cross-Group Links On Selected Nodes |
Hide cross-group links at all times |
Hide Cross-Group Links |
Hide all links (or show all links) |
Hide All Links To show all links, choose Hide All Links again to turn off this mode. |
Add nodes and links
To add a new undefined node |
Perform these steps |
---|---|
At the current pointer location |
Select a place on the graph where to put the new node. Press Insert. |
That links to the selected node |
|
That links to an existing node with current focus |
Press Tab until the node to which you want to link has focus. Press Alt+Shift+Insert. |
To add nodes for |
Perform these steps |
---|---|
Items in the solution |
|
Items related to nodes on the graph |
Open the shortcut menu for the node. Choose Show and the kind of relationship that interests you. For an assembly, choose:
For a class, choose:
For a method, choose:
For a field, choose:
|
Compiled .NET assemblies (.dll or .exe) or binaries |
Use Architecture Explorer to find and drag items and relationships to the graph. |
To add a link between existing nodes
Select the source node.
A toolbar starts to appear above the node.
On the toolbar, choose Create new link from this node to which ever node that you click on next. Select the target node.
A link appears between the two nodes.
Add comments to the graph
Select the node where you want to add a linked comment.
A toolbar starts to appear above the node.
On the toolbar, choose Create a new comment node with a new link to the selected node.
Type your comments. To type on a new line, press SHIFT+Enter.
Delete nodes
You can delete nodes from a graph without affecting the underlying code. To delete a node, select the node, and then press the Delete key. When you delete nodes, their definitions are removed from the DGML (.dgml) file.
When you delete nodes from a group, the Refetch Children button appears inside the group. To retrieve missing nodes, choose Refetch Children. Graphs that are created by editing the DGML, adding undefined nodes, or by using earlier versions of Visual Studio Ultimate, do not support this capability.
Warning
Before you share a graph that was created using Visual Studio Ultimate with those who use Visual Studio Premium or Visual Studio Professional, make sure any nodes you want others to see are visible on the graph. Otherwise, those users won't be able to retrieve deleted nodes.
Group nodes
To |
Perform these steps |
---|---|
Show container nodes as group nodes or leaf nodes |
To show container nodes as leaf nodes, select the nodes. Open the shortcut menu for your selection. Choose Group, Convert To Leaf. To show container nodes as group nodes, select the nodes. Open the shortcut menu for your selection. Choose Group, Convert To Group. To show all leaf nodes as group nodes, open the shortcut menu for the graph. Choose Group, Turn On Grouping. To show all group nodes as leaf nodes, open the shortcut menu for the graph. Choose Group, Turn Off Grouping. |
Add a node to a group |
Drag the node onto the group. You can also drag nodes out of a group. |
Add a node to a non-group node |
You can convert any node into a group. Drag the node onto the target node. |
Group selected nodes |
|
Group nodes that have specific categories or properties |
|
Group nodes according to their property values |
|
Remove groups |
Select the group or groups that you want to remove. Open the shortcut menu for your selection. Choose Group, Remove Group. |
Remove nodes from their parent group up to their grandparent, or outside a group, if they have no grandparent group |
Select the nodes that you want to move. Open the shortcut menu for your selection. Choose Group, Remove From Parent. |
To group nodes by editing the graph's .dgml file
To convert a node to a group, open the shortcut menu for the node. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file and highlights the <Node/> element for that node.
-or-
To add a new group:
Open the shortcut menu for a blank area of the graph. Choose Goto, DGML.
In the <Nodes> section, add a new <Node/> element.
In the <Node/> element, add a Group attribute to specify whether the group appears expanded or collapsed. For example:
<Nodes> <Node Id="MyFirstGroup" Group="Expanded" /> <Node Id="MySecondGroup" Group="Collapsed" /> </Nodes>
In the <Links> section, make sure that a <Link/> element that has the following attributes exist for each relationship between a group node and its child nodes:
A Source attribute that specifies the group node
A Target attribute that specifies the child node
A Category attribute that specifies a Contains relationship between the group node and its child node
For example:
<Links> <Link Category="Contains" Source="MyFirstNewGroup" Target="FirstGroupChildOne" /> <Link Category ="Contains" Source="MyFirstNewGroup" Target="FirstGroupChildTwo" /> <Link Category ="Contains" Source="MySecondNewGroup" Target="SecondGroupChildOne" /> <Link Category="Contains" Source="MySecondNewGroup" Target="SecondGroupChildTwo" /> </Links>
For more information about the Category attribute, see Assign Categories to Nodes and Links.
Merge graphs
You can merge graphs by copying and pasting nodes between graphs. If the node identifiers match, then pasting nodes functions like a merge operation. To make this task easier, put all the assemblies or binaries that you want to visualize in the same folder so that the full path of each assembly or binary is the same for each graph that you want to merge.
Alternatively, you can create a single graph for the assemblies or binaries that you want to visualize by following one of these steps:
Drag the assemblies or binaries to the same graph.
-or-
Open Architecture Explorer. Under File System, choose Select Files to browse, select, and open the assemblies or binaries. To refine the graph, select specific items that you want to visualize. When you are finished, choose Create a new graph document from all the selected nodes on the Architecture Explorer toolbar.
Change the style of the graph
You can change the background color and border color of the graph by editing the graph's .dgml file. To change the style of nodes and links, see Change the Style of Nodes and Links.
Open the shortcut menu from the graph surface. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file.
In the <DirectedGraph> element, add any of the following attributes to change its style:
To change the
Add the following attribute
Background color
Background="ColorNameOrHexadecimalValue"
Border color
Stroke="StrokeValue"
For example:
<DirectedGraph Background="Green" xmlns="https://schemas.microsoft.com/vs/2009/dgml" > ... ... </DirectedGraph>
Change the style of nodes and links
You can change the icons on nodes and the colors of nodes and links. You can use predefined colors and icons, or you can specify custom ones by editing the graph's .dgml file. See Apply Custom Styles to Nodes and Links.
For example, you can choose a color to highlight nodes and links that have a certain category or property. This lets you identify and focus on specific areas of the graph.
To apply a predefined color or icon to nodes with a certain category or property
If the Legend box is not visible, open the shortcut menu for the graph. Choose Show Legend.
In the Legend box, see if the node category or property appears in the list.
If the list does not include the category or property, choose + in the Legend box, Node Category or Node Property, and the category or property.
The category or property now appears in the Legend box.
Note
To create and assign a category to a node, see Assign Categories to Nodes and Links. To create and assign a property to a node, see Assign Properties to Nodes and Links.
In the Legend box, open the drop-down list next to the category or property.
Use the following table to select the style that you want to change:
To change the
Choose
Background color
Background
Outline color
Stroke
Text color
Foreground
Icon
Icons
The Color Set Picker box appears for you to select a color (or icon).
In the Color Set Picker dialog box, perform one of the following:
To apply a
Perform these steps
Set of colors (or icons
Open the Select color (or icon) set list. Select a set of colors (or icons).
To revert to the default color (or icon), in the Select color (icon) set list, choose None.
Specific color (or icon)
Open the category or property value list. Select a color (or icon).
Note
You can rearrange, delete, or temporarily inactivate styles in the Legend box. See Modify the Legend Box.
To apply a predefined color to links with a certain category or property
If the Legend box is not visible, open the shortcut menu for the graph. Choose Show Legend.
In the Legend box, see if the category or property appears in the list.
If the list does not include the category or property, choose + in the Legend box, Link Category or Link Property, and the category or property.
The category or property now appears in the Legend box.
Note
To create and assign a category to a link, see Assign Categories to Nodes and Links. To create and assign a property to a link, see Assign Properties to Nodes and Links.
In the Legend box, open the list next to the category or property.
Select Stroke to change the link's outline and arrowhead color.
The Color Set Picker box appears for you to select a color.
In the Color Set Picker box, perform one of the following:
To apply a
Perform these steps
Set of colors
Open the Select colorset list. Select a set of colors.
To revert to the default color, in the Select color set list, choose None.
Specific color
Open the type or property value list to select a color.
Note
You can rearrange, delete, or temporarily inactivate styles in the Legend box. See Modify the Legend Box.
Apply Custom Styles to Nodes and Links
You can apply custom styles to the following items:
Single nodes and links
Groups of nodes and links
Groups of nodes and links based on certain conditions
To apply a custom style to a single node
Open the shortcut menu for the node whose style you want to customize. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file and highlights the <Node/> element for that node.
In the <Node/> element, add any of the following attributes to customize its style:
To change the
Add the following attribute
Background color
Background="ColorNameOrHexadecimalValue"
Outline
Stroke="ColorNameOrHexadecimalValue"
Outline thickness
StrokeThickness="StrokeValue"
Text color
Foreground="ColorNameOrHexadecimalValue"
Icon
Icon="IconFilePathLocation"
Text size
FontSize="FontSizeValue"
Text type
FontFamily="FontFamilyName"
Text weight
FontWeight="FontWeightValue"
Text style
FontStyle="FontStyleName"
For example, you can specify Italic as the text style.
Texture
Style="Glass"
- or -
Style="Plain"
Shape
To replace the shape with an icon, set the Shape property to None and set the Icon property to the path with the icon file.
Shape="ShapeFilePathLocation"
For example:
<Nodes> <Node Id="MyNode" Background="#FF008000" Stroke="#FF000000" Foreground="#FFFFFFFF" Icon="...\Icons\Globe.png"/> </Nodes>
To apply a custom style to a single link
On the graph, move the mouse pointer on top of the link. A tooltip appears and identifies the source node and the target node of the link. (Keyboard: Press Tab until focus is on the link.)
Open the shortcut menu for the graph. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file.
Find the <Link/> element that contains both the names of the source node and target node.
In the <Link/> element, add any of the following attributes to customize its style:
To change the
Add the following attribute
Outline and arrowhead color
Stroke="ColorNameOrHexadecimalValue"
Outline thickness
StrokeThickness="StrokeValue"
Outline style
StrokeDashArray="StrokeArrayValues"
For example:
<Links> <Link Source="MyFirstNode" Target="MySecondNode" Background="Green" Stroke="#FF000000" StrokeDashArray="2,2"/> </Links>
To apply custom styles to a group of nodes or links
Assign any categories or properties that you want to the nodes or links.
Tip
If you have repeating styles across many nodes or links, you might consider applying a category to those nodes or links, and then applying a style to that category. For more information, see Assign Categories to Nodes and Links and Assign Properties to Nodes and Links.
Open the shortcut menu for the graph surface. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file.
If a <Styles></Styles> element does not exist, add one under the <DirectedGraph></DirectedGraph> element after the <Links></Links> element.
In the <Styles></Styles> element, under the <Style/> element and specify the following attributes:
TargetType="Node | Link | Graph"
GroupLabel="NameInLegendBox"
ValueLabel="NameInStylePickerBox"
To apply a custom style to all target types, do not use a condition.
To apply a conditional style to groups of nodes or links
In the <Style/> element, add a <Condition/> element that contains an Expression attribute to specify an expression that returns a Boolean value.
For example:
<Condition Expression="MyCategory"/>
- or -
<Condition Expression="MyCategory > 100"/>
- or -
<Condition Expression="HasCategory('MyCategory')"/>
This expression uses the following Backus-Naur Form (BNF) syntax:
<Expression> ::= <BinaryExpression> | <UnaryExpression> | "("<Expression>")" | <MemberBindings> | <Literal> | <Number>
<BinaryExpression> ::= <Expression> <Operator> <Expression>
<UnaryExpression> ::= "!" <Expression> | "+" <Expression> | "-" <Expression>
<Operator> ::= "<" | "<=" | "=" | ">=" | ">" | "!=" | "or" | "and" | "+" | "*" | "/" | "-"
<MemberBindings> ::= <MemberBindings> | <MemberBinding> "." <MemberBinding>
<MemberBinding> ::= <MethodCall> | <PropertyGet>
<MethodCall> ::= <Identifier> "(" <MethodArgs> ")"
<PropertyGet> ::= Identifier
<MethodArgs> ::= <Expression> | <Expression> "," <MethodArgs> | <empty>
<Identifier> ::= [^. ]*
<Literal> ::= single or double-quoted string literal
<Number> ::= string of digits with optional decimal point
You can specify multiple <Condition/> elements, which must all be true to apply the style.
On the next line after the <Condition/> element, add one or multiple <Setter/> elements to specify a Property attribute and a fixed Value attribute or a computed Expression attribute to apply to the graph, nodes, or links that meet the condition.
For example:
<Setter Property="BackGround" Value="Green"/>
As a simple complete example, the following condition specifies that a node appears green or red based on whether its Passed category is set to True or False:
<?xml version="1.0" encoding="utf-8"?>
<DirectedGraph xmlns="https://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="MyFirstNode" Passed="True" />
<Node Id="MySecondNode" Passed="False" />
</Nodes>
<Links>
</Links>
<Styles>
<Style TargetType="Node" GroupLabel="Passed" ValueLabel="True">
<Condition Expression="Passed='True'"/>
<Setter Property="Background" Value="Green"/>
</Style>
<Style TargetType="Node" GroupLabel="Passed" ValueLabel="False">
<Condition Expression="Passed='False'"/>
<Setter Property="Background" Value="Red"/>
</Style>
</Styles>
</DirectedGraph>
The following table includes some example conditions that you can use:
Modify the Legend box
You can rearrange, delete, or temporarily inactivate styles in the Legend box:
Open the shortcut menu for a style in the Legend box.
Perform one of the following tasks:
To
Choose
Move the style up
Move Up
Move the item down
Move Down
Delete the item
Delete
Inactivate the item
Disable
Reactivate the item
Enable
Copy styles from one graph to another graph
Make sure the Legend box appears on the source graph. If it is not visible, open the shortcut menu for a blank area of the source graph. Choose Show Legend.
Open the shortcut menu for the Legend box. Choose Copy Legend.
Paste the legend onto the target graph.
Assign properties to nodes and links
You can organize nodes and links by assigning properties to them. For example, you can select nodes that have specific properties so that you can group them, change their style, or hide them.
To assign a property to a node
Open the shortcut menu for the node. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file and highlights the <Node/> element for that node.
In the <Node/> element, specify the name of the property and its value. For example:
<Nodes> <Node Id="MyNode" MyPropertyName="PropertyValue" /> </Nodes>
Add a <Property/> element to the <Properties> section to specify attributes such as its visible name and data type:
<Properties> <Property Id="MyPropertyName" Label="My Property" DataType="System.DataType"/> </Properties>
To assign a property to a link
On the graph, move the mouse pointer on top of the link. A tooltip appears and identifies the source node and the target node of the link. (Keyboard: Press Tab until focus is on the link.)
Open the shortcut menu for the graph. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file.
Find the <Link/> element that contains both the names of the source node and target node.
In the <Node/> element, specify the name of the property and its value. For example:
<Links> <Link Source="MyFirstNode" Target="MySecondNode" MyPropertyName="PropertyValue" /> </Links>
Add a <Property/> element to the <Properties> section to specify attributes such as its visible name and data type:
<Properties> <Property Id="MyPropertyName" Label="My Property Name" DataType="System.DataType"/> </Properties>
Assign categories to nodes and links
You can organize nodes by assigning categories to them. For example, you can select nodes that are in certain categories so that you can group them, change their style, or hide them. You can highlight links that have certain categories. For more information, see the following sections:
Group nodes
Change the style of nodes and links
Hide or show nodes
To assign a category to a node
- To assign a predefined category, such as Category 1, open the shortcut menu for the node. Choose Categorize and a predefined category.
- or -
To create and assign a custom category:
- Choose the node that you want to categorize. Press F4 to open the Properties window. Type the category name in the node's New Category property. Press ENTER.
- or -
Open the shortcut menu for the node. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file and highlights the <Node/> element for that node.
In the <Node/> element, add a Category attribute to specify the name of the category. For example:
<Nodes> <Node Id="MyNode" Category="MyCategory" /> </Nodes>
Add a <Category/> element to the <Categories> section so that you can use the Label attribute to specify the display text for that category:
<Categories> <Category Id="MyCategory" Label="My Category" /> </Categories>
To assign a category to a link
On the graph, move the mouse pointer over the link to show the tooltip and to identify the source node and the target node of the link. (Keyboard: Press Tab until focus is on the link.)
Open the shortcut menu for the graph. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file.
Find the <Link/> element that contains both the names of the source node and target node.
In the <Link/> element, add a Category attribute to specify the name of the category. For example:
<Links> <Link Source="MyFirstNode" Target="MySecondNode" Category="MyCategory" </Links>
Add a <Category/> element to the <Categories> section so that you can use the Label attribute to specify the display text for that category:
<Categories> <Category Id="MyCategory" Label="My Category" /> </Categories>
You can create hierarchical categories to help you organize nodes and add attributes to child categories by using inheritance.
To create hierarchical categories
Add a <Category/> element for the parent category, and then add the BasedOn attribute to the child category's <Category/> element.
For example:
<Nodes> <Node Id="MyFirstNode" Label="My First Node" Category= "MyCategory" /> <Node Id="MySecondNode" Label="My Second Node" /> </Nodes> <Links> <Link Source="MyFirstNode" Target="MySecondNode" /> </Links> <Categories> <Category Id="MyCategory" Label="My Category" BasedOn="MyParentCategory"/> <Category Id="MyParentCategory" Label="My Parent Category" Background="Green"/> </Categories>
In this example, the background of MyFirstNode is green because its Category attribute inherits the Background attribute of MyParentCategory.
Link items to nodes or links
You can link items, such as documents or URLs, to a node or to a link by editing the graph's .dgml file and adding a Reference attribute to the <Node/> element for a node or the <Link/> element for a link. You can then open and view that content from the node or link. The Reference attribute specifies the path of that content. This can be a path relative to the location of the .dgml file or an absolute path.
Warning
If you use relative paths, and the .dgml file is moved to a different location, then those paths will no longer resolve. When you try to open and view the linked content, an error stating that the content cannot be viewed will occur.
For example, you might want to link the following items:
To describe the changes to a class, you might link the URL of a work item, document, or another .dgml file to the node for a class.
You might link a layer diagram to a group node that represents a layer in the software's logical architecture.
To show more information about a component that exposes an interface, you might link a component diagram to the node for that interface.
Link a node to a Team Foundation Server work item or bug, or some other information that is related to the node.
To link an item to a node
On the graph, open the shortcut menu for the node. Choose Goto, DGML.
Visual Studio opens the graph's .dgml file and highlights the <Node/> element for that node.
Perform one of the tasks in the following table:
To link
Perform these steps
A single item
In the <Node/> or <Link/> element, add a Reference attribute to specify the location of the item.
Note
You can have only one Reference attribute per element.
For example:
<Nodes> <Node Id="MyNode" Reference="MyDocument.txt" /> </Nodes> <Properties> <Property Id="Reference" Label="My Document" DataType="System.String" IsReference="True" /> </Properties>
Multiple items
In the <Node/> or <Link/> element, add a new attribute to specify the location of each reference.
In the <Properties> section:
Add a <Property/> element for each new type of reference.
Set the Id attribute to the name of the new reference attribute.
Add the IsReference attribute and set it to True to make the reference appear on the item's Goto shortcut menu.
Use the Label attribute to specify the display text on the item's Goto shortcut menu.
For example:
<Nodes> <Node Id="MyNode" SequenceDiagram="MySequenceDiagram.sequencediagram" ActiveBugs="MyActiveBugs.wiq"/> </Nodes> <Properties> <Property Id="SequenceDiagram" Label="My Sequence Diagram" DataType="System.String" IsReference="True" /> <Property Id="ActiveBugs" Label="Active Bugs" DataType="System.String" IsReference="True" /> </Properties>
On the graph, the name of the node appears underlined. When you open the shortcut menu for the node or the link, you will see a Goto shortcut menu that contains the linked items for you to choose.
Use the ReferenceTemplate attribute to specify a common string, such as a URL, that is used by multiple references instead of repeating that string in the reference.
The ReferenceTemplate attribute specifies a placeholder for the value of the reference. In the following example, the {0} placeholder in the ReferenceTemplate attribute will be replaced by the values of the MyFirstReference and MySecondReference attributes in the <Node/> element to produce a full path:
<Nodes> <Node Id="MyNode" MyFirstReference="MyFirstDocument" MySecondReference="MySecondDocument"/> <Node Id="MySecondNode" MyFirstReference="AnotherFirstDocument" MySecondReference="AnotherSecondDocument"/> </Nodes> <Properties> <Property Id="MyFirstReference" Label="My First Document" DataType="System.String" IsReference="True" ReferenceTemplate="http://www.Fabrikam.com/FirstDocuments/{0}.asp"/> <Property Id="MySecondReference" Label="My Second Document" DataType="System.String" IsReference="True" ReferenceTemplate=" http://www.Fabrikam.com/SecondDocuments/{0}.asp"/> </Properties>
To view the referenced item or items from the graph, open the shortcut menu for the node or the link. Choose Goto and then the item.
Create aliases for commonly-used paths
Replacing commonly-used paths with aliases helps reduce the size of the .dgml file and the time required to load or save the file. To create an alias, add a <Paths></Paths> section at the end of the .dgml file. In this section, add a <Path/> element to define an alias for the path:
<Paths>
<Path Id="MyPathAlias" Value="C:\...\..." />
</Paths>
To reference the alias from an element in the .dgml file, enclose the Id value of the <Path/> element with a dollar sign ($) and parentheses (()):
<Nodes>
<Node Id="MyNode" Reference="$(MyPathAlias)MyDocument.txt" />
</Nodes>
<Properties>
<Property Id="Reference" Label="My Document" DataType="System.String" IsReference="True" />
</Properties>
Understanding Directed Graph Markup Language (DGML)
DGML uses simple XML to describe cyclical and acyclic directed graphs. A directed graph is a set of nodes that are connected by links, or edges. Nodes and links can be used represent network structures, such as elements in a software project. Use DGML to visualize information, perform complexity analysis, or just browse and edit directed graphs.
Nodes and links are called graph elements, or just elements. The following table describes the kinds of elements that are used in DGML:
Note
When you edit a .dgml file, IntelliSense helps you identify attributes that are available for each element and their values. To specify color in an attribute, use names for common colors, such as "Blue", or ARGB hexadecimal values, such as "#ffa0b1c3". DGML uses a small subset of Windows Presentation Foundation (WPF) color definition formats. For more information, see Colors Class.
Element |
Example Format |
---|---|
<DirectedGraph></DirectedGraph> This element is the root element of directed graph (.dgml) document. All other DGML elements appear within the scope of this element. The following list describes optional attributes that you can include:
|
|
<Nodes></Nodes> This optional element contains a list of <Node/> elements, which define nodes on the graph. For more information, see the <Node/> element. Note When you reference an undefined node in a <Link/> element, the graph creates a <Node/> element automatically. |
|
<Node/> This element defines a single node. It appears within the <Nodes><Nodes/> element list. This element must include the following attributes:
The following list describes some of the optional attributes that you can include:
|
|
<Links></Links> This element contains the list of <Link> elements, which define links between nodes. For more information, see the <Link/> element. |
|
<Link/> This element defines a single link that connects a source node to a target node. It appears within the <Links></Links> element list. Note If this element references an undefined node, the graph document automatically creates a node that has the specified attributes, if any. This element must include the following attributes:
The following list describes some of the optional attributes that you can include:
|
|
<Categories></Categories> This element contains the list of <Category/> elements. For more information, see the <Category/> element. |
|
<Category/> This element defines a Category attribute, which is used to identify elements that share this attribute. A Category attribute can be used to organize graph elements, provide for shared attributes through inheritance, or define additional metadata. This element must include the following attributes:
The following list describes some of the optional attributes that you can include:
Categories also provide some basic template behavior that controls the appearance of nodes and links when they are displayed on a graph. See Apply Custom Styles to Nodes and Links. |
|
<Properties></Properties> This element contains the list of <Property/> elements. For more information, see the <Property/> element. |
|
<Property/> This element defines a Property attribute that you can use to assign a value to any DGML element or attribute, including categories and other properties. This element must include the following attributes:
If you want the property to appear in the Properties window, use the Label property to specify the property's display name. See Assign Properties to Nodes and Links. |
|