| igraph Reference Manual |
|---|
int igraph_minimum_spanning_tree_prim(const igraph_t *graph, igraph_t *mst, const igraph_vector_t *weights);
This function uses Prim's method for carrying out the computation, see Prim, R.C.: Shortest connection networks and some generalizations, Bell System Technical Journal, Vol. 36, 1957, 1389--1401.
If the graph has more than one minimum spanning tree, the current implementation returns always the same one.
Directed graphs are considered as undirected for this computation.
If the graph is not connected then its minimum spanning forest is returned. This is the set of the minimum spanning trees of each component.
Arguments:
graph: |
The graph object. |
mst: |
The result of the computation, a graph object containing
the minimum spanning tree of the graph.
Do not initialize this object before passing it to
this function, but be sure to call |
weights: |
A vector containing the weights of the the edges. in the same order as the simple edge iterator visits them. |
Returns:
|
Error code:
|
Time complexity: O(|V|+|E|), |V| is the number of vertices, |E| the number of edges in the graph.
See also:
|
|
<< 8.1. igraph_minimum_spanning_tree_unweighted — Calculates one minimum spanning tree of an unweighted graph. |
9. Transitivity or Clustering Coefficient >> |