pub struct SpatialEncoding {
pub spatial_bias: Array1<f64>,
pub max_distance: usize,
}Expand description
Spatial encoding using shortest-path distances (SPD) between node pairs.
Computes the all-pairs shortest path distance matrix via BFS on unweighted graphs, then provides learnable bias terms indexed by distance.
Fields§
§spatial_bias: Array1<f64>Learnable bias for each distance value: [max_distance + 1]
Index 0 = self-loop, index k = distance k
max_distance: usizeMaximum distance to encode (larger distances use max_distance bias)
Implementations§
Source§impl SpatialEncoding
impl SpatialEncoding
Sourcepub fn compute_spd_matrix(&self, adj: &CsrMatrix) -> Array2<usize>
pub fn compute_spd_matrix(&self, adj: &CsrMatrix) -> Array2<usize>
Compute all-pairs shortest path distances via BFS.
Returns a matrix [n, n] where entry (i, j) is the shortest path
distance from node i to node j. Unreachable pairs get distance
max_distance + 1.
Trait Implementations§
Source§impl Clone for SpatialEncoding
impl Clone for SpatialEncoding
Source§fn clone(&self) -> SpatialEncoding
fn clone(&self) -> SpatialEncoding
Returns a duplicate of the value. Read more
1.0.0 · 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 SpatialEncoding
impl RefUnwindSafe for SpatialEncoding
impl Send for SpatialEncoding
impl Sync for SpatialEncoding
impl Unpin for SpatialEncoding
impl UnsafeUnpin for SpatialEncoding
impl UnwindSafe for SpatialEncoding
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 more