MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / test_topological_ordering

Function test_topological_ordering

numpy_ml/tests/test_utils.py:303–323  ·  view source on GitHub ↗
(N=1)

Source from the content-addressed store, hash-verified

301
302
303def test_topological_ordering(N=1):
304 np.random.seed(12345)
305 i = 0
306 while i < N:
307 p = np.random.uniform(0.25, 1)
308 n_v = np.random.randint(5, 10)
309
310 G = random_DAG(n_v, p)
311 G_nx = to_networkx(G)
312
313 if nx.is_directed_acyclic_graph(G_nx):
314 topo_order = G.topological_ordering()
315
316 # test topological order
317 seen_it = set()
318 for n_i in topo_order:
319 seen_it.add(n_i)
320 assert any([c_i in seen_it for c_i in G.get_neighbors(n_i)]) == False
321
322 print("PASSED")
323 i += 1
324
325
326def test_is_acyclic(N=1):

Callers

nothing calls this directly

Calls 4

random_DAGFunction · 0.90
to_networkxFunction · 0.85
topological_orderingMethod · 0.80
get_neighborsMethod · 0.80

Tested by

no test coverage detected