MCPcopy
hub / github.com/celery/celery / topsort

Method topsort

celery/utils/graph.py:63–83  ·  view source on GitHub ↗

Sort the graph topologically. Returns: List: of objects in the order in which they must be handled.

(self)

Source from the content-addressed store, hash-verified

61 self.adjacent.update(graph.adjacent)
62
63 def topsort(self):
64 """Sort the graph topologically.
65
66 Returns:
67 List: of objects in the order in which they must be handled.
68 """
69 graph = DependencyGraph()
70 components = self._tarjan72()
71
72 NC = {
73 node: component for component in components for node in component
74 }
75 for component in components:
76 graph.add_arc(component)
77 for node in self:
78 node_c = NC[node]
79 for successor in self[node]:
80 successor_c = NC[successor]
81 if node_c != successor_c:
82 graph.add_edge(node_c, successor_c)
83 return [t[0] for t in graph._khan62()]
84
85 def valency_of(self, obj):
86 """Return the valency (degree) of a vertex in the graph."""

Callers 2

test_topsortMethod · 0.80
_finalize_stepsMethod · 0.80

Calls 5

_tarjan72Method · 0.95
add_arcMethod · 0.95
add_edgeMethod · 0.95
_khan62Method · 0.95
DependencyGraphClass · 0.85

Tested by 1

test_topsortMethod · 0.64