mstree.kruskal: Kruskal's minimum spanning tree in boost

Description Usage Arguments Details Value Author(s) References Examples

View source: R/interfaces.R

Description

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

Usage

1

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>

References

Boost Graph Library ( www.boost.org/libs/graph/doc/index.html )

The Boost Graph Library: User Guide and Reference Manual; by Jeremy G. Siek, Lie-Quan Lee, and Andrew Lumsdaine; (Addison-Wesley, Pearson Education Inc., 2002), xxiv+321pp. ISBN 0-201-72914-8

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
con1 <- file(system.file("XML/kmstEx.gxl",package="RBGL"), open="r")
km <- fromGXL(con1)
close(con1)

mstree.kruskal(km)
edgeData(km, "B", "D", "weight") <- 1.1
edgeData(km, "B", "E", "weight") <- .95
mstree.kruskal(km)

con2 <- file(system.file("XML/telenet.gxl",package="RBGL"), open="r")
km2 <- fromGXL(con2)
close(con2)

m <- mstree.kruskal(km2)
print(sum(m[[2]]))

Example output

Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

$edgeList
     [,1] [,2] [,3] [,4]
from "A"  "E"  "E"  "B" 
to   "C"  "D"  "A"  "D" 

$weights
       [,1] [,2] [,3] [,4]
weight    1    1    1    1

$nodes
[1] "A" "B" "C" "D" "E"

$edgeList
     [,1] [,2] [,3] [,4]
from "B"  "A"  "E"  "E" 
to   "E"  "C"  "A"  "D" 

$weights
       [,1] [,2] [,3] [,4]
weight 0.95    1    1    1

$nodes
[1] "A" "B" "C" "D" "E"

[1] 145

RBGL documentation built on Nov. 8, 2020, 5 p.m.