Thanks to visit codestin.com
Credit goes to lib.rs

#graphs #export #format #viz #metadata #date

gexf

Lightweight Rust library to export graphs in the GEXF format (Gephi)

2 releases

Uses new Rust 2024

0.1.1 Oct 13, 2025
0.1.0 Oct 13, 2025

#2690 in Encoding

MIT license

17KB
376 lines

gexf

A tiny, dependency-light Rust library to export graphs to the GEXF format, compatible with Gephi and other tools.

Features

  • Directed / undirected / mutual graphs (defaultedgetype)
  • Node labels and arbitrary attributes
  • Gephi viz extras: position, size, color
  • Metadata (<meta>): creator, description, last modified date
  • Write to any std::io::Write sink or straight to String

Quick start

cargo add gexf
use gexf::{GraphBuilder, EdgeType, Node};

let gexf = GraphBuilder::new(EdgeType::Directed)
    .meta("my-app", "Sample")
    .add_node(Node::new("n0").with_label("Alice"))?
    .add_node(Node::new("n1").with_label("Bob"))?
    .add_edge("n0", "n1")?
    .try_build()?;

let xml = gexf.to_string()?; // or gexf.write(File::create("graph.gexf")?)

Notes

  • This crate emits GEXF 1.3 with the viz namespace (viz:*).
  • Dynamic graphs (spells, time slices) are not supported.
  • Attributes here are simple key–value pairs written under <attvalues>. The full <attributes> schema is not supported.

Disclaimer

This crate was mostly developed by ChatGPT. I only cleaned it up and fixed a bunch of bugs.

Dependencies

~1.5–2MB
~36K SLoC