Table of Contents

Class GraphClusteringExtensions

Namespace
Graph1x.Algorithms
Assembly
Graph1x.dll

Clustering coefficients: how close each vertex's neighborhood is to a clique. Edge direction is ignored, self-loops never count, and on multigraphs neighbors are counted once regardless of parallel edges.

public static class GraphClusteringExtensions
Inheritance
GraphClusteringExtensions
Inherited Members

Methods

AverageClusteringCoefficient<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)

Gets the average of the local clustering coefficients over all vertices (0 for the empty graph).

public static double AverageClusteringCoefficient<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The graph to measure.

Returns

double

The average clustering coefficient in [0, 1].

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

ClusteringCoefficients<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)

Gets the local clustering coefficient of every vertex.

public static IReadOnlyDictionary<TVertex, double> ClusteringCoefficients<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The graph to measure.

Returns

IReadOnlyDictionary<TVertex, double>

The local clustering coefficient per vertex.

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

GlobalClusteringCoefficient<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)

Gets the global clustering coefficient (transitivity): three times the triangle count over the number of connected triples. Graphs without connected triples score 0.

public static double GlobalClusteringCoefficient<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The graph to measure.

Returns

double

The global clustering coefficient in [0, 1].

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

LocalClusteringCoefficient<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>, TVertex)

Gets the local clustering coefficient of vertex: the fraction of its distinct-neighbor pairs that are themselves connected. Vertices with fewer than two neighbors score 0.

public static double LocalClusteringCoefficient<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph, TVertex vertex) where TVertex : notnull where TEdge : IEdge<TVertex>

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The graph to measure.

vertex TVertex

The vertex to measure.

Returns

double

The local clustering coefficient in [0, 1].

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

Exceptions

ArgumentException

vertex is not in the graph.