pub struct MotifTensor {
pub data: Array3<f64>,
pub n: usize,
}Expand description
A third-order motif tensor T[i,j,k] encoding 3-node interaction patterns.
For an undirected graph, entry T[i,j,k] = 1 iff the induced subgraph on {i,j,k} forms a triangle (all three edges present).
For directed/weighted variants, use directed_motif_tensor.
Fields§
§data: Array3<f64>Shape: (n, n, n) where n = number of nodes
n: usizeNumber of nodes
Implementations§
Source§impl MotifTensor
impl MotifTensor
Sourcepub fn from_adjacency(adj: &Array2<f64>) -> Self
pub fn from_adjacency(adj: &Array2<f64>) -> Self
Build the triangle motif tensor from a graph adjacency matrix.
T[i,j,k] = A[i,j] * A[j,k] * A[i,k] (all three edges present).
For a 0/1 adjacency matrix this is exactly 1 for triangles and 0 otherwise. For weighted graphs the entry equals the product of the three edge weights.
§Arguments
adj– symmetric adjacency matrix (shape n × n)
Sourcepub fn triangle_count(&self) -> f64
pub fn triangle_count(&self) -> f64
Count the total number of directed triangles encoded in the tensor.
Each undirected triangle {i,j,k} contributes 6 directed entries (all permutations), so divide by 6 to get the undirected count.
Sourcepub fn tensor_vec_product(&self, x: &[f64]) -> Vec<f64>
pub fn tensor_vec_product(&self, x: &[f64]) -> Vec<f64>
Compute the tensor-vector product T ×_1 x ×_2 x:
(T x^2)[i] = Σ_{j,k} T[i,j,k] x[j] x[k]
This is the “mode-1 multilinear product” used in tensor eigenvector centrality.
Sourcepub fn z_eigenvector_centrality(&self) -> Result<(f64, Vec<f64>)>
pub fn z_eigenvector_centrality(&self) -> Result<(f64, Vec<f64>)>
Compute the Z-eigenvector centrality of the motif tensor using the shifted power method.
Returns (eigenvalue, eigenvector) where the eigenvector satisfies
T x^2 = λ x. All entries of the returned vector are non-negative.
§Errors
Returns GraphError::InvalidGraph if n = 0.
Auto Trait Implementations§
impl Freeze for MotifTensor
impl RefUnwindSafe for MotifTensor
impl Send for MotifTensor
impl Sync for MotifTensor
impl Unpin for MotifTensor
impl UnsafeUnpin for MotifTensor
impl UnwindSafe for MotifTensor
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> 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