Graph Export
February 25, 2026 ยท View on GitHub
Export the entire knowledge graph to JSON for programmatic access and integration with other tools.
Export Commands
Export during graph update:
cgr start --repo-path /path/to/repo --update-graph --clean -o my_graph.json
Export existing graph without updating:
cgr export -o my_graph.json
Adjust Memgraph batching during export:
cgr export -o my_graph.json --batch-size 5000
Working with Exported Data
from codebase_rag.graph_loader import load_graph
graph = load_graph("my_graph.json")
summary = graph.summary()
print(f"Total nodes: {summary['total_nodes']}")
print(f"Total relationships: {summary['total_relationships']}")
functions = graph.find_nodes_by_label("Function")
classes = graph.find_nodes_by_label("Class")
for func in functions[:5]:
relationships = graph.get_relationships_for_node(func.node_id)
print(f"Function {func.properties['name']} has {len(relationships)} relationships")
Example Analysis Script
python examples/graph_export_example.py my_graph.json
Use Cases
Exported graph data is useful for:
- Integration with other tools
- Custom analysis scripts
- Building documentation generators
- Creating code metrics dashboards
See the Python SDK for more programmatic access patterns.