Learn R Programming

gRapHD (version 0.2.5)

randTree: Random tree

Description

Generates a random tree

Usage

randTree(p,seed=1)

Arguments

p

number of vertices.

seed

seed (for the random generator, see set.seed).

Value

A list containing:

edges

matrix with 2 columns, each row representing one edge, and each column one of the vertices in the edge.

seed

seed.

p

number of vertices.

References

Rodionov, A.S., Choo, H. On Generating Random Network Structures: Trees. Springer-Verlag Lecture Notes in Computer Science, vol. 2658, pp. 879-887, June 2003.

Examples

Run this code
# NOT RUN {
tree <- randTree(p=10, seed=1)
plot(new("gRapHD",edges=tree$edges))
tree
# $edges
#       [,1] [,2]
#  [1,]    3    4
#  [2,]    3    5
#  [3,]    2    3
#  [4,]    4    6
#  [5,]    6    9
#  [6,]    1    6
#  [7,]    6   10
#  [8,]    6    7
#  [9,]    5    8
#
# $seed
# [1] 1
#
# $p
# [1] 10
# }

Run the code above in your browser using DataLab