GraphML output support for [petgraph]

docs.rs badge crates.io badge Rust CI codecov


This crate extends petgraph with GraphML output support.

This crate exports a single type [GraphMl] which combines a build-pattern for configuration and provides creating strings ([GraphMl::to_string]) and writing to writers ([GraphMl::to_writer]).

Usage

Add this to your Cargo.toml:

toml [dependencies] petgraph-graphml = "2.0.1"

Example

For a simple graph like Graph with three nodes and two edges this is the generated GraphML output.

```rust let graph = makegraph(); // Configure output settings // Enable pretty printing and exporting of node weights. // Use the Display implementation of NodeWeights for exporting them. let graphml = GraphMl::new(&graph) .prettyprint(true) .exportnodeweights_display();

asserteq!( graphml.tostring(), r#" 0 1 2 "# ); ```

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.