Classes
Methods
addEdge(v1, v2, weight)
Adds a weighted edge between two vertices.
Parameters:
| Name | Type | Description |
|---|---|---|
v1 |
string | First vertex name. |
v2 |
string | Second vertex name. |
weight |
number | The weight/compatibility score of the edge. |
- Source:
Throws:
-
If one of the vertices is not found.
- Type
- Error
kruskalMST() → {Object}
Finds the Minimum Spanning Tree (MST) using Kruskal's algorithm.
- Source:
Returns:
Returns { mst: Array, weight: number }.
- Type
- Object
primMST(startVertex) → {Object}
Finds the Minimum Spanning Tree (MST) using Prim's algorithm.
Parameters:
| Name | Type | Description |
|---|---|---|
startVertex |
string | The starting vertex for the traversal. |
- Source:
Returns:
Returns { mst: Array, weight: number }.
- Type
- Object