#!/usr/bin/env python3
"""Debug script to check what matches are found."""

import networkx as nx
from nxcypher import NXCypher

# Create test graph with self-loop
G = nx.DiGraph()
G.add_node('n1', __labels__={'A'})
G.add_edge('n1', 'n1', __labels__={'LOOP'})

# Also add a normal edge for comparison
G.add_node('n2', __labels__={'B'})
G.add_edge('n1', 'n2', __labels__={'REL'})

print("=== Graph ===")
print(f"Nodes: {list(G.nodes(data=True))}")
print(f"Edges: {list(G.edges(data=True))}")
print()

# Test 1: MATCH ()-->() should match ALL directed edges (including self-loop)
print("=== Test 1: MATCH ()-->() RETURN count(*) ===")
result1 = NXCypher(G).run("MATCH ()-->() RETURN count(*)")
print(f"Result: {result1}")
print(f"Expected: {{'COUNT(*)': [2]}} (self-loop + normal edge)")
print()

# Test 2: Return the nodes to see what's matched
print("=== Test 2: MATCH (a)-->(b) RETURN a, b ===")
result2 = NXCypher(G).run("MATCH (a)-->(b) RETURN a, b")
print(f"Result: {result2}")
print(f"Should include both (n1->n1) and (n1->n2)")
print()

# Test 3: Explicit self-loop match
print("=== Test 3: MATCH (n)-->(n) RETURN n ===")
result3 = NXCypher(G).run("MATCH (n)-->(n) RETURN n")
print(f"Result: {result3}")
print(f"Should only include n1")
