Download scripts/dev/3.7_test_visualisations.py from SlappAI/Singularity: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/SlappAI/Singularity/resolve/c8aa03645367f13b28133e72d9204fa09654b00a/scripts/dev/3.7_test_visualisations.py
- Command line
-
hf download hf://SlappAI/Singularity@c8aa03645367f13b28133e72d9204fa09654b00a/scripts/dev/3.7_test_visualisations.py
-
curl -L -o 3.7_test_visualisations.py https://huggingface.co/SlappAI/Singularity/resolve/c8aa03645367f13b28133e72d9204fa09654b00a/scripts/dev/3.7_test_visualisations.py
1.15 kB
| # test_build_and_visualize_graph.py | |
| import os | |
| import sys | |
| import json | |
| import networkx as nx | |
| # Add the path to access agn_service | |
| 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 | |
| # Define paths | |
| index_file_path = "graphs/index.json" # Path to index.json file | |
| output_image = "test_graph_visualization.png" | |
| # Load index data | |
| def load_index_data(file_path): | |
| with open(file_path, "r") as file: | |
| return json.load(file) | |
| # Main execution | |
| if __name__ == "__main__": | |
| # Step 1: Load index data from index.json | |
| data = load_index_data(index_file_path) | |
| # Step 2: Build the graph using the data loaded from index.json | |
| G = build_graph_from_index(data) | |
| # Step 3: Generate and save the graph visualization | |
| 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.") |