Class ForestDisjointSet<T>
Disjoint-set implementation with path compression and union-by-rank optimizations.
Inheritance
Implements
Inherited Members
Namespace: QuikGraph.Collections
Assembly: QuikGraph.dll
Syntax
[Serializable]
public class ForestDisjointSet<T> : IDisjointSet<T>
Type Parameters
Name | Description |
---|---|
T | Element type. |
Constructors
| Improve this Doc View SourceForestDisjointSet()
Initializes a new instance of the ForestDisjointSet<T> class.
Declaration
public ForestDisjointSet()
ForestDisjointSet(Int32)
Initializes a new instance of the ForestDisjointSet<T> class.
Declaration
public ForestDisjointSet(int capacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | Element capacity. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
Properties
| Improve this Doc View SourceElementCount
Gets the current number of elements.
Declaration
public int ElementCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
SetCount
Gets the current number of sets.
Declaration
public int SetCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceAreInSameSet(T, T)
Gets a value indicating if left and right are contained in the same set.
Declaration
public bool AreInSameSet(T left, T right)
Parameters
Type | Name | Description |
---|---|---|
T | left | Left value. |
T | right | Right value. |
Returns
Type | Description |
---|---|
System.Boolean | True if both values are in the same set, false otherwise. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
Contains(T)
Gets a value indicating whether the value is in the data structure.
Declaration
public bool Contains(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value is already in the set, false otherwise. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
FindSet(T)
Finds the set containing the value
.
Declaration
public T FindSet(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | Value to search. |
Returns
Type | Description |
---|---|
T | Root value of the set. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
MakeSet(T)
Creates a new set for the value
.
Declaration
public void MakeSet(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Union(T, T)
Merges the sets from the two values.
Declaration
public bool Union(T left, T right)
Parameters
Type | Name | Description |
---|---|---|
T | left | Left value. |
T | right | Right value. |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|