コード例 #1
0
ファイル: axiom_rules.py プロジェクト: caelan/downward
def get_strongly_connected_components(dependencies):
    sorted_vars = sorted(dependencies.derived_variables)
    variable_to_index = {var: index for index, var in enumerate(sorted_vars)}

    adjacency_list = []
    for derived_var in sorted_vars:
        pos = dependencies.positive_dependencies[derived_var]
        neg = dependencies.negative_dependencies[derived_var]
        indices = [variable_to_index[atom] for atom in sorted(pos.union(neg))]
        adjacency_list.append(indices)

    index_groups = sccs.get_sccs_adjacency_list(adjacency_list)
    groups = [[sorted_vars[i] for i in g] for g in index_groups]
    return groups
コード例 #2
0
 def get_strongly_connected_components(self):
     unweighted_graph = [[] for _ in range(self.num_variables)]
     assert(len(self.weighted_graph) <= self.num_variables)
     for source, target_weights in self.weighted_graph.items():
         unweighted_graph[source] = sorted(target_weights.keys())
     return sccs.get_sccs_adjacency_list(unweighted_graph)