MCPcopy Create free account
hub / github.com/Integuru-AI/Integuru / detect_cycles

Method detect_cycles

integuru/models/DAGManager.py:33–47  ·  view source on GitHub ↗

Detects if there are cycles in the DAG managed by this class. If a cycle is found, it returns the list of nodes involved in the cycle. If no cycle is found, it returns None. Returns: - A list of nodes forming a cycle, or None if no cycles are found.

(self)

Source from the content-addressed store, hash-verified

31 self.graph.nodes[node_id][attr] = value
32
33 def detect_cycles(self):
34 """
35 Detects if there are cycles in the DAG managed by this class.
36 If a cycle is found, it returns the list of nodes involved in the cycle.
37 If no cycle is found, it returns None.
38
39 Returns:
40 - A list of nodes forming a cycle, or None if no cycles are found.
41 """
42 try:
43 cycle = list(nx.find_cycle(self.graph, orientation='original'))
44 print("Cycle detected:")
45 return cycle
46 except nx.exception.NetworkXNoCycle:
47 return None
48
49 def get_node(self, node_id: str) -> Optional[Dict]:
50 """

Callers 1

check_end_conditionFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected