bw_graph_tools.graph_traversal.base

Attributes

Settings

Exceptions

GraphTraversalException

Common base class for all non-exit exceptions.

Classes

BaseGraphTraversal

Base class for common graph traversal methods. Should be inherited from, not used directly.

Module Contents

exception bw_graph_tools.graph_traversal.base.GraphTraversalException[source]

Bases: Exception

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

class bw_graph_tools.graph_traversal.base.BaseGraphTraversal(lca: bw2calc.LCA, settings: Settings, functional_unit_unique_id: int = -1, static_activity_indices=None)[source]

Bases: Generic[Settings]

Base class for common graph traversal methods. Should be inherited from, not used directly.

Parameters:
  • lca (bw2calc.LCA) – Already instantiated LCA object with inventory and impact assessment calculated.

  • settings (object) – Settings for the graph traversal

  • functional_unit_unique_id (int) – An integer id we can use for the functional unit virtual activity. Shouldn’t overlap any other activity ids. Don’t change unless you really know what you are doing.

  • static_activity_indices (set) – A set of activity matrix indices which we don’t want the graph to traverse - i.e. we stop traversal when we hit these nodes, but still add them to the returned nodes dictionary, and calculate their direct and cumulative scores.

_caching_solver[source]
_edges: List[bw_graph_tools.graph_traversal.graph_objects.Edge] = [][source]
_flows: List[bw_graph_tools.graph_traversal.graph_objects.Flow] = [][source]
_functional_unit_unique_id = -1[source]
_max_calc[source]
_nodes: Dict[int, bw_graph_tools.graph_traversal.graph_objects.Node][source]
_root_node[source]
property edges[source]

List of Edge instances. Edges link two Node instances.

Note that there are no Edge instances which link Flow instances - these are handled separately.

See the Edge documentation for its other attributes.

property flows[source]

List of Flow instances.

A Flow instance is a characterized biosphere flow associated with a specific Node instance.

See the Flow documentation for its other attributes.

lca[source]
metadata[source]
property nodes[source]

List of Node dataclass instances.

Each Node instance has a unique_id, regardless of graph traversal class. In some classes, each node in the database will only appear once in this list of graph traversal node instances, but in NewNodeEachVisitGraphTraversal, we create a new Node every time we reach a database node, even if we have seen it before.

See the Node documentation for its other attributes.

settings[source]
static_activity_indices = None[source]
bw_graph_tools.graph_traversal.base.Settings[source]