pub struct SignedGraph {
pub n_nodes: usize,
pub edges: Vec<SignedEdge>,
pub pos_adj: Vec<Vec<usize>>,
pub neg_adj: Vec<Vec<usize>>,
}Expand description
A signed (undirected) graph with separate positive and negative adjacency lists.
Fields§
§n_nodes: usizeNumber of nodes.
edges: Vec<SignedEdge>All edges.
pos_adj: Vec<Vec<usize>>Positive adjacency list: pos_adj[i] = list of (neighbor, weight=+1.0).
neg_adj: Vec<Vec<usize>>Negative adjacency list: neg_adj[i] = list of (neighbor, weight=+1.0).
Implementations§
Source§impl SignedGraph
impl SignedGraph
Sourcepub fn add_edge(&mut self, src: usize, dst: usize, sign: i8)
pub fn add_edge(&mut self, src: usize, dst: usize, sign: i8)
Add a signed edge (undirected: both directions are recorded).
Sourcepub fn positive_edge_count(&self) -> usize
pub fn positive_edge_count(&self) -> usize
Return the number of positive edges.
Sourcepub fn negative_edge_count(&self) -> usize
pub fn negative_edge_count(&self) -> usize
Return the number of negative edges.
Sourcepub fn abs_degree(&self, v: usize) -> usize
pub fn abs_degree(&self, v: usize) -> usize
Degree of node v in the absolute-value adjacency (all edges regardless of sign).
Trait Implementations§
Source§impl Clone for SignedGraph
impl Clone for SignedGraph
Source§fn clone(&self) -> SignedGraph
fn clone(&self) -> SignedGraph
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 SignedGraph
impl RefUnwindSafe for SignedGraph
impl Send for SignedGraph
impl Sync for SignedGraph
impl Unpin for SignedGraph
impl UnsafeUnpin for SignedGraph
impl UnwindSafe for SignedGraph
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> 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