pub struct Graph { /* private fields */ }Expand description
Undirected, unweighted graph backed by an adjacency list.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn with_vertices(n: u32) -> Self
pub fn with_vertices(n: u32) -> Self
Construct an empty graph on n vertices and no edges.
Sourcepub fn add_vertices(&mut self, count: u32) -> (VertexId, VertexId)
pub fn add_vertices(&mut self, count: u32) -> (VertexId, VertexId)
Append count new isolated vertices, returning the id range
(first, last_inclusive) of the new vertices.
Sourcepub fn add_edge(&mut self, u: VertexId, v: VertexId) -> IgraphResult<()>
pub fn add_edge(&mut self, u: VertexId, v: VertexId) -> IgraphResult<()>
Add a single undirected edge between u and v.
Self-loops are allowed (added once); parallel edges are allowed.
Sourcepub fn add_edges<I>(&mut self, edges: I) -> IgraphResult<()>
pub fn add_edges<I>(&mut self, edges: I) -> IgraphResult<()>
Add a sequence of undirected edges.
Sourcepub fn neighbors(&self, v: VertexId) -> IgraphResult<&[VertexId]>
pub fn neighbors(&self, v: VertexId) -> IgraphResult<&[VertexId]>
Neighbors of v. Order is insertion order.
Sourcepub fn degree(&self, v: VertexId) -> IgraphResult<usize>
pub fn degree(&self, v: VertexId) -> IgraphResult<usize>
Degree of v (counting self-loops once each, parallel edges separately).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more