|
|
|
|
|
import os |
|
import sys |
|
import json |
|
import networkx as nx |
|
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), "../")) |
|
from app.services.agn_service.load_graph import load_graph |
|
from app.services.agn_service.build_graph_from_index import build_graph_from_index |
|
from app.services.agn_service.visualize_graph import visualize_graph |
|
|
|
|
|
index_file_path = "graphs/index.json" |
|
output_image = "test_graph_visualization.png" |
|
|
|
|
|
def load_index_data(file_path): |
|
with open(file_path, "r") as file: |
|
return json.load(file) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
data = load_index_data(index_file_path) |
|
|
|
|
|
G = build_graph_from_index(data) |
|
|
|
|
|
if G: |
|
visualize_graph(G, output_file=output_image) |
|
print(f"Graph visualization generated and saved as {output_image}") |
|
else: |
|
print("Failed to build graph.") |