Skip to main content

MotifTensor

Struct MotifTensor 

Source
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: usize

Number of nodes

Implementations§

Source§

impl MotifTensor

Source

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)
Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V