powergrid_synth.core.analysis
This module provides tools for analyzing the topological properties of power grid graphs.
It includes the GridAnalyzer for calculating metrics like degree distribution,
path lengths, and clustering coefficients.
Module Contents
- class powergrid_synth.core.analysis.GridAnalyzer(graph)[source]
A class to perform topological analysis on power grid graphs. Can be used for both synthetic and real-world grids.
- Parameters:
graph (nx.Graph) – The networkx graph object representing the power grid.
- get_basic_stats()[source]
Returns fundamental counts (nodes, edges, density).
- Returns:
A dictionary containing ‘num_nodes’, ‘num_edges’, and ‘density’.
- Return type:
Dict[str, Any]
- get_clustering_metrics()[source]
Calculates global and average local clustering coefficients.
- Return type:
Dict[str, float]
- get_path_metrics()[source]
Calculates path-based metrics: Diameter and Average Shortest Path Length.
- Return type:
Dict[str, Any]
- plot_degree_distribution(ax=None, log_scale=True, figsize=(6, 4), title='Degree Distribution')[source]
Plots the degree distribution.
- Parameters:
ax (Optional[matplotlib.pyplot.Axes]) – Matplotlib axes to plot on. If None, creates a new figure.
log_scale (bool) – If True, plots log-log. If False, plots linear histogram.
figsize (tuple) – Size of figure if creating a new one.
title (str) – Title of the plot.