#connection #generic #undirected #vertices #graph #structure #represents

easy_graph

Data structure that represent generic vertices and undirected connections

6 releases

0.1.5 Mar 6, 2020
0.1.4 Mar 6, 2020

#762 in Science

Download history 8/week @ 2024-02-16 5/week @ 2024-02-23 1/week @ 2024-03-01 1/week @ 2024-03-08 52/week @ 2024-03-29

53 downloads per month

MIT license

18KB
358 lines

Easy graph

Easy rust realization of generic graph

Description

Data structure that represent generic vertices and undirected connections

Example

let verts = vec![0, 1, 2, 3, 4, 10];
let conns = vec![(0, 1), (1, 2), (2, 3), (3, 4), (10, 0), (4, 10)];

let graph = Graph::from_data(verts.into_iter(), conns.into_iter());
assert_eq!(verts.len(), graph.len());

let new_vertex = 15;
assert!(graph.add_vertex(new_vertex));
assert!(graph.contains(&new_vertex));

graph.add_edge(&1, &4);
assert!(graph.is_connected(&1, &4));
assert!(graph.is_connected(&4, &1));

No runtime deps