Skip to main content

memoize_incident_rels

Function memoize_incident_rels 

Source
pub fn memoize_incident_rels<V>(base: GraphQuery<V>) -> GraphQuery<V>
where V: GraphValue + Clone + 'static, V::Id: Clone + Eq + Hash + 'static,
Expand description

Wrap query_incident_rels and query_degree with an eager HashMap cache.

The cache is built upfront at construction time by calling query_nodes() and query_incident_rels(n) for each node. All other fields pass through unchanged.

Recommended for algorithms that call query_incident_rels repeatedly (e.g., betweenness centrality).

§Cache Semantics

  • Eager: the full cache is built when memoize_incident_rels is called.
  • Per-GraphQuery cache — not global.
  • No RefCell needed (immutable after construction).