numberOfComponents -- computes the number of connected components of a graph

Synopsis

• Usage:
n = numberOfComponents G
• Inputs:
• G, an instance of the type Graph,
• Outputs:
• n, an integer, the number of connected components of G

Description

A connected component is a list of vertexSet of a graph that are connected, i.e. there exists a path of edges between any two vertexSet in the component.

 i1 : G = graph(toList(1..8),{{1,2},{2,3},{3,4},{5,6}}); i2 : numberOfComponents G;

Ways to use numberOfComponents :

• "numberOfComponents(Graph)"

For the programmer

The object numberOfComponents is .