[−][src]Struct avatar_graph::Graph
Represents an Avatar Graph.
Fields
nodes: Vec<Node>
Stores nodes.
edges: Vec<(usize, usize)>
Stores edges between nodes.
Implementations
impl Graph
[src]
pub fn new() -> Graph
[src]
Creates a new empty graph.
pub fn add_node(&mut self, node: Node) -> usize
[src]
Adds a new node.
pub fn add_edge(&mut self, a: usize, b: usize) -> usize
[src]
Adds a new edge.
pub fn cores(&self) -> usize
[src]
Counts the number of cores.
pub fn non_cores(&self) -> usize
[src]
Counts the number of non-cores.
pub fn edges_of(&self, node: usize) -> Vec<usize>
[src]
Returns a list of nodes connected by edges of a node.
pub fn unique_edges(&self) -> usize
[src]
Counts the number of unique edges.
pub fn self_unique_edges(&self) -> usize
[src]
Counts the number of self unique edges.
pub fn remove_self_unique_edges(&mut self)
[src]
REmoves all self unique edges.
pub fn self_edges(&self) -> usize
[src]
Counts the number of self edges.
pub fn remove_self_edges(&mut self)
[src]
Removes all self edges.
pub fn matrix(&self) -> Vec<Vec<u8>>
[src]
Returns a matrix representation of the graph.
0
means there is no edge.1
means there is an edge.2
means there is a unique edge.3
means there is an edge and a unique edge.
pub fn distance(
&self,
ind: usize
) -> Result<Vec<(usize, u64)>, Vec<(usize, u64)>>
[src]
&self,
ind: usize
) -> Result<Vec<(usize, u64)>, Vec<(usize, u64)>>
Assigns each node a distance number from a particular node.
Returns Ok
if the entire graph is connected.
Returns Err
if there is some node that is disconnected.
pub fn avatar_distance(&self, ind: usize) -> Vec<(usize, u64)>
[src]
Returns avatar distances of nodes from a core node.
The avatar distance is greater or equal to shortest distance. An avatar distance for a node is the sum of avatar distances of its children, which have shorter or equal distance to the core.
The avatar distance is also the number of paths to the core self.
pub fn max_avatars(&self, ind: usize) -> (u64, Vec<usize>)
[src]
Returns a list of maximum avatars and their maximum avatar distance.
pub fn contractible(&self, ind: usize) -> usize
[src]
Returns the nodes that are contractible.
A node is contractible if it has only one children with shorter distance to core. However, nodes that are directly connected to core are not counted.
pub fn swap(&mut self, a: usize, b: usize)
[src]
Swaps two nodes.
pub fn along(&self, a: usize, b: usize) -> Result<Vec<usize>, ()>
[src]
Returns nodes that are visited when walking from a
to b
with decreasing avatar distance.
pub fn all_reachable_along(&self, a: usize, b: usize) -> bool
[src]
Returns true
if all nodes are reachable from a
to b
when
walking along the gradient of avatar distances.
pub fn avatar_connectivity(&self, ind: usize) -> bool
[src]
Returns true
if a graph has correct avatar connectivity.
pub fn is_avatar_graph(&self, ind: usize) -> bool
[src]
Returns true
if the graph is an Avatar Graph seen from a core.
pub fn corify(&mut self)
[src]
Marks all nodes as core that can be a core, unmarks all nodes that can not be a core.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnwindSafe for Graph
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,