getReachableNodes {BiCausality} | R Documentation |
getReachableNodes function
Description
getReachableNodes is a support function for inferring reachable nodes that have some directed path to a node targetNode
.
This function uses Breadth-first search (BFS) algorithm.
Usage
getReachableNodes(adjMat, targetNode)
Arguments
adjMat |
is an adjacency matrix of a directed graph of which its elements are binary: zero for no edge, and one for having an edge. |
targetNode |
is a node in a graph that we want to find a set of nodes that can reach this target node via some paths. |
Value
This function returns a set of node IDs that have some directed path to a node targetNode
.
Examples
# Given an example of adjacency matrix
A<-matrix(FALSE,5,5)
A[2,1]<-TRUE
A[c(3,4),2]<-TRUE
A[5,3]<-TRUE
# Get a set of reachable nodes of targetNode.
followers<-getReachableNodes(adjMat=A,targetNode=1)
[Package BiCausality version 0.1.4 Index]