Skip to content

Add unweighted shortest-path between two selected nodes#4

Merged
Mnikley merged 1 commit into
mainfrom
feat/shortest-path
Jun 18, 2026
Merged

Add unweighted shortest-path between two selected nodes#4
Mnikley merged 1 commit into
mainfrom
feat/shortest-path

Conversation

@enricobono99

Copy link
Copy Markdown
Collaborator

Add a "Shortest Path" action that, given exactly two selected nodes, adds the fewest-hops path connecting them - its nodes and the edges between them - to the current selection. Computed on the visible subgraph so it honours active filters.

  • New pure, node-safe module graph/shortest_path.js (mirrors communities.js / visible_graph.js): buildVisibleGraph(cache) + graphology bidirectional BFS, returning {found, nodes, edges, hops}; edge ids derived from consecutive node pairs via graph.edges(u, v) on the undirected multigraph.
  • Promote graphology-shortest-path to a direct dependency, export bidirectional from the graphology vendor entry, add it to the bundle pkgs list, and rebundle (graphology.bundle.mjs).
  • selectShortestPathBetweenSelected() on GraphSelectionManager reuses the existing updateSelectedState selection machinery.
  • "Shortest Path" button in the Select Elements card, below Expand/Reduce Neighbors, gated via toggleStyleElementsThatRequireExactlyTwoSelectedNodes (enabled only when exactly two nodes are selected).
  • tests/shortest-path.test.js covers direct/multi-hop, shorter-of-two, undirected reverse, disconnected, source==target, non-visible endpoint, hidden edge, and parallel edges.

Add a "Shortest Path" action that, given exactly two selected nodes, adds
the fewest-hops path connecting them - its nodes and the edges between
them - to the current selection. Computed on the visible subgraph so it
honours active filters.

- New pure, node-safe module graph/shortest_path.js (mirrors communities.js
  / visible_graph.js): buildVisibleGraph(cache) + graphology bidirectional
  BFS, returning {found, nodes, edges, hops}; edge ids derived from
  consecutive node pairs via graph.edges(u, v) on the undirected multigraph.
- Promote graphology-shortest-path to a direct dependency, export
  bidirectional from the graphology vendor entry, add it to the bundle pkgs
  list, and rebundle (graphology.bundle.mjs).
- selectShortestPathBetweenSelected() on GraphSelectionManager reuses the
  existing updateSelectedState selection machinery.
- "Shortest Path" button in the Select Elements card, below Expand/Reduce
  Neighbors, gated via toggleStyleElementsThatRequireExactlyTwoSelectedNodes
  (enabled only when exactly two nodes are selected).
- tests/shortest-path.test.js covers direct/multi-hop, shorter-of-two,
  undirected reverse, disconnected, source==target, non-visible endpoint,
  hidden edge, and parallel edges.
@Mnikley Mnikley merged commit 066164a into main Jun 18, 2026
2 checks passed
@Mnikley Mnikley deleted the feat/shortest-path branch June 18, 2026 10:56
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.

2 participants