Show / Hide Table of Contents

Class ForestDisjointSet<T>

Disjoint-set implementation with path compression and union-by-rank optimizations.

Inheritance
System.Object
ForestDisjointSet<T>
Implements
IDisjointSet<T>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

ForestDisjointSet()

Initializes a new instance of the ForestDisjointSet<T> class.

Declaration
public ForestDisjointSet()
| Improve this Doc View Source

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

capacity is negative or int.MaxValue.

Properties

| Improve this Doc View Source

ElementCount

Gets the current number of elements.

Declaration
public int ElementCount { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

SetCount

Gets the current number of sets.

Declaration
public int SetCount { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

AreInSameSet(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

left is null.

System.ArgumentNullException

right is null.

| Improve this Doc View Source

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

value is null.

| Improve this Doc View Source

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

value is null.

| Improve this Doc View Source

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

value is null.

| Improve this Doc View Source

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 left and right were unioned, false if they already belong to the same set.

Exceptions
Type Condition
System.ArgumentNullException

left is null.

System.ArgumentNullException

right is null.

Implements

IDisjointSet<T>

Extension Methods

GraphMLExtensions.SerializeToGraphML<TVertex, TEdge, TGraph>(TGraph, String)
GraphMLExtensions.SerializeToGraphML<TVertex, TEdge, TGraph>(TGraph, String, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>)
GraphMLExtensions.SerializeToGraphML<TVertex, TEdge, TGraph>(TGraph, XmlWriter)
GraphMLExtensions.SerializeToGraphML<TVertex, TEdge, TGraph>(TGraph, XmlWriter, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>)
GraphMLExtensions.DeserializeFromGraphML<TVertex, TEdge, TGraph>(TGraph, XmlReader, IdentifiableVertexFactory<TVertex>, IdentifiableEdgeFactory<TVertex, TEdge>)
GraphMLExtensions.DeserializeFromGraphML<TVertex, TEdge, TGraph>(TGraph, TextReader, IdentifiableVertexFactory<TVertex>, IdentifiableEdgeFactory<TVertex, TEdge>)
GraphMLExtensions.DeserializeFromGraphML<TVertex, TEdge, TGraph>(TGraph, String, IdentifiableVertexFactory<TVertex>, IdentifiableEdgeFactory<TVertex, TEdge>)
GraphMLExtensions.DeserializeAndValidateFromGraphML<TVertex, TEdge, TGraph>(TGraph, TextReader, IdentifiableVertexFactory<TVertex>, IdentifiableEdgeFactory<TVertex, TEdge>)
SerializationExtensions.SerializeToXml<TVertex, TEdge, TGraph>(TGraph, XmlWriter, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>, String, String, String, String)
SerializationExtensions.SerializeToXml<TVertex, TEdge, TGraph>(TGraph, XmlWriter, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>, String, String, String, String, Action<XmlWriter, TGraph>, Action<XmlWriter, TVertex>, Action<XmlWriter, TEdge>)
  • Improve this Doc
  • View Source
In This Article
Back to top QuikGraph