pub struct CellularSheaf {
pub n_nodes: usize,
pub n_edges: usize,
pub node_stalks: Vec<usize>,
pub edge_stalks: Vec<usize>,
pub edges: Vec<(usize, usize)>,
pub restriction_maps: HashMap<(usize, usize), Vec<Vec<f64>>>,
}Expand description
A cellular sheaf on an undirected graph.
A sheaf assigns:
- A vector space
ℝ^{d_v}to each vertexv(vertex stalk). - A vector space
ℝ^{d_e}to each edgee(edge stalk). - Restriction maps
F_{v ◁ e} : ℝ^{d_e} → ℝ^{d_v}for each vertex-edge incidence.
The coboundary operator δ : C^0 → C^1 and the resulting Hodge-0 sheaf Laplacian L = δ^T δ capture the sheaf’s cohomology.
Reference: Hansen & Ghrist (2019).
Fields§
§n_nodes: usizeNumber of nodes
n_edges: usizeNumber of edges (oriented pairs (u,v) with u < v)
node_stalks: Vec<usize>Stalks at nodes: node_stalks[v] = dimension of the stalk at v
edge_stalks: Vec<usize>Stalks at edges: edge_stalks[e] = dimension of the stalk at edge e
edges: Vec<(usize, usize)>Oriented edge list: edges[e] = (tail, head) with tail < head
restriction_maps: HashMap<(usize, usize), Vec<Vec<f64>>>Restriction maps: maps[(v, e)] = the matrix F_{v◁e} : ℝ^{d_e} → ℝ^{d_v}
stored row-major as Vec<Vec
Implementations§
Source§impl CellularSheaf
impl CellularSheaf
Sourcepub fn trivial(n_nodes: usize, edges: Vec<(usize, usize)>) -> Result<Self>
pub fn trivial(n_nodes: usize, edges: Vec<(usize, usize)>) -> Result<Self>
Create a trivial sheaf on a graph where all stalks have dimension 1.
The restriction maps are initialised to the identity (or ±1 depending on orientation).
§Arguments
n_nodes– number of nodesedges– oriented edge list(tail, head), both < n_nodes
Sourcepub fn new(
n_nodes: usize,
node_dim: usize,
edges: Vec<(usize, usize)>,
edge_dim: usize,
maps: HashMap<(usize, usize), Vec<Vec<f64>>>,
) -> Result<Self>
pub fn new( n_nodes: usize, node_dim: usize, edges: Vec<(usize, usize)>, edge_dim: usize, maps: HashMap<(usize, usize), Vec<Vec<f64>>>, ) -> Result<Self>
Create a sheaf with user-specified stalk dimensions and restriction maps.
node_dim and edge_dim give the stalk dimensions.
maps is a map from (node_id, edge_id) to a matrix of shape
(node_dim, edge_dim).
Sourcepub fn set_restriction(
&mut self,
v: usize,
e: usize,
map: Vec<Vec<f64>>,
) -> Result<()>
pub fn set_restriction( &mut self, v: usize, e: usize, map: Vec<Vec<f64>>, ) -> Result<()>
Set the restriction map for vertex v and edge e.
The matrix map should have shape (stalk_dim[v], edge_stalk[e]).
Sourcepub fn coboundary_operator(&self) -> Array2<f64>
pub fn coboundary_operator(&self) -> Array2<f64>
Compute the coboundary matrix δ : C^0 → C^1.
The full coboundary operator has shape
(sum_e d_e) × (sum_v d_v).
For a section x = (x_v)_{v}, the coboundary δ(x) at edge e = (u,v) is:
δ(x)_e = F_{v◁e} x_v − F_{u◁e} x_u
Returns the matrix as Array2<f64>.
Sourcepub fn hodge_laplacian_0(&self) -> Array2<f64>
pub fn hodge_laplacian_0(&self) -> Array2<f64>
Compute the Hodge-0 sheaf Laplacian L_0 = δ^T δ.
Shape: (sum_v d_v) × (sum_v d_v).
Sourcepub fn cohomology_h0(&self) -> usize
pub fn cohomology_h0(&self) -> usize
Compute the dimension of the 0th sheaf cohomology H^0(G; F).
dim H^0 = dim ker(δ) = total_node_dim − rank(δ).
A dimension of 1 corresponds to a “consistent” global section (like a constant function on a constant sheaf).
Sourcepub fn cohomology_h1(&self) -> usize
pub fn cohomology_h1(&self) -> usize
Compute the dimension of the 1st sheaf cohomology H^1(G; F).
dim H^1 = dim ker(δ^T) restricted to the image complement = total_edge_dim − rank(δ).
Trait Implementations§
Source§impl Clone for CellularSheaf
impl Clone for CellularSheaf
Source§fn clone(&self) -> CellularSheaf
fn clone(&self) -> CellularSheaf
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CellularSheaf
impl RefUnwindSafe for CellularSheaf
impl Send for CellularSheaf
impl Sync for CellularSheaf
impl Unpin for CellularSheaf
impl UnsafeUnpin for CellularSheaf
impl UnwindSafe for CellularSheaf
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
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>
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>
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