-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdig.py
More file actions
47 lines (35 loc) Β· 1.65 KB
/
Copy pathdig.py
File metadata and controls
47 lines (35 loc) Β· 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# diagnose_qekgr.py
import sys
sys.path.insert(0, '.')
try:
import qekgr
from qekgr import EntangledGraph, QuantumInference, EntangledQueryEngine
print('π QE-KGR Library Test')
print('=' * 30)
graph = EntangledGraph(hilbert_dim=4)
print(f'β
Created quantum graph with Hilbert dimension: {graph.hilbert_dim}')
alice = graph.add_quantum_node('Alice', state='researcher',
metadata={'field': 'quantum_physics'})
bob = graph.add_quantum_node('Bob', state='professor',
metadata={'field': 'computer_science'})
print('β
Added quantum nodes: Alice, Bob')
edge = graph.add_entangled_edge(alice, bob,
relations=['collaborates', 'co_authors'],
amplitudes=[0.8, 0.6])
print(f'β
Added entangled edge with strength: {edge.entanglement_strength:.3f}')
inference = QuantumInference(graph)
walk_result = inference.quantum_walk(start_node='Alice', steps=5)
print(f'β
Quantum walk completed: {len(walk_result.path)} steps')
print(' Path: ' + ' -> '.join(walk_result.path))
query_engine = EntangledQueryEngine(graph)
results = query_engine.query('Who collaborates with Alice?')
print(f'β
Query processed: {len(results)} results found')
if results:
print(f' Top result confidence: {results[0].confidence_score:.3f}')
print()
print('π All core functionality working!')
print('π QE-KGR is ready for quantum-enhanced knowledge reasoning!')
except Exception as e:
print(f'β Error: {e}')
import traceback
traceback.print_exc()