npm package: @ruvector/mincut-wasm
Description: WASM bindings for subpolynomial-time dynamic minimum cut (Stoer-Wagner algorithm)
Author: RuVector Team
Latest version: 0.1.0

# @ruvector/mincut-wasm

WASM bindings for subpolynomial-time dynamic minimum cut using the Stoer-Wagner algorithm.

## Features

- **WasmMinCut**: Basic dynamic minimum cut (insert/delete/query)
- **WasmThreeLevelHierarchy**: 3-level decomposition (Expander → Precluster → Cluster)
- **WasmLocalKCut**: Deterministic local k-cut discovery with 4-color coding
- **WasmMinCutWrapper**: Full API with connectivity curve analysis

## Installation

```bash
npm install @ruvector/mincut-wasm
```

## Usage

### Browser (ES Modules)

```javascript
import init, { WasmMinCut, WasmThreeLevelHierarchy, WasmLocalKCut } from '@ruvector/mincut-wasm';

// Initialize WASM module
await init();

// Basic min-cut
const mincut = WasmMinCut.fromEdges([[0, 1, 1.0], [1, 2, 1.0], [0, 2, 1.0]]);
console.log('Min cut value:', mincut.minCutValue());
console.log('Partition:', mincut.partition());
console.log('Cut edges:', mincut.cutEdges());

// Dynamic updates
mincut.insertEdge(2, 3, 2.0);
console.log('New min cut value:', mincut.minCutValue());

// Batch operations
const newEdges = [[3, 4, 1.5], [4, 5, 2.0]];
mincut.batchInsert(newEdges);
console.log('Stats:', mincut.stats());
```

### 3-Level Hierarchy Decomposition

```javascript
const hierarchy = new WasmThreeLevelHierarchy();
hierarchy.insertEdge(0, 1, 1.0);
hierarchy.insertEdge(1, 2, 1.0);
hierarchy.insertEdge(2, 0, 1.0);
hierarchy.insertEdge(2, 3, 0.5);
hierarchy.insertEdge(3, 4, 1.0);
hierarchy.insertEdge(4, 5, 1.0);
hierarchy.insertEdge(5, 3, 1.0);

hierarchy.build();
console.log('Hierarchy stats:', hierarchy.stats());
console.log('Global min cut:', hierarchy.globalMinCut());
```

### Local k-Cut Discovery

```javascript
const lkcut = new WasmLocalKCut(5, 100, 2);
lkcut.insertEdge(0, 1, 1.0);
lkcut.insertEdge(1, 2, 1.0);
lkcut.insertEdge(2, 3, 1.0);

const cuts = lkcut.query(0);
console.log('Local cuts from vertex 0:', cuts);
```

## API Reference

### WasmMinCut

| Method | Description |
|--------|-------------|
| `new()` | Create empty min-cut structure |
| `fromEdges(edges)` | Create from edges array `[[u, v, weight], ...]` |
| `insertEdge(u, v, weight)` | Insert an edge, returns new min-cut value |
| `deleteEdge(u, v)` | Delete an edge, returns new min-cut value |
| `minCutValue()` | Get current minimum cut value |
| `partition()` | Get partition as `{ s: [...], t: [...] }` |
| `cutEdges()` | Get cut edges as array |
| `numVertices()` | Get number of vertices |
| `numEdges()` | Get number of edges |
| `isConnected()` | Check if graph is connected |
| `stats()` | Get comprehensive statistics |
| `batchInsert(edges)` | Insert multiple edges |
| `batchDelete(edges)` | Delete multiple edges |

### WasmThreeLevelHierarchy

| Method | Description |
|--------|-------------|
| `new()` | Create with default configuration |
| `withPhi(phi)` | Create with custom expansion parameter |
| `insertEdge(u, v, weight)` | Insert an edge |
| `deleteEdge(u, v)` | Delete an edge |
| `build()` | Build the hierarchy (required after insertions) |
| `stats()` | Get hierarchy statistics |
| `globalMinCut()` | Get global minimum cut estimate |

### WasmLocalKCut

| Method | Description |
|--------|-------------|
| `new(lambda_max, volume_bound, beta)` | Create structure |
| `insertEdge(u, v, weight)` | Insert an edge |
| `deleteEdge(u, v)` | Delete an edge |
| `query(source)` | Query local cuts from source vertex |

## Performance

- Subpolynomial time complexity: O(n^(1-ε)) per update
- WASM provides near-native performance in browsers
- Suitable for graphs with 10K+ vertices

## License

MIT

## See Also

- [ruvector-mincut](https://crates.io/crates/ruvector-mincut) - Core Rust implementation
- [ruvector-mincut-node](https://crates.io/crates/ruvector-mincut-node) - Node.js native bindings