pub struct MultiDiGraph { /* private fields */ }Implementations§
Source§impl MultiDiGraph
impl MultiDiGraph
Sourcepub fn get_node_index(&self, node: &str) -> Option<usize>
pub fn get_node_index(&self, node: &str) -> Option<usize>
br-r37-c1-7qqr8: positional index of a node, matching
DiGraph::get_node_index. MultiDiGraph carried the
NodeIndexLookupCache (br-r37-c1-ic4cv) but only ever used its
present-set half, so there was no accessor to populate the index half
from — which is what the edge-attr index lookaside needs.
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.
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-s0d4x: reorder every PRED row into NetworkX’s
MultiDiGraph.copy() walk order — the multigraph counterpart of
DiGraph::reorder_pred_rows_for_nx_copy_walk: each pred row’s cells
sort by (pos(u), index of v within succ[u]); succ rows are
recreated in their original order by the u-major walk.
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. Keyed cells move
wholesale; pred selects the adjacency side.
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 number_of_selfloops(&self) -> usize
Sourcepub fn edge_keys(&self, source: &str, target: &str) -> Option<Vec<usize>>
pub fn edge_keys(&self, source: &str, target: &str) -> Option<Vec<usize>>
Return an iterator over keys for edges from source to target. Edge keys as Vec.
Sourcepub fn edge_keys_iter(
&self,
source: &str,
target: &str,
) -> Option<impl Iterator<Item = &usize>>
pub fn edge_keys_iter( &self, source: &str, target: &str, ) -> Option<impl Iterator<Item = &usize>>
Edge keys as iterator.
pub fn revision(&self) -> u64
Sourcepub fn csr(&self) -> Arc<MultiDiCsr> ⓘ
pub fn csr(&self) -> Arc<MultiDiCsr> ⓘ
Revision-keyed integer CSR of distinct successor and predecessor rows. Row order follows the existing map-backed rows exactly, so consumers can replace string-key walks without changing observable traversal order.
pub fn has_node(&self, node: &str) -> bool
pub fn has_edge(&self, source: &str, target: &str) -> bool
Sourcepub fn has_edge_by_indices(&self, source_idx: usize, target_idx: usize) -> bool
pub fn has_edge_by_indices(&self, source_idx: usize, target_idx: usize) -> bool
br-r37-c1-s8dj1: now a REAL index path.
It used to resolve both indices back to names and call has_edge(&str, &str), which hashes the full-length keys again — so a caller’s O(1)
index resolution bought nothing, and PyMultiDiGraph’s exact-string
branch (br-r37-c1-ptiz2) inherited the slope it was written to remove.
An edges bucket is dropped as soon as its last key goes (see
remove_edge), so membership of the pair map is exactly has_edge.
Sourcepub fn edge_key_count_by_indices(
&self,
source_idx: usize,
target_idx: usize,
) -> usize
pub fn edge_key_count_by_indices( &self, source_idx: usize, target_idx: usize, ) -> usize
br-r37-c1-s8dj1: how many PARALLEL edges a pair carries, addressed by
node POSITION. number_of_edges(u, v) built two owned canonicals and
hashed the pair to answer what is a bucket length, and measured 0.272x
of networkx at 2000-character keys — the worst surviving row on this
class after the keyed has_edge path landed.
Falls back to the name path while the lookaside is still warming up, so it inherits the same amortisation guard rather than forcing a build.
Sourcepub fn edge_attrs_by_indices(
&self,
source_idx: usize,
target_idx: usize,
key: usize,
) -> Option<&AttrMap>
pub fn edge_attrs_by_indices( &self, source_idx: usize, target_idx: usize, key: usize, ) -> Option<&AttrMap>
br-r37-c1-s8dj1: attributes of a KEYED directed edge, addressed by node
POSITION — the directed twin of MultiGraph::edge_attrs_by_indices, and
the primitive whose absence is why PyMultiDiGraph::has_edge left its
keyed form on the string path.
pub fn nodes_ordered(&self) -> Vec<&str>
Sourcepub fn get_node_name(&self, index: usize) -> Option<&str>
pub fn get_node_name(&self, index: usize) -> Option<&str>
Resolve the current node name for an insertion-order index.
Sourcepub fn node_index_matches_int(&self, idx: usize) -> bool
pub fn node_index_matches_int(&self, idx: usize) -> bool
br-cc-nbunchbulk: int membership fast path for _nbunch_present — see the
DiGraph accessor.
pub fn successors(&self, node: &str) -> Option<Vec<&str>>
pub fn successors_iter( &self, node: &str, ) -> Option<impl Iterator<Item = &str> + '_>
pub fn predecessors(&self, node: &str) -> Option<Vec<&str>>
pub fn predecessors_iter( &self, node: &str, ) -> Option<impl Iterator<Item = &str> + '_>
pub fn neighbors(&self, node: &str) -> Option<Vec<&str>>
pub fn neighbors_iter( &self, node: &str, ) -> Option<impl Iterator<Item = &str> + '_>
pub fn node_attrs(&self, node: &str) -> Option<&AttrMap>
pub fn edge_attrs( &self, source: &str, target: &str, key: usize, ) -> Option<&AttrMap>
pub fn edge_attr_values( &self, source: &str, target: &str, ) -> Option<impl Iterator<Item = &AttrMap> + '_>
pub fn evidence_ledger(&self) -> &EvidenceLedger
pub fn drain_decision_records(&mut self) -> Vec<DecisionRecord>
pub fn runtime_policy(&self) -> &RuntimePolicy
pub fn set_runtime_policy(&mut self, runtime_policy: RuntimePolicy)
pub fn is_directed(&self) -> bool
pub fn is_multigraph(&self) -> bool
Sourcepub fn out_degree(&self, node: &str) -> usize
pub fn out_degree(&self, node: &str) -> usize
Return the out-degree of a node (number of outgoing parallel edges).
Sourcepub fn in_degree(&self, node: &str) -> usize
pub fn in_degree(&self, node: &str) -> usize
Return the in-degree of a node (number of incoming parallel edges).
Sourcepub fn degree(&self, node: &str) -> usize
pub fn degree(&self, node: &str) -> usize
Return the degree of a node (in-degree + out-degree).
Sourcepub fn isolates(&self) -> Vec<String>
pub fn isolates(&self) -> Vec<String>
br-r37-c1-mgisol (cc): native isolate detection for MultiDiGraph. A node
is isolated iff it has no incident edges in either direction (empty/absent
successor AND predecessor rows). A self-loop records the node in both its
own successor and predecessor rows, keeping it non-isolated (matches nx’s
degree-2 self-loop convention). Yields nodes in insertion order, identical
to the old multidigraph_to_simple_digraph projection path but without the
per-call O(V+E) simple-graph rebuild.
Sourcepub fn number_of_isolates(&self) -> usize
pub fn number_of_isolates(&self) -> usize
br-r37-c1-mgisol (cc): isolate count without the simple-digraph projection.
Sourcepub fn is_isolate(&self, node: &str) -> bool
pub fn is_isolate(&self, node: &str) -> bool
br-r37-c1-mgisol (cc): O(1) isolate predicate. Absent node -> false
(mirrors is_isolate_directed(&DiGraph)); the binding validates presence.
pub fn add_node(&mut self, node: impl AsRef<str> + Into<String>) -> bool
pub fn add_node_with_attrs( &mut self, node: impl AsRef<str> + Into<String>, attrs: AttrMap, ) -> bool
pub fn add_edge( &mut self, source: impl Into<String>, target: impl Into<String>, ) -> Result<usize, GraphError>
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-l5ve7: bulk node insert WITH attrs, one ledger record — MultiDiGraph mirror of DiGraph::extend_nodes_with_attrs_unrecorded. Existing nodes merge attrs (extend).
Sourcepub fn extend_keyed_edges_with_attrs_unrecorded<I>(&mut self, edges: I) -> usize
pub fn extend_keyed_edges_with_attrs_unrecorded<I>(&mut self, edges: I) -> usize
br-r37-c1-l5ve7: bulk KEYED edge insert WITH attrs, one ledger record — for native copy/convert paths that replicate a source multigraph’s exact internal keys (add_edge_impl pays TWO record_decision calls per edge). Endpoint nodes are created on demand; an existing (u, v, key) cell merges attrs (extend), matching add_edge_with_key_and_attrs.
Sourcepub fn extend_fresh_index_keyed_edges_with_attrs_unrecorded<I, N>(
&mut self,
nodes: N,
edges: I,
) -> usize
pub fn extend_fresh_index_keyed_edges_with_attrs_unrecorded<I, N>( &mut self, nodes: N, edges: I, ) -> usize
Bulk-add keyed attributed directed multiedges into a fresh graph when the
caller has already assigned NetworkX-compatible node indices and per-pair
keys. This avoids hashing/copying canonical endpoint strings for every
edge in fresh MultiDiGraph.add_edges_from batches.
pub fn add_edge_with_attrs( &mut self, source: impl Into<String>, target: impl Into<String>, attrs: AttrMap, ) -> Result<usize, GraphError>
pub fn add_edge_with_key_and_attrs( &mut self, source: impl Into<String>, target: impl Into<String>, key: usize, attrs: AttrMap, ) -> Result<usize, GraphError>
Sourcepub fn replace_edge_attrs(
&mut self,
source: &str,
target: &str,
key: usize,
attrs: AttrMap,
) -> bool
pub fn replace_edge_attrs( &mut self, source: &str, target: &str, key: usize, attrs: AttrMap, ) -> bool
br-r37-c1-sjf4t: overwrite the attribute map for an existing (source, target, key) edge. Returns whether the edge existed.
Sourcepub fn set_edge_attr_value(
&mut self,
source: &str,
target: &str,
key: usize,
attr_key: &str,
value: CgseValue,
) -> bool
pub fn set_edge_attr_value( &mut self, source: &str, target: &str, key: usize, attr_key: &str, value: CgseValue, ) -> bool
Overwrite one attribute value on an existing keyed edge. This is the hot path for algorithms that clone graph topology and patch one derived edge field without rebuilding every edge’s full attribute map.
Sourcepub fn set_ordered_edge_attr_values<I>(
&mut self,
attr_key: &str,
values: I,
) -> boolwhere
I: IntoIterator<Item = CgseValue>,
pub fn set_ordered_edge_attr_values<I>(
&mut self,
attr_key: &str,
values: I,
) -> boolwhere
I: IntoIterator<Item = CgseValue>,
Overwrite one attribute on all keyed edges in edges_ordered_borrowed
order. Returns false if the caller supplied the wrong value count.
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.
pub fn remove_edge( &mut self, source: &str, target: &str, key: Option<usize>, ) -> bool
pub fn clear_edges(&mut self)
pub fn remove_node(&mut self, node: &str) -> bool
Sourcepub fn remove_nodes_from<'a, I>(&mut self, nodes: I) -> (usize, usize)where
I: IntoIterator<Item = &'a str>,
pub fn remove_nodes_from<'a, I>(&mut self, nodes: I) -> (usize, usize)where
I: IntoIterator<Item = &'a str>,
br-r37-c1-mgrnf: batch node removal — amortised analogue of remove_node.
MultiDiGraph::remove_node pays THREE O(|V|) shift_removes (successors,
predecessors, nodes) per call, so a caller loop of k removals was
O(k·|V|). This does each pass ONCE via retain — O(|V|+|E|) total, matching
the simple DiGraph::remove_nodes_from batch. Returns
(removed_node_count, removed_edge_instance_count). The revision bump
invalidates csr_cache exactly as repeated remove_node would.
pub fn edges_ordered(&self) -> Vec<MultiDiEdgeSnapshot>
pub fn edges_ordered_borrowed(&self) -> Vec<(&str, &str, usize, &AttrMap)>
Sourcepub fn weighted_size_int(&self, weight: &str) -> Option<i128>
pub fn weighted_size_int(&self, weight: &str) -> Option<i128>
br-r37-c1-wsize (cc): integer size(weight) from the store — directed
multigraph twin of Graph::weighted_size_int. Each parallel directed edge
is one bucket entry contributing its weight once (size halves degree’s
in+out double count). Returns None on any non-integer weight (caller uses
the exact degree path); missing weight defaults to nx’s int 1.
pub fn try_for_each_edge_ordered_borrowed<E>( &self, visit: impl FnMut(&str, &str, usize, &AttrMap) -> Result<(), E>, ) -> Result<(), E>
pub fn try_for_each_indexed_edge_ordered_borrowed<E>( &self, visit: impl FnMut(usize, usize, &str, &str, usize, &AttrMap) -> Result<(), E>, ) -> Result<(), E>
Sourcepub fn reversed(&self) -> Self
pub fn reversed(&self) -> Self
Return a reversed copy with NetworkX-compatible node/edge row order.
This is the directed-multigraph sibling of DiGraph::reversed, but it
cannot simply swap successors and predecessors: NetworkX materializes
MultiDiGraph.reverse(copy=True) by walking G.edges(keys=True, data=True)
in source-node order and adding (v, u, key) to the result. Predecessor
rows may have been formed by historical edge insertion order, which is not
always the same as that source-major edge stream. Rebuild the two row maps
from the observed edge stream while avoiding the expensive per-edge
add_edge policy path.
Sourcepub fn out_edges_ordered_borrowed<'a>(
&'a self,
node: &str,
) -> Vec<(&'a str, &'a str, usize, &'a AttrMap)>
pub fn out_edges_ordered_borrowed<'a>( &'a self, node: &str, ) -> Vec<(&'a str, &'a str, usize, &'a AttrMap)>
Out-edges of a single source node in nx adjacency order (successors[node].keys() then key-bucket order), borrowing attrs.
Equivalent to edges_ordered_borrowed() filtered to one source,
but O(out-deg(node)) instead of O(E) — and it clones nothing. Used
by MultiDiGraph.edges(nbunch) to avoid scanning/cloning every
edge when only a handful of sources are requested.
pub fn snapshot(&self) -> MultiDiGraphSnapshot
Trait Implementations§
Source§impl Clone for MultiDiGraph
impl Clone for MultiDiGraph
Source§fn clone(&self) -> MultiDiGraph
fn clone(&self) -> MultiDiGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more