Find Dependencies
Copy
// Direct dependencies
MATCH (n {name: 'UserService'})-[:DEPENDS_ON]->(dep)
RETURN dep.name, dep.type
// Transitive dependencies (any depth)
MATCH (n {name: 'UserService'})-[:DEPENDS_ON*]->(dep)
RETURN DISTINCT dep.name, dep.type
Find Dependents
Copy
// What depends on this class?
MATCH (dependent)-[:DEPENDS_ON*]->(n {name: 'UserService'})
RETURN DISTINCT dependent.name, dependent.type
Shortest Path
Copy
// How are two classes connected?
MATCH path = shortestPath(
(a {name: 'OrderController'})-[*]-(b {name: 'Database'})
)
RETURN path
Circular Dependencies
Copy
// Find cycles in the dependency graph
MATCH path = (n)-[:DEPENDS_ON*2..10]->(n)
RETURN path
LIMIT 10
Most Connected Nodes
Copy
// Potential god classes
MATCH (n {type: 'Class'})-[:DEPENDS_ON]->(dep)
RETURN n.name, count(dep) as dependencies
ORDER BY dependencies DESC
LIMIT 20
Orphan Classes
Copy
// Potentially dead code
MATCH (n {type: 'Class'})
WHERE NOT ()-[:DEPENDS_ON]->(n)
RETURN n.name, n.filePath
Namespace Contents
Copy
// All types in a namespace
MATCH (ns {type: 'Namespace', name: 'MyApp.Services'})-[:CONTAINS]->(type)
RETURN type.name, type.type
Inheritance Tree
Copy
// All classes that inherit from a base
MATCH (derived)-[:INHERITS*]->(base {name: 'BaseController'})
RETURN derived.name
Interface Implementations
Copy
// All implementations of an interface
MATCH (impl)-[:IMPLEMENTS]->(interface {name: 'IUserService'})
RETURN impl.name, impl.filePath
Method Calls
Copy
// What methods does this method call?
MATCH (m {name: 'CreateOrder'})-[:CALLS]->(called)
RETURN called.name, called.type
// What calls this method?
MATCH (caller)-[:CALLS]->(m {name: 'GetUser'})
RETURN caller.name, caller.type