DistributionGraph#

class shift.DistributionGraph#

A class representing distribution system as a graph.

Internally, graph data is stored using networkx Graph instance.

Examples

>>> dgraph = DistributionGraph()

Adding a node the system.

>>> from shift import NodeModel
>>> dgraph.add_node(NodeModel(name="node_1"))

Adding multiple nodes to the system.

>>> from gdm import DistributionLoad
>>> dgraph.add_nodes([NodeModel(name="node_2", assets={DistributionLoad}),
    NodeModel(name="node_3")])

Adding an edge to the system.

>>> from shift import EdgeModel
>>> dgraph.add_edge("node_1", "node_2", edge_data=EdgeModel(name="node1_node2",
    edge_type=DistributionBranchBase))

Getting node data.

>>> dgraph.get_node("node_1")

Getting all nodes.

>>> dgraph.get_nodes()

Getting filtered nodes.

>>> dgraph.get_nodes(filter_func=lambda x: len(x.assets) == 0)

Remove a node.

>>> dgraph.remove_node("node_2")

Methods#

DistributionGraph.__init__()

DistributionGraph.add_node(node)

Adds node to the graph.

DistributionGraph.add_nodes(nodes)

Adds multiple nodes to the graph.

DistributionGraph.add_edge(from_node, ...)

Adds edge to the graph.

DistributionGraph.get_node(node_name)

Get node data by node name.

DistributionGraph.get_nodes([filter_func])

Returns list of nodes.

DistributionGraph.remove_node(node_name)

Removes a node from the system.

DistributionGraph.get_edge(from_node, to_node)

Get edge data.

DistributionGraph.remove_edge(from_node, to_node)

Removes an edge from the system.

DistributionGraph.get_undirected_graph()

Method to return undirected graph.

DistributionGraph.get_dfs_tree()

Internal method to directed dfs tree from vsource.