mirror of
https://github.com/safishamsi/graphify.git
synced 2026-07-12 18:37:12 +00:00
e7a03a0539
call-graph INFERRED edges, multi-language semantic extraction, SHA256 cache, MCP stdio server with shortest_path, Q&A memory feedback loop
28 lines
539 B
Rust
28 lines
539 B
Rust
use std::collections::HashMap;
|
|
|
|
struct Graph {
|
|
nodes: HashMap<String, Vec<String>>,
|
|
}
|
|
|
|
impl Graph {
|
|
fn new() -> Self {
|
|
Graph { nodes: HashMap::new() }
|
|
}
|
|
|
|
fn add_node(&mut self, id: String) {
|
|
self.nodes.insert(id, vec![]);
|
|
}
|
|
|
|
fn add_edge(&mut self, src: String, tgt: String) {
|
|
self.nodes.entry(src).or_default().push(tgt);
|
|
}
|
|
}
|
|
|
|
fn build_graph(edges: Vec<(String, String)>) -> Graph {
|
|
let mut g = Graph::new();
|
|
for (src, tgt) in edges {
|
|
g.add_edge(src, tgt);
|
|
}
|
|
g
|
|
}
|