fund-flow-backend / tests /test_graph.py
Aniket2006's picture
refactor: migrate test suite to centralize in tests/ directory and configure path resolution
53c4b9e
Raw
History Blame Contribute Delete
1.15 kB
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import warnings
warnings.filterwarnings('ignore')
from src.data_loader import get_processed_data
import src.graph_builder as gb
import time
print("Loading data...")
transactions_df, node_features_df = get_processed_data()
print(f"Data loaded. {len(transactions_df)} transactions.")
print("Building graph...")
start = time.time()
G = gb.build_graph(transactions_df)
print(f"Built graph in {time.time() - start:.2f}s")
print(f"Nodes: {G.number_of_nodes()}, Edges: {G.number_of_edges()}")
print("Attaching node features...")
start = time.time()
G = gb.attach_node_features(G, node_features_df)
print(f"Attached features in {time.time() - start:.2f}s")
print("Computing Louvain...")
start = time.time()
louvain = gb.compute_louvain(G)
print(f"Computed Louvain in {time.time() - start:.2f}s")
print(f"Found {len(set(louvain.values()))} communities.")
print("Computing Subgraph...")
center = node_features_df.index[0]
sub_G = gb.get_subgraph(G, center)
print(f"Subgraph for {center}: {sub_G.number_of_nodes()} nodes, {sub_G.number_of_edges()} edges")