bw_graph_tools.graph_traversal_utils

Attributes

brightway_available

Functions

get_path_from_matrix(→ List)

Get the path with the most mass or energetic flow from source (the function unit) to target (something deep in the supply chain). Both source and target are integer matrix indices.

path_as_brightway_objects(→ List[bw2data.Edge])

Module Contents

bw_graph_tools.graph_traversal_utils.get_path_from_matrix(matrix: scipy.sparse.spmatrix, source: int, target: int, algorithm: str = 'BF') List[source]

Get the path with the most mass or energetic flow from source (the function unit) to target (something deep in the supply chain). Both source and target are integer matrix indices.

algorithm should be either BF (Bellman-Ford) or J (Johnson). Dijkstra is not recommended as we have negative weights.

Returns a list like [source, int, int, int, target].

bw_graph_tools.graph_traversal_utils.path_as_brightway_objects(source_node: bw2data.Node, target_node: bw2data.Node, lca: bw2calc.LCA | None = None) List[bw2data.Edge][source]
bw_graph_tools.graph_traversal_utils.brightway_available = True[source]