{# FG-4: corpus-wide graph overview fragment — lazy-loaded into #graph-overview. Context: available — False when the knowledge graph isn't built (no [graph] data yet) OR when assembly raised; renders a notice, never counts. error — True when _get_graph_overview() raised (generic notice, no detail leaked — the cause stays in the server log only). paper_count — Paper nodes in the graph. entity_count — Entity nodes in the graph. indexed/total— papers.graph_indexed=1 over all papers (FG-2 count idiom). by_type — {entity_type: count}. by_predicate — {predicate: edge_count}. by_source — {mention_source: count} (schema / biobert / llm_cloud). last_indexed — best-effort MAX(last_updated) over indexed papers, or None. All content is rendered through Jinja autoescape ONLY — never |safe, never striptags (scientific entity text legitimately contains < and >). #} {% if not available %}
{% if error %}

Could not load the knowledge graph overview — check the server logs.

{% else %}

No knowledge graph yet — run a brain-build or lit-monitor graph backfill --all to populate the graph, then this overview will fill in.

{% endif %}
{% else %}

Graph health

{% set _pct = ((indexed / total * 100) | round(0, "floor") | int) if total else 0 %}

{{ indexed }}/{{ total }} papers indexed ({{ _pct }}%) {{ paper_count }} paper nodes {{ entity_count }} entity nodes {% if last_indexed %} last indexed {{ last_indexed[:10] }} {% endif %}

{# --- Entities by type --------------------------------------------------- #}

Entities by type

{% if by_type %} {% for type_, count in by_type.items() %} {% endfor %}
TypeCount
{{ type_ }}{{ count }}
{% else %}

No entities in the graph yet.

{% endif %} {# --- Edges by predicate ------------------------------------------------- #}

Edges by predicate

{% if by_predicate %} {% for pred, count in by_predicate.items() %} {% endfor %}
PredicateCount
{{ pred }}{{ count }}
{% else %}

No edges in the graph yet.

{% endif %} {# --- Entities (mentions) by extraction source --------------------------- #}

Mentions by source

{% if by_source %} {% for src, count in by_source.items() %} {% endfor %}
SourceCount
{{ src }}{{ count }}
{% else %}

No mention edges in the graph yet.

{% endif %}
{% endif %}