classGraph (version 0.7-5)

bGraph: Create a "Branch Graph" (Simple Tree with Root and Leaves)

Description

Create a “Branch Graph”, i.e., a simple tree with root and \(n\) (simple) branches or leaves.

Usage

bGraph(n, root = "Mom",
       leaves = paste(l.prefix, seq(length = n), sep = ""),
       l.prefix = "D", weights = NULL,
       mode = c("undirected", "directed"))

Value

a graph object of class graphNEL.

Arguments

n

integer specifying the number of leave branches.

root

the node on which to root the tree.

leaves

the nodes to be used as leaves.

l.prefix

a string specifying .....

weights

.......

mode

string indicating which mode is to be used.

Author

Martin Maechler, Aug.2005

See Also

class graphNEL; ftM2graphNEL.

Examples

Run this code
require("graph") ## Using package 'graph' => plot() method (via package 'Rgraphviz'):

(bg7 <- bGraph(7)) # 8 nodes {Mom, D1..D7}; 7 edges
plot(bg7) # draws the graph

(bgD3 <- bGraph(3, mode="directed"))
plot(bgD3) # directed: using arrows

(bgw2 <- bGraph(2, weights = c(10,1)))
plot(bgw2) # {maybe use lwd for weights in the future?}
if(require("Matrix"))
  show(as(bgw2, "sparseMatrix")) # shows the weights

Run the code above in your browser using DataCamp Workspace