pub struct Graph {
pub num_vertices: usize,
pub edges: Vec<Vec<usize>>,
pub weights: Option<Vec<Vec<f64>>>,
}
Expand description
Graph representation for quantum walks
Fields§
§num_vertices: usize
Number of vertices
edges: Vec<Vec<usize>>
Adjacency list representation
weights: Option<Vec<Vec<f64>>>
Optional edge weights
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn new_empty(num_vertices: usize) -> Self
pub fn new_empty(num_vertices: usize) -> Self
Create an empty graph with given number of vertices
Sourcepub fn add_weighted_edge(&mut self, u: usize, v: usize, weight: f64)
pub fn add_weighted_edge(&mut self, u: usize, v: usize, weight: f64)
Add a weighted edge
Sourcepub fn adjacency_matrix(&self) -> Array2<f64>
pub fn adjacency_matrix(&self) -> Array2<f64>
Get the adjacency matrix
Sourcepub fn laplacian_matrix(&self) -> Array2<f64>
pub fn laplacian_matrix(&self) -> Array2<f64>
Get the Laplacian matrix
Sourcepub fn normalized_laplacian_matrix(&self) -> Array2<f64>
pub fn normalized_laplacian_matrix(&self) -> Array2<f64>
Get the normalized Laplacian matrix
Sourcepub fn transition_matrix(&self) -> Array2<f64>
pub fn transition_matrix(&self) -> Array2<f64>
Get the transition matrix for random walks
Sourcepub fn is_bipartite(&self) -> bool
pub fn is_bipartite(&self) -> bool
Check if the graph is bipartite
Sourcepub fn algebraic_connectivity(&self) -> f64
pub fn algebraic_connectivity(&self) -> f64
Calculate the algebraic connectivity (second smallest eigenvalue of Laplacian)
Sourcepub fn all_pairs_shortest_paths(&self) -> Array2<f64>
pub fn all_pairs_shortest_paths(&self) -> Array2<f64>
Get shortest path distances between all pairs of vertices
Sourcepub fn from_adjacency_matrix(matrix: &Array2<f64>) -> QuantRS2Result<Self>
pub fn from_adjacency_matrix(matrix: &Array2<f64>) -> QuantRS2Result<Self>
Create a graph from an adjacency matrix
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnwindSafe for Graph
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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.