Skip to content

Hide practically-redundant edges from the entity tree browser (with "Show redundant" toggle)#1253

Open
Copilot wants to merge 3 commits into
devfrom
copilot/fix-tree-browser-redundant-edges
Open

Hide practically-redundant edges from the entity tree browser (with "Show redundant" toggle)#1253
Copilot wants to merge 3 commits into
devfrom
copilot/fix-tree-browser-redundant-edges

Conversation

Copilot AI commented May 19, 2026

Copy link
Copy Markdown
Contributor

The tree browser renders a child directly under a high-level ancestor even when it is already reachable via a more specific term, producing huge flat lists (e.g. ~1,974 direct children under GO:anatomical structure development). The redundant edges are OWL-valid (adenohypophysis development is_a anatomical structure development is not entailment-redundant), so the fix belongs at the display layer, not in the data.

Where the fix lives

  • Applied in frontend/src/pages/ontologies/entities/extractEntityHierarchy.ts, which already operates on the in-memory entity subgraph loaded for the tree.
  • Not in rdf2json / HierarchicalParentsAnnotator: that would silently strip edges from the documented hierarchicalParents / hierarchicalAncestors API responses and from every other consumer of HIERARCHICAL_PARENT (HierarchyMetricsAnnotator, V1TermRepository, McpClass, …), and would require a full re-ingest to reconfigure.

"Show redundant" toggle

A new "Show redundant" checkbox is added in EntityTree.tsx alongside the existing tree-view checkboxes (Show counts / Show obsolete terms / Show all siblings). Unticked by default → new (reduced) behaviour. Tick to restore the pre-fix behaviour where every hierarchical edge is shown.

State lives in the Redux ontologies slice as displayRedundant (default false); showRedundant / hideRedundant actions wire the checkbox to the slice; the flag is plumbed through createTreeFromEntitiesextractEntityHierarchy, where the reduction pass is skipped entirely when showRedundant === true. The tree refetches when the toggle changes, and the setting resets along with the other tree settings on ontology / entity changes.

Algorithm

Transitive reduction on the child→parent multimap, run after the existing cycle breaker (skipped entirely when "Show redundant" is ticked):

  • For each child c with ≥ 2 parents, compute each parent's strict ancestor closure by walking childToParentRelations upward (memoised across children).
  • Mark parent pᵢ redundant iff some other parent pⱼ reaches pᵢ, and pᵢ does not also reach pⱼ — the asymmetry guard keeps both endpoints of a hierarchical cycle.
  • Delete the redundant (c → pᵢ) relation in place; parentToChildRelations and root detection downstream automatically reflect the trim.

Behaviour on the canonical example

c is_a   a
c part_of b
b is_a   a

With "Show redundant" unticked (default), parents of c go from {a, b}{b}. c still appears under a in the tree, just transitively via b. With "Show redundant" ticked, both edges remain (pre-fix behaviour).

Edge cases handled

  • Independent siblings (no ancestor relation) — both kept.
  • Chains of length > 2 — only the most specific parent retained.
  • Mutual a ↔ b cycles — both kept.
  • Single-parent nodes — untouched (early exit).

Copilot AI linked an issue May 19, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/EBISPOT/ols4/sessions/0230412b-1fde-44df-a8ba-5d8d4628de79

Co-authored-by: jamesamcl <454895+jamesamcl@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tree browser to show correct structural edges Hide practically-redundant edges from the entity tree browser May 19, 2026
Copilot AI requested a review from jamesamcl May 19, 2026 07:27
@jamesamcl

Copy link
Copy Markdown
Member

@copilot Can you put this under a toggle "Show redundant" with the other checkboxes. Unticked by default (the new behaviour). But you can tick it to go back to the old behaviour.

Agent-Logs-Url: https://github.com/EBISPOT/ols4/sessions/265e618c-9fc2-4e1a-b84d-f0a23f33db14

Co-authored-by: jamesamcl <454895+jamesamcl@users.noreply.github.com>

Copilot AI commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Can you put this under a toggle "Show redundant" with the other checkboxes. Unticked by default (the new behaviour). But you can tick it to go back to the old behaviour.

Added a "Show redundant" checkbox alongside the existing tree-view toggles, unticked by default (new reduced behaviour); ticking it restores the previous behaviour. The flag is held in the Redux slice as displayRedundant, plumbed through createTreeFromEntitiesextractEntityHierarchy, and the tree refetches when toggled. In 1274dcc.

Copilot AI changed the title Hide practically-redundant edges from the entity tree browser Hide practically-redundant edges from the entity tree browser (with "Show redundant" toggle) May 19, 2026
@jamesamcl jamesamcl marked this pull request as ready for review May 19, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tree browser shows redundant edges

2 participants