pub struct CsrView<W> { /* private fields */ }Expand description
A frozen, read-optimised copy of a graph.
§Examples
use xgraph::core::{CsrView, GraphView, ShortestPath};
use xgraph::graph::Graph;
let mut graph = Graph::<u32, &str, &str>::new(false);
let a = graph.add_node("A");
let b = graph.add_node("B");
graph.add_edge(a, b, 5, "rail").unwrap();
let frozen = CsrView::from_view(&graph);
assert_eq!(frozen.node_count(), 2);
// Algorithms are written against the abstraction, so they apply unchanged.
assert_eq!(frozen.dijkstra(a).unwrap()[&b], 5);Implementations§
Trait Implementations§
Source§impl<W: Copy> GraphView for CsrView<W>
impl<W: Copy> GraphView for CsrView<W>
Source§type NodeIds<'a> = CsrNodeIds<'a>
where
Self: 'a
type NodeIds<'a> = CsrNodeIds<'a> where Self: 'a
The iterator
node_ids returns.Source§fn is_directed(&self) -> bool
fn is_directed(&self) -> bool
Whether edges are one-way.
Source§fn node_count(&self) -> usize
fn node_count(&self) -> usize
The number of nodes in the graph.
Source§fn edge_count(&self) -> usize
fn edge_count(&self) -> usize
The number of edges in the graph, counting parallel edges separately.
Source§fn contains_node(&self, node: NodeId) -> bool
fn contains_node(&self, node: NodeId) -> bool
Whether a node with this ID exists.
Source§fn node_ids(&self) -> Self::NodeIds<'_>
fn node_ids(&self) -> Self::NodeIds<'_>
Every node ID in the graph, in ascending order. Read more
Source§fn links(&self, node: NodeId) -> Self::Links<'_>
fn links(&self, node: NodeId) -> Self::Links<'_>
Every connection leading out of
node, one per incident edge. Read moreSource§fn edge_endpoints(&self, edge: EdgeId) -> Option<(NodeId, NodeId)>
fn edge_endpoints(&self, edge: EdgeId) -> Option<(NodeId, NodeId)>
The endpoints of an edge, as stored. Read more
Auto Trait Implementations§
impl<W> Freeze for CsrView<W>
impl<W> RefUnwindSafe for CsrView<W>
impl<W> Send for CsrView<W>
impl<W> Sync for CsrView<W>
impl<W> Unpin for CsrView<W>
impl<W> UnsafeUnpin for CsrView<W>
impl<W> UnwindSafe for CsrView<W>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<G> Bridges for G
impl<G> Bridges for G
Source§fn articulation_points(&self) -> Result<Vec<NodeId>, TraversalError>
fn articulation_points(&self) -> Result<Vec<NodeId>, TraversalError>
Finds every articulation point: a node whose removal splits a component. Read more
Source§fn bridge_edges(&self) -> Result<Vec<EdgeId>, TraversalError>
fn bridge_edges(&self) -> Result<Vec<EdgeId>, TraversalError>
Finds every bridge, identified by edge. Read more
Source§fn bridges(&self) -> Result<Vec<(NodeId, NodeId)>, TraversalError>
fn bridges(&self) -> Result<Vec<(NodeId, NodeId)>, TraversalError>
Finds every bridge, identified by its endpoints. Read more
Source§fn tarjan_from(
&self,
root: NodeId,
state: &mut TarjanState,
) -> Result<(), TraversalError>
fn tarjan_from( &self, root: NodeId, state: &mut TarjanState, ) -> Result<(), TraversalError>
Runs Tarjan’s depth-first sweep over the component containing
root.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<G> Centrality for G
impl<G> Centrality for G
Source§fn degree_centrality(&self) -> HashMap<NodeId, usize>
fn degree_centrality(&self) -> HashMap<NodeId, usize>
Degree centrality: the number of edges incident to each node. Read more
Source§fn betweenness_centrality(
&self,
) -> Result<HashMap<NodeId, f64>, CentralityError>
fn betweenness_centrality( &self, ) -> Result<HashMap<NodeId, f64>, CentralityError>
Betweenness centrality: how often each node lies on a shortest path between others. Read more
Source§fn par_betweenness_centrality(
&self,
) -> Result<HashMap<NodeId, f64>, CentralityError>where
Self: Sync,
fn par_betweenness_centrality(
&self,
) -> Result<HashMap<NodeId, f64>, CentralityError>where
Self: Sync,
Betweenness centrality, with the per-source sweeps shared across cores. Read more
Source§fn closeness_centrality(&self) -> Result<HashMap<NodeId, f64>, CentralityError>
fn closeness_centrality(&self) -> Result<HashMap<NodeId, f64>, CentralityError>
Closeness centrality: how near each node is to all the nodes it can reach. Read more
Source§fn par_closeness_centrality(
&self,
) -> Result<HashMap<NodeId, f64>, CentralityError>where
Self: Sync,
fn par_closeness_centrality(
&self,
) -> Result<HashMap<NodeId, f64>, CentralityError>where
Self: Sync,
Closeness centrality, with the per-source sweeps shared across cores. Read more
Source§fn eigenvector_centrality(
&self,
max_iter: usize,
tolerance: f64,
) -> Result<HashMap<NodeId, f64>, CentralityError>
fn eigenvector_centrality( &self, max_iter: usize, tolerance: f64, ) -> Result<HashMap<NodeId, f64>, CentralityError>
Eigenvector centrality: a node is important when its neighbours are important. Read more
Source§fn pagerank(
&self,
damping: f64,
max_iter: usize,
tolerance: f64,
) -> Result<HashMap<NodeId, f64>, CentralityError>
fn pagerank( &self, damping: f64, max_iter: usize, tolerance: f64, ) -> Result<HashMap<NodeId, f64>, CentralityError>
PageRank: the stationary distribution of a random walk that teleports. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<G> CommunityDetection for G
impl<G> CommunityDetection for G
Source§fn detect_communities(
&self,
gamma: f64,
) -> Result<HashMap<usize, Vec<NodeId>>, CommunityDetectionError>
fn detect_communities( &self, gamma: f64, ) -> Result<HashMap<usize, Vec<NodeId>>, CommunityDetectionError>
Detects communities with the given resolution and otherwise default settings. Read more
Source§fn detect_communities_with_config(
&self,
config: CommunityConfig,
) -> Result<HashMap<usize, Vec<NodeId>>, CommunityDetectionError>
fn detect_communities_with_config( &self, config: CommunityConfig, ) -> Result<HashMap<usize, Vec<NodeId>>, CommunityDetectionError>
Detects communities with full control over the algorithm’s settings.
Source§impl<G> Connectivity for G
impl<G> Connectivity for G
Source§fn predecessors(&self) -> Predecessors
fn predecessors(&self) -> Predecessors
Builds the reverse adjacency of the graph. Read more
Source§fn weakly_connected_components(
&self,
) -> Result<Vec<Vec<NodeId>>, TraversalError>
fn weakly_connected_components( &self, ) -> Result<Vec<Vec<NodeId>>, TraversalError>
Finds the weakly connected components: those of the graph with direction ignored. Read more
Source§fn strongly_connected_components(
&self,
) -> Result<Vec<Vec<NodeId>>, TraversalError>
fn strongly_connected_components( &self, ) -> Result<Vec<Vec<NodeId>>, TraversalError>
Finds the strongly connected components using Kosaraju’s algorithm. Read more
Source§fn connected_components(&self) -> Result<Vec<Vec<NodeId>>, TraversalError>
fn connected_components(&self) -> Result<Vec<Vec<NodeId>>, TraversalError>
Finds the components appropriate to the graph’s directionality. Read more
Source§fn is_weakly_connected(&self) -> Result<bool, TraversalError>
fn is_weakly_connected(&self) -> Result<bool, TraversalError>
Whether the graph is in one piece once direction is ignored. Read more
Source§fn is_strongly_connected(&self) -> Result<bool, TraversalError>
fn is_strongly_connected(&self) -> Result<bool, TraversalError>
Whether every node can reach every other node along edge directions. Read more
Source§fn is_connected(&self) -> Result<bool, TraversalError>
fn is_connected(&self) -> Result<bool, TraversalError>
Whether the graph is connected in the sense appropriate to its directionality.
Source§impl<G> DominatingSet for G
impl<G> DominatingSet for G
Source§fn dominating_set(&self) -> Result<HashSet<NodeId>, TraversalError>
fn dominating_set(&self) -> Result<HashSet<NodeId>, TraversalError>
Finds a dominating set greedily. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<G> ShortestPath for G
impl<G> ShortestPath for G
Source§fn dijkstra(
&self,
start: NodeId,
) -> Result<HashMap<NodeId, Self::Weight>, ShortestPathError>
fn dijkstra( &self, start: NodeId, ) -> Result<HashMap<NodeId, Self::Weight>, ShortestPathError>
Shortest-path distances from
start to every reachable node. Read moreSource§fn dijkstra_with_predecessors(
&self,
start: NodeId,
) -> Result<(HashMap<NodeId, Self::Weight>, HashMap<NodeId, NodeId>), ShortestPathError>
fn dijkstra_with_predecessors( &self, start: NodeId, ) -> Result<(HashMap<NodeId, Self::Weight>, HashMap<NodeId, NodeId>), ShortestPathError>
Shortest-path distances together with the predecessor tree. Read more
Source§impl<G> SpanningTree for G
impl<G> SpanningTree for G
Source§fn minimum_spanning_forest(&self) -> Result<Vec<EdgeId>, TraversalError>where
Self::Weight: PartialOrd,
fn minimum_spanning_forest(&self) -> Result<Vec<EdgeId>, TraversalError>where
Self::Weight: PartialOrd,
Finds a minimum spanning forest with Kruskal’s algorithm. Read more
Source§fn minimum_spanning_weight(
&self,
) -> Result<Option<Self::Weight>, TraversalError>
fn minimum_spanning_weight( &self, ) -> Result<Option<Self::Weight>, TraversalError>
The total weight of a minimum spanning forest. Read more
Source§impl<G> ToDot for G
impl<G> ToDot for G
Source§impl<G> TopologicalSort for G
impl<G> TopologicalSort for G
Source§impl<G> Traversal for G
impl<G> Traversal for G
Source§fn explore_into(
&self,
start: NodeId,
stop_at: Option<NodeId>,
visited: &mut HashSet<NodeId>,
) -> Result<bool, TraversalError>
fn explore_into( &self, start: NodeId, stop_at: Option<NodeId>, visited: &mut HashSet<NodeId>, ) -> Result<bool, TraversalError>
Source§fn reachable_from(
&self,
start: NodeId,
) -> Result<HashSet<NodeId>, TraversalError>
fn reachable_from( &self, start: NodeId, ) -> Result<HashSet<NodeId>, TraversalError>
Returns every node reachable from
start, including start itself.Source§fn bfs_path(
&self,
start: NodeId,
target: NodeId,
) -> Result<Option<Vec<NodeId>>, TraversalError>
fn bfs_path( &self, start: NodeId, target: NodeId, ) -> Result<Option<Vec<NodeId>>, TraversalError>
Source§fn dfs_preorder_into(
&self,
start: NodeId,
visited: &mut HashSet<NodeId>,
order: &mut Vec<NodeId>,
) -> Result<(), TraversalError>
fn dfs_preorder_into( &self, start: NodeId, visited: &mut HashSet<NodeId>, order: &mut Vec<NodeId>, ) -> Result<(), TraversalError>
Visits every node reachable from
start in depth-first pre-order. Read moreSource§fn dfs_postorder_into(
&self,
start: NodeId,
visited: &mut HashSet<NodeId>,
order: &mut Vec<NodeId>,
) -> Result<(), TraversalError>
fn dfs_postorder_into( &self, start: NodeId, visited: &mut HashSet<NodeId>, order: &mut Vec<NodeId>, ) -> Result<(), TraversalError>
Visits every node reachable from
start in depth-first post-order. Read moreSource§fn has_cycle(&self) -> Result<bool, TraversalError>
fn has_cycle(&self) -> Result<bool, TraversalError>
Detects whether the graph contains a cycle. Read more
Source§fn has_cycle_from(
&self,
root: NodeId,
visited: &mut HashSet<NodeId>,
) -> Result<bool, TraversalError>
fn has_cycle_from( &self, root: NodeId, visited: &mut HashSet<NodeId>, ) -> Result<bool, TraversalError>
Detects a cycle in the component reachable from
root. Read more