Algorithmic Solutions > LEDA > LEDA Guide > Graphs and Related Data Types > GML Parser for Graphs

GML Parser for Graphs

GML is a simple and extendible file format to store graphs with any kind of additional information.

Example for GML Format

Here is an example of a graph in GML format. The graph has three nodes 1, 2, and 3, and three edges connecting 1 and 2, 2 and 3, and 3 and 1.
# This is a comment.
graph [ # Lists start with '['.
  directed 1 # This is a directed graph (0 for undirected).
  # The following is an object of type string.
  # It will be ignored unless you specify a rule for graph.text.
  text "This is a string object."
  node [ id 1 ] # This defines a node with id 1.
  node [ id 2 ]
  node [ id 3 ]
  edge [ # This defines an edge leading from node 1 to node 2. 
    source 1
    target 2
  edge [
    source 2
    target 3
  edge [
    source 3
    target 1
] # Lists end with ']'.

The data type graph provides functions to read and write graphs in GML format. These functions use the data type GML parser for Graphs.

It is also possible to use the GML parser for Graphs directly. It provides easy to use means to extend and adapt it for special needs.

Example of how to use GML format and native graph file format


  • Powerful and easy to use



  • If you need to store your graphs with additional information and readability of the resulting files is an issue, consider using the GML format and the GML parser for Graphs.

See also:

Native File Format for Graphs

Graphs and Related Data Types

Manual Entries:

GML parser for Graphs

Please send any suggestions, comments or questions to
© Copyright 2001-2003, Algorithmic Solutions Software GmbH