desc

The idea behind the desc element is that applications writing
GraphML documents are encouraged to describe the content of elements.
Therefore, each element has an optional desc element as its
first child.

DTD Definition

<!ELEMENT desc (#PCDATA)>

Contents

desc elements should contain meta information useful for
human readers of a graphml document. For example, they may
contain a specification of the level of sophistication of
the contained graph. Another example would be a
brief description of the data associated with a particular
key.

Like nodes, edges may also contain a graph. For example, the decomposition
tree of a series-parallel graph is best described as graphs within edges.

Attributes

Edges may have the following attributes:

id

Optionalid tag for the edge.

source

Specifies the source node of this edge. The value of source must be a valid node id.

sourcePort

Specifies the source port of this edge. The value of sourcePort must match the value of the
name attribute of a port of the source node of this edge.

target

Specifies the target node of this edge. The value of target must be a valid node id.

targetPort

Specifies the target port of this edge. The value of targetPort must match the value of the
name attribute of a port of the target node of this edge.

directed

Whether an edge is directed is determined by the directed attribute of the surrounding
graph element, unless it is explicitly overwritten by the edge's own directed attribute.

Remarks

In the corresponding Schemas definition,
graph, node, and edgeid"s
are distinguished as different types, so as to ensure that edges attach
to nodes, etc. With DTD-validated documents, a parser encounter edges
omething other than a node as source or target, so that an
exception should be thrown.

endpoint

The end points of nodes and edges are specified with the source and target attributes. Hyperedges, however, can have any number of end points, so XML attributes are no longer appropriate. Instead, the hyperedge element contains a number of endpoint elements.

graph

In GraphML, graphs are represented by lists of nodes, edges and hyperedges (rather than, e.g., an adjacency list). The node, edge and hyperedge
elements may appear in any order, to allow applications to write out their
graphs with a single pass over their internal representation.

Examples

A graph with directed and undirected edges
Here is a graph with mixed directed and undirected edges. Note that the edge e2 gets the default value as specified by the directed attribute of the graph element.

Remarks

The fact that nodes, edges and hyperedges may come in any order
implies that most parsers must use more than one pass over their internal
data structures. With the graphml-parseinfo extension,
some standard orderings may be signalled to ease the burden on parsers.
A light-weight parser may thus refuse to process a file that does not
signify the required ordering using this extension.

hyperedge

Hyperedges are edges incident to any number of nodes (rather
just two). As a generalization of edges, each incidence may
be incoming, outgoing, or undirected. and attached to a specific
port. Hence, an element endpoint encapsulates the relation
between a hyperedge and a node it is incident to.

Attributes

key

Each data element must have a key attribute. The value of this attribute must match the id of a key element in graphml.

In turn, the graphml element contains a list of keys for the graph. The idea being that this list serves as a reference (and description via the desc elements) for data attributes which are potentially used in the document.

Attributes

id

Nodes must have an id, so that they can be referred to by edges.

Remarks

Applications may or may not be able to deal with recursive definitions.
The fall-back interpretation for an application not dealing with nested
graphs is to ignore the contained graph element, while applications not
dealing with cyclic or non-tree containment throw an exception when encountering
such situation.

Attributes

The name of this port. The edge attributes sourceport and targetport use this attribute to address the port.

Remarks

Port names are of type NMTOKEN (rather than ID) to allow reuse of names in different nodes (e.g., north/west/...).

In the Schema specification, port ids are scoped and required
to be unique within a node, like node ids are to be unique within a graph.
Thus, the potential for naming conflicts of ports is eliminated.