Trace tree paths and colour by tree distance in the inspector - #39
Merged
Conversation
Pinning two points now traces the tree path between them: the map highlights the connecting edges and the inspector lists every node along the way with its step number and running tree distance. A second control colours the whole map by tree distance from the selected point. These were only reachable from Python (model.path, distances_from) even though the tree layout is what the tool is pitched on. Both are one breadth-first walk over the adjacency index the neighbourhood explorer already builds, so nothing new is written to the exported HTML; the file grows by 20 KB regardless of dataset size. A walk costs 4 ms on a 200k-point map and 12 ms at 1M, and repeating it from the same anchor is free. Scratch buffers cost 12 bytes per point. - The Neighbors and Path chips replace the "Show neighborhood" toggle. The chip picks what the list below it contains, so no panel or toolbar button is added. Path is disabled until a second point is pinned. - Distance colouring registers a synthetic column and hands it to the existing Color by menu, so the legend, colormap and selector work unmodified. - Path lists start at 20 rows behind a "Show all" button. Rendering a 216-node path in full was the slowest thing the inspector did (277 ms at 200k points, versus 111 ms capped).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #37. The tree layout is what TMAP is pitched on, but the operations that make a tree worth having were reachable only from Python (
model.path,distances_from). The interactive HTML — the thing people actually share — could not do them.This adds two of them to the inspector.
Path. Pin two points and the map highlights the tree path between them. The inspector lists every node along the way with its step number and running tree distance.
Colour by distance. One click colours the whole map by tree distance from the selected point.
UI
The
NeighborsandPathchips replace the old "Show neighborhood" toggle. The chip picks what the list below it contains, so no new panel or toolbar button is added — the section head goes from one button to two chips.Pathis disabled with a tooltip until a second point is pinned, so it is discoverable before it is usable.Distance colouring is a text link that registers a synthetic column and hands it to the existing Color by menu, so the legend, colormap and selector work unmodified.
Cost
Both features are one breadth-first walk over the adjacency index #37 already builds. Nothing new is written to the exported HTML — the file grows by 20 KB (6 KB gzipped) regardless of dataset size.
Walk cost, measured on the shipped code:
Scratch buffers are allocated once and reused: 12 bytes per point (12 MB at 1M, against a ~478 MB baseline heap for a map that size).
End to end in the browser, click to handler complete:
Path lists start at 20 rows behind a "Show all" button. Rendering a 216-node path in full was the slowest thing the inspector did — 277 ms at 200k points versus 111 ms capped — and long paths are common.
Checked on real maps
examples/pet_breed_audit.py, unmodified: 3,669 Oxford-IIIT Pets images, 37 breeds, 90.0% probe accuracy. Tracing from a Japanese Chin to a Siamese gives a 43-step path:The dog-to-cat crossing runs Chihuahua → Sphynx, which is the bridge described in the README. That map has no SMILES, only
add_images, so it also exercises the image fallback in the path rows.Also checked on 10k and 200k ChEMBL molecules and a synthetic 1M-point tree.
Notes
scatterplot.select).test_subtree_isolation_is_not_offeredkeeps it out.