Topological Searches

Once you converted your network into a MultiGraph there are several functions to perform topological searches and analyses at your disposal. You can either use the general-purpose functions that come with NetworkX (see http:/networkx.github.io/documentation/networkx-1.10/reference/algorithms.html) or topology’s own ones which are specialized on electrical networks.

calc_distance_to_bus

pandapower.topology.calc_distance_to_bus(net, bus, respect_switches=True, nogobuses=None, notravbuses=None, weight='weight', g=None)

Calculates the shortest distance between a source bus and all buses connected to it.

Parameters:
  • **net** (pandapowerNet)

  • **bus** (integer)

  • **respect_switches** (boolean, True) –

    True: open line switches are being considered (no edge between nodes).

    False: open line switches are being ignored.

  • **nogobuses** (integer/list, None)

  • **notravbuses** (integer/list, None)

  • **weight** (string, None)

  • **g** (nx.MultiGraph, None)

Returns:

dist - Returns a pandas series with containing all distances to the source bus

in km. If weight=None dist is the topological distance (int).

Example

>>> from pandapower.topology.graph_searches import calc_distance_to_bus
>>> dist = calc_distance_to_bus(net, 5)

connected_component

pandapower.topology.connected_component(mg, bus, notravbuses=[])

Finds all buses in a NetworkX graph that are connected to a certain bus.

Parameters:
  • **mg** (NetworkX graph)

  • **bus** (integer)

  • **notravbuses** (list/set) – lines connected to these buses are not being considered in the graph

Returns:

cc (generator) - Returns a generator that yields all buses connected to the input bus

Example

>>> from pandapower.topology.create_graph import create_nxgraph
>>> from pandapower.topology.graph_searches import connected_component
>>> mg = create_nxgraph(net)
>>> cc = connected_component(mg, 5)

connected_components

pandapower.topology.connected_components(mg, notravbuses=set())

Clusters all buses in a NetworkX graph that are connected to each other.

Parameters:

**mg** (NetworkX graph)

OPTIONAL: notravbuses (set) - Indices of notravbuses: lines connected to these buses are not being considered in the graph

Returns:

cc (generator) - Returns a generator that yields all clusters of buses connected

to each other.

Example

>>> from pandapower.topology.create_graph import create_nxgraph
>>> from pandapower.topology.graph_searches import connected_components
>>> mg = create_nxgraph(net)
>>> cc = connected_components(mg, 5)

unsupplied_buses

pandapower.topology.unsupplied_buses(net, mg=None, slacks=None, respect_switches=True)

Finds buses, that are not connected electrically (no lines, trafos etc or if respect_switches is True only connected via open switches) to an external grid and that are in service.

Parameters:
  • **net** (pandapowerNet)

  • **mg** (NetworkX graph)

  • **in_service_only** (boolean, False) – included in unsupplied_buses.

  • **slacks** (set, None) – existing slack buses are considered.

  • **respect_switches** (boolean, True) – given mg.

Returns:

ub (set) - unsupplied buses

Example

>>> from pandapower.topology.graph_searches import unsupplied_buses
>>> unsupplied_buses(net)

determine_stubs

pandapower.topology.determine_stubs(net, roots=None, mg=None, respect_switches=False)

Finds stubs in a network. Open switches are being ignored. Results are being written in a new column in the bus table (“on_stub”) and line table (“is_stub”) as True/False value.

Parameters:
  • **net** (pandapowerNet)

  • **roots** (integer/list, None) – ext_grid buses will be set as roots)

Example

>>> from pandapower.topology.graph_searches import determine_stubs
>>> determine_stubs(net, roots = [0, 1])