GraphML Representation of Nested Graph Structures

Questions & Answers

Summary

How nested graph structures are represented in GraphML.
For a better user experience, please go to the integrated documentation viewer to read this article.

Description

The GraphML file format defines nested graphs in the context of their enclosing nodes: a subgraph is listed as the content of the GraphML <node> element that contains the subgraph.

The GraphML representation for a graph that has a subgraph nested within a subgraph, for example, looks something like the one shown below. The recursive nesting of the subgraphs can be observed from the <graph> elements within <node> elements.

<?xml version="1.0" encoding="UTF-8"?>
<graphml>
  <graph id="G" edgedefault="directed">
    <node id="n0"/>
    <node id="n1"/>
    <node id="n2">
      <graph id="n2::" edgedefault="directed">
        <node id="n2::n0"/>
        <node id="n2::n1">
          <graph id="n2::n1::" edgedefault="directed">
            <node id="n2::n1::n0"/>
            <node id="n2::n1::n1"/>
            <node id="n2::n1::n2"/>
            <edge id="e0" source="n2::n1::n1" target="n2::n1::n0"/>
            <edge id="e1" source="n2::n1::n2" target="n2::n1::n1"/>
          </graph>
        </node>
        <node id="n2::n2"/>
        <edge id="e2" source="n2::n1" target="n2::n0"/>
        <edge id="e3" source="n2::n2" target="n2::n1"/>
      </graph>
    </node>
    <edge id="e4" source="n1" target="n0"/>
    <edge id="e5" source="n1" target="n2::n1"/>
    <edge id="e6" source="n0" target="n2"/>
  </graph>
</graphml>
Although the XML id attributes for the nodes in this example somehow mimic the graph's nesting structure, this scheme is not necessary. For proper parsing of a GraphML file, it is nevertheless mandatory that the id attributes of nodes and edges have unique values.

For the sake of clearer presentation the above GraphML file is "structure-only," i.e., it lacks the yFiles node and edge realizer definitions which are responsible for the actual graphical representation of nodes and edges.
The resources below include GraphML files that show both the structure-only representation as well as the full-fledged representation with the complete graphical information for the realizers.

Resources

Categories this article belongs to:
GraphML > GraphML Extension Package > GraphML
yFiles for Java > yFiles Viewer > GraphML Extension Package > GraphML
Applies to:
yFiles for Java 2: 2.7, 2.8, 2.9, 2.10, 2.11, 2.12, 2.13, 2.14, 2.15, 2.16, 2.17, 2.18
GraphML: 2.4, 3.0
Keywords:
GraphML - nesting - nested - graph - structure - group - node - folder - GroupNodeRealizer - ProxyAutoBoundsNode - recursive