Skip to main content

GraphOps

Trait GraphOps 

Source
pub trait GraphOps: GraphBase {
    // Required methods
    fn add_node(&mut self, data: Self::NodeData) -> GraphResult<NodeIndex>;
    fn remove_node(&mut self, index: NodeIndex) -> GraphResult<Self::NodeData>;
    fn add_edge(
        &mut self,
        from: NodeIndex,
        to: NodeIndex,
        data: Self::EdgeData,
    ) -> GraphResult<EdgeIndex>;
    fn remove_edge(&mut self, index: EdgeIndex) -> GraphResult<Self::EdgeData>;
    fn update_node(
        &mut self,
        index: NodeIndex,
        data: Self::NodeData,
    ) -> GraphResult<Self::NodeData>;
    fn update_edge(
        &mut self,
        index: EdgeIndex,
        data: Self::EdgeData,
    ) -> GraphResult<Self::EdgeData>;
    fn clear(&mut self);
    fn reserve(&mut self, additional_nodes: usize, additional_edges: usize);
}
Expand description

图可变操作 trait

定义图的可变操作

Required Methods§

Source

fn add_node(&mut self, data: Self::NodeData) -> GraphResult<NodeIndex>

添加节点

Source

fn remove_node(&mut self, index: NodeIndex) -> GraphResult<Self::NodeData>

删除节点,返回节点数据

Source

fn add_edge( &mut self, from: NodeIndex, to: NodeIndex, data: Self::EdgeData, ) -> GraphResult<EdgeIndex>

添加边

Source

fn remove_edge(&mut self, index: EdgeIndex) -> GraphResult<Self::EdgeData>

删除边,返回边数据

Source

fn update_node( &mut self, index: NodeIndex, data: Self::NodeData, ) -> GraphResult<Self::NodeData>

更新节点数据,返回旧数据

Source

fn update_edge( &mut self, index: EdgeIndex, data: Self::EdgeData, ) -> GraphResult<Self::EdgeData>

更新边数据,返回旧数据

Source

fn clear(&mut self)

清空图

Source

fn reserve(&mut self, additional_nodes: usize, additional_edges: usize)

预分配容量

Implementors§

Source§

impl<T, E> GraphOps for Graph<T, E>