This wasn't my original plan; I wanted to detach/reattach edges, but that seems more complicated now when I consider the possibility of detaching the source of an edge.
I think I'm not going to bother with a mechanic for deleting nodes. Just disconnect edges and repurpose them. That way the number of widges per node doesn't get worse, and I also don't have to worry about undoing deletion.
TSIVHIQJRWRTIYKRGVE2OUBHKJMAU3CAFRPUUTCTQKTC3WL5C2YAC KA3WML5YL2EKXNDNL2GP4GVVCPZYAAZBOQLVJH3GD2LEXUI4OB6AC R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC SMZJGK56DYOP2CYIYDV3QXVHL5P52IEF34GFBESNMULJDMDLJR2AC UJ2RZ43LIVRIBWIXHXMLIQIQTL32VVEN4CVU7PEBTITQFPO4EXXQC 5N57VOATVSATXDBSRBNNPQU3BHONGN22EOMHZAD3DV5367WJRSLQC J62CVGNGJZSN7TMTE2SG53O47YG4SJGJFTUFKVOZY4TM4KAC566QC QFUZ53WLZETJ7SQTEHL7NLTEXDPX2WX2S3Y7VO53SSSIFADGUTNQC test_remove_value = function()local h = {1,2,3}table.remove_value(h, 1)check_eq(h, {2,3}, "a")local h = {1,2,3}table.remove_value(h, 2)check_eq(h, {1,3}, "b")local h = {1,2,3}table.remove_value(h, 3)check_eq(h, {1,2}, "b")local h = {1,2,3}table.remove_value(h, 4)check_eq(h, {1,2,3}, "b")end
table.remove_value = function(h, val)local i = table.find(h, val)if i thentable.remove(h, i)endend
detach_edge = function(edge)local src, dest = edge[1], edge[2]table.remove_value(Nodes[src].outgoing_edges, dest)table.remove_value(Nodes[dest].incoming_edges, src)end
on_edge = function(sx,sy)-- check if mouse is on the border of a node and also on an edge to another node.-- reading from Surface; I'm going to regret this.for _,shape in ipairs(Surface) doif shape.type == 'line' thenif shape.keys then-- it's an edge; assuming keys are in a specific, brittle orderif distance_sq(sx,sy, shape.data[1], shape.data[2]) < 5*5 thenreturn shape.keysendif distance_sq(sx,sy, shape.data[3], shape.data[4]) < 5*5 thenreturn shape.keysendendendendend