pub struct GraphQuery<'a, N, E>(/* private fields */);
Expand description
A wrapper for ascertaining the structure of the underlying graph.
This type is used in forward_traverse
and
reverse_traverse
callbacks.
Implementations§
Source§impl<'a, N, E> GraphQuery<'a, N, E>
impl<'a, N, E> GraphQuery<'a, N, E>
Sourcepub fn new(ir: &'a StableGraph<N, E>) -> Self
pub fn new(ir: &'a StableGraph<N, E>) -> Self
Creates a new GraphQuery
from a reference to a
StableGraph
.
Sourcepub fn neighbors_directed(
&self,
x: NodeIndex,
direction: Direction,
) -> Neighbors<'_, E>
pub fn neighbors_directed( &self, x: NodeIndex, direction: Direction, ) -> Neighbors<'_, E>
Gets information about the immediate parent or child nodes of the node at the given index.
§Remarks
Direction::Outgoing
gives children, while
Direction::Incoming
gives parents.
Sourcepub fn edges_directed(
&self,
x: NodeIndex,
direction: Direction,
) -> Edges<'_, E, Directed>
pub fn edges_directed( &self, x: NodeIndex, direction: Direction, ) -> Edges<'_, E, Directed>
Gets edges pointing at the parent or child nodes of the node at the given index.
§Remarks
Direction::Outgoing
gives children, while
Direction::Incoming
gives parents.
Source§impl<'a, O> GraphQuery<'a, NodeInfo<O>, EdgeInfo>where
O: Operation,
impl<'a, O> GraphQuery<'a, NodeInfo<O>, EdgeInfo>where
O: Operation,
Sourcepub fn get_binary_operands(
&self,
index: NodeIndex,
) -> Result<(NodeIndex, NodeIndex), GraphQueryError>
pub fn get_binary_operands( &self, index: NodeIndex, ) -> Result<(NodeIndex, NodeIndex), GraphQueryError>
Returns the left and right node indices to a binary operation.
§Errors
- No node exists at the given index.
- The node at the given index isn’t a binary operation.
- The node at the given index doesn’t have a 1 left and 1 right parent
Sourcepub fn get_unary_operand(
&self,
index: NodeIndex,
) -> Result<NodeIndex, GraphQueryError>
pub fn get_unary_operand( &self, index: NodeIndex, ) -> Result<NodeIndex, GraphQueryError>
Returns the unary operand node index to a unary operation.
§Errors
- No node exists at the given index.
- The node at the given index isn’t a unary operation.
- The node at the given index doesn’t have a single unary operand.
Sourcepub fn get_unordered_operands(
&self,
index: NodeIndex,
) -> Result<Vec<NodeIndex>, GraphQueryError>
pub fn get_unordered_operands( &self, index: NodeIndex, ) -> Result<Vec<NodeIndex>, GraphQueryError>
Returns the unordered operands to the given operation.
§Remarks
As these operands are unordered, their order is undefined. Use
EdgeInfo::Ordered
and call
GraphQuery::get_ordered_operands
if you need a defined order.
§Errors
- No node exists at the given index.
- The node at the given index isn’t a unary operation.
- The node at the given index doesn’t have a single unary operand.