mstree.kruskal {RBGL} | R Documentation

## Kruskal's minimum spanning tree in boost

### Description

compute the minimum spanning tree (MST) for a graph and return a representation in matrices

### Usage

    mstree.kruskal(x)

### Arguments

`x` | instance of class graph

### Details

calls to kruskal minimum spanning tree algorithm of Boost graph library

### Value

a list

`edgeList` | a matrix m of dimension 2 by number of edges in the MST, with m[i,j] the jth node in edge i
`weights` | a vector of edge weights corresponding to the columns of `edgeList`
`nodes` | the vector of nodes of the input graph `x`

### Author(s)

VJ Carey <stvjc@channing.harvard.edu>

### See Also

`prim.minST`

### Examples

    km <- fromGXL(file(system.file("XML/kmstEx.gxl",package="RBGL"), open="r"))
    mstree.kruskal(km)
    edgeData(km, "B", "D", "weight") <- 1.1
    edgeData(km, "B", "E", "weight") <- .95
    mstree.kruskal(km)
    km2 <- fromGXL(file(system.file("XML/telenet.gxl",package="RBGL"), open="r"))
    m <- mstree.kruskal(km2)
    print(sum(m[[2]]))

[Package RBGL version 1.10.0 Index]