Remove all hanging edges. e.g. edge with at least one vertex of valance <= 1
(self)
| 158 | self.raw_wires.center_at_origin() |
| 159 | |
| 160 | def trim(self): |
| 161 | """ Remove all hanging edges. |
| 162 | e.g. edge with at least one vertex of valance <= 1 |
| 163 | """ |
| 164 | while np.any(self.vertex_valance <= 1): |
| 165 | edge_to_keep = np.all(self.vertex_valance[self.edges] > 1, |
| 166 | axis=1).tolist() |
| 167 | self.raw_wires.filter_edges(edge_to_keep) |
| 168 | vertex_to_keep = [len(self.get_vertex_neighbors(i)) > 0 for i in |
| 169 | range(self.num_vertices)] |
| 170 | self.raw_wires.filter_vertices(vertex_to_keep) |
| 171 | |
| 172 | self.__initialize_wires() |
| 173 | if len(self.vertices) == 0: |
| 174 | raise RuntimeError("Zero vertices left after trimming.") |
| 175 | |
| 176 | def filter_vertices(self, to_keep): |
| 177 | """ Remove all vertices other than the ones marked with to_keep. |