pub struct CommunityGraph {
pub nodes: HashMap<u64, GraphNode>,
pub edges: Vec<GraphEdge>,
pub adjacency: HashMap<u64, Vec<(u64, f64)>>,
}Expand description
Undirected weighted graph with adjacency lists
Fields§
§nodes: HashMap<u64, GraphNode>Node collection indexed by ID
edges: Vec<GraphEdge>All edges (stored once; adjacency is bidirectional)
adjacency: HashMap<u64, Vec<(u64, f64)>>Adjacency list: node_id → [(neighbour_id, weight)]
Implementations§
Source§impl CommunityGraph
impl CommunityGraph
Sourcepub fn add_node(&mut self, id: u64, label: &str)
pub fn add_node(&mut self, id: u64, label: &str)
Add a node; overwrites if the ID already exists
Sourcepub fn add_edge(&mut self, from: u64, to: u64, weight: f64)
pub fn add_edge(&mut self, from: u64, to: u64, weight: f64)
Add an undirected edge between from and to with the given weight.
If either node does not exist it is created with an empty label.
Sourcepub fn degree(&self, node_id: u64) -> f64
pub fn degree(&self, node_id: u64) -> f64
Sum of edge weights incident to a node (weighted degree)
Sourcepub fn total_weight(&self) -> f64
pub fn total_weight(&self) -> f64
Sum of all edge weights in the graph (counted once per edge)
Trait Implementations§
Source§impl Clone for CommunityGraph
impl Clone for CommunityGraph
Source§fn clone(&self) -> CommunityGraph
fn clone(&self) -> CommunityGraph
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 moreSource§impl Debug for CommunityGraph
impl Debug for CommunityGraph
Source§impl Default for CommunityGraph
impl Default for CommunityGraph
Source§fn default() -> CommunityGraph
fn default() -> CommunityGraph
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CommunityGraph
impl RefUnwindSafe for CommunityGraph
impl Send for CommunityGraph
impl Sync for CommunityGraph
impl Unpin for CommunityGraph
impl UnsafeUnpin for CommunityGraph
impl UnwindSafe for CommunityGraph
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more