spt method
Arguments
- x
a igraph object
- from
a specific node of network.
- to
other nodes of the network, length of it must be larger than 2.
- weights
a numeric vector giving edge weights or a character. If this is
NULLand the graph has aweightedge attribute, then the attribute is used. If this isNAthen no weights are used even if the graph has aweightattribute. If this is a character, the graph has the edge attribute which is numeric, then it will be used, default isNULL.- ...
additional parameters
Examples
library(igraph)
set.seed(123)
g <- igraph::sample_gnp(100, .1) %>%
set_edge_attr(name='weight', value=abs(rnorm(E(.),3)))
tr1 <- spt(g, from = 6, to=V(g), weights = 'weight')
tr1
#>
#> Phylogenetic tree with 65 tips and 35 internal nodes.
#>
#> Tip labels:
#> 4, 7, 8, 9, 10, 12, ...
#> Node labels:
#> 6, 1, 32, 3, 82, 2, ...
#>
#> Rooted; includes branch length(s).
tr2 <- spt(g, from = 6, to = V(g), weights = NA)
tr2
#>
#> Phylogenetic tree with 70 tips and 30 internal nodes.
#>
#> Tip labels:
#> 4, 5, 7, 8, 9, 10, ...
#> Node labels:
#> 6, 1, 40, 2, 32, 3, ...
#>
#> Unrooted; no branch length.
