pub struct WasmSparsifier { /* private fields */ }Expand description
Dynamic spectral graph sparsifier for WASM.
Maintains a compressed shadow graph that preserves the Laplacian energy
of the full graph within (1 ± epsilon).
Implementations§
Source§impl WasmSparsifier
impl WasmSparsifier
Sourcepub fn new(config_json: &str) -> Result<WasmSparsifier, JsValue>
pub fn new(config_json: &str) -> Result<WasmSparsifier, JsValue>
Create a new sparsifier with the given JSON configuration.
Pass "{}" or default_config() for defaults.
Sourcepub fn build_from_edges(
edges_json: &str,
config_json: &str,
) -> Result<WasmSparsifier, JsValue>
pub fn build_from_edges( edges_json: &str, config_json: &str, ) -> Result<WasmSparsifier, JsValue>
Build a sparsifier from a JSON edge list: [[u, v, weight], ...].
Sourcepub fn insert_edge(
&mut self,
u: u32,
v: u32,
weight: f64,
) -> Result<(), JsValue>
pub fn insert_edge( &mut self, u: u32, v: u32, weight: f64, ) -> Result<(), JsValue>
Insert an edge into the full graph and update the sparsifier.
Sourcepub fn delete_edge(&mut self, u: u32, v: u32) -> Result<(), JsValue>
pub fn delete_edge(&mut self, u: u32, v: u32) -> Result<(), JsValue>
Delete an edge from the full graph and update the sparsifier.
Sourcepub fn update_embedding(
&mut self,
node: u32,
old_neighbors_json: &str,
new_neighbors_json: &str,
) -> Result<(), JsValue>
pub fn update_embedding( &mut self, node: u32, old_neighbors_json: &str, new_neighbors_json: &str, ) -> Result<(), JsValue>
Handle an embedding move for a node (JSON: [[neighbor, weight], ...]).
Sourcepub fn sparsifier_edges(&self) -> String
pub fn sparsifier_edges(&self) -> String
Get the current sparsifier edges as JSON.
Sourcepub fn compression_ratio(&self) -> f64
pub fn compression_ratio(&self) -> f64
Get the current compression ratio.
Sourcepub fn rebuild_local(&mut self, nodes_json: &str) -> Result<(), JsValue>
pub fn rebuild_local(&mut self, nodes_json: &str) -> Result<(), JsValue>
Rebuild the sparsifier around specific nodes (JSON array of u32).
Sourcepub fn rebuild_full(&mut self) -> Result<(), JsValue>
pub fn rebuild_full(&mut self) -> Result<(), JsValue>
Full reconstruction of the sparsifier.
Sourcepub fn num_vertices(&self) -> u32
pub fn num_vertices(&self) -> u32
Number of vertices in the full graph.
Sourcepub fn sparsifier_num_edges(&self) -> u32
pub fn sparsifier_num_edges(&self) -> u32
Number of edges in the sparsifier.
Trait Implementations§
Source§impl From<WasmSparsifier> for JsValue
impl From<WasmSparsifier> for JsValue
Source§fn from(value: WasmSparsifier) -> Self
fn from(value: WasmSparsifier) -> Self
Source§impl FromWasmAbi for WasmSparsifier
impl FromWasmAbi for WasmSparsifier
Source§impl IntoWasmAbi for WasmSparsifier
impl IntoWasmAbi for WasmSparsifier
Source§impl LongRefFromWasmAbi for WasmSparsifier
impl LongRefFromWasmAbi for WasmSparsifier
Source§impl OptionFromWasmAbi for WasmSparsifier
impl OptionFromWasmAbi for WasmSparsifier
Source§impl OptionIntoWasmAbi for WasmSparsifier
impl OptionIntoWasmAbi for WasmSparsifier
Source§impl RefFromWasmAbi for WasmSparsifier
impl RefFromWasmAbi for WasmSparsifier
Source§type Anchor = RcRef<WasmSparsifier>
type Anchor = RcRef<WasmSparsifier>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for WasmSparsifier
impl RefMutFromWasmAbi for WasmSparsifier
Source§impl TryFromJsValue for WasmSparsifier
impl TryFromJsValue for WasmSparsifier
Source§impl VectorFromWasmAbi for WasmSparsifier
impl VectorFromWasmAbi for WasmSparsifier
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmSparsifier]>
Source§impl VectorIntoWasmAbi for WasmSparsifier
impl VectorIntoWasmAbi for WasmSparsifier
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmSparsifier]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmSparsifier
impl WasmDescribeVector for WasmSparsifier
impl SupportsConstructor for WasmSparsifier
impl SupportsInstanceProperty for WasmSparsifier
impl SupportsStaticProperty for WasmSparsifier
Auto Trait Implementations§
impl !Freeze for WasmSparsifier
impl !RefUnwindSafe for WasmSparsifier
impl Send for WasmSparsifier
impl Sync for WasmSparsifier
impl Unpin for WasmSparsifier
impl UnsafeUnpin for WasmSparsifier
impl UnwindSafe for WasmSparsifier
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.