MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / all_partial_orderings

Function all_partial_orderings

lib/sqlalchemy/testing/util.py:118–133  ·  lib/sqlalchemy/testing/util.py::all_partial_orderings
(tuples, elements)

Source from the content-addressed store, hash-verified

116
117
118def all_partial_orderings(tuples, elements):
119 edges = defaultdict(set)
120 for parent, child in tuples:
121 edges[child].add(parent)
122
123 def _all_orderings(elements):
124 if len(elements) == 1:
125 yield list(elements)
126 else:
127 for elem in elements:
128 subset = set(elements).difference([elem])
129 if not subset.intersection(edges[elem]):
130 for sub_ordering in _all_orderings(subset):
131 yield [elem] + sub_ordering
132
133 return iter(_all_orderings(elements))
134
135
136def function_named(fn, name):

Callers 1

Calls 2

_all_orderingsFunction · 0.85
addMethod · 0.45

Tested by 1