logo

EO principles respected here We recommend IntelliJ IDEA

cargo crates.io PDD status codecov Hits-of-Code Lines of code License

This Rust library helps you build a Simple Object DiGraph (SODG) for reo compiler of EO programs.

Create a graph:

rust use sodg::Sodg; let mut g = Sodg::empty(); g.add(0)?; // add a vertex no.0 g.add(1)?; // add a vertex no.1 g.bind(0, 1, "foo")?; // connect v0 to v1 with label "foo" g.put(1, "Hello, world!".as_bytes().to_vec())?; // attach data to v1

You can find a vertex by the label of an edge departing from another vertex:

rust let id = g.kid(0, "foo")?; // returns 1

You can find all kids of a vertex:

rust let kids: Vec<(String, u32)> = g.kids(0);

You can read the data of a vertex:

rust let bytes: Vec<u8> = g.data(1)?; // empty if no data written before

Then, you can print the graph:

rust println!("{:?}", g);

Also, you can serialize and deserialize the graph.