pub struct RandomWalkKernel {
pub lambda: f64,
pub max_steps: usize,
}Expand description
Random Walk kernel for graphs
Fields§
§lambda: f64§max_steps: usizeImplementations§
Source§impl RandomWalkKernel
impl RandomWalkKernel
pub fn new(lambda: f64, max_steps: usize) -> Self
Sourcepub fn compute_graph_kernel(&self, g1: &Graph, g2: &Graph) -> f64
pub fn compute_graph_kernel(&self, g1: &Graph, g2: &Graph) -> f64
Compute the random-walk graph kernel (Gärtner / Kashima et al.).
The geometric random-walk kernel between graphs G1 and G2 is
K(G1, G2) = Σ_{i,j} [ (I - λ A_×)^{-1} ]_{ij}where A_× is the adjacency matrix of the direct (tensor) product graph
G1 × G2, whose nodes are pairs (u, v) with u ∈ G1, v ∈ G2, and
A_×[(u,v),(u',v')] = A1[u,u'] · A2[v,v']. The closed form sums the
geometric series Σ_t λ^t A_×^t = (I - λ A_×)^{-1} over all start/end
pairs (uniform start/stop probabilities).
We form A_× of size (n1·n2) × (n1·n2), then solve the linear system
(I - λ A_×) s = 1 for s and return Σ_i s_i. The kernel is
well-defined when λ < 1 / ρ(A_×); if the system is singular or the
product graph is empty we fall back to 0.0.
Trait Implementations§
Source§impl Clone for RandomWalkKernel
impl Clone for RandomWalkKernel
Source§fn clone(&self) -> RandomWalkKernel
fn clone(&self) -> RandomWalkKernel
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RandomWalkKernel
impl RefUnwindSafe for RandomWalkKernel
impl Send for RandomWalkKernel
impl Sync for RandomWalkKernel
impl Unpin for RandomWalkKernel
impl UnsafeUnpin for RandomWalkKernel
impl UnwindSafe for RandomWalkKernel
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 more