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§
Sourcefn is_transposed(&self) -> bool
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)
Sourcefn num_nodes(&self) -> usize
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.
Provided Methods§
Sourcefn has_node(&self, node_id: NodeId) -> bool
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
.
Sourcefn num_nodes_by_type(&self) -> Result<HashMap<NodeType, usize>>
fn num_nodes_by_type(&self) -> Result<HashMap<NodeType, usize>>
Returns the number of nodes of each type, if known.
Sourcefn actual_num_nodes(&self) -> Result<usize>
fn actual_num_nodes(&self) -> Result<usize>
Returns the number of nodes in the graph, if known.
Sourcefn num_arcs_by_type(&self) -> Result<HashMap<(NodeType, NodeType), usize>>
fn num_arcs_by_type(&self) -> Result<HashMap<(NodeType, NodeType), usize>>
Returns the number of arcs of each type, if known.
Sourcefn iter_nodes<'a>(
&'a self,
pl: impl ProgressLog + 'a,
) -> impl Iterator<Item = NodeId> + 'a
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.
Sourcefn par_iter_nodes<'a>(
&'a self,
pl: impl ConcurrentProgressLog + 'a,
) -> impl ParallelIterator<Item = NodeId> + 'awhere
Self: Sync,
fn par_iter_nodes<'a>(
&'a self,
pl: impl ConcurrentProgressLog + 'a,
) -> impl ParallelIterator<Item = NodeId> + 'awhere
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.