pub trait VisitableGraph {
type GData;
type NData: Clone;
type EData: Clone;
Show 44 methods
// Required methods
fn data(&self) -> &Self::GData;
fn node_data(
&self,
id: impl AsRef<NodeID>,
) -> Result<Cow<'static, Self::NData>>;
fn edge_data(
&self,
id: impl AsRef<EdgeID>,
) -> Result<Cow<'static, Self::EData>>;
fn is_empty(&self) -> bool;
fn node_count(&self) -> usize;
fn edge_count(&self) -> usize;
fn all_nodes(&self) -> Nodes;
fn all_edges(&self) -> Edges;
fn has_node(&self, id: impl AsRef<NodeID>) -> bool;
fn has_edge(&self, id: impl AsRef<EdgeID>) -> bool;
fn has_edge_from_to(
&self,
source: impl AsRef<NodeID>,
target: impl AsRef<NodeID>,
) -> bool;
fn has_edge_between(
&self,
a: impl AsRef<NodeID>,
b: impl AsRef<NodeID>,
) -> bool;
fn source(&self, id: impl AsRef<EdgeID>) -> Result<NodeID>;
fn target(&self, id: impl AsRef<EdgeID>) -> Result<NodeID>;
fn endpoints(&self, id: impl AsRef<EdgeID>) -> Result<(NodeID, NodeID)>;
fn out_edges(&self, id: impl AsRef<NodeID>) -> Result<Edges>;
fn in_edges(&self, id: impl AsRef<NodeID>) -> Result<Edges>;
fn incident_edges(&self, id: impl AsRef<NodeID>) -> Result<Edges>;
fn out_degree(&self, id: impl AsRef<NodeID>) -> Result<usize>;
fn in_degree(&self, id: impl AsRef<NodeID>) -> Result<usize>;
fn degree(&self, id: impl AsRef<NodeID>) -> Result<usize>;
fn successors(&self, id: impl AsRef<NodeID>) -> Result<Nodes>;
fn predecessors(&self, id: impl AsRef<NodeID>) -> Result<Nodes>;
fn neighbors(&self, id: impl AsRef<NodeID>) -> Result<Nodes>;
fn has_successors(&self, id: impl AsRef<NodeID>) -> Result<bool>;
fn has_predecessors(&self, id: impl AsRef<NodeID>) -> Result<bool>;
fn has_neighbors(&self, id: impl AsRef<NodeID>) -> Result<bool>;
fn all_roots(&self) -> Nodes;
fn all_leaves(&self) -> Nodes;
fn non_roots(&self) -> Nodes;
fn non_leaves(&self) -> Nodes;
fn all_internals(&self) -> Nodes;
fn is_leaf(&self, id: impl AsRef<NodeID>) -> Result<bool>;
fn is_root(&self, id: impl AsRef<NodeID>) -> Result<bool>;
fn is_internal(&self, id: impl AsRef<NodeID>) -> Result<bool>;
// Provided methods
fn elements(&self) -> Elements { ... }
fn edges_from_to(
&self,
source: impl AsRef<NodeID>,
target: impl AsRef<NodeID>,
) -> Result<Edges> { ... }
fn edges_between(
&self,
a: impl AsRef<NodeID>,
b: impl AsRef<NodeID>,
) -> Result<Edges> { ... }
fn edges_from_to_nodes(
&self,
sources: &Nodes,
targets: &Nodes,
) -> Result<Edges> { ... }
fn edges_between_nodes(&self, a: &Nodes, b: &Nodes) -> Result<Edges> { ... }
fn nodes_successors(&self, ids: &Nodes) -> Result<Nodes> { ... }
fn nodes_predecessors(&self, ids: &Nodes) -> Result<Nodes> { ... }
fn transitive_successors(&self, ids: &Nodes) -> Result<Nodes> { ... }
fn transitive_predecessors(&self, ids: &Nodes) -> Result<Nodes> { ... }
}Required Associated Types§
Required Methods§
Sourcefn node_data(&self, id: impl AsRef<NodeID>) -> Result<Cow<'static, Self::NData>>
fn node_data(&self, id: impl AsRef<NodeID>) -> Result<Cow<'static, Self::NData>>
Returns a reference to the node’s data.
Sourcefn edge_data(&self, id: impl AsRef<EdgeID>) -> Result<Cow<'static, Self::EData>>
fn edge_data(&self, id: impl AsRef<EdgeID>) -> Result<Cow<'static, Self::EData>>
Returns a reference to the edge’s data.
Sourcefn node_count(&self) -> usize
fn node_count(&self) -> usize
Returns the number of nodes in the graph.
Sourcefn edge_count(&self) -> usize
fn edge_count(&self) -> usize
Returns the number of edges in the graph.
Sourcefn has_node(&self, id: impl AsRef<NodeID>) -> bool
fn has_node(&self, id: impl AsRef<NodeID>) -> bool
Returns true if the graph contains the given node.
Sourcefn has_edge(&self, id: impl AsRef<EdgeID>) -> bool
fn has_edge(&self, id: impl AsRef<EdgeID>) -> bool
Returns true if the graph contains the given edge.
Sourcefn has_edge_from_to(
&self,
source: impl AsRef<NodeID>,
target: impl AsRef<NodeID>,
) -> bool
fn has_edge_from_to( &self, source: impl AsRef<NodeID>, target: impl AsRef<NodeID>, ) -> bool
Returns true if the graph contains an edge from source to target.
Sourcefn has_edge_between(&self, a: impl AsRef<NodeID>, b: impl AsRef<NodeID>) -> bool
fn has_edge_between(&self, a: impl AsRef<NodeID>, b: impl AsRef<NodeID>) -> bool
Returns true if the graph contains an edge between a and b,
regardless of direction.
Sourcefn source(&self, id: impl AsRef<EdgeID>) -> Result<NodeID>
fn source(&self, id: impl AsRef<EdgeID>) -> Result<NodeID>
Returns the source node of the edge.
Sourcefn target(&self, id: impl AsRef<EdgeID>) -> Result<NodeID>
fn target(&self, id: impl AsRef<EdgeID>) -> Result<NodeID>
Returns the target node of the edge.
Sourcefn endpoints(&self, id: impl AsRef<EdgeID>) -> Result<(NodeID, NodeID)>
fn endpoints(&self, id: impl AsRef<EdgeID>) -> Result<(NodeID, NodeID)>
Returns the endpoints of the edge.
Sourcefn out_edges(&self, id: impl AsRef<NodeID>) -> Result<Edges>
fn out_edges(&self, id: impl AsRef<NodeID>) -> Result<Edges>
Returns the out-edges of the node.
Sourcefn incident_edges(&self, id: impl AsRef<NodeID>) -> Result<Edges>
fn incident_edges(&self, id: impl AsRef<NodeID>) -> Result<Edges>
Returns the incident edges of the node.
Sourcefn out_degree(&self, id: impl AsRef<NodeID>) -> Result<usize>
fn out_degree(&self, id: impl AsRef<NodeID>) -> Result<usize>
Returns the number of out-edges of the node.
Sourcefn in_degree(&self, id: impl AsRef<NodeID>) -> Result<usize>
fn in_degree(&self, id: impl AsRef<NodeID>) -> Result<usize>
Returns the number of in-edges of the node.
Sourcefn degree(&self, id: impl AsRef<NodeID>) -> Result<usize>
fn degree(&self, id: impl AsRef<NodeID>) -> Result<usize>
Returns the number of incident edges of the node.
Sourcefn successors(&self, id: impl AsRef<NodeID>) -> Result<Nodes>
fn successors(&self, id: impl AsRef<NodeID>) -> Result<Nodes>
Returns the immediate successors of the node.
Sourcefn predecessors(&self, id: impl AsRef<NodeID>) -> Result<Nodes>
fn predecessors(&self, id: impl AsRef<NodeID>) -> Result<Nodes>
Returns the immediate predecessors of the node.
Sourcefn neighbors(&self, id: impl AsRef<NodeID>) -> Result<Nodes>
fn neighbors(&self, id: impl AsRef<NodeID>) -> Result<Nodes>
Returns the immediate neighbors of the node.
Sourcefn has_successors(&self, id: impl AsRef<NodeID>) -> Result<bool>
fn has_successors(&self, id: impl AsRef<NodeID>) -> Result<bool>
Returns true if the node has successors.
Sourcefn has_predecessors(&self, id: impl AsRef<NodeID>) -> Result<bool>
fn has_predecessors(&self, id: impl AsRef<NodeID>) -> Result<bool>
Returns true if the node has predecessors.
Sourcefn has_neighbors(&self, id: impl AsRef<NodeID>) -> Result<bool>
fn has_neighbors(&self, id: impl AsRef<NodeID>) -> Result<bool>
Returns true if the node has neighbors.
Sourcefn all_leaves(&self) -> Nodes
fn all_leaves(&self) -> Nodes
The set of all “leaves” (nodes with no successors) in the graph.
Sourcefn non_roots(&self) -> Nodes
fn non_roots(&self) -> Nodes
The set of all nodes that are not roots (i.e., nodes with at least one predecessor).
Sourcefn non_leaves(&self) -> Nodes
fn non_leaves(&self) -> Nodes
The set of all nodes that are not leaves (i.e., nodes with at least one successor).
Sourcefn all_internals(&self) -> Nodes
fn all_internals(&self) -> Nodes
The set of all nodes that are neither roots nor leaves (i.e., nodes with at least one predecessor and at least one successor).
Sourcefn is_leaf(&self, id: impl AsRef<NodeID>) -> Result<bool>
fn is_leaf(&self, id: impl AsRef<NodeID>) -> Result<bool>
Returns true if the node is a leaf (i.e., has no successors).
Provided Methods§
Sourcefn edges_from_to(
&self,
source: impl AsRef<NodeID>,
target: impl AsRef<NodeID>,
) -> Result<Edges>
fn edges_from_to( &self, source: impl AsRef<NodeID>, target: impl AsRef<NodeID>, ) -> Result<Edges>
Returns the edges that have the given source and target nodes.
Only returns more than one edge in the case of codirected edges.
Sourcefn edges_between(
&self,
a: impl AsRef<NodeID>,
b: impl AsRef<NodeID>,
) -> Result<Edges>
fn edges_between( &self, a: impl AsRef<NodeID>, b: impl AsRef<NodeID>, ) -> Result<Edges>
Returns the edges that have the given nodes as endpoints.
Only returns more than one edge in the case of parallel edges.
Sourcefn edges_from_to_nodes(&self, sources: &Nodes, targets: &Nodes) -> Result<Edges>
fn edges_from_to_nodes(&self, sources: &Nodes, targets: &Nodes) -> Result<Edges>
Returns the edges connecting the given source nodes to the given target nodes.
Sourcefn edges_between_nodes(&self, a: &Nodes, b: &Nodes) -> Result<Edges>
fn edges_between_nodes(&self, a: &Nodes, b: &Nodes) -> Result<Edges>
Returns the edges connecting the given sets of nodes.
Sourcefn nodes_successors(&self, ids: &Nodes) -> Result<Nodes>
fn nodes_successors(&self, ids: &Nodes) -> Result<Nodes>
Returns the immediate successors of all the given nodes.
Sourcefn nodes_predecessors(&self, ids: &Nodes) -> Result<Nodes>
fn nodes_predecessors(&self, ids: &Nodes) -> Result<Nodes>
Returns the immediate predecessors of all the given nodes.
Sourcefn transitive_successors(&self, ids: &Nodes) -> Result<Nodes>
fn transitive_successors(&self, ids: &Nodes) -> Result<Nodes>
Returns the transitive successors of all the given nodes (i.e., all the nodes reachable from the out-edges of the given nodes).
The given nodes will not be included unless they are also reachable from the out-edges of other nodes.
Sourcefn transitive_predecessors(&self, ids: &Nodes) -> Result<Nodes>
fn transitive_predecessors(&self, ids: &Nodes) -> Result<Nodes>
Returns the transitive predecessors of all the given nodes (i.e., all the nodes reachable from the in-edges of the given nodes).
The given nodes will not be included unless they are also reachable from the in-edges of other nodes.
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.