Skip to main content

GraphQuery

Trait GraphQuery 

Source
pub trait GraphQuery: GraphBase {
    // Required methods
    fn get_node(&self, index: NodeIndex) -> GraphResult<&Self::NodeData>;
    fn get_edge(&self, index: EdgeIndex) -> GraphResult<&Self::EdgeData>;
    fn edge_endpoints(
        &self,
        index: EdgeIndex,
    ) -> GraphResult<(NodeIndex, NodeIndex)>;
    fn neighbors(&self, node: NodeIndex) -> impl Iterator<Item = NodeIndex>;
    fn incident_edges(&self, node: NodeIndex) -> impl Iterator<Item = EdgeIndex>;
    fn has_edge(&self, from: NodeIndex, to: NodeIndex) -> bool;
    fn out_degree(&self, node: NodeIndex) -> GraphResult<usize>;
    fn nodes(&self) -> impl Iterator<Item = NodeRef<'_, Self::NodeData>>;
    fn edges(&self) -> impl Iterator<Item = EdgeRef<'_, Self::EdgeData>>;

    // Provided methods
    fn in_degree(&self, node: NodeIndex) -> GraphResult<usize> { ... }
    fn degree(&self, node: NodeIndex) -> GraphResult<usize> { ... }
}
Expand description

图查询 trait

定义图的只读查询操作

Required Methods§

Source

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

获取节点引用

Source

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

获取边引用

Source

fn edge_endpoints( &self, index: EdgeIndex, ) -> GraphResult<(NodeIndex, NodeIndex)>

获取边的端点

Source

fn neighbors(&self, node: NodeIndex) -> impl Iterator<Item = NodeIndex>

获取节点的出边邻居迭代器

Source

fn incident_edges(&self, node: NodeIndex) -> impl Iterator<Item = EdgeIndex>

获取节点的关联边迭代器

Source

fn has_edge(&self, from: NodeIndex, to: NodeIndex) -> bool

检查是否存在从 from 到 to 的边

Source

fn out_degree(&self, node: NodeIndex) -> GraphResult<usize>

获取节点的出度

Source

fn nodes(&self) -> impl Iterator<Item = NodeRef<'_, Self::NodeData>>

获取所有节点迭代器

Source

fn edges(&self) -> impl Iterator<Item = EdgeRef<'_, Self::EdgeData>>

获取所有边迭代器

Provided Methods§

Source

fn in_degree(&self, node: NodeIndex) -> GraphResult<usize>

获取节点的入度(有向图)

Source

fn degree(&self, node: NodeIndex) -> GraphResult<usize>

获取节点的总度数

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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