Graph Metrics¶
Compute statistics that describe the overall graph structure.
Basic Metrics¶
from grafeo.algorithms import graph_metrics
metrics = graph_metrics(db)
print(f"Nodes: {metrics.node_count}")
print(f"Edges: {metrics.edge_count}")
print(f"Density: {metrics.density:.4f}")
print(f"Avg Degree: {metrics.average_degree:.2f}")
Density¶
Ratio of actual edges to possible edges.
Diameter¶
Longest shortest path in the graph.
Radius¶
Minimum eccentricity (shortest max distance from any node).
Clustering Coefficient¶
Measure of how clustered the graph is.
from grafeo.algorithms import clustering_coefficient
# Global clustering coefficient
global_cc = clustering_coefficient(db, method='global')
# Local clustering coefficients
local_cc = clustering_coefficient(db, method='local')
# Average local
avg_cc = clustering_coefficient(db, method='average')
Degree Distribution¶
from grafeo.algorithms import degree_distribution
dist = degree_distribution(db)
for degree, count in sorted(dist.items()):
print(f"Degree {degree}: {count} nodes")
Summary Table¶
| Metric | Range | Interpretation |
|---|---|---|
| Density | 0-1 | Higher = more connected |
| Diameter | 1-n | Lower = more compact |
| Clustering | 0-1 | Higher = more clustered |
| Avg Degree | 0-n | Higher = more edges per node |