pypsa.SubNetwork.adjacency_matrix#
- SubNetwork.adjacency_matrix(branch_components: Collection[str] | None = None, investment_period: int | str | None = None, busorder: pd.Index | None = None, weights: pd.Series | None = None) sp.sparse.coo_matrix#
Construct a sparse adjacency matrix (directed).
- Parameters:
n (Network | SubNetwork) – Network or sub-network.
branch_components (iterable sublist of branch_components) – Buses connected by any of the selected branches are adjacent (default: branch_components (network) or passive_branch_components (sub_network))
investment_period (int | str | None) – Investment period to use for the matrix representation of the adjacency matrix.
busorder (pd.Index subset of n.buses.index) – Basis to use for the matrix representation of the adjacency matrix (default: buses.index (network) or buses_i() (sub_network))
weights (pd.Series or None (default)) – If given must provide a weight for each branch, multi-indexed on branch_component name and branch name.
- Returns:
adjacency_matrix (sp.sparse.coo_matrix)
Directed adjacency matrix
Examples
>>> n.adjacency_matrix() <COOrdinate sparse matrix of dtype 'float64' with ... stored elements and shape (..., ...)>