MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _write_cycle_graph

Function _write_cycle_graph

tests/test_cycles_cli.py:13–28  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

11
12
13def _write_cycle_graph(tmp_path):
14 g = nx.DiGraph()
15 g.add_node("a", label="a.py", file_type="code", source_file="a.py")
16 g.add_node("b", label="b.py", file_type="code", source_file="b.py")
17 g.add_node("c", label="c.py", file_type="code", source_file="c.py")
18 g.add_node("d", label="d.py", file_type="code", source_file="d.py")
19 # 2-file cycle: a.py <-> b.py
20 g.add_edge("a", "b", relation="imports_from", source_file="a.py", confidence="EXTRACTED")
21 g.add_edge("b", "a", relation="imports_from", source_file="b.py", confidence="EXTRACTED")
22 # 3-file cycle: b.py -> c.py -> d.py -> b.py
23 g.add_edge("b", "c", relation="imports_from", source_file="b.py", confidence="EXTRACTED")
24 g.add_edge("c", "d", relation="imports_from", source_file="c.py", confidence="EXTRACTED")
25 g.add_edge("d", "b", relation="imports_from", source_file="d.py", confidence="EXTRACTED")
26 gp = tmp_path / "graph.json"
27 gp.write_text(json.dumps(json_graph.node_link_data(g, edges="links")), encoding="utf-8")
28 return gp
29
30
31def _write_acyclic_graph(tmp_path):

Calls 2

add_nodeMethod · 0.80
add_edgeMethod · 0.80

Tested by

no test coverage detected