Skip to content

usrsem/graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graph library for pixelplex

example workflow example workflow codecov

Description

Full documentation available here

Implementation

Choosed adjacency matrix implementation.

Examples

Create empty graph with u32 node and String edge weight:

let mut g = MatrixGraph::<u32, String>::default()

Or create from IntoIterator:

let edges = [
   (1, 2, 3),
   (3, 4, 7),
   (1, 3, 4),
];

let g = MatrxiGraph::<u32, u32>::from_edges(edges.into_iter());

Adding nodes and edges:

let mut g = MatrixGraph::<u32, String>::default()
let first = g.add_node(34);
let second = g.add_node(52);
g.add_edge(first, second, "First");
g.add_edge(second, first, "Second");

Removing nodes and edges:

g.remove_node(2);
g.remove_edge(0, 1);

Iterating over breadth first traverse of graph:

let start_node_idx = 0;
for entry in g.bfs_iter(start_node_idx) {
   println!("Node: {}, edges: {:?}", entry.node, entry.edges);
}

Deserialize from Trivial Graph Format:

let tgf = load_tgf_as_str();
let g = serialization::de_tgf::<u32, String>(tgf).expect("Something bad");

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages