Struct GraphQuery

Source
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>

Source

pub fn new(ir: &'a StableGraph<N, E>) -> Self

Creates a new GraphQuery from a reference to a StableGraph.

Source

pub fn get_node(&self, x: NodeIndex) -> Option<&N>

Gets a node from its index.

Source

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.

Source

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,

Source

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
Source

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.
Source

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.
Source

pub fn get_ordered_operands( &self, index: NodeIndex, ) -> Result<Vec<NodeIndex>, GraphQueryError>

Returns the unordered operands to the given operation.

§Remarks

The operands node indices are returned in 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.

Trait Implementations§

Source§

impl<'a, N, E> From<&'a StableGraph<N, E>> for GraphQuery<'a, N, E>

Source§

fn from(x: &'a StableGraph<N, E>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, N, E> Freeze for GraphQuery<'a, N, E>

§

impl<'a, N, E> RefUnwindSafe for GraphQuery<'a, N, E>

§

impl<'a, N, E> Send for GraphQuery<'a, N, E>
where N: Sync, E: Sync,

§

impl<'a, N, E> Sync for GraphQuery<'a, N, E>
where N: Sync, E: Sync,

§

impl<'a, N, E> Unpin for GraphQuery<'a, N, E>

§

impl<'a, N, E> UnwindSafe for GraphQuery<'a, N, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.