mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 07:16:17 +00:00
- 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>
57 lines
1.7 KiB
Rust
57 lines
1.7 KiB
Rust
//! Prints the page-level graph's size by edge kind and times extraction and layout.
|
|
//! `cargo run --release -p synapse-ffi --example graph_stats -- /path/to/graph`
|
|
|
|
use synapse_ffi::api::graph::SynapseGraph;
|
|
use synapse_ffi::api::layout::ForceLayout;
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
let dir = std::env::args()
|
|
.nth(1)
|
|
.ok_or_else(|| anyhow::anyhow!("usage: graph_stats <graph dir>"))?;
|
|
let g = SynapseGraph::open(dir)?;
|
|
let t = std::time::Instant::now();
|
|
let d = g.graph_data()?;
|
|
let built = t.elapsed();
|
|
let t = std::time::Instant::now();
|
|
g.graph_data()?;
|
|
let cached = t.elapsed();
|
|
let mut by_kind = [0usize; 7];
|
|
for &k in &d.kinds {
|
|
by_kind[k as usize] += 1;
|
|
}
|
|
let journals = d.nodes.iter().filter(|n| n.journal_date.is_some()).count();
|
|
let clusters = d.nodes.iter().map(|n| n.cluster).max().map_or(0, |c| c + 1);
|
|
println!(
|
|
"nodes {} ({journals} journals), edges {}, clusters {clusters}",
|
|
d.nodes.len(),
|
|
d.kinds.len()
|
|
);
|
|
let names = [
|
|
"link",
|
|
"tag",
|
|
"property",
|
|
"block_ref",
|
|
"embed",
|
|
"mention",
|
|
"synapse",
|
|
];
|
|
for (n, c) in names.iter().zip(by_kind) {
|
|
println!(" {n:<10} {c}");
|
|
}
|
|
println!("build {built:?}, cached {cached:?}");
|
|
let mut l = ForceLayout::new(
|
|
d.nodes.len() as u32,
|
|
d.sources.clone(),
|
|
d.targets.clone(),
|
|
d.weights.clone(),
|
|
None,
|
|
);
|
|
let t = std::time::Instant::now();
|
|
let mut ticks = 0;
|
|
while l.step(10).alpha > 0.0 {
|
|
ticks += 10;
|
|
}
|
|
println!("layout settled after ~{ticks} ticks in {:?}", t.elapsed());
|
|
Ok(())
|
|
}
|