# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import networkx as nx
import matplotlib.pyplot as plt
from scipy.io import loadmat

dat = loadmat('ACTIVSg200r-bus.mat')
bus = dat['bus'] # each row (bus-number, bus-type)
dat = loadmat('ACTIVSg200r-branch.mat')
branch = dat['branch'] # each row (from-bus, to-bus, line-limits)

[nbus, unused] = bus.shape
[nbranch, unused] =  branch.shape

[1,2,3]-[1,1,1]

a = {1:[1,2,2]-1, 2:[10,20], 3:[50]}
print(a)
len(a)

# +
G = nx.Graph()
for i in range(nbus):
    G.add_node(bus[i,0])
# for i in range(nbranch):

G.add_edges_from(branch[:,[0,1]])
# -

# plt.subplot(121)
plt.figure(figsize=[10,10])
nx.draw_planar(G, with_labels=True)



StarcoderdataJupyterScriptsDedupFiltered