Directed Graph Markup Language (DGML) reference - Visual Studio (Windows) (original) (raw)

Directed Graph Markup Language (DGML) describes information used for visualization and to perform complexity analysis, and is the format used to persist code maps in Visual Studio. It uses simple XML to describe both 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.

Note that some versions of Visual Studio support only a subset of DGML capabilities, see Version support for architecture and modeling tools.

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.

DGML syntax

The following table describes kinds of elements that are used in DGML:

<?xml version="1.0" encoding="utf-8"?>  
<DirectedGraph Title="DrivingTest" Background="Blue" xmlns="http://schemas.microsoft.com/vs/2009/dgml">  
   <Nodes>  
      ...  
   </Nodes>  
   <Links>  
      ...  
   </Links>  
   <Categories>  
      ...  
   </Categories>  
   <Properties>  
      ...  
   </Properties>  
</DirectedGraph>  
<?xml version="1.0" encoding="utf-8"?>  
<DirectedGraph Title="DrivingTest" xmlns="http://schemas.microsoft.com/vs/2009/dgml">  
   <Nodes>  
      <Node ... />  
   </Nodes>  
   <Links>  
      <Link ... />  
   </Links>  
</DirectedGraph>  
<?xml version="1.0" encoding="utf-8"?>  
<DirectedGraph Title="DrivingTest" xmlns="http://schemas.microsoft.com/vs/2009/dgml">  
   <Nodes>  
      <Node Id="Driver" Label="Student" Category="Person" />  
      <Node Id="Passenger" Label="Instructor" Category="Person" />  
      <Node Id="Car" Label="Car" Category="Automobile" />  
      <Node Id="Truck" Label="Truck" Category="Automobile" />  
   </Nodes>  
   <Links>  
      <Link ... />  
   </Links>  
   <Categories>  
      <Category Id="Person" Background="Orange" />  
      <Category Id="Automobile" Background="Yellow"/>  
   </Categories>  
</DirectedGraph>  
<?xml version="1.0" encoding="utf-8"?>  
<DirectedGraph Title="DrivingTest" xmlns="http://schemas.microsoft.com/vs/2009/dgml">  
   <Links>  
      <Link ... />  
   </Links>  
</DirectedGraph>  
<?xml version="1.0" encoding="utf-8"?>  
<DirectedGraph Title="DrivingTest" xmlns="http://schemas.microsoft.com/vs/2009/dgml">  
   <Nodes>  
      <Node Id="Driver" Label="Student" Category="Person" />  
      <Node Id="Passenger" Label="Instructor" Category="Person" />  
      <Node Id="Car" Label="Car" Category="Automobile" />  
      <Node Id="Truck" Label="Truck" Category="Automobile" />  
   </Nodes>  
   <Links>  
      <Category Id="Person" Background="Orange" />  
      <Category Id="Automobile" Background="Yellow"/>  
      <Link Source="Driver" Target="Car" Label="Passed" Stroke="Black" Background="Green" Category="PassedTest" />  
      <Link Source="Driver" Target="Truck" Label="Failed" Stroke="Black" Background="Red" Category="PassedTest" />  
   </Links>  
</DirectedGraph>  
<?xml version="1.0" encoding="utf-8"?>  
<DirectedGraph Title="DrivingTest" xmlns="http://schemas.microsoft.com/vs/2009/dgml">  
   <Categories>  
       <Category ... />  
   </Categories>  
</DirectedGraph>  
<?xml version="1.0" encoding="utf-8"?>  
<DirectedGraph Title="DrivingTest" xmlns="http://schemas.microsoft.com/vs/2009/dgml">  
   <Nodes>  
      <Node Id="Driver" Label="Driver" Category="Person" />  
      <Node Id="Car" Label="Car" Category="Automobile" />  
      <Node Id="Truck" Label="Truck" Category="Automobile" />  
      <Node Id="Passenger" Category="Person" />  
   </Nodes>  
   <Links>  
      <Link Source="Driver" Target="Car" Label="Passed" Category="PassedTest" />  
      <Link Source="Driver" Target="Truck" Label="Failed" Category="FailedTest" />  
   </Links>  
   <Categories>  
      <Category Id="Person" Background="Orange" />  
      <Category Id="Automobile" Background="Yellow"/>  
      <Category Id="PassedTest" Label="Passed" Stroke="Black" Background="Green" />  
      <Category Id="FailedTest" Label="Failed" BasedOn="PassedTest" Background="Red" />  
   </Categories>  
</DirectedGraph>  
<?xml version="1.0" encoding="utf-8"?>  
<DirectedGraph Title="DrivingTest" xmlns="http://schemas.microsoft.com/vs/2009/dgml">  
   <Properties>  
       <Property ... />  
   </Properties>  
</DirectedGraph>  
<?xml version="1.0" encoding="utf-8"?>  
<DirectedGraph Title="DrivingTest" xmlns="http://schemas.microsoft.com/vs/2009/dgml">  
   <Nodes>  
      <Node Id="Driver" Label="Driver" Category="Person" DrivingAge="18"/>  
      <Node Id="Car" Label="Car" Category="Automobile" />  
      <Node Id="Truck" Label="Truck" Category="Automobile" />  
      <Node Id="Passenger" Category="Person" />  
   </Nodes>  
   <Links>  
      <Link Source="Driver" Target="Car" Label="Passed" Category="PassedTest" />  
      <Link Source="Driver" Target="Truck" Label="Failed" Category="FailedTest" />  
   </Links>  
   <Categories>  
      <Category Id="Person" Background="Orange" />  
      <Category Id="Automobile" Background="Yellow"/>  
      <Category Id="PassedTest" Label="Passed" Stroke="Black" Background="Green" />  
      <Category Id="FailedTest" Label="Failed" BasedOn="PassedTest" Background="Red" />  
   </Categories>  
   <Properties>  
       <Property Id="DrivingAge" Label="Driving Age" DataType="System.Int32" />  
   </Properties>  
</DirectedGraph>  

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 of the 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>

See also