What is it?

No brain-fucking to use the Graph Exchange XML Format in your programs!

Libgexf is the official C++ toolkit library for the GEXF file format. It is free software available under the MIT License. Though the library is written in C++ a variety of language bindings make it available in other environments.

Libgexf currently only works on Linux systems (tested on Ubuntu 8.10 and 9.04), but the portability will be increased on demand. Python, Perl and Java binding facilities are also provided.

How to use it?

Using the library in your C++ programs is very simple:

  1. add -I/usr/include/libgexf -I/usr/include/libxml2 to the g++ compiler options
  2. add -lgexf -lxml2 to the g++ linker options
  3. insert #include <libgexf.h> in your C++ program. Namespace: libgexf

That's all, folks! See related README files for each language binding.


  • static graph
  • basic topology (no hierarchical graphs or hypergraphs for the moment)
  • full data attributes
  • read/write GEXF 1.0 (legacy Gephi 0.6) and 1.1 (Gephi 0.7+)
  • data integrity and type checking
  • RelaxNG and XSD validator


This is how to create a GEXF file:

#include <stdlib.h>

// if libgexf is installed
#include <libgexf/libgexf.h>

void create() {

    libgexf::GEXF *gexf = new libgexf::GEXF();

    libgexf::DirectedGraph& graph = gexf->getDirectedGraph();

    // nodes

    // edges
    graph.addEdge("0", "0", "1");

    // node labels
    libgexf::Data& data = gexf->getData();
    data.setLabel("0", "Hello");
    data.setLabel("1", "world");

    // attributes
    data.addNodeAttributeColumn("0", "foo", libgexf::BOOLEAN);
    data.setNodeAttributeDefault("0", "false");
    data.setNodeValue("1", "0", "true");

    // meta data
    libgexf::MetaData& meta = gexf->getMetaData();
    meta.setCreator("The Hitchhiker's Guide to the Galaxy");
    meta.setDescription("The answer is 42.");

    // write gexf file
    libgexf::FileWriter *writer = new libgexf::FileWriter();
    writer->init("life.gexf", gexf);

The result will be:

<?xml version="1.0" encoding="UTF-8"?>
<gexf xmlns="http://www.gexf.net/1.1draft" version="1.1">
        <creator>The Hitchhiker's Guide to the Galaxy<creator>
        <description>The answer is 42.<description>
    <graph mode="static" defaultedgetype="undirected">
        <attributes class="node">
            <attribute id="0" title="foo" type="boolean">
            <node id="0" label="Hello"/>
            <node id="1" label="world"/>
                    <attvalue for="0" value="true">
            <edge id="0" source="0" target="1"/>

Release policy

The development is divided into 2 series: stable and unstable. The stable serie represents an interface which should not change until further additions, and is well tested. The unstable serie is the cutting-edge development version packaged for testing. Interfaces may change.

Stable serie has a pair second revision number, i.e. 1.2.x
Unstable serie has an odd second revision number, i.e. 1.1.x

Get started!

Download the latest release and try the examples now!