Description Usage Arguments Details Value Author(s) References Examples
Returns all vertices reachable from one specific vertex (assuming that there are no cycles).
1 |
model |
|
edges |
matrix with 2 columns, each row representing one edge, and each column one of the vertices in the edge. |
v |
initial vertex ( |
p |
number of vertices. |
Given a list of edges, and a specific vertex v
, returns a vector with all
vertices in the connected component containing v. The function assumes that the graph is acyclic.
Vector with all vertices reachable from v
, or 0
if v
is
an isolated vertex.
Gabriel Coelho Goncalves de Abreu (abreu_ga@yahoo.com.br)
Cormen, T.H., Leiserson, C.E., Rivest, R.L. and Stein, C. Introduction to Algorithms, 2nd Edition. MIT Press and McGraw-Hill, 2001, pp.540:9.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | set.seed(7,kind="Mersenne-Twister")
dataset <- matrix(rnorm(1000),nrow=100,ncol=10)
m <- minForest(dataset,stat="BIC")
DFS(edges=m@edges,v=1,p=10)
# [1] 5 2 9 8
#######################################################################
data(dsDiscr)
m1 <- minForest(dsDiscr,homog=TRUE,forbEdges=NULL,stat="BIC")
vertices <- DFS(edges=m1@edges, v=1, p=m1@p)
# result
vertices
# numeric(0)
# meaning that 1 is an isolated vertex
# OR
m1 <- minForest(dsDiscr,homog=TRUE,forbEdges=NULL,stat="LR")
vertices <- DFS(edges=m1@edges, v=1, p=m1@p)
# result
vertices
# [1] 4 8 12 19 18 14 7 17 5 3 10 13 15 9 6 20 16 11 2
# meaning that 1 reachs all vertices (a tree)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.