Skip to main content

MultiDiGraph

Struct MultiDiGraph 

Source
pub struct MultiDiGraph { /* private fields */ }

Implementations§

Source§

impl MultiDiGraph

Source

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.

Source

pub fn clone_with_fresh_policy(&self) -> Self

br-r37-c1-7dpyg: structural clone with a FRESH RuntimePolicy — see Graph::clone_with_fresh_policy.

Source

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.

Source

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.

Source

pub fn new(mode: CompatibilityMode) -> Self

Source

pub fn with_runtime_policy(runtime_policy: RuntimePolicy) -> Self

Source

pub fn strict() -> Self

Source

pub fn hardened() -> Self

Source

pub fn mode(&self) -> CompatibilityMode

Source

pub fn node_count(&self) -> usize

Source

pub fn edge_count(&self) -> usize

Source

pub fn number_of_selfloops(&self) -> usize

Source

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.

Source

pub fn edge_keys_iter( &self, source: &str, target: &str, ) -> Option<impl Iterator<Item = &usize>>

Edge keys as iterator.

Source

pub fn revision(&self) -> u64

Source

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.

Source

pub fn has_node(&self, node: &str) -> bool

Source

pub fn has_edge(&self, source: &str, target: &str) -> bool

Source

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.

Source

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.

Source

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.

Source

pub fn nodes_ordered(&self) -> Vec<&str>

Source

pub fn get_node_name(&self, index: usize) -> Option<&str>

Resolve the current node name for an insertion-order index.

Source

pub fn node_index_matches_int(&self, idx: usize) -> bool

br-cc-nbunchbulk: int membership fast path for _nbunch_present — see the DiGraph accessor.

Source

pub fn successors(&self, node: &str) -> Option<Vec<&str>>

Source

pub fn successors_iter( &self, node: &str, ) -> Option<impl Iterator<Item = &str> + '_>

Source

pub fn predecessors(&self, node: &str) -> Option<Vec<&str>>

Source

pub fn predecessors_iter( &self, node: &str, ) -> Option<impl Iterator<Item = &str> + '_>

Source

pub fn neighbors(&self, node: &str) -> Option<Vec<&str>>

Source

pub fn neighbors_iter( &self, node: &str, ) -> Option<impl Iterator<Item = &str> + '_>

Source

pub fn node_attrs(&self, node: &str) -> Option<&AttrMap>

Source

pub fn edge_attrs( &self, source: &str, target: &str, key: usize, ) -> Option<&AttrMap>

Source

pub fn edge_attr_values( &self, source: &str, target: &str, ) -> Option<impl Iterator<Item = &AttrMap> + '_>

Source

pub fn evidence_ledger(&self) -> &EvidenceLedger

Source

pub fn drain_decision_records(&mut self) -> Vec<DecisionRecord>

Source

pub fn runtime_policy(&self) -> &RuntimePolicy

Source

pub fn set_runtime_policy(&mut self, runtime_policy: RuntimePolicy)

Source

pub fn is_directed(&self) -> bool

Source

pub fn is_multigraph(&self) -> bool

Source

pub fn out_degree(&self, node: &str) -> usize

Return the out-degree of a node (number of outgoing parallel edges).

Source

pub fn in_degree(&self, node: &str) -> usize

Return the in-degree of a node (number of incoming parallel edges).

Source

pub fn degree(&self, node: &str) -> usize

Return the degree of a node (in-degree + out-degree).

Source

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.

Source

pub fn number_of_isolates(&self) -> usize

br-r37-c1-mgisol (cc): isolate count without the simple-digraph projection.

Source

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.

Source

pub fn add_node(&mut self, node: impl AsRef<str> + Into<String>) -> bool

Source

pub fn add_node_with_attrs( &mut self, node: impl AsRef<str> + Into<String>, attrs: AttrMap, ) -> bool

Source

pub fn add_edge( &mut self, source: impl Into<String>, target: impl Into<String>, ) -> Result<usize, GraphError>

Source

pub fn extend_nodes_with_attrs_unrecorded<I>(&mut self, nodes: I) -> usize
where I: IntoIterator<Item = (String, AttrMap)>,

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).

Source

pub fn extend_keyed_edges_with_attrs_unrecorded<I>(&mut self, edges: I) -> usize
where I: IntoIterator<Item = (String, String, usize, AttrMap)>,

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.

Source

pub fn extend_fresh_index_keyed_edges_with_attrs_unrecorded<I, N>( &mut self, nodes: N, edges: I, ) -> usize
where I: IntoIterator<Item = (usize, usize, usize, AttrMap)>, N: IntoIterator<Item = String>,

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.

Source

pub fn add_edge_with_attrs( &mut self, source: impl Into<String>, target: impl Into<String>, attrs: AttrMap, ) -> Result<usize, GraphError>

Source

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>

Source

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.

Source

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.

Source

pub fn set_ordered_edge_attr_values<I>( &mut self, attr_key: &str, values: I, ) -> bool
where 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.

Source

pub fn replace_node_attrs(&mut self, node: &str, attrs: AttrMap) -> bool

br-r37-c1-sjf4t: overwrite the attribute map for an existing node.

Source

pub fn remove_edge( &mut self, source: &str, target: &str, key: Option<usize>, ) -> bool

Source

pub fn clear_edges(&mut self)

Source

pub fn remove_node(&mut self, node: &str) -> bool

Source

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.

Source

pub fn edges_ordered(&self) -> Vec<MultiDiEdgeSnapshot>

Source

pub fn edges_ordered_borrowed(&self) -> Vec<(&str, &str, usize, &AttrMap)>

Source

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.

Source

pub fn try_for_each_edge_ordered_borrowed<E>( &self, visit: impl FnMut(&str, &str, usize, &AttrMap) -> Result<(), E>, ) -> Result<(), E>

Source

pub fn try_for_each_indexed_edge_ordered_borrowed<E>( &self, visit: impl FnMut(usize, usize, &str, &str, usize, &AttrMap) -> Result<(), E>, ) -> Result<(), E>

Source

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.

Source

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.

Source

pub fn snapshot(&self) -> MultiDiGraphSnapshot

Trait Implementations§

Source§

impl Clone for MultiDiGraph

Source§

fn clone(&self) -> MultiDiGraph

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 MultiDiGraph

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.