mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 23:36:20 +00:00
feat(graph): graph view with network, local, synapse, cluster and namespace modes
- synapse-ffi: graph_data() returns the whole page-level graph (links, tags, property refs, block refs/embeds per page, unlinked mentions, decayed synapses) as parallel arrays with degree, backlinks, Louvain clusters and primary tags; cached by op seq, synapse state and hour. - synapse-ffi: ForceLayout, a Barnes-Hut force layout stepped from Dart on a Rust worker thread (pin/unpin for dragging, reheat). - app: Graph view with a mode selector (Network, Local, Synapses, Clusters, Namespaces, Timeline), filters (title, tag, date range, min links, orphans, journals, mentions), pan/zoom, node drag, hover highlighting, activation pulse, cluster hulls, radial namespace/tag tree, and a local graph panel on every page. Edges render as one vertex mesh, nodes in colour/size batches, culled to the viewport. - Tests: Rust extraction/mentions/cache/clusters/layout; widget tests for mode switching, filters and layout restarts; a real-app integration smoke test with frame timings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6a4a76670b
commit
e43452f5af
29 files changed
+6177
-76
No files matched your search
@@ -169,3 +169,57 @@ pub struct BlockHit {
|
||||
pub content: String,
|
||||
pub page_title: String,
|
||||
}
|
||||
|
||||
/// Kind codes of [`GraphData::kinds`].
|
||||
pub mod edge_kind {
|
||||
pub const LINK: u8 = 0;
|
||||
pub const TAG: u8 = 1;
|
||||
pub const PROPERTY: u8 = 2;
|
||||
pub const BLOCK_REF: u8 = 3;
|
||||
pub const EMBED: u8 = 4;
|
||||
/// Unlinked reference: the target's title appears in the source's text.
|
||||
pub const MENTION: u8 = 5;
|
||||
/// Hebbian association (undirected), weight = decayed synapse strength.
|
||||
pub const SYNAPSE: u8 = 6;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct GraphNode {
|
||||
pub id: String,
|
||||
pub title: String,
|
||||
pub journal_date: Option<String>,
|
||||
pub origin_journal: Option<String>,
|
||||
pub created_at: i64,
|
||||
/// Distinct neighbours over structural edges (links, tags, properties, block refs).
|
||||
pub degree: u32,
|
||||
/// Distinct pages referencing this one.
|
||||
pub backlinks: u32,
|
||||
/// Community (Louvain), numbered by size: 0 is the largest.
|
||||
pub cluster: u32,
|
||||
/// Node index of the tag this page uses most, if any.
|
||||
pub primary_tag: Option<u32>,
|
||||
}
|
||||
|
||||
/// The whole page-level graph, edges as parallel arrays (cheap to move across the FFI).
|
||||
/// Edges are directed source → target, except synapses (stored once, `source < target`).
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct GraphData {
|
||||
pub nodes: Vec<GraphNode>,
|
||||
pub sources: Vec<u32>,
|
||||
pub targets: Vec<u32>,
|
||||
/// See [`edge_kind`].
|
||||
pub kinds: Vec<u8>,
|
||||
/// Number of references (structural edges) or synapse strength.
|
||||
pub weights: Vec<f32>,
|
||||
/// Op-log sequence the data was built at.
|
||||
pub seq: i64,
|
||||
}
|
||||
|
||||
/// One batch of layout iterations.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct LayoutFrame {
|
||||
/// `x0, y0, x1, y1, ...`
|
||||
pub positions: Vec<f32>,
|
||||
/// Remaining "temperature"; the layout is settled when it reaches 0.
|
||||
pub alpha: f32,
|
||||
}
|
||||
Reference in new issue
Block a user