Skip to main content

Graph

Struct Graph 

Source
pub struct Graph { /* private fields */ }
Expand description

Validated immutable graph used by every native algorithm.

Implementations§

Source§

impl Graph

Source

pub fn betweenness_centrality( &self, options: BetweennessOptions, ) -> Result<Vec<NodeScore>, GraphError>

Compute node betweenness centrality with NetworkX-compatible scaling.

Source

pub fn edge_betweenness_centrality( &self, options: BetweennessOptions, ) -> Result<Vec<EdgeScore>, GraphError>

Compute edge betweenness centrality, retaining parallel-edge identity.

Source§

impl Graph

Source

pub fn simple_cycles(&self, options: CycleOptions) -> CycleResult

Enumerate bounded simple cycles with in-search pruning.

Source§

impl Graph

Source

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

Source

pub fn leiden(&self, options: LeidenOptions) -> Result<LeidenResult, GraphError>

Compute weighted Leiden communities with connected refinement.

Source§

impl Graph

Source

pub fn louvain_communities( &self, options: LouvainOptions, ) -> Result<CommunityResult, GraphError>

Compute a deterministic weighted multi-level Louvain partition.

Source§

impl Graph

Source

pub fn traverse( &self, options: &TraversalOptions, ) -> Result<TraversalResult, GraphError>

Execute deterministic BFS or DFS over the loaded graph.

Source

pub fn degree( &self, node_id: impl Into<NodeId>, kind: DegreeKind, ) -> Result<NodeDegree, GraphError>

Compute one node degree.

Source

pub fn degrees(&self, kind: DegreeKind) -> Vec<NodeDegree>

Compute degrees for all nodes in deterministic ID order.

Source

pub fn shortest_path( &self, source: impl Into<NodeId>, target: impl Into<NodeId>, direction: TraversalDirection, allowed_labels: &BTreeSet<String>, max_depth: Option<usize>, ) -> PathResult

Find an unweighted shortest path in the loaded graph.

Source

pub fn neighbors( &self, node_id: impl Into<NodeId>, direction: TraversalDirection, ) -> Result<Vec<NodeId>, GraphError>

Deterministic neighboring node IDs.

Source

pub fn successors( &self, node_id: impl Into<NodeId>, ) -> Result<Vec<NodeId>, GraphError>

Deterministic successors under the graph’s direction semantics.

Source

pub fn predecessors( &self, node_id: impl Into<NodeId>, ) -> Result<Vec<NodeId>, GraphError>

Deterministic predecessors under the graph’s direction semantics.

Source

pub fn out_edge_ids( &self, node_id: impl Into<NodeId>, ) -> Result<Vec<EdgeId>, GraphError>

Stable IDs of outgoing edges. Undirected graphs return every incident edge exactly once.

Source

pub fn in_edge_ids( &self, node_id: impl Into<NodeId>, ) -> Result<Vec<EdgeId>, GraphError>

Stable IDs of incoming edges. Undirected graphs return every incident edge exactly once.

Source

pub fn incident_edge_ids( &self, node_id: impl Into<NodeId>, ) -> Result<Vec<EdgeId>, GraphError>

Stable IDs of all incident edges, with self-loops returned once.

Source

pub fn edges_between( &self, source: impl Into<NodeId>, target: impl Into<NodeId>, direction: TraversalDirection, ) -> Result<Vec<EdgeId>, GraphError>

All stable edge IDs between two nodes under the selected direction.

Source

pub fn has_edge_between( &self, source: impl Into<NodeId>, target: impl Into<NodeId>, direction: TraversalDirection, ) -> Result<bool, GraphError>

Whether at least one edge connects an endpoint pair under the selected traversal direction.

Source§

impl Graph

Source

pub fn new( kind: GraphKind, nodes: impl IntoIterator<Item = Node>, edges: impl IntoIterator<Item = Edge>, ) -> Result<Self, GraphError>

Validate and construct a graph.

Source

pub fn with_attributes( kind: GraphKind, graph_attributes: Attributes, nodes: impl IntoIterator<Item = Node>, edges: impl IntoIterator<Item = Edge>, ) -> Result<Self, GraphError>

Validate and construct a graph with graph-level metadata.

Source

pub fn kind(&self) -> GraphKind

Declared graph topology contract.

Source

pub fn is_directed(&self) -> bool

Whether the graph is directed.

Source

pub fn is_multigraph(&self) -> bool

Whether the graph declares support for parallel endpoint-pair edges.

Source

pub fn attributes(&self) -> &Attributes

Graph-level immutable attributes.

Source

pub fn node_count(&self) -> usize

Number of nodes.

Source

pub fn edge_count(&self) -> usize

Number of stored edges. Undirected adjacency does not duplicate this public edge count.

Source

pub fn nodes(&self) -> &[Node]

Nodes in deterministic external-ID order.

Source

pub fn edges(&self) -> &[Edge]

Edges in deterministic stable-ID order.

Source

pub fn node(&self, id: impl Into<NodeId>) -> Option<&Node>

Look up a node.

Source

pub fn edge(&self, id: impl Into<EdgeId>) -> Option<&Edge>

Look up an edge.

Source

pub fn contains_node(&self, id: impl Into<NodeId>) -> bool

Whether the graph contains a node.

Source

pub fn contains_edge(&self, id: impl Into<EdgeId>) -> bool

Whether the graph contains an edge.

Source§

impl Graph

Source

pub fn copy(&self) -> Self

Cheaply clone the immutable, reference-counted graph allocation.

Source

pub fn to_directed(&self) -> Result<Self, GraphError>

Materialize directed traversal semantics without losing undirected edges or graph metadata.

Source

pub fn to_undirected(&self) -> Result<Self, GraphError>

Return an immutable graph with undirected traversal semantics while preserving every original edge record and graph attribute.

Source

pub fn induced_subgraph( &self, node_ids: impl IntoIterator<Item = impl Into<NodeId>>, ) -> Result<Self, GraphError>

Materialize an induced subgraph containing exactly the requested nodes and edges whose endpoints are both selected.

Source

pub fn relabel( &self, mapping: &BTreeMap<NodeId, NodeId>, ) -> Result<Self, GraphError>

Return a graph with external node IDs replaced and every endpoint rewired. Distinct nodes may not merge implicitly.

Source

pub fn compose(&self, right: &Self) -> Result<Self, GraphError>

Compose two immutable graphs. Right-hand attributes take precedence.

Source

pub fn export_parts(&self) -> (Attributes, Vec<Node>, Vec<Edge>)

Create an owned export DTO with independently mutable attributes.

Trait Implementations§

Source§

impl Clone for Graph

Source§

fn clone(&self) -> Graph

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Graph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Graph

Source§

type Target = GraphInner

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl PartialEq for Graph

Source§

fn eq(&self, other: &Graph) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Graph

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

§

impl UnwindSafe for Graph

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.