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.
Namespace: Algs4Net
public class CC
The CC type exposes the following members.
Name | Description | |
---|---|---|
![]() | Connected |
Returns true if vertices v and w are in the same
connected component. |
![]() | Id |
Returns the component id of the connected component containing vertex v. |
![]() ![]() | MainTest |
Demo test the CC data type. |
![]() | Size |
Returns the number of vertices in the connected component containing vertex v. |
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.