rust-port/wifi-densepose-rs/crates/ruv-neural/ruv-neural-wasm/README.md
WebAssembly bindings for browser-based brain topology visualization.
ruv-neural-wasm provides JavaScript-callable functions for creating, analyzing,
and visualizing brain connectivity graphs directly in the browser. It wraps
ruv-neural-core types with wasm-bindgen and implements lightweight
WASM-compatible versions of graph algorithms (Stoer-Wagner mincut, spectral
embedding via power iteration, topology metrics, and cognitive state decoding)
that run without heavy native dependencies.
Note: This crate is excluded from the default workspace build. Build it
separately targeting wasm32-unknown-unknown.
create_brain_graph -- parse BrainGraph from JSONcompute_mincut -- Stoer-Wagner on graphs up to 500 nodescompute_topology_metrics -- density, efficiency,
modularity, Fiedler value, entropy, module countembed_graph -- power iteration on normalized Laplacian
(no LAPACK dependency)decode_state -- threshold-based cognitive state classification
from topology metricsload_rvf / export_rvf -- read and write RuVector binary filesstreaming): WebSocket-compatible streaming data processorviz_data): Data structures for D3.js and Three.js rendering# Requires wasm-pack or cargo with wasm32 target
cargo build -p ruv-neural-wasm --target wasm32-unknown-unknown --release
# Or with wasm-pack for npm-ready output
wasm-pack build ruv-neural-wasm --target web
import init, {
create_brain_graph,
compute_mincut,
compute_topology_metrics,
embed_graph,
decode_state,
export_rvf,
version,
} from './ruv_neural_wasm.js';
await init();
const graphJson = JSON.stringify({
num_nodes: 3,
edges: [
{ source: 0, target: 1, weight: 0.8, metric: "Coherence", frequency_band: "Alpha" },
{ source: 1, target: 2, weight: 0.5, metric: "Coherence", frequency_band: "Beta" },
],
timestamp: 0.0,
window_duration_s: 1.0,
atlas: { Custom: 3 },
});
const graph = create_brain_graph(graphJson);
const mincut = compute_mincut(graphJson);
const metrics = compute_topology_metrics(graphJson);
const embedding = embed_graph(graphJson, 2);
const rvfBytes = export_rvf(graphJson);
console.log('Version:', version());
| Function | Description |
|---|---|
create_brain_graph(json) | Parse JSON into a BrainGraph JS object |
compute_mincut(json) | Stoer-Wagner minimum cut, returns MincutResult |
compute_topology_metrics(json) | Compute TopologyMetrics for a graph |
embed_graph(json, dim) | Spectral embedding via power iteration |
decode_state(json) | Classify CognitiveState from TopologyMetrics |
load_rvf(bytes) | Parse RVF binary data into JS object |
export_rvf(json) | Serialize BrainGraph to RVF bytes |
version() | Return crate version string |
| Module | Key Types |
|---|---|
graph_wasm | wasm_mincut, wasm_embed, wasm_topology_metrics, wasm_decode |
streaming | WebSocket streaming data processor |
viz_data | D3.js / Three.js visualization structures |
Depends on ruv-neural-core for BrainGraph, TopologyMetrics, RvfFile,
and CognitiveState types. Uses wasm-bindgen and serde-wasm-bindgen for
JS interop. Designed for browser-based dashboards and real-time visualization
applications.
MIT OR Apache-2.0