pub struct ForceCache { /* private fields */ }Expand description
Converge-once-then-freeze layout cache. A force layout is a pure function of
the graph structure (node count + edge set) and the paint rect, so this holds the
last-computed positions and only re-runs layout_positions when the structure or
rect actually changes. Embed it on a stateful host (e.g. a GraphView) and call
ForceCache::positions from the render path — the O(n log n) (with Barnes–Hut)
or O(n²) (small graphs) layout stops running every frame, which is the other half
(besides Barnes–Hut) of killing the 30 000-node hang.
Implementations§
Source§impl ForceCache
impl ForceCache
Sourcepub fn positions(
&mut self,
layout: Layout,
scene: &Scene,
rect: Rect,
) -> &[Pos2]
pub fn positions( &mut self, layout: Layout, scene: &Scene, rect: Rect, ) -> &[Pos2]
The node positions for scene under layout in rect, computed on the first
call and on any structural/rect change, and returned from cache otherwise.
Sourcepub fn is_settled(&self, layout: Layout, scene: &Scene, rect: Rect) -> bool
pub fn is_settled(&self, layout: Layout, scene: &Scene, rect: Rect) -> bool
Whether the next positions call for this layout/scene
in this rect will be a cache hit (a no-op relayout) — the frozen/settled
signal a tick can assert.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Force a recompute on the next positions call.
Trait Implementations§
Source§impl Clone for ForceCache
impl Clone for ForceCache
Source§fn clone(&self) -> ForceCache
fn clone(&self) -> ForceCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more