Description Usage Arguments Details Value Author(s) References Examples
The function returns the neighborhood set of given vertices in the form of list. Optionally user can choose to include the given vertices in the list, too.
1 | neighborhood(graph, index, return.self = FALSE)
|
graph |
An object of |
index |
Names of nodes, whose neighborhood set should be returned |
return.self |
logical, should the vertex itself also be returned? |
Let v be a vertex in a (di)graph, the out-neighborhood or successor set (N+(v), x belongs to V(G) and v->x) and the in-neighborhood or predecessor set (N-(v), x belongs to V(G) and x->v) are jointly returned.
The returned list is indexed by the given node indices, NULL
is
returned in case of non-existing node.
The nodes are unique, that is, duplicated nodes are removed in results.
A list indexed by the given node indices, each entry containing the neighborhood set of that node (or furthermore including that node).
Jitao David Zhang <jitao_david.zhang@roche.com>
D.B. West. Introduction to Graph Theory, Second Edition. Prentice Hall, 2001
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | V <- c("Hamburg","Stuttgart","Berlin","Paris","Bremen")
E <- list("Hamburg"=c("Berlin","Bremen"),
"Stuttgart"=c("Berlin","Paris"),
"Berlin"=c("Stuttgart","Bremen"),
"Paris"=c("Stuttgart"),
"Bremen"=c("Hamburg","Berlin"))
g <- new("graphNEL", nodes=V, edgeL=E, edgemode="directed")
if(require(Rgraphviz) & interactive()) {
plot(g, "neato")
}
## simple uses
neighborhood(g, "Hamburg")
neighborhood(g, c("Hamburg", "Berlin","Paris"))
## in case of non-existing nodes
neighborhood(g, c("Stuttgart","Ulm"))
## also applicable to non-directed graphs
neighborhood(ugraph(g), c("Stuttgart","Berlin"))
|
Attaching package: 'KEGGgraph'
The following object is masked from 'package:graphics':
plot
Loading required package: Rgraphviz
Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, sd, var, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, basename, cbind, colMeans, colSums, colnames,
dirname, do.call, duplicated, eval, evalq, get, grep, grepl,
intersect, is.unsorted, lapply, lengths, mapply, match, mget,
order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind,
rowMeans, rowSums, rownames, sapply, setdiff, sort, table, tapply,
union, unique, unsplit, which, which.max, which.min
Loading required package: grid
$Hamburg
[1] "Berlin" "Bremen"
$Hamburg
[1] "Berlin" "Bremen"
$Berlin
[1] "Stuttgart" "Bremen" "Hamburg"
$Paris
[1] "Stuttgart"
$Stuttgart
[1] "Berlin" "Paris"
$Ulm
NULL
$Stuttgart
[1] "Berlin" "Paris"
$Berlin
[1] "Hamburg" "Stuttgart" "Bremen"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.