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§
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 Methods§
Sourcefn merge_nodes(
&mut self,
keep: Self::NodeId,
remove: Self::NodeId,
direct_edge: Self::EdgeId,
)where
Self: Sized,
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 fromkeeptoremove) from both nodes’ incident edge sets. - Rehomes every outgoing edge of
removeso that it originates fromkeepinstead, 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".