Skip to content

fix(graph): return outgoing edges in document order - #795

Merged
michaelpporter merged 1 commit into
mainfrom
fix/jump-first-neighbour-order
Oct 12, 2026
Merged

michaelpporter merged 1 commit into
mainfrom
fix/jump-first-neighbour-order

Conversation

@michaelpporter

Copy link
Copy Markdown
Owner

Refs #790

petgraph prepends each new edge to a node's adjacency list, so get_outgoing_edges / get_filtered_outgoing_edges (and the grouped variant, which wraps them) returned a note's edges newest-first. Anything that takes the first match ("Jump to first neighbour", PrevNextView, walk_to_roots) picked the last field in the note. Both queries now reverse to insertion order, which is the order the builders read fields from the note.

traverse_note's iterative DFS emitted children in reverse link order, which the old reversed graph order had been cancelling out. It now pushes children reversed, so it keeps link order. Side effect: when two children both link to the same note, the earlier child now claims it.

Tests:

  • 3 new Rust tests using the issue's 2026-W38 example (flat, filtered, grouped). They failed before the fix with exactly reversed order.
  • 1 new traverse_note test.
  • Dev vault: 14 of 15 notes with repeated explicit field types now match document order. The remaining one mixes typed_link and list_note edges; each builder is in document order, and the builders run one after the other.

petgraph prepends each new edge to a node's adjacency list, so
get_outgoing_edges / get_filtered_outgoing_edges (and the grouped variant)
returned a note's edges newest-first. Anything taking the first match —
'Jump to first neighbour', PrevNextView, walk_to_roots — picked the last
field in the note instead of the first. Reverse to restore insertion order.

traverse_note's iterative DFS emitted children in reverse link order, which
the old reversed graph order happened to cancel out; push children in
reverse so it keeps link order.

Refs #790
@michaelpporter
michaelpporter merged commit 7948d8f into main Oct 12, 2026
1 check passed
@michaelpporter
michaelpporter deleted the fix/jump-first-neighbour-order branch October 12, 2026 01:04
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.

1 participant