https://github.com/jonasbb/petgraph-graphml
GraphML output generator for petgraph
https://github.com/jonasbb/petgraph-graphml
graphml petgraph rust
Last synced: 3 months ago
JSON representation
GraphML output generator for petgraph
- Host: GitHub
- URL: https://github.com/jonasbb/petgraph-graphml
- Owner: jonasbb
- License: apache-2.0
- Created: 2018-05-13T19:32:35.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-01-11T23:46:53.000Z (6 months ago)
- Last Synced: 2025-04-06T05:04:28.530Z (3 months ago)
- Topics: graphml, petgraph, rust
- Language: Rust
- Homepage:
- Size: 118 KB
- Stars: 17
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# [GraphML][graphmlwebsite] output support for [petgraph]
[](https://docs.rs/petgraph-graphml/)
[](https://crates.io/crates/petgraph-graphml/)
[](https://github.com/jonasbb/petgraph-graphml)
[](https://codecov.io/gh/jonasbb/petgraph-graphml)---
This crate extends [petgraph][] with [GraphML][graphmlwebsite] 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 = "4.0.0"
```## Example
For a simple graph like  this is the generated GraphML output.
```rust
let graph = make_graph();
// 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)
.pretty_print(true)
.export_node_weights_display();assert_eq!(
graphml.to_string(),
r#"
0
1
2
"#
);
```[`GraphMl`]: https://docs.rs/petgraph-graphml/*/petgraph_graphml/struct.GraphMl.html
[`GraphMl::to_string`]: https://docs.rs/petgraph-graphml/*/petgraph_graphml/struct.GraphMl.html#method.to_string
[`GraphMl::to_writer`]: https://docs.rs/petgraph-graphml/*/petgraph_graphml/struct.GraphMl.html#method.to_writer
[graphmlwebsite]: http://graphml.graphdrawing.org/
[petgraph]: https://docs.rs/petgraph/## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)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.