Connectivity

com.phasmidsoftware.gryphon.adjunct.Connectivity
See theConnectivity companion object
trait Connectivity[V] extends DisjointSet[V, Connectivity[V]], Connected[V]

A trait that combines the functionalities of a disjoint set and connectivity queries.

Connectivity extends both DisjointSet and Connected, allowing for efficient operations on disjoint sets as well as determining connectivity between elements.

This trait is useful for scenarios where a combination of union-find operations and connectivity checks is required, such as network connectivity, clustering, and graph algorithms like Kruskal's Minimum Spanning Tree (MST).

The type parameter V represents the type of elements in the disjoint set.

Type parameters

V

the type of elements managed by this connectivity structure.

Attributes

Companion
object
Graph
Supertypes
trait Connected[V]
trait DisjointSet[V, Connectivity[V]]
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Inherited and Abstract methods

def connect(v1: V, v2: V): Connectivity[V]

Merges the sets containing the given elements v1 and v2. After the operation the two elements belong to the same set.

Merges the sets containing the given elements v1 and v2. After the operation the two elements belong to the same set.

Value parameters

v1

the first element to be connected.

v2

the second element to be connected.

Attributes

Returns

the updated disjoint set with the connection established.

Inherited from:
DisjointSet
def getDisjointSet(key: V): V

Returns the root (representative) of the component containing key.

Returns the root (representative) of the component containing key.

Value parameters

key

a key.

Attributes

Returns

the root of the component tree to which key belongs.

Inherited from:
DisjointSet
def isConnected(v1: V, v2: V): Boolean

Determines whether v1 and v2 belong to the same connected component.

Determines whether v1 and v2 belong to the same connected component.

Value parameters

v1

an object.

v2

another object.

Attributes

Returns

true if v1 and v2 are in the same component.

Inherited from:
Connected
def put(key: V): Connectivity[V]

Adds the specified key to the disjoint set data structure and initializes it as a new singleton set if it does not already exist.

Adds the specified key to the disjoint set data structure and initializes it as a new singleton set if it does not already exist.

Value parameters

key

the element to be added to the disjoint set.

Attributes

Returns

the updated disjoint set containing the newly added key.

Inherited from:
DisjointSet
def size: Int

The number of disjoint sets (components), not the number of objects.

The number of disjoint sets (components), not the number of objects.

Attributes

Returns

the number of disjoint sets.

Inherited from:
DisjointSet