pub struct DiGraph { /* private fields */ }Implementations§
Source§impl DiGraph
impl DiGraph
Sourcepub fn clone_with_fresh_policy(&self) -> Self
pub fn clone_with_fresh_policy(&self) -> Self
br-r37-c1-7dpyg: structural clone with a FRESH RuntimePolicy — see Graph::clone_with_fresh_policy.
pub fn new(mode: CompatibilityMode) -> Self
pub fn with_runtime_policy(runtime_policy: RuntimePolicy) -> Self
pub fn strict() -> Self
pub fn hardened() -> Self
pub fn mode(&self) -> CompatibilityMode
pub fn node_count(&self) -> usize
pub fn edge_count(&self) -> usize
pub fn revision(&self) -> u64
Sourcepub fn csr(&self) -> Arc<DiCsr> ⓘ
pub fn csr(&self) -> Arc<DiCsr> ⓘ
br-r37-c1-d58s8 P1: revision-keyed integer CSR of both row families. O(V+E) rebuild only when the graph changed since the cached build; kernels get index walks identical to the String walks (per-row order preserved).
Sourcepub fn edge_weights_all_int(&self, attr: &str) -> bool
pub fn edge_weights_all_int(&self, attr: &str) -> bool
br-r37-c1-d58s8: revision-keyed memo of “every edge’s attr
value is an integer (missing = default 1 = int)”.
pub fn has_node(&self, node: &str) -> bool
Sourcepub fn successors_indices(&self, idx: usize) -> Option<&[usize]>
pub fn successors_indices(&self, idx: usize) -> Option<&[usize]>
br-r37-c1-1l8s0: direct slice access to the eager succ index row.
Sourcepub fn predecessors_indices(&self, idx: usize) -> Option<&[usize]>
pub fn predecessors_indices(&self, idx: usize) -> Option<&[usize]>
Direct slice access to the eager pred index row.
pub fn has_edge(&self, source: &str, target: &str) -> bool
pub fn nodes_ordered(&self) -> Vec<&str>
pub fn get_node_index(&self, node: &str) -> Option<usize>
pub fn get_node_name(&self, index: usize) -> Option<&str>
Sourcepub fn successors(&self, node: &str) -> Option<Vec<&str>>
pub fn successors(&self, node: &str) -> Option<Vec<&str>>
Successors of node (outgoing neighbors). Returns None if node absent.
pub fn successors_iter( &self, node: &str, ) -> Option<impl Iterator<Item = &str> + '_>
Sourcepub fn predecessors(&self, node: &str) -> Option<Vec<&str>>
pub fn predecessors(&self, node: &str) -> Option<Vec<&str>>
Predecessors of node (incoming neighbors). Returns None if node absent.
Sourcepub fn apply_row_orders(&mut self, orders: &[(String, Vec<String>)], pred: bool)
pub fn apply_row_orders(&mut self, orders: &[(String, Vec<String>)], pred: bool)
br-r37-c1-u3qyn: restore explicit succ/pred row orders (pickle
round-trip) — see Graph::apply_row_orders. which selects the
adjacency side.
Sourcepub fn reorder_pred_rows_for_nx_copy_walk(&mut self)
pub fn reorder_pred_rows_for_nx_copy_walk(&mut self)
br-r37-c1-0ek49: reorder every PRED row into NetworkX’s
DiGraph.copy() walk order. nx copy rebuilds via the u-major
succ walk ((u, v, d) for u in _adj for v in _adj[u]), which
recreates succ rows in their original order but fills each pred
row in walk order: (pos(u), index of v within succ[u]). Call on
a fresh clone inside copy-shaped constructors; graph content is
unchanged, only pred row order moves.
pub fn predecessors_iter( &self, node: &str, ) -> Option<impl Iterator<Item = &str> + '_>
Sourcepub fn neighbors(&self, node: &str) -> Option<Vec<&str>>
pub fn neighbors(&self, node: &str) -> Option<Vec<&str>>
Neighbors = successors (matches NetworkX DiGraph.neighbors() convention).
pub fn neighbors_iter( &self, node: &str, ) -> Option<impl Iterator<Item = &str> + '_>
pub fn neighbor_count(&self, node: &str) -> usize
Sourcepub fn out_degree(&self, node: &str) -> usize
pub fn out_degree(&self, node: &str) -> usize
Out-degree: number of successors.
Sourcepub fn out_degree_by_index(&self, idx: usize) -> usize
pub fn out_degree_by_index(&self, idx: usize) -> usize
br-r37-c1-degidx: index-based degree accessors — O(1), zero String hashing (the &str path costs get_index_of per call; degree pays it twice). Used by the directed DegreeView iterator which walks nodes in index order.
pub fn in_degree_by_index(&self, idx: usize) -> usize
pub fn degree_by_index(&self, idx: usize) -> usize
Sourcepub fn out_edges<'a>(&'a self, node: &'a str) -> Vec<(&'a str, &'a str)>
pub fn out_edges<'a>(&'a self, node: &'a str) -> Vec<(&'a str, &'a str)>
Outgoing edges from node as (source, target) pairs.
Sourcepub fn in_edges<'a>(&'a self, node: &'a str) -> Vec<(&'a str, &'a str)>
pub fn in_edges<'a>(&'a self, node: &'a str) -> Vec<(&'a str, &'a str)>
Incoming edges to node as (source, target) pairs.
pub fn node_attrs(&self, node: &str) -> Option<&AttrMap>
Sourcepub fn edge_attrs(&self, source: &str, target: &str) -> Option<&AttrMap>
pub fn edge_attrs(&self, source: &str, target: &str) -> Option<&AttrMap>
Attributes of directed edge source→target.
Sourcepub fn edge_attrs_by_indices(
&self,
source_idx: usize,
target_idx: usize,
) -> Option<&AttrMap>
pub fn edge_attrs_by_indices( &self, source_idx: usize, target_idx: usize, ) -> Option<&AttrMap>
br-r37-c1-d58s8: index-keyed attr access (oriented). Zero node-map probes for callers already holding indices.
Sourcepub fn edges_indexed(
&self,
) -> impl Iterator<Item = ((usize, usize), &AttrMap)> + '_
pub fn edges_indexed( &self, ) -> impl Iterator<Item = ((usize, usize), &AttrMap)> + '_
br-r37-c1-prdir: iterate every directed edge as
((source_idx, target_idx), &AttrMap) straight from the index-keyed edge
store, in insertion order. Lets COO/CSR exporters read each edge’s weight
with ONE attr lookup instead of the per-edge edges.get(&(u,v)) hash that
the successors-then-edge_attrs_by_indices path pays.
pub fn evidence_ledger(&self) -> &EvidenceLedger
pub fn runtime_policy(&self) -> &RuntimePolicy
pub fn set_runtime_policy(&mut self, runtime_policy: RuntimePolicy)
Sourcepub fn is_directed(&self) -> bool
pub fn is_directed(&self) -> bool
Type identity: always true for DiGraph.
Sourcepub fn is_multigraph(&self) -> bool
pub fn is_multigraph(&self) -> bool
Type identity: always false for DiGraph (not a multigraph).
pub fn add_node(&mut self, node: impl Into<String>) -> bool
pub fn add_node_with_attrs( &mut self, node: impl Into<String>, attrs: AttrMap, ) -> bool
pub fn apply_node_defaults(&mut self, defaults: &AttrMap) -> bool
pub fn add_edge( &mut self, source: impl Into<String>, target: impl Into<String>, ) -> Result<(), GraphError>
pub fn add_edge_with_attrs( &mut self, source: impl Into<String>, target: impl Into<String>, attrs: AttrMap, ) -> Result<(), GraphError>
Sourcepub fn extend_edges_unrecorded<I, S, T>(&mut self, edges: I) -> usize
pub fn extend_edges_unrecorded<I, S, T>(&mut self, edges: I) -> usize
Bulk-add a sequence of attribute-free directed edges. Bypasses
the per-edge runtime_policy.record_decision call that
[add_edge_with_attrs] makes. Instead, emit one summary record
for the whole batch.
Intended for fnx-internal callers that build a fresh graph
from a known-good edge list where per-edge compatibility
accounting would add constant-factor overhead without adding
useful policy evidence. Nodes referenced by edges are
auto-created if absent, matching add_edge semantics.
Sourcepub fn extend_nodes_unrecorded<I, N>(&mut self, nodes: I) -> usize
pub fn extend_nodes_unrecorded<I, N>(&mut self, nodes: I) -> usize
br-r37-c1-digbatch: bulk-add plain nodes (no attrs), one summary ledger
record — the directed sibling of Graph::extend_nodes_unrecorded, backing
PyDiGraph’s fast integer-node path (add_nodes_from(range) / int list).
First insertion wins order; existing nodes are skipped.
Sourcepub fn extend_nodes_with_attrs_unrecorded<I>(&mut self, nodes: I) -> usize
pub fn extend_nodes_with_attrs_unrecorded<I>(&mut self, nodes: I) -> usize
br-r37-c1-dgctor: bulk-add nodes WITH attrs, one summary ledger
record — the directed sibling of Graph::extend_nodes_unrecorded
extended with per-node AttrMaps. First insertion wins the order;
re-inserting an existing node merges attrs (matching
add_node_with_attrs).
Sourcepub fn extend_edges_with_attrs_unrecorded<I>(&mut self, edges: I) -> usize
pub fn extend_edges_with_attrs_unrecorded<I>(&mut self, edges: I) -> usize
br-r37-c1-dgctor: bulk-add ATTRIBUTED directed edges without
per-edge ledger records — the directed sibling of
Graph::extend_edges_with_attrs_unrecorded. Insert-or-MERGE
(duplicate (source, target) extends the existing AttrMap, matching
add_edge_with_attrs); nodes auto-created in first-appearance
order. Callers must pre-screen “__fnx_incompatible” attr keys.
Sourcepub fn extend_prepared_edges_with_attrs_row_staged_unrecorded<I, N>(
&mut self,
new_nodes: N,
edges: I,
) -> usize
pub fn extend_prepared_edges_with_attrs_row_staged_unrecorded<I, N>( &mut self, new_nodes: N, edges: I, ) -> usize
Bulk-add ATTRIBUTED directed edges when the caller has already identified newly-created nodes. This keeps edge-map insertion in global input order, then stages successor and predecessor row commits by row so adjacency maps are probed once per touched row rather than once per edge.
Sourcepub fn extend_existing_index_edges_with_attrs_unrecorded<I>(
&mut self,
edges: I,
) -> usize
pub fn extend_existing_index_edges_with_attrs_unrecorded<I>( &mut self, edges: I, ) -> usize
Bulk-add attributed directed edges into a fresh graph when the caller has already assigned NetworkX-compatible node indices in first-seen order.
This bypasses the string-key lookup path in
[extend_prepared_edges_with_attrs_row_staged_unrecorded]: node labels
are installed once, then edges are committed directly by (source_idx, target_idx). Duplicate directed edges merge attributes without appending
another successor/predecessor entry, matching DiGraph.add_edges_from.
br-r37-c1-dodattrbatch: bulk-add ATTRIBUTED directed edges by EXISTING
node index. All endpoints MUST already exist (callers gate on int-labeled
nodes). A new edge takes the AttrMap; a duplicate (source, target) MERGES
last-wins like add_edge_with_attrs. Sibling of the fresh-index attr extend
minus node creation; integer index rows only (no String hashing).
pub fn extend_fresh_index_edges_with_attrs_unrecorded<I, N>( &mut self, nodes: N, edges: I, ) -> usize
pub fn apply_edge_defaults(&mut self, defaults: &AttrMap) -> bool
Sourcepub fn replace_edge_attrs(
&mut self,
source: &str,
target: &str,
attrs: AttrMap,
) -> bool
pub fn replace_edge_attrs( &mut self, source: &str, target: &str, attrs: AttrMap, ) -> bool
br-r37-c1-sjf4t: overwrite the attribute map for an existing edge.
Sourcepub fn replace_node_attrs(&mut self, node: &str, attrs: AttrMap) -> bool
pub fn replace_node_attrs(&mut self, node: &str, attrs: AttrMap) -> bool
br-r37-c1-sjf4t: overwrite the attribute map for an existing node.
Sourcepub fn remove_edge(&mut self, source: &str, target: &str) -> bool
pub fn remove_edge(&mut self, source: &str, target: &str) -> bool
Remove directed edge source→target. Returns true if it existed.
Sourcepub fn remove_node(&mut self, node: &str) -> bool
pub fn remove_node(&mut self, node: &str) -> bool
Remove node and all incident edges (both incoming and outgoing).
pub fn remove_nodes_from<'a, I>(&mut self, nodes: I) -> (usize, usize)where
I: IntoIterator<Item = &'a str>,
Sourcepub fn edges_ordered(&self) -> Vec<EdgeSnapshot>
pub fn edges_ordered(&self) -> Vec<EdgeSnapshot>
Edges in deterministic order: iterate nodes in insertion order, then each node’s successors in insertion order.
pub fn edges_ordered_borrowed(&self) -> Vec<(&str, &str, &AttrMap)>
Sourcepub fn reversed(&self) -> Self
pub fn reversed(&self) -> Self
br-r37-c1-revborrow: O(V+E) directed transpose. The reverse of a
DiGraph keeps the SAME node table (identical insertion order, identical
indices), so reversing is a pure topology flip — no String hashing, no
per-edge node-index lookups, no re-insertion through the name table (the
edge-iterate + edges_ordered() clone + extend_edges_with_attrs_*
re-hash path is O(E) String/hash work this avoids entirely).
Successor rows are rebuilt by walking the ORIGINAL successor rows in
node-major (ascending source index) order and appending the reversed
endpoint, so the reversed graph’s edges_ordered() stream is
byte-identical to NetworkX’s reverse(), which walks self.edges()
(u-major successor order) and adds each (v, u). pred_indices[u] ends
up equal to the original succ_indices[u], matching NetworkX’s reversed
pred order as well. Node + edge attribute maps are cloned verbatim.
Sourcepub fn edges_ordered_indices(&self) -> Vec<(usize, usize)>
pub fn edges_ordered_indices(&self) -> Vec<(usize, usize)>
Directed edge endpoints in the same order as edges_ordered_borrowed.
pub fn snapshot(&self) -> DiGraphSnapshot
Sourcepub fn to_undirected(&self) -> Graph
pub fn to_undirected(&self) -> Graph
Convert to an undirected Graph by dropping directionality. Both (u→v) and (v→u) merge into a single undirected edge. When both exist, the latter’s attributes overwrite the former’s.