MCPcopy
hub / github.com/networkx/networkx / find_creation_sequence

Function find_creation_sequence

networkx/algorithms/threshold.py:408–436  ·  view source on GitHub ↗

Find a threshold subgraph that is close to largest in G. Returns the labeled creation sequence of that threshold graph.

(G)

Source from the content-addressed store, hash-verified

406
407@nx._dispatchable
408def find_creation_sequence(G):
409 """
410 Find a threshold subgraph that is close to largest in G.
411 Returns the labeled creation sequence of that threshold graph.
412 """
413 cs = []
414 # get a local pointer to the working part of the graph
415 H = G
416 while H.order() > 0:
417 # get new degree sequence on subgraph
418 dsdict = dict(H.degree())
419 ds = [(d, v) for v, d in dsdict.items()]
420 ds.sort()
421 # Update threshold graph nodes
422 if ds[-1][0] == 0: # all are isolated
423 cs.extend(zip(dsdict, ["i"] * (len(ds) - 1) + ["d"]))
424 break # Done!
425 # pull off isolated nodes
426 while ds[0][0] == 0:
427 (d, iso) = ds.pop(0)
428 cs.append((iso, "i"))
429 # find new biggest node
430 (d, bigv) = ds.pop()
431 # add edges of star to t_g
432 cs.append((bigv, "d"))
433 # form subgraph of neighbors of big node
434 H = H.subgraph(H.neighbors(bigv))
435 cs.reverse()
436 return cs
437
438
439# Properties of Threshold Graphs

Callers 1

find_threshold_graphFunction · 0.85

Calls 8

orderMethod · 0.80
appendMethod · 0.80
degreeMethod · 0.45
itemsMethod · 0.45
popMethod · 0.45
subgraphMethod · 0.45
neighborsMethod · 0.45
reverseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…