View source: R/structural-properties.R
| count_reachable | R Documentation |
count_reachable(graph, mode = c("out", "in", "all", "total"))
graph |
The input graph. |
mode |
Character constant, defines how edge directions are considered
in directed graphs.
|
Counts the number of vertices reachable from each vertex in the graph.
For each vertex in the graph, this function counts how many vertices are reachable from it, including the vertex itself. A vertex is reachable from another if there is a directed path between them. For undirected graphs, two vertices are reachable from each other if they are in the same connected component.
An integer vector of length vcount(graph).
The i-th element is the number of vertices reachable from vertex i
(including vertex i itself).
Gabor Csardi csardi.gabor@gmail.com
components(), subcomponent(), is_connected()
Connected components
articulation_points(),
biconnected_components(),
component_distribution(),
decompose(),
is_biconnected()
# In a directed path graph, the reachability depends on direction
g <- make_graph(~ 1 -+ 2 -+ 3 -+ 4 -+ 5)
count_reachable(g, mode = "out")
count_reachable(g, mode = "in")
# In an undirected graph, reachability is the same in all directions
g2 <- make_graph(~ 1 - 2 - 3 - 4 - 5)
count_reachable(g2, mode = "out")
# A graph with multiple components
g3 <- make_graph(~ 1 - 2 - 3, 4 - 5, 6)
count_reachable(g3, mode = "all")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.