query: peg-based query language for ad-hoc graph exploration
poc-memory query "degree > 15"
poc-memory query "key ~ 'journal.*' AND degree > 10"
poc-memory query "neighbors('identity.md') WHERE strength > 0.5"
poc-memory query "community_id = community('identity.md')" --fields degree,category
Grammar-driven: the peg definition IS the language spec. Supports
boolean logic (AND/OR/NOT), numeric and string comparison, regex
match (~), graph traversal (neighbors() with WHERE), and function
calls (community(), degree()). Output flags: --fields, --sort,
--limit, --count.
New dependency: peg 0.8 (~68KB, 2 tiny deps).
This commit is contained in:
parent
71e6f15d82
commit
a36449032c
5 changed files with 544 additions and 1 deletions
|
|
@ -43,6 +43,13 @@ impl Graph {
|
|||
self.adj.values().map(|e| e.len()).sum::<usize>() / 2
|
||||
}
|
||||
|
||||
/// All edges for a node (full Edge data including rel_type)
|
||||
pub fn edges_of(&self, key: &str) -> &[Edge] {
|
||||
self.adj.get(key)
|
||||
.map(|v| v.as_slice())
|
||||
.unwrap_or(&[])
|
||||
}
|
||||
|
||||
/// All neighbor keys with strengths
|
||||
pub fn neighbors(&self, key: &str) -> Vec<(&String, f32)> {
|
||||
self.adj.get(key)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue