kcml commited on
Commit
23e3936
·
1 Parent(s): d44d9e7

improve connection deletion

Browse files
Files changed (1) hide show
  1. handcrafted_solution.py +7 -5
handcrafted_solution.py CHANGED
@@ -509,16 +509,18 @@ def delete_one_vert(vertices, vertices_3d, connections, vert_to_del):
509
  vertices = np.delete(vertices, idx)
510
  vertices_3d = np.delete(vertices_3d, idx, axis=0)
511
  conn_to_del = []
512
- for i, c in enumerate(connections):
513
  if c[0] == idx or c[1] == idx:
514
- conn_to_del.append(i)
 
 
515
  if c[0] >= idx:
516
- connections[i] = (connections[i][0]-1, connections[i][1])
517
  if c[1] >= idx:
518
- connections[i] = (connections[i][0], connections[i][1]-1)
519
 
520
  #print(f'del {len(conn_to_del)} connections')
521
- connections = np.delete(connections, (conn_to_del), axis=0)
522
  connections = connections.tolist()
523
  #print(vertices, vertices_3d, connections)
524
  if vertices:
 
509
  vertices = np.delete(vertices, idx)
510
  vertices_3d = np.delete(vertices_3d, idx, axis=0)
511
  conn_to_del = []
512
+ for ic, c in enumerate(connections):
513
  if c[0] == idx or c[1] == idx:
514
+ conn_to_del.append(ic)
515
+ connections = np.delete(connections, (conn_to_del), axis=0)
516
+ for ic, c in enumerate(connections):
517
  if c[0] >= idx:
518
+ connections[ic] = (connections[ic][0]-1, connections[ic][1])
519
  if c[1] >= idx:
520
+ connections[ic] = (connections[ic][0], connections[ic][1]-1)
521
 
522
  #print(f'del {len(conn_to_del)} connections')
523
+
524
  connections = connections.tolist()
525
  #print(vertices, vertices_3d, connections)
526
  if vertices: