(wires)
| 27 | return np.array(path, dtype=float); |
| 28 | |
| 29 | def chain_wires(wires): |
| 30 | assert(wires.num_vertices > 0); |
| 31 | visited = np.zeros(wires.num_vertices, dtype=bool); |
| 32 | path = [0]; |
| 33 | visited[0] = True; |
| 34 | while not np.all(visited): |
| 35 | front = path[0]; |
| 36 | front_neighbors = wires.get_vertex_neighbors(int(front)); |
| 37 | for v in front_neighbors: |
| 38 | if visited[v]: continue; |
| 39 | path.insert(0, v); |
| 40 | visited[v] = True; |
| 41 | break; |
| 42 | end = path[-1]; |
| 43 | end_neighbors = wires.get_vertex_neighbors(int(end)); |
| 44 | for v in end_neighbors: |
| 45 | if visited[v]: continue; |
| 46 | visited[v] = True; |
| 47 | path.append(v); |
| 48 | break; |
| 49 | |
| 50 | first_neighbors = wires.get_vertex_neighbors(int(path[0])).squeeze(); |
| 51 | if len(path) > 2 and path[-1] in first_neighbors: |
| 52 | # Close the loop. |
| 53 | path.append(path[0]); |
| 54 | |
| 55 | path = wires.vertices[path]; |
| 56 | return path; |
| 57 | |
| 58 | def main(): |
| 59 | args = parse_args(); |
no test coverage detected