pub struct NetworkGraph {
pub n: usize,
pub directed: bool,
pub adj: Vec<Vec<(usize, f64)>>,
}Expand description
Adjacency-list graph for network dynamics simulations.
Supports directed and undirected graphs with optional edge weights.
Node indices are in 0..n.
Fields§
§n: usizeNumber of nodes.
directed: boolWhether the graph is directed.
adj: Vec<Vec<(usize, f64)>>Adjacency list: adj[i] = list of (neighbor, weight).
Implementations§
Source§impl NetworkGraph
impl NetworkGraph
Sourcepub fn add_edge(&mut self, u: usize, v: usize, w: f64)
pub fn add_edge(&mut self, u: usize, v: usize, w: f64)
Adds a directed edge u → v with weight w.
Sourcepub fn degree(&self, u: usize) -> usize
pub fn degree(&self, u: usize) -> usize
Returns the degree (out-degree for directed) of node u.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Returns the number of edges (undirected counts each once).
Sourcepub fn erdos_renyi(n: usize, p: f64, seed: u64) -> Self
pub fn erdos_renyi(n: usize, p: f64, seed: u64) -> Self
Builds an Erdős-Rényi random graph G(n, p) with given seed.
Sourcepub fn bfs_distances(&self, s: usize) -> Vec<i64>
pub fn bfs_distances(&self, s: usize) -> Vec<i64>
Returns BFS distances from source node s (-1 means unreachable).
Sourcepub fn average_path_length(&self) -> f64
pub fn average_path_length(&self) -> f64
Average shortest path length (only reachable pairs).
Sourcepub fn clustering_coefficient(&self, u: usize) -> f64
pub fn clustering_coefficient(&self, u: usize) -> f64
Local clustering coefficient for node u.
Sourcepub fn mean_clustering(&self) -> f64
pub fn mean_clustering(&self) -> f64
Mean clustering coefficient over all nodes.
Trait Implementations§
Source§impl Clone for NetworkGraph
impl Clone for NetworkGraph
Source§fn clone(&self) -> NetworkGraph
fn clone(&self) -> NetworkGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NetworkGraph
impl RefUnwindSafe for NetworkGraph
impl Send for NetworkGraph
impl Sync for NetworkGraph
impl Unpin for NetworkGraph
impl UnsafeUnpin for NetworkGraph
impl UnwindSafe for NetworkGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.