MCPcopy Index your code
hub / github.com/nodejs/node / FindCycles

Method FindCycles

tools/gyp/pylib/gyp/input.py:1711–1729  ·  view source on GitHub ↗

Returns a list of cycles in the graph, where each cycle is its own list.

(self)

Source from the content-addressed store, hash-verified

1709 return list(flat_list)
1710
1711 def FindCycles(self):
1712 """
1713 Returns a list of cycles in the graph, where each cycle is its own list.
1714 """
1715 results = []
1716 visited = set()
1717
1718 def Visit(node, path):
1719 for child in node.dependents:
1720 if child in path:
1721 results.append([child] + path[: path.index(child) + 1])
1722 elif child not in visited:
1723 visited.add(child)
1724 Visit(child, [child] + path)
1725
1726 visited.add(self)
1727 Visit(self, [self])
1728
1729 return results
1730
1731 def DirectDependencies(self, dependencies=None):
1732 """Returns a list of just direct dependencies."""

Callers 9

BuildDependencyListFunction · 0.95
test_no_cycle_lineMethod · 0.80
test_no_cycle_dagMethod · 0.80
test_cycle_two_nodesMethod · 0.80
test_two_cyclesMethod · 0.80
test_big_cycleMethod · 0.80

Calls 3

VisitFunction · 0.85
addMethod · 0.65
setFunction · 0.50

Tested by 7

test_no_cycle_lineMethod · 0.64
test_no_cycle_dagMethod · 0.64
test_cycle_two_nodesMethod · 0.64
test_two_cyclesMethod · 0.64
test_big_cycleMethod · 0.64