Skip to main content

GraphMut

Trait GraphMut 

Source
pub trait GraphMut: Graph {
    type NodeMut<'graph>: NodeMut<'graph, Graph = Self>
       where Self: 'graph;
    type EdgeMut<'graph>: EdgeMut<'graph, Graph = Self>
       where Self: 'graph;

    // Required methods
    fn get_node_mut(&mut self, id: Self::NodeId) -> Option<Self::NodeMut<'_>>;
    fn get_edge_mut(&mut self, id: Self::EdgeId) -> Option<Self::EdgeMut<'_>>;

    // Provided method
    fn merge_nodes(
        &mut self,
        keep: Self::NodeId,
        remove: Self::NodeId,
        direct_edge: Self::EdgeId,
    )
       where Self: Sized { ... }
}
Expand description

The mutable half of Graph: node/edge handles that can rewrite the graph structure, plus structural edits.

Read-only algorithms (dominators, DFS, loop analysis) bound only Graph, so a read-only view (e.g. a checked-out function’s CFG behind an immutable reference) can implement Graph without providing a mutable surface it does not have. Graphs that own their storage (e.g. owning::OwningGraph) also implement GraphMut.

Required Associated Types§

Source

type NodeMut<'graph>: NodeMut<'graph, Graph = Self> where Self: 'graph

Source

type EdgeMut<'graph>: EdgeMut<'graph, Graph = Self> where Self: 'graph

Required Methods§

Source

fn get_node_mut(&mut self, id: Self::NodeId) -> Option<Self::NodeMut<'_>>

Source

fn get_edge_mut(&mut self, id: Self::EdgeId) -> Option<Self::EdgeMut<'_>>

Provided Methods§

Source

fn merge_nodes( &mut self, keep: Self::NodeId, remove: Self::NodeId, direct_edge: Self::EdgeId, )
where Self: Sized,

Merges remove into keep at the graph-structural level.

  • Removes direct_edge (the edge from keep to remove) from both nodes’ incident edge sets.
  • Rehomes every outgoing edge of remove so that it originates from keep instead, updating both the edge record and the nodes’ edge sets.

The caller is responsible for any payload-level cleanup (e.g. removing remove from a parent list, transferring instruction lists, etc.).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<NodeId: Identifier, EdgeId: Identifier, NodeData, EdgeData> GraphMut for OwningGraph<NodeId, EdgeId, NodeData, EdgeData>

Source§

type NodeMut<'a> = NodeMutRef<'a, NodeId, EdgeId, NodeData, EdgeData> where Self: 'a

Source§

type EdgeMut<'a> = EdgeMutRef<'a, NodeId, EdgeId, NodeData, EdgeData> where Self: 'a