Skip to content

Commit 903b580

Browse files
committed
update
1 parent 101b580 commit 903b580

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

gui-mvp/frontend/src/canvas/exporterStdio.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,25 @@ function extractTopoOrder(nodes: RFNode[], edges: RFEdge[], scope: Set<string>):
122122
const n = nodeById.get(id)
123123
const x = (n as any)?.position?.x ?? 0
124124
const y = (n as any)?.position?.y ?? 0
125-
return { y, x, id }
125+
return { x, y, id }
126126
}
127-
127+
128128
const cmp = (a: string, b: string) => {
129+
// Keep Start earliest whenever possible
129130
if (a === start.id) return -1
130131
if (b === start.id) return 1
132+
131133
const ka = sortKey(a), kb = sortKey(b)
132-
if (ka.y !== kb.y) return ka.y - kb.y
134+
135+
// Left-to-right first
133136
if (ka.x !== kb.x) return ka.x - kb.x
137+
// Then top-to-bottom
138+
if (ka.y !== kb.y) return ka.y - kb.y
139+
140+
// Stable tie-breaker
134141
return ka.id.localeCompare(kb.id)
135142
}
143+
136144

137145
// init queue (indegree 0)
138146
const queue: string[] = []

0 commit comments

Comments
 (0)