Learn R Programming

predictionet (version 1.18.0)

adj.get.hops: Function to identify all children of a parent

Description

This function uses a depth-first search algorithm to identify all the children (and their corresponding depth) of a node.

Usage

adj.get.hops(adjmat)

Arguments

adjmat
adjacency matrix; parents in rows, children in columns

Value

two-column matrix containing the names of the children in the first column and their corresponding depth in the descent in the second column

Details

The algorithm is based on the depth-first search.

Examples

Run this code
## check whether a list of two nodes are children of another node
set.seed(54321)
mytopo <- matrix(sample(0:1, 100, replace=TRUE, prob=c(0.7,0.3)), nrow=10, dimnames=list(LETTERS[1:10], LETTERS[1:10]))
adj.get.hops(adjmat=mytopo)

Run the code above in your browser using DataLab