Home   >   User Resources   >   Online Help   >   apaGraph.MinimumSpanningTree.FromEdges
 

 

Function index Version 3.0.0

apaGraph.MinimumSpanningTree.FromEdges(Edges, NumberOfNodes, IsWeighted)

Excel=apaGraph.MinimumSpanningTree.FromEdges(Edges, NumberOfNodes, IsWeighted)

Result

Returns the minimum spanning tree (MST) of a graph given as an edge list, using Kruskal’s algorithm. If the graph is not connected, the minimum spanning forest, i.e. one minimum spanning tree per connected component, is returned.

Syntax

Edges: graph as an edge list, i.e. an m x 3 data matrix, the first two columns containing the node indices and the third column the distance between the two nodes; additional columns are ignored

NumberOfNodes: optional; total number of nodes; default: the highest node index in Edges

IsWeighted: optional; TRUE to use the distances in the third column, FALSE to assume unit distances; default: TRUE

Remarks

Returns an edge list with one row per tree edge: the first two columns contain the 1-based indices of the connected nodes (smaller index first) and the third column their distance. A connected graph with n nodes gives n - 1 rows; a graph with c connected components gives n - c rows. Nodes without edges, e.g. when NumberOfNodes exceeds the highest node index in Edges, form their own components. If no tree edge exists, the function returns a row of #N/A.

Self-loops are ignored. Of several edges between the same two nodes, the shortest is used. Edges with the same distance are taken in the order of the edge list. With IsWeighted = FALSE, every spanning tree is minimal; the function then returns the spanning tree given by the order of the edge list.

Applied to the output of apaGraph.kNN.Build or apaGraph.kNN.Build.K, the function returns the MST of the kNN graph. It equals the MST of all data points, i.e. apaGraph.MinimumSpanningTree, only if the kNN graph contains all of its edges; comparing the total distances of both trees shows whether this is the case.

Pressing Esc aborts the calculation; the function then returns "Calculation aborted by user."