Skip to content

factory

get_state_dependency_graph(states=None)

Parameters:

Name Type Description Default
states None or Iterable

If specified, specific state(s) to sort. Otherwise, will generate dependency graph over all states

None

Returns:

Type Description
DiGraph

State dependency graph of supported object states

Source code in omnigibson/object_states/factory.py
def get_state_dependency_graph(states=None):
    """
    Args:
        states (None or Iterable): If specified, specific state(s) to sort. Otherwise, will generate dependency graph
            over all states

    Returns:
        nx.DiGraph: State dependency graph of supported object states
    """
    states = REGISTERED_OBJECT_STATES.values() if states is None else states
    dependencies = {state: set.union(state.get_dependencies(), state.get_optional_dependencies()) for state in states}
    return nx.DiGraph(dependencies)

get_states_by_dependency_order(states=None)

Parameters:

Name Type Description Default
states None or Iterable

If specified, specific state(s) to sort. Otherwise, will generate dependency graph over all states

None

Returns:

Type Description
list

all states in topological order of dependency

Source code in omnigibson/object_states/factory.py
def get_states_by_dependency_order(states=None):
    """
    Args:
        states (None or Iterable): If specified, specific state(s) to sort. Otherwise, will generate dependency graph
            over all states

    Returns:
        list: all states in topological order of dependency
    """
    return list(reversed(list(nx.algorithms.topological_sort(get_state_dependency_graph(states)))))