-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats_vis.py
More file actions
31 lines (27 loc) · 907 Bytes
/
Copy pathstats_vis.py
File metadata and controls
31 lines (27 loc) · 907 Bytes
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
#!/usr/bin/env python3
import os
from kg.graph_store import KnowledgeGraphStore
from kg.vis import create_visualization
def main():
# 1️⃣ Load the graph
storage_dir = os.path.expanduser("~/.mr_kg_data")
gs = KnowledgeGraphStore(storage_path=storage_dir)
# 2️⃣ Print basic stats
stats = gs.get_statistics()
print("📊 Knowledge Graph stats:", stats)
# 3️⃣ Build a visualization PNG
kg_json = os.path.join(storage_dir, "knowledge_graph.json")
output_png = "kg_graph.png"
print(f"🔧 Generating visualization → {output_png}")
result = create_visualization(
kg_json_path=kg_json,
output_path=output_png,
format='png',
layout='dot'
)
if result:
print("✅ Visualization written to", result)
else:
print("❌ Visualization failed. See errors above.")
if __name__ == "__main__":
main()