Table of Contents

Class EdgePartition

Namespace
Graphity
Assembly
Graphity.Core.dll

A partition of the edges of a graph into groups: the edges behind each edge of a condensed graph, or the blocks of a graph.

public sealed class EdgePartition : IndexPartition
Inheritance
EdgePartition
Inherited Members

Examples

Here, byPackage groups the methods of a program by package. Its condensed graph packageCalls holds the calls between packages (see Of(Graph, ReadOnlySpan<int>, int)). byPackageCall tells which calls between methods are behind the call from service to model:

EdgePartition byPackageCall = Graphs.EdgePartition(packageCalls, byPackage);
int serviceToModel = packageCalls.EdgeIndexOf(service, model);
SortedIntView behind = byPackageCall.EdgesOf(serviceToModel);
// behind: [5, 7] - the calls load -> parse and save -> format

Remarks

Get(e) returns the group of edge e, or -1 if it is in no group, and EdgesOf(int) the edge indices of a group in ascending order. The groups come from one of two methods:

  • EdgePartition(Graph, NodePartition) groups the edges of the graph of a NodePartition by the edge of its condensed graph that they condense to: the group IDs are the edge indices of the condensed graph. Edges within a group of nodes, and edges from or to a node in no group, condense to no edge and are in no group.
  • Blocks groups the edges by block (biconnected component); self-loops are in no block.

Reduce combines data on the edges into one value per group, such as the number of call sites behind each call between packages.

Instances are immutable and safe to share between threads.

Memory: 4 x (EdgeCount + MappedCount + GroupCount) bytes, where MappedCount is the number of edges that belong to a group.

Properties

EdgeCount

Gets the number of edges of the partitioned graph, in a group or not. Equivalent to IndexCount.

public int EdgeCount { get; }

Property Value

int

Remarks

Time: O(1).

Methods

EdgesOf(int)

Returns the edge indices in group groupId, in ascending order. Equivalent to IndicesOf(groupId).

public SortedIntView EdgesOf(int groupId)

Parameters

groupId int

Group ID in 0..GroupCount-1.

Returns

SortedIntView

The edge indices in the group.

Remarks

The result is a view of this partition's own array, not a copy.

Time: O(1).

Exceptions

ArgumentOutOfRangeException

groupId is out of range.