MCPcopy Index your code
hub / github.com/clips/pattern / sorted

Method sorted

pattern/graph/__init__.py:476–483  ·  view source on GitHub ↗

Returns a list of nodes sorted by WEIGHT or CENTRALITY. Nodes with a lot of traffic will be at the start of the list.

(self, order=WEIGHT, threshold=0.0)

Source from the content-addressed store, hash-verified

474 return bc
475
476 def sorted(self, order=WEIGHT, threshold=0.0):
477 """ Returns a list of nodes sorted by WEIGHT or CENTRALITY.
478 Nodes with a lot of traffic will be at the start of the list.
479 """
480 o = lambda node: getattr(node, order)
481 nodes = ((o(n), n) for n in self.nodes if o(n) >= threshold)
482 nodes = reversed(sorted(nodes))
483 return [n for w, n in nodes]
484
485 def prune(self, depth=0):
486 """ Removes all nodes with less or equal links than depth.

Callers 4

test_canvas.jsFile · 0.80
test_sortedMethod · 0.80
02-export.pyFile · 0.80
01-graph.pyFile · 0.80

Calls

no outgoing calls

Tested by 1

test_sortedMethod · 0.64