Browse and rearrange dependency graphs
You can rearrange items on dependency graphs to make them easier to read and improve rendering performance.
Requirements
Visual Studio Ultimate, Visual Studio Premium, or Visual Studio Professional
To create dependency graphs, you must have Visual Studio Ultimate. See Map dependencies across your code on dependency graphs.
In this topic
Managing large graphs
Changing the graph layout
Browsing the graph
Examining nodes and links
Hiding or showing nodes and links
Grouping nodes
For more ways to browse the graph by using the mouse or keyboard, choose the help link on a blank graph.
Managing Large Graphs
When you generate a dependency graph the first time, Visual Studio creates a code index for all the dependencies it finds. Though this process might take some time, especially for large solutions or graphs with many links, this index improves performance of later operations. If the code changes later, then Visual Studio reindexes the updated code only.
If you don't want to wait for the graph to finish generating, you can cancel the generation process at any time and try the following suggestions:
Graph only the specific dependencies that interest you. See Map dependencies across your code on dependency graphs.
Before you generate the graph for an entire solution, reduce the scope of the solution.
After you generate the graph, try the following suggestions:
On the graph toolbar, choose Quick Clusters so that you can see natural dependency clusters in the code. See Changing the graph layout.
Organize the graph into smaller areas by grouping related nodes. Collapse those groups to see only the intergroup dependencies, which appear automatically. See Grouping nodes.
Edit the graph manually to remove nodes and links you don't need. Changing the graph doesn't affect the underlying code. See Edit and customize dependency graphs.
Changing the Graph Layout
To |
On the graph toolbar or the graph shortcut menu |
---|---|
Arrange the dependency flow for the entire graph in a specific direction. This can help you see architectural layers in the code. |
Choose one of the following to show the graph as a tree:
|
See natural dependency clusters in the code. |
Choose Quick Clusters to see the most dependent nodes at the center of the clusters and the least dependent nodes at the outside of those clusters. |
To move specific nodes on the graph, drag them. To move other nodes and links out of the way as you drag nodes, press and hold the SHIFT key as you drag nodes. To change the layout inside a group independently of the graph by selecting one of the tree layouts, Quick Clusters, or List View, which arranges the group's contents into a list. See Grouping nodes.
Note
The following functionality is not available in this release: Neighborhood Browse Mode, Butterfly Mode, Advanced Selection, and Dependency Matrix View.
Browsing the Graph
To |
Perform these steps |
---|---|
Scan the graph |
Drag the graph in any direction. |
Zoom in or out of the graph |
Rotate the mouse wheel. - or - Choose the plus sign (+) or the minus sign (-) on the graph toolbar. - or - To zoom in on a specific area, use the right mouse button to draw a rectangle around the area. |
Resize and fit the graph in its window |
On the graph toolbar, choose Zoom to Fit. - or - Double-click an empty area of the graph. |
Resize and center the graph on a specific node |
Expand the node. Double-click inside an empty area of the node. Visual Studio resizes the graph so the entire group fits inside the graph window. If you double-click a collapsed namespace, class, or its members, Visual Studio shows you the code definition. |
Change focus independently of the currently selected node |
Press TAB. A dotted line appears around the node that is currently in focus. |
Find a node on the graph by its name. Tip To find items in the solution but not on the graph, find them in Solution Explorer, and then drag them to the graph. |
Important You can use the search box to find matches in collapsed groups only if those groups were expanded previously. To find these matches and expand their parent groups automatically, choose this option under the search box. |
Find the source or target of a link Use this method when there are too many links to easily see the source or target of a specific link. |
|
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:
|
Examining Nodes and Links
Dependency graphs show the following kinds of links:
An individual link represents a single relationship between two nodes.
A cross-group link represents a relationship between two nodes in different groups.
An aggregate link represents all the relationships that point in the same direction between two groups.
Tip
By default, the graph shows cross-group links only for selected nodes. To show these links at all times, on the graph toolbar, open the Change how links are rendered on the graph list . Choose Show All Cross-Group Links.
This hides aggregated links between groups.
To |
Perform these steps |
---|---|
See more information about a node or a link |
Move the mouse pointer on top of the node or link until a tooltip appears. The tooltip for an aggregated link lists the individual dependencies that it represents. - or - Open the shortcut menu for the node or the link. Choose Properties. |
Show or hide the contents of a group |
|
See the code definition for a namespace, type, or member |
Open the shortcut menu for the node. Choose Goto, Go To Definition. -or- Double-click the node. For expanded groups, double-click the header on the group. -or- Select the node. Press F12. For example:
|
Find the source or target of a link Use this method when there are too many links to easily see the source or target of a specific link. |
|
Examine dependencies and items that participate in an aggregate link |
For a single link:
For multiple links:
Visual Studio expands the groups at both ends of the link and shows only those items and dependencies that participate in the link. Note When you examine dependencies between items in partial groups, you might see the following behavior:
To see missing items from a group, choose Refetch Children, which indicates that not all members of a group appear on the graph. You can also try undoing your actions (Keyboard: choose CTRL+Z) and examine the dependencies on a new graph. |
Examine dependencies across multiple nodes in different groups |
|
See the items that a node or link references Note This applies only when the Reference attribute is set for the node or link in the graph's .dgml file. To add references to items from nodes or links, see Edit and customize dependency graphs. |
Open the shortcut menu for the node. Choose Goto and the item. |
Hiding or Showing 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 All 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. |
Grouping 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. |
Change the layout inside a group |
|
Add a node to a group |
Drag the node onto the group. While you drag the node, Visual Studio displays an indicator to show that you are moving the node. 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 containers |
|
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. |
You can also organize nodes into groups by editing the graph's .dgml file.
To convert a node to a group or add a new group
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 in Edit and customize dependency graphs.