Surging Object DiGraph (SODG)


Keywords
graph, oop, eolang, rust, rust-crate, rust-lang, rust-library
License
Other

Documentation

logo

EO principles respected here We recommend IntelliJ IDEA

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

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

Create a graph:

use sodg::Sodg;
use sodg::Hex;
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, Hex::from_str_bytes("Hello, world!"))?; // attach data to v1

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

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

You can find all kids of a vertex:

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

You can read the data of a vertex:

let hex: Hex = g.data(1)?;
let num: i64 = hex.to_i64()?;

Then, you can print the graph:

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

Also, you can serialize and deserialize the graph.

How to Contribute

First, install Rust and then:

$ cargo test --vv

If everything goes well, fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run cargo test again. Also, run cargo fmt and cargo clippy.