Click or drag to resize
CC Class

The CC class represents a data type for determining the connected components in an undirected graph. The Id operation determines in which connected component a given vertex lies; the Connected operation determines whether two vertices are in the same connected component; the Count operation determines the number of connected components; and the Count operation determines the number of vertices in the connect component containing a given vertex. The Component identifier of a connected component is one of the vertices in the connected component: two vertices have the same component identifier if and only if they are in the same connected component.

This implementation uses depth-first search. The constructor takes time proportional to V + E (in the worst case), V is the number of vertices and E is the number of edges. Afterwards, the Id, Count, Connected, and Count operations take constant time.

Inheritance Hierarchy
SystemObject
  Algs4NetCC

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class CC

The CC type exposes the following members.

Constructors
  NameDescription
Public methodCC
Computes the connected components of the undirected graph G.
Top
Properties
  NameDescription
Public propertyCount
Returns the number of connected components in the graph G.
Top
Methods
  NameDescription
Public methodConnected
Returns true if vertices v and w are in the same connected component.
Public methodId
Returns the component id of the connected component containing vertex v.
Public methodStatic memberMainTest
Demo test the CC data type.
Public methodSize
Returns the number of vertices in the connected component containing vertex v.
Top
Remarks

For additional documentation, see Section 4.1 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class CC implementation by the respective authors.

See Also