Visualizes the DAG using Matplotlib with arrows indicating direction.
(graph: nx.DiGraph)
| 69 | |
| 70 | |
| 71 | def visualize_dag(graph: nx.DiGraph) -> None: |
| 72 | """ |
| 73 | Visualizes the DAG using Matplotlib with arrows indicating direction. |
| 74 | """ |
| 75 | plt.switch_backend("Agg") |
| 76 | |
| 77 | pos = nx.spring_layout(graph) |
| 78 | |
| 79 | nx.draw_networkx_nodes(graph, pos, node_size=700, node_color="lightblue") |
| 80 | |
| 81 | nx.draw_networkx_edges( |
| 82 | graph, pos, edgelist=graph.edges, arrowstyle="->", arrowsize=20 |
| 83 | ) |
| 84 | |
| 85 | labels = {node: f"{node}" for node in graph.nodes()} |
| 86 | nx.draw_networkx_labels(graph, pos, labels, font_size=10) |
| 87 | |
| 88 | edge_labels = nx.get_edge_attributes(graph, "cUrl") |
| 89 | nx.draw_networkx_edge_labels(graph, pos, edge_labels=edge_labels) |
| 90 | |
| 91 | plt.title("Directed Acyclic Graph (DAG)") |
| 92 | plt.savefig("dag_visualization.png") |
| 93 | plt.close() |
| 94 | |
| 95 | |
| 96 | def find_json_path(json_obj, target_value, current_path=None): |
no outgoing calls
no test coverage detected