Skip to content

buildMST

geometryfunctionOpenCV 5.0.0
import { buildMST } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSnumNodes, inputEdges, resultingEdges, algorithm
FUNCTIONbuildMST
RETURN TYPEboolean
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Builds a Minimum Spanning Tree (MST) using the specified algorithm (see MSTAlgorithm).

Supports graphs with negative edge weights. Self-loop edges (edges where source and target are the same) are ignored. If multiple edges exist between the same pair of nodes, only the one with the lowest weight is considered. If the graph is disconnected or input is invalid, the function returns false.

Note: The root parameter is ignored for algorithms that do not require a starting node.

Note: Additional MST algorithms may be supported in the future via the algorithm parameter (see MSTAlgorithm).

throws: cv::Error (StsBadArg) if an invalid algorithm is specified.

buildMST(numNodes: number, inputEdges: MSTEdgeVector, resultingEdges: MSTEdgeVector, algorithm: number, root: number): boolean;
2 available overloads
buildMST(numNodes: number, inputEdges: MSTEdgeVector, resultingEdges: MSTEdgeVector, algorithm: number): boolean;
buildMST(numNodes: number, inputEdges: MSTEdgeVector, resultingEdges: MSTEdgeVector, algorithm: number, root: number): boolean;
numNodes

Number of nodes in the graph (must be greater than 0).

inputEdges

Input vector of edges representing the graph.

resultingEdges

Output destination, filled by the native operation. Output vector to store the edges of the resulting MST.

algorithm

Specifies which algorithm to use to compute the MST (see MSTAlgorithm).

root

Starting node for the MST algorithm (only used for certain algorithms).

Returns

true if a valid MST was successfully built; false otherwise.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.