wholecell.utils.dependency_graph

Tools for working with dependency graphs

class wholecell.utils.dependency_graph.DependencyGraph[source]

Bases: object

Represents a dependency graph

dependencies

Mapping from node to that node’s dependents

Initialize dependencies to empty dictionary

_topo_sort_dfs(node, explored, reverse_ordering)[source]
add_dep_relation(a, b)[source]

Add an edge such that a depends on b

If a or b does not exist yet as a node, it will be created.

Parameters:
  • a – The name of the node that depends on b

  • b – The name of the node that is depended-upon by a

add_nodes(nodes)[source]

Add nodes with no dependencies

Parameters:

nodes – Nodes to add

get_topological_ordering()[source]

Get a topological ordering of the nodes

Returns:

List of dependency names such that the dependencies can be loaded in the order in which they appear in the list without violating dependency relationships.

Raises:

InvalidDependencyGraphError – If the graph contains a cycle

class wholecell.utils.dependency_graph.ExplorationStatus[source]

Bases: object

EXPLORED = 3

Node has been visited and added to list.

EXPLORING = 2

Node has been visited but not added to list. This means that we have not yet finished with the node.

UNEXPLORED = 1

Node has not yet been visited.

exception wholecell.utils.dependency_graph.InvalidDependencyGraphError[source]

Bases: Exception

Exception for invalid dependency graphs