Graph

Trait Graph 

Source
pub trait Graph<W, E: Edge<W>, Ty: EdgeDir> {
    // Required methods
    fn add_vertex(&mut self) -> usize;
    fn remove_vertex(&mut self, vertex_id: usize) -> Result<()>;
    fn remove_vertex_unchecked(&mut self, vertex_id: usize);
    fn add_edge(
        &mut self,
        src_id: usize,
        dst_id: usize,
        edge: E,
    ) -> Result<usize>;
    fn add_edge_unchecked(
        &mut self,
        src_id: usize,
        dst_id: usize,
        edge: E,
    ) -> usize;
    fn update_edge(
        &mut self,
        src_id: usize,
        dst_id: usize,
        edge_id: usize,
        edge: E,
    ) -> Result<()>;
    fn update_edge_unchecked(
        &mut self,
        src_id: usize,
        dst_id: usize,
        edge_id: usize,
        edge: E,
    );
    fn remove_edge(
        &mut self,
        src_id: usize,
        dst_id: usize,
        edge_id: usize,
    ) -> Result<E>;
    fn remove_edge_unchecked(
        &mut self,
        src_id: usize,
        dst_id: usize,
        edge_id: usize,
    ) -> E;
}
Expand description

Provides basic functionalities to store graph information.

Required Methods§

Source

fn add_vertex(&mut self) -> usize

Adds a vertex to the graph.

§Returns

Unique id of the newly added vertex.

Source

fn remove_vertex(&mut self, vertex_id: usize) -> Result<()>

Removes the vertex with id: vertex_id from graph.

§Arguments

vertex_id: Id of the vertex to be removed.

Source

fn remove_vertex_unchecked(&mut self, vertex_id: usize)

Removes the vertex with id: vertex_id from graph.

§Arguments

vertex_id: Id of the vertex to be removed.

Source

fn add_edge(&mut self, src_id: usize, dst_id: usize, edge: E) -> Result<usize>

Adds edge from vertex with id src_id: to vertex with id: dst_id.

§Arguments
  • src_id: Id of the source vertex.
  • dst_id: Id of the destination vertex.
  • edge: Edge to be added from source to destination.
§Returns
  • Err:
  • Ok: Containing unique id of the newly added edge.
Source

fn add_edge_unchecked(&mut self, src_id: usize, dst_id: usize, edge: E) -> usize

Adds edge from vertex with id src_id: to vertex with id: dst_id.

§Arguments
  • src_id: Id of the source vertex.
  • dst_id: Id of the destination vertex.
  • edge: Edge to be added from source to destination.
§Returns

Unique id of the newly added edge.

Source

fn update_edge( &mut self, src_id: usize, dst_id: usize, edge_id: usize, edge: E, ) -> Result<()>

Replaces the edge with id: edge_id with edge.

§Arguments
  • src_id: Id of source vertex.
  • dst_id: Id of destination vertex.
  • edge_id: Id of the to be updated edge.
  • edge: New edge to replace the old one.
Source

fn update_edge_unchecked( &mut self, src_id: usize, dst_id: usize, edge_id: usize, edge: E, )

Replaces the edge with id: edge_id with edge.

§Arguments
  • src_id: Id of source vertex.
  • dst_id: Id of destination vertex.
  • edge_id: Id of the to be updated edge.
  • edge: New edge to replace the old one.
Source

fn remove_edge( &mut self, src_id: usize, dst_id: usize, edge_id: usize, ) -> Result<E>

Removes the edge with id: edge_id.

§Arguments
  • src_id: Id of source vertex.
  • dst_id: Id of destination vertex.
  • edge_id: Id of edge to be removed.
§Returns
  • Err:
  • Ok: Containing removed edge.
Source

fn remove_edge_unchecked( &mut self, src_id: usize, dst_id: usize, edge_id: usize, ) -> E

Removes the edge with id: edge_id.

§Arguments
  • src_id: Id of source vertex.
  • dst_id: Id of destination vertex.
  • edge_id: Id of edge to be removed.
§Returns

Removed edge.

Implementors§

Source§

impl<W, E: Edge<W>, Dir: EdgeDir, S: GraphStorage<W, E, Dir>> Graph<W, E, Dir> for SimpleGraph<W, E, Dir, S>

For documentation about each function checkout Graph trait.