Graph Types
Graph Types
Section titled “Graph Types”Arxo builds and analyzes multiple graph representations of your codebase. Each graph captures different architectural relationships.
Import Graph
Section titled “Import Graph”The Import Graph represents module-level dependencies extracted from import/require statements.
What It Captures
Section titled “What It Captures”Nodes: Files, modules, or packages (depending on grouping) Edges: Import/dependency relationships
Example
Section titled “Example”import { theme } from '../styles/theme';import { logger } from '../utils/logger';
// src/pages/Home.tsximport { Button } from '../components/Button';Import Graph:
pages/Home.tsx → components/Button.tsxcomponents/Button.tsx → styles/theme.tsxcomponents/Button.tsx → utils/logger.tsxGrouping Options
Section titled “Grouping Options”Control granularity with group_by and group_depth:
File-level (default):
import_graph: group_by: fileFolder-level:
import_graph: group_by: folder group_depth: 1 # Group by immediate parent folderPackage-level:
import_graph: group_by: folder group_depth: 2 # Group by top-level packagesUse Cases
Section titled “Use Cases”- Detect circular dependencies (SCC metric)
- Measure propagation cost
- Identify architectural layers
- Validate import rules
Call Graph
Section titled “Call Graph”The Call Graph represents function and method invocations.
What It Captures
Section titled “What It Captures”Nodes: Functions, methods, classes Edges: Function calls, method invocations
Example
Section titled “Example”export function log(message: string) { console.log(message);}
// services/api.tsimport { log } from '../utils/logger';
export async function fetchData(url: string) { log(`Fetching ${url}`); return fetch(url);}
// components/DataLoader.tsximport { fetchData } from '../services/api';
export function DataLoader() { const data = fetchData('/api/data'); // ...}Call Graph:
DataLoader() → fetchData()fetchData() → log()fetchData() → fetch()Cross-Language Calls
Section titled “Cross-Language Calls”Arxo tracks calls across language boundaries:
TypeScript → Python (via REST API):
fetch('/api/analyze')
// backend/main.py@app.route('/api/analyze')def analyze(): return run_analysis()Use Cases
Section titled “Use Cases”- Analyze runtime dependencies
- Find unused functions
- Detect code smells (God functions)
- Impact analysis for changes
Entity Graph
Section titled “Entity Graph”The Entity Graph represents high-level component relationships.
What It Captures
Section titled “What It Captures”Nodes: Files, modules, components Edges: Various relationships (imports, calls, shared types)
Example
Section titled “Example”In a React application:
Feature/Auth → Component/LoginFormFeature/Auth → Service/AuthAPIService/AuthAPI → Util/HttpComponent/LoginForm → Util/ValidationUse Cases
Section titled “Use Cases”- High-level architecture visualization
- Component boundaries
- Feature dependencies
- Architectural diagrams
Graph Metrics
Section titled “Graph Metrics”Each graph enables different metrics:
Import Graph Metrics
Section titled “Import Graph Metrics”| Metric | What It Measures |
|---|---|
| SCC | Circular dependencies |
| Propagation Cost | Change impact |
| Modularity | Community structure |
| Hierarchy | Layer violations |
Call Graph Metrics
Section titled “Call Graph Metrics”| Metric | What It Measures |
|---|---|
| Call Depth | Nesting complexity |
| Unused Functions | Dead code |
| Effect Violations | Side effect boundaries |
| Critical Path | Most-called functions |
Entity Graph Metrics
Section titled “Entity Graph Metrics”| Metric | What It Measures |
|---|---|
| Centrality | Critical components |
| Core-Periphery | Architectural zones |
| Coupling | Component dependencies |
Graph Visualization
Section titled “Graph Visualization”Export Graph Data
Section titled “Export Graph Data”Export graphs for visualization:
# Export import graph as GraphMLarxo analyze --format json --output report.json
# Extract graph from reportjq '.graphs.import_graph' report.json > import_graph.jsonVisualization Tools
Section titled “Visualization Tools”Use these tools to visualize exported graphs:
- Graphviz - DOT format rendering
- Gephi - Network analysis and visualization
- Cytoscape - Biological network visualization
- D3.js - Custom web visualizations
- Neo4j - Graph database queries
Example: Graphviz DOT
Section titled “Example: Graphviz DOT”Convert Arxo output to DOT format:
import json
with open('report.json') as f: report = json.load(f)
import_graph = report['graphs']['import_graph']
print('digraph G {')for node in import_graph['nodes']: print(f' "{node}" [label="{node}"];')
for edge in import_graph['edges']: print(f' "{edge["source"]}" -> "{edge["target"]}";')print('}')Render with Graphviz:
python to_dot.py | dot -Tpng -o graph.pngGraph Filtering
Section titled “Graph Filtering”Exclude Patterns
Section titled “Exclude Patterns”Filter out noise:
import_graph: exclude: - "**/node_modules/**" - "**/test/**" - "**/*.test.ts" - "**/dist/**"Language-Specific Filters
Section titled “Language-Specific Filters”import_graph: languages: - typescript - python exclude: - "**/*.spec.ts" # TypeScript tests - "**/test_*.py" # Python testsSize Thresholds
Section titled “Size Thresholds”Limit graph size for performance:
import_graph: max_nodes: 10000 max_edges: 50000Advanced Topics
Section titled “Advanced Topics”Graph Persistence
Section titled “Graph Persistence”Graphs are cached between runs:
# Cache location (default)~/.cache/arxo/graphs/<project-hash>/
# Disable cachingarxo analyze --no-analysis-cache
# Clear cachearxo cache clearIncremental Updates
Section titled “Incremental Updates”When files change, Arxo:
- Detects changed files (via git or filesystem)
- Invalidates affected graph nodes
- Re-parses only changed files
- Updates graph edges
- Recomputes affected metrics
Graph Queries
Section titled “Graph Queries”Future feature: Query graphs directly
# Find all paths from A to Barxo graph query --from "src/A.ts" --to "src/B.ts"
# Find modules with most dependenciesarxo graph query --top-dependencies 10Next Steps
Section titled “Next Steps”- Configuration Guide - Configure graph options
- SCC Metric - Detect circular dependencies
- Propagation Cost - Measure change impact
- Centrality Metric - Find critical nodes