Skip to main content

render_multi_user

Function render_multi_user 

Source
pub async fn render_multi_user(
    pairs: &[(String, Arc<dyn GraphDBTrait>)],
) -> Result<String, VisualizationError>
Expand description

Render a combined HTML visualization aggregating multiple (user_label, graph_db) pairs into one output.

Each pair’s nodes are tagged with a source_user attribute carrying the supplied human-readable label so the d3 template can color-code by user. Mirrors Python’s aggregate_multi_user_graphs() in cognee/modules/visualization/cognee_network_visualization.py:115-157:

  • Nodes are deduplicated by str(node_id) with first-write-wins semantics so iteration order across the supplied pairs determines the surviving node entry.
  • Edges are deduplicated by the (source, target, relation) tuple.
  • The source_user field is only populated when the inbound node does not already carry one (Python’s if not node_info.get("source_user")).

An empty input produces a valid-but-empty HTML document.

pairs is a slice of (user_label, graph_db) tuples; the label is taken as an arbitrary &str to keep this crate decoupled from cognee_models::User. Callers should resolve the underlying user record and pass user.email (or the stringified id as a fallback) so the userColors palette key matches Python.