Graph API¶
builder
¶
GraphBuilder
¶
Source code in src/nervapack/graph/builder.py
build_from_entities(entities)
¶
Takes a list of ParsedEntity and constructs a directed graph. Files are nodes, entities are nodes. Contains/Defines edges connect them.
Source code in src/nervapack/graph/builder.py
remove_nodes_for_file(file_path)
¶
Removes the file node and all entities associated with it.
Source code in src/nervapack/graph/builder.py
retrieval
¶
RetrievalMetadata
dataclass
¶
Metadata about the graph traversal process.
Source code in src/nervapack/graph/retrieval.py
GraphRetriever
¶
Source code in src/nervapack/graph/retrieval.py
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
retrieve_context(start_node_ids, max_hops=2)
¶
Retrieves a sub-graph using K-Hop BFS from the given start nodes. Uses Betweenness Centrality to prune high-degree "hub" nodes if necessary.
Also tracks metadata about the traversal which can be accessed via self.last_metadata.
Source code in src/nervapack/graph/retrieval.py
format_as_markdown(subgraph)
¶
Formats the retrieved sub-graph into a minimized, clean Markdown block.
Source code in src/nervapack/graph/retrieval.py
get_source_files(subgraph)
¶
Return deduplicated file paths of all non-file nodes in the subgraph.