pub struct Graph { /* private fields */ }Expand description
Validated immutable graph used by every native algorithm.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn betweenness_centrality(
&self,
options: BetweennessOptions,
) -> Result<Vec<NodeScore>, GraphError>
pub fn betweenness_centrality( &self, options: BetweennessOptions, ) -> Result<Vec<NodeScore>, GraphError>
Compute node betweenness centrality with NetworkX-compatible scaling.
Sourcepub fn edge_betweenness_centrality(
&self,
options: BetweennessOptions,
) -> Result<Vec<EdgeScore>, GraphError>
pub fn edge_betweenness_centrality( &self, options: BetweennessOptions, ) -> Result<Vec<EdgeScore>, GraphError>
Compute edge betweenness centrality, retaining parallel-edge identity.
Source§impl Graph
impl Graph
Sourcepub fn simple_cycles(&self, options: CycleOptions) -> CycleResult
pub fn simple_cycles(&self, options: CycleOptions) -> CycleResult
Enumerate bounded simple cycles with in-search pruning.
Source§impl Graph
impl Graph
Sourcepub fn spring_layout(
&self,
options: LayoutOptions,
) -> Result<Vec<NodePosition>, GraphError>
pub fn spring_layout( &self, options: LayoutOptions, ) -> Result<Vec<NodePosition>, GraphError>
Compute deterministic Fruchterman-Reingold positions.
This exact kernel is quadratic in node count per iteration. It is intentionally explicit rather than silently switching to an approximate layout for larger graphs.
Source§impl Graph
impl Graph
Sourcepub fn leiden(&self, options: LeidenOptions) -> Result<LeidenResult, GraphError>
pub fn leiden(&self, options: LeidenOptions) -> Result<LeidenResult, GraphError>
Compute weighted Leiden communities with connected refinement.
Source§impl Graph
impl Graph
Sourcepub fn louvain_communities(
&self,
options: LouvainOptions,
) -> Result<CommunityResult, GraphError>
pub fn louvain_communities( &self, options: LouvainOptions, ) -> Result<CommunityResult, GraphError>
Compute a deterministic weighted multi-level Louvain partition.
Source§impl Graph
impl Graph
Sourcepub fn traverse(
&self,
options: &TraversalOptions,
) -> Result<TraversalResult, GraphError>
pub fn traverse( &self, options: &TraversalOptions, ) -> Result<TraversalResult, GraphError>
Execute deterministic BFS or DFS over the loaded graph.
Sourcepub fn degree(
&self,
node_id: impl Into<ExternalId>,
kind: DegreeKind,
) -> Result<NodeDegree, GraphError>
pub fn degree( &self, node_id: impl Into<ExternalId>, kind: DegreeKind, ) -> Result<NodeDegree, GraphError>
Compute one node degree.
Sourcepub fn degrees(&self, kind: DegreeKind) -> Vec<NodeDegree>
pub fn degrees(&self, kind: DegreeKind) -> Vec<NodeDegree>
Compute degrees for all nodes in deterministic ID order.
Sourcepub fn shortest_path(
&self,
source: impl Into<ExternalId>,
target: impl Into<ExternalId>,
direction: TraversalDirection,
allowed_labels: &BTreeSet<String>,
max_depth: Option<usize>,
) -> PathResult
pub fn shortest_path( &self, source: impl Into<ExternalId>, target: impl Into<ExternalId>, direction: TraversalDirection, allowed_labels: &BTreeSet<String>, max_depth: Option<usize>, ) -> PathResult
Find an unweighted shortest path in the loaded graph.
Sourcepub fn neighbors(
&self,
node_id: impl Into<ExternalId>,
direction: TraversalDirection,
) -> Result<Vec<ExternalId>, GraphError>
pub fn neighbors( &self, node_id: impl Into<ExternalId>, direction: TraversalDirection, ) -> Result<Vec<ExternalId>, GraphError>
Deterministic neighboring node IDs.
Sourcepub fn successors(
&self,
node_id: impl Into<ExternalId>,
) -> Result<Vec<ExternalId>, GraphError>
pub fn successors( &self, node_id: impl Into<ExternalId>, ) -> Result<Vec<ExternalId>, GraphError>
Deterministic successors under the graph’s direction semantics.
Sourcepub fn predecessors(
&self,
node_id: impl Into<ExternalId>,
) -> Result<Vec<ExternalId>, GraphError>
pub fn predecessors( &self, node_id: impl Into<ExternalId>, ) -> Result<Vec<ExternalId>, GraphError>
Deterministic predecessors under the graph’s direction semantics.
Sourcepub fn out_edge_ids(
&self,
node_id: impl Into<ExternalId>,
) -> Result<Vec<EdgeId>, GraphError>
pub fn out_edge_ids( &self, node_id: impl Into<ExternalId>, ) -> Result<Vec<EdgeId>, GraphError>
Stable IDs of outgoing edges. Undirected graphs return every incident edge exactly once.
Sourcepub fn in_edge_ids(
&self,
node_id: impl Into<ExternalId>,
) -> Result<Vec<EdgeId>, GraphError>
pub fn in_edge_ids( &self, node_id: impl Into<ExternalId>, ) -> Result<Vec<EdgeId>, GraphError>
Stable IDs of incoming edges. Undirected graphs return every incident edge exactly once.
Sourcepub fn incident_edge_ids(
&self,
node_id: impl Into<ExternalId>,
) -> Result<Vec<EdgeId>, GraphError>
pub fn incident_edge_ids( &self, node_id: impl Into<ExternalId>, ) -> Result<Vec<EdgeId>, GraphError>
Stable IDs of all incident edges, with self-loops returned once.
Sourcepub fn edges_between(
&self,
source: impl Into<ExternalId>,
target: impl Into<ExternalId>,
direction: TraversalDirection,
) -> Result<Vec<EdgeId>, GraphError>
pub fn edges_between( &self, source: impl Into<ExternalId>, target: impl Into<ExternalId>, direction: TraversalDirection, ) -> Result<Vec<EdgeId>, GraphError>
All stable edge IDs between two nodes under the selected direction.
Sourcepub fn has_edge_between(
&self,
source: impl Into<ExternalId>,
target: impl Into<ExternalId>,
direction: TraversalDirection,
) -> Result<bool, GraphError>
pub fn has_edge_between( &self, source: impl Into<ExternalId>, target: impl Into<ExternalId>, direction: TraversalDirection, ) -> Result<bool, GraphError>
Whether at least one edge connects an endpoint pair under the selected traversal direction.
Source§impl Graph
impl Graph
Sourcepub fn new(
kind: GraphKind,
nodes: impl IntoIterator<Item = Node>,
edges: impl IntoIterator<Item = Edge>,
) -> Result<Graph, GraphError>
pub fn new( kind: GraphKind, nodes: impl IntoIterator<Item = Node>, edges: impl IntoIterator<Item = Edge>, ) -> Result<Graph, GraphError>
Validate and construct a graph.
Sourcepub fn with_attributes(
kind: GraphKind,
graph_attributes: BTreeMap<String, Value>,
nodes: impl IntoIterator<Item = Node>,
edges: impl IntoIterator<Item = Edge>,
) -> Result<Graph, GraphError>
pub fn with_attributes( kind: GraphKind, graph_attributes: BTreeMap<String, Value>, nodes: impl IntoIterator<Item = Node>, edges: impl IntoIterator<Item = Edge>, ) -> Result<Graph, GraphError>
Validate and construct a graph with graph-level metadata.
Sourcepub fn is_directed(&self) -> bool
pub fn is_directed(&self) -> bool
Whether the graph is directed.
Sourcepub fn is_multigraph(&self) -> bool
pub fn is_multigraph(&self) -> bool
Whether the graph declares support for parallel endpoint-pair edges.
Sourcepub fn attributes(&self) -> &BTreeMap<String, Value>
pub fn attributes(&self) -> &BTreeMap<String, Value>
Graph-level immutable attributes.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of stored edges. Undirected adjacency does not duplicate this public edge count.
Sourcepub fn contains_node(&self, id: impl Into<ExternalId>) -> bool
pub fn contains_node(&self, id: impl Into<ExternalId>) -> bool
Whether the graph contains a node.
Sourcepub fn contains_edge(&self, id: impl Into<EdgeId>) -> bool
pub fn contains_edge(&self, id: impl Into<EdgeId>) -> bool
Whether the graph contains an edge.
Source§impl Graph
impl Graph
Sourcepub fn to_directed(&self) -> Result<Graph, GraphError>
pub fn to_directed(&self) -> Result<Graph, GraphError>
Materialize directed traversal semantics without losing undirected edges or graph metadata.
Sourcepub fn to_undirected(&self) -> Result<Graph, GraphError>
pub fn to_undirected(&self) -> Result<Graph, GraphError>
Return an immutable graph with undirected traversal semantics while preserving every original edge record and graph attribute.
Sourcepub fn induced_subgraph(
&self,
node_ids: impl IntoIterator<Item = impl Into<ExternalId>>,
) -> Result<Graph, GraphError>
pub fn induced_subgraph( &self, node_ids: impl IntoIterator<Item = impl Into<ExternalId>>, ) -> Result<Graph, GraphError>
Materialize an induced subgraph containing exactly the requested nodes and edges whose endpoints are both selected.
Sourcepub fn relabel(
&self,
mapping: &BTreeMap<ExternalId, ExternalId>,
) -> Result<Graph, GraphError>
pub fn relabel( &self, mapping: &BTreeMap<ExternalId, ExternalId>, ) -> Result<Graph, GraphError>
Return a graph with external node IDs replaced and every endpoint rewired. Distinct nodes may not merge implicitly.