Table of Contents

Class IndexMapping

Namespace
Graphity
Assembly
Graphity.Core.dll

A mapping from the indices 0..IndexCount-1 to the indices of another numbering. It is the common base of the node and edge mappings and of the partitions.

public abstract class IndexMapping
Inheritance
IndexMapping
Derived
Inherited Members

Remarks

The indices are node IDs or edge indices. Get(i) is the index that i maps to, or -1 if i is not mapped; a mapping with unmapped indices is partial. A NodeMapping maps the node IDs of one graph to those of another, and an EdgeMapping does the same for edge indices. Neither maps two indices to the same index, so both can be inverted. An IndexPartition maps indices to groups and lists the indices of each group. Several indices can map to the same group.

That a node or edge mapping maps no two indices to the same index is a contract, not a check: Of(ReadOnlySpan<int>) accepts an array that breaks it, and only Inverted and Remapped(Graph, NodeMapping) reject such a mapping.

Instances are immutable and safe to share between threads. No other assembly can derive from this class.

Memory: 4 x IndexCount bytes; a partition holds more.

Properties

IndexCount

Gets the number of indices this mapping maps from, mapped or not.

public int IndexCount { get; }

Property Value

int

Remarks

It is the length of the arrays that Gather returns and that Reduce takes.

Time: O(1).

IsPartial

Gets whether some index is not mapped. Equivalent to MappedCount < IndexCount.

public bool IsPartial { get; }

Property Value

bool

Remarks

Time: O(1).

MappedCount

Gets the number of indices that are mapped; in a partition, the number of indices that belong to a group.

public int MappedCount { get; }

Property Value

int

Remarks

Time: O(1).

Methods

Get(int)

Returns the index that id maps to, or -1 if id is not mapped.

public int Get(int id)

Parameters

id int

Index in 0..IndexCount-1.

Returns

int

The index that id maps to, or -1.

Remarks

In a partition, it is the group of id.

Time: O(1).

Exceptions

ArgumentOutOfRangeException

id is out of range.

IsMapped(int)

Returns whether id is mapped. Equivalent to Get(id) != -1.

public bool IsMapped(int id)

Parameters

id int

Index in 0..IndexCount-1.

Returns

bool

true if id is mapped.

Remarks

Time: O(1).

Exceptions

ArgumentOutOfRangeException

id is out of range.