Trait SwhGraph

Source
pub trait SwhGraph {
    // Required methods
    fn path(&self) -> &Path;
    fn is_transposed(&self) -> bool;
    fn num_nodes(&self) -> usize;
    fn num_arcs(&self) -> u64;
    fn has_arc(&self, src_node_id: NodeId, dst_node_id: NodeId) -> bool;

    // Provided methods
    fn has_node(&self, node_id: NodeId) -> bool { ... }
    fn num_nodes_by_type(&self) -> Result<HashMap<NodeType, usize>> { ... }
    fn actual_num_nodes(&self) -> Result<usize> { ... }
    fn num_arcs_by_type(&self) -> Result<HashMap<(NodeType, NodeType), usize>> { ... }
    fn iter_nodes<'a>(
        &'a self,
        pl: impl ProgressLog + 'a,
    ) -> impl Iterator<Item = NodeId> + 'a { ... }
    fn par_iter_nodes<'a>(
        &'a self,
        pl: impl ConcurrentProgressLog + 'a,
    ) -> impl ParallelIterator<Item = NodeId> + 'a
       where Self: Sync { ... }
}

Required Methods§

Source

fn path(&self) -> &Path

Return the base path of the graph

Source

fn is_transposed(&self) -> bool

Returns whether the graph is in the ori->snp->rel,rev->dir->cnt direction (with a few dir->rev arcs)

Source

fn num_nodes(&self) -> usize

Return the largest node id in the graph plus one.

For graphs directly loaded from disk this is the actual number of nodes, but it is an overestimate for some graphs (eg. Subgraph).

Use actual_num_nodes if you need the exact number of nodes in the graph.

Source

fn num_arcs(&self) -> u64

Return the number of arcs in the graph.

Source

fn has_arc(&self, src_node_id: NodeId, dst_node_id: NodeId) -> bool

Return whether there is an arc going from src_node_id to dst_node_id.

Provided Methods§

Source

fn has_node(&self, node_id: NodeId) -> bool

Returns whether the given node id exists in the graph

This is usually true iff node_id < self.num_nodes(), but may be false when using a filtered view such as Subgraph.

Source

fn num_nodes_by_type(&self) -> Result<HashMap<NodeType, usize>>

Returns the number of nodes of each type, if known.

Source

fn actual_num_nodes(&self) -> Result<usize>

Returns the number of nodes in the graph, if known.

Source

fn num_arcs_by_type(&self) -> Result<HashMap<(NodeType, NodeType), usize>>

Returns the number of arcs of each type, if known.

Source

fn iter_nodes<'a>( &'a self, pl: impl ProgressLog + 'a, ) -> impl Iterator<Item = NodeId> + 'a

Returns an iterator on all the nodes

Order is not guaranteed.

Updates the progress logger on every node id from 0 to self.num_nodes(), even those that are filtered out.

Source

fn par_iter_nodes<'a>( &'a self, pl: impl ConcurrentProgressLog + 'a, ) -> impl ParallelIterator<Item = NodeId> + 'a
where Self: Sync,

Returns a parallel iterator on all the nodes

Order is not guaranteed.

Updates the progress logger on every node id from 0 to self.num_nodes(), even those that are filtered out.

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<G: SwhGraph> SwhGraph for GraphSpy<G>

Source§

impl<G: SwhGraph> SwhGraph for Transposed<G>

Source§

impl<G: SwhGraph, NodeFilter: Fn(usize) -> bool, ArcFilter: Fn(usize, usize) -> bool> SwhGraph for Subgraph<G, NodeFilter, ArcFilter>

Source§

impl<P, FG: UnderlyingGraph, BG: UnderlyingGraph> SwhGraph for SwhBidirectionalGraph<P, FG, BG>

Source§

impl<P, G: UnderlyingGraph> SwhGraph for SwhUnidirectionalGraph<P, G>

Source§

impl<T: Deref> SwhGraph for T
where <T as Deref>::Target: SwhGraph,