Connected components of a graph
Calculate the maximal (weakly or strongly) connected components of a graph
component_distribution(graph, cumulative = FALSE, mul.size = FALSE, ...)
components(graph, mode = c("weak", "strong"))
- The graph to analyze.
- Logical, if TRUE the cumulative distirubution (relative frequency) is calculated.
- Logical. If TRUE the relative frequencies will be multiplied by the cluster sizes.
- Character string, either
weakor strong. For directed graphs weakimplies weakly, strongstrongly connected components to search. It is ignored for undirected graphs.
- Additional attributes to pass to
cluster, right now only
is_connected decides whether the graph is weakly or strongly
components finds the maximal (weakly or strongly) connected components
of a graph.
count_components does almost the same as
components but returns only
the number of clusters found instead of returning the actual clusters.
component_distribution creates a histogram for the maximal connected
The weakly connected components are found by a simple breadth-first search. The strongly connected components are implemented by two consecutive depth-first searches.
is_connecteda logical constant.
componentsa named list with three components:
membership numeric vector giving the cluster id to which each vertex belongs. csize numeric vector giving the sizes of the clusters. no numeric constant, the number of clusters.
count_componentsan integer constant is returned.
component_distributiona numeric vector with the relative frequencies. The length of the vector is the size of the largest component plus one. Note that (for currently unknown reasons) the first element of the vector is the number of clusters of size zero, so this is always zero.
g <- sample_gnp(20, 1/20) clu <- components(g) groups(clu)