Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

decompose

Decompose a graph into components


Description

Creates a separate graph for each component of a graph.

Usage

decompose(graph, mode = c("weak", "strong"), max.comps = NA, min.vertices = 0)

Arguments

graph

The original graph.

mode

Character constant giving the type of the components, wither weak for weakly connected components or strong for strongly connected components.

max.comps

The maximum number of components to return. The first max.comps components will be returned (which hold at least min.vertices vertices, see the next parameter), the others will be ignored. Supply NA here if you don't want to limit the number of components.

min.vertices

The minimum number of vertices a component should contain in order to place it in the result list. Eg. supply 2 here to ignore isolate vertices.

Value

A list of graph objects.

Author(s)

See Also

is_connected to decide whether a graph is connected, components to calculate the connected components of a graph.

Examples

# the diameter of each component in a random graph
g <- sample_gnp(1000, 1/1000)
components <- decompose(g, min.vertices=2)
sapply(components, diameter)

igraph

Network Analysis and Visualization

v1.2.10
GPL (>= 2)
Authors
See AUTHORS file.
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.