Supported Metrics
This page documents the metrics included with the current version. The contents are generated directly from the graphreadability.metrics.metrics.py
.
This module contains all metric functions. A metric should be a function that takes a NetworkX graph as the first argument and returns a float. It may also take additional arguments, which should be specified in the docstring.
__count_crossings(G, crosses_limit=1000000.0)
Count the number of edge crossings in a graph.
Parameters
G : nx.Graph The graph to calculate the metric for.
Returns
int The number of edge crossings in the graph.
Source code in graphreadability/metrics/metrics.py
__crossing_angle_old(G, crossing_limit=1000000.0)
Calculate the metric for the edge crossings angle. crossing_limit specifies the maximum number of crossings allowed, which is limited due to long execution times.
Source code in graphreadability/metrics/metrics.py
__stress(G)
Calculate the metric for stress.
Stress is a measure of how well the graph preserves the pairwise distances between nodes.
Parameters
G : nx.Graph The graph to calculate the metric for.
Returns
float The stress metric.
Source code in graphreadability/metrics/metrics.py
angular_resolution(G, all_nodes=False)
Calculate the metric for angular resolution.
This metric captures how evenly the edges leaving a node are distributed. If all_nodes is True, include nodes with degree 1, for which the angle will always be perfect.
Parameters
G : nx.Graph The graph to calculate the metric for. all_nodes : bool Whether to include all nodes in the calculation.
Returns
float The angular resolution metric.
Source code in graphreadability/metrics/metrics.py
aspect_ratio(G)
Calculate the metric for aspect ratio.
Aspect ratio is the ratio of the width to the height of the smallest bounding box that contains all nodes.
Parameters
G : nx.Graph The graph to calculate the metric for.
Returns
float The aspect ratio metric.
Source code in graphreadability/metrics/metrics.py
crossing_angle(G, crossing_limit=1000000.0)
Calculate the metric for the edge crossings angle.
The edge crossings angle metric compares the angle of a crossing to an ideal angle. crossing_limit specifies the maximum number of crossings allowed, which is limited due to long execution times.
Parameters
G : nx.Graph The graph to calculate the metric for. crossing_limit : int The maximum number of crossings allowed.
Returns
float The edge crossings angle metric.
Raises
ValueError If the number of edges exceeds the crossing limit.
Source code in graphreadability/metrics/metrics.py
edge_crossing(G, subtract_tri=True, subtract_4=True)
Calculate the metric for the number of edge_crossing, scaled against the total number of possible crossings.
Parameters
G : nx.Graph The graph to calculate the metric for. verbose : bool Whether to print additional information about the metric.
Returns
float The edge crossing metric.
Source code in graphreadability/metrics/metrics.py
edge_length(G, ideal_edge_length=None)
Calculate the edge length metric.
The edge length metric compares the edge lengths to an ideal length. Default ideal is average of all edge lengths.
Parameters
G : nx.Graph The graph to calculate the metric for. ideal : float The ideal edge length.
Returns
float The edge length metric.
Source code in graphreadability/metrics/metrics.py
edge_orthogonality(G)
Calculate the metric for edge orthogonality.
Parameters
G : nx.Graph The graph to calculate the metric for. optimal_angle : float The optimal angle for edge orthogonality.
Returns
float The edge orthogonality metric.
Source code in graphreadability/metrics/metrics.py
gabriel_ratio(G)
Calculate the metric for the gabriel ratio.
A graph is a Gabriel graph if no node falls within the area of any circles constructed using each edge as its diameter.
Parameters
G : nx.Graph The graph to calculate the metric for.
Returns
float The gabriel ratio metric.
Source code in graphreadability/metrics/metrics.py
neighbourhood_preservation(G, k=None)
Calculate the metric for neighbourhood preservation.
Neighbourhood preservation is the average of the ratio of the number of neighbors by edges to the number of neighbors by k-nearest neighbors. This metric attempts to capture how well the geometry of the graph preserves the topology of the graph.
Parameters
G : nx.Graph The graph to calculate the metric for. k : int The number of nearest neighbours to consider.
Returns
float The neighbourhood preservation metric.
Source code in graphreadability/metrics/metrics.py
node_orthogonality(G)
Calculate the metric for node orthogonality.
Source code in graphreadability/metrics/metrics.py
node_resolution(G)
Calculate the metric for node resolution.
Node resolution is the ratio of the smallest and largest distance between any pair of nodes.
Parameters
G : nx.Graph The graph to calculate the metric for.
Returns
float The node resolution metric.
Source code in graphreadability/metrics/metrics.py
node_uniformity(G)
Calculate the metric for node uniformity.
Node uniformity is the ratio of the number of nodes to the number of cells in a grid that contains all nodes.
Parameters
G : nx.Graph The graph to calculate the metric for.
Returns
float The node uniformity metric.