How to: Browse and Navigate Graph Documents

In Visual Studio Ultimate, you can perform different tasks to help you explore the nodes and links on a graph document.

In This Topic

  • Selecting a layout

  • Browsing the graph

  • Inspecting nodes and links on the graph

Selecting a Layout

Certain layouts are more suitable than other layouts for specific tasks. To select a suitable layout to explore code on the graph, perform these steps:

To select a layout for the graph

  1. If the graph toolbar is not visible, on the View menu, point to Toolbars, and then click Directed Graph.

  2. On the graph toolbar, select a task and a layout from the following table:

    Task

    Select

    Explore architectural layers in the code

    Tree layout:

    • Left to right

    • Right to left

    • Top to bottom

    • Bottom to top

    Show nodes as a tree structure.

    The graph tries to arrange nodes so that most of the dependencies flow in the specified direction.

    Explore concepts or natural clusters in the code

    Quick Clusters

    Show nodes as clusters.

    The graph arranges the most dependent nodes near the center of the clusters and the least dependent nodes near the outside of those clusters.

    Explore dense areas of dependencies in the code

    Dependency Matrix View

    Show nodes as rows and columns in a matrix. Dependencies are represented as cells at the intersections of the row and column that they connect. Cell colors represent different kinds of dependencies.

    The graph arranges rows and columns alphabetically or by the number of links per node.

    To arrange rows alphabetically, next to Dependency Matrix View, click Sort Rows By Display Name. To arrange rows by the number of links, click the same button again, which will have the tooltip: Sort Rows By Link Density.

    To arrange columns alphabetically, click Sort Columns By Display Name. To arrange columns by the number of links, click the same button again, which will have the tooltip: Sort Columns By Link Density.

    To see dependencies regardless of their direction, click Show Reflexive View. To see dependencies based only on direction, click the same button again, which will have the tooltip: Hide Reflexive View.

  3. If you select tree layout or quick clusters layout, you can also select modes to perform the following tasks:

    Task

    Mode

    Explore the flow of dependencies through the code

    Butterfly Mode

    Show only those linked nodes that are on the same path as the selected nodes. If no nodes are selected, then the graph selects the primary hub.

    Circular links do not appear in this mode. Instead, nodes that participate in circular relationships are copied so that they appear on both sides of the selected nodes. Dependencies that are more than one level away from the selected node will not necessarily appear in order because the graph layout is based on the shortest path from the selected node.

    To turn on this mode, click Turn on Butterfly Mode. To turn off this mode, click the same button, which now shows the tooltip: Turn off Butterfly Mode. You cannot undo butterfly mode.

    NoteNote
    Deleting selected nodes in this mode causes connected nodes to disappear from the graph. This occurs because the selected nodes no longer exist on the graph. To restore the missing connected nodes, turn off butterfly mode.

    To change the center of the butterfly layout, double-click another node.

    Explore the local neighborhood around selected nodes

    Neighborhood Browse Mode

    Show only those nodes that are specific number of links away from selected nodes.

    To turn on this mode, click the Neighborhood Browse Mode drop-down list, and then select the level of nodes that you want to see.

    NoteNote
    To change the center of the neighborhood, double-click another node.

    To turn off this mode and see all nodes, click the Neighborhood Browse Mode drop-down list, and then select All.

Browsing the Graph

When there are too many links to see the details of the graph, use the following tasks to browse the graph more easily:

To

Perform these steps

Drag the graph left, right, up, or down

Press and hold CTRL as you drag the graph.

Zoom in or out of the graph

Press and hold CTRL as you rotate the mouse wheel.

- or -

Click the plus sign (+) or the minus sign (-) on the graph toolbar.

To zoom in on a specific area, use the right mouse button to draw a rectangle around the area.

Select recently selected nodes

To select a previously selected node, on the Visual Studio toolbar, click the Navigate Backward drop-down list, point to the current graph, and then select a node.

To select a node that was selected after the current one, click Navigate Forward.

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.

  1. Change the graph layout to tree layout or quick clusters layout.

    For more information, see Selecting a Layout.

  2. Point to a link on the graph.

    Visual Studio displays two arrow buttons above the link. Visual Studio also shows a tooltip that identifies the source and target of the link and any other available details about the link.

  3. Click the arrow button that points in the direction that you want to follow.

    Depending on the direction that you selected, the source or target appears selected.

Find a node by name

Press CTRL+F

To

Perform these steps

Show or hide the contents of a group

To expand a single group, right-click the node, point to Group, and then click Expand. You can also click the chevron button to expand the group.

To expand all groups, right-click the graph, point to Group, and then click Expand All.

To collapse a single group, right-click the node, point to Group, and then click Collapse.

- or -

Click the chevron button to collapse the group.

To collapse all groups, right-click the graph, point to Group, and then click Collapse All.

To expand or collapse a selected group by using the keyboard, click the PLUS key (+) or the MINUS key (-).

To expand or collapse everything inside a selected group, press and hold the SHIFT key while you click the PLUS key (+) or the MINUS key (-).

View the properties of a node or link

Point to the node or link until the tooltip appears.

For example, the tooltip for an aggregated link lists the kinds of individual dependencies that it represents.

- or -

Right-click the node or the link, and then click Properties.

Examine the dependencies behind a link

NoteNote
This applies only when each end of the link is connected to an assembly. If the assembly information has been removed from the graph, then nothing will happen.
  1. Change the graph layout to tree layout or quick clusters layout.

    For more information, see Selecting a Layout.

  2. Double-click the link that represents the dependency.

    - or -

    1. Point to the link that represents the dependency.

      Visual Studio displays two arrow buttons above the link.

    2. Click the plus sign (+) between the two arrow buttons.

  3. In the Generate Dependency Graph dialog box, select the kinds of structures and their properties that you want to examine for that dependency.

Examine a node more closely

Double-click the node.

- or -

Right-click the node, and then click View Content.

TipTip
In butterfly or neighborhood browse mode, double-clicking a node makes that node the center of the graph.

For example:

  • For an assembly node, a new dependency graph opens to show that single assembly and its external dependencies. 

  • For a namespace node, the code file for the first alphabetical class in that namespace opens to show the definition of that class.

    NoteNote
    When you perform this task on a node for a Visual Basic .NET namespace, the code file behind the namespace does not open. This issue also occurs when you perform this task on a group of selected nodes that include a Visual Basic .NET namespace. To work around this issue, navigate manually to the code file behind the namespace, or omit the node for the namespace from your selection.
  • For a class or a partial class node, the code file for that class opens to show the definition of that class.

  • For a method node, the code file for the parent class opens to show the definition of that method.

View the items that a node or link references

NoteNote
Available only when the Reference attribute is set for the node or link in the graph's .dgml file. For more information about how to add references to items from nodes or links, see How to: Edit and Customize Graph Documents.

If the node or link references a single item, double-click the node or link.

- or -

Move the mouse pointer over the link, and then click the plus sign (+).

If the node or link references multiple items, right-click the node or node, point to Goto, and then click a reference.

See Also

Concepts

How to: Generate Dependency Graphs for .NET Code

How to: Explore Code with Dependency Graphs

How to: Edit and Customize Graph Documents