| 72 | |
| 73 | === Additional Functionality === |
| 74 | One possible criticism of this approach is the absence of automated index management, which only needs to be implemented for the `remove_vertex(g)` method. One solution, might be to simply have that function call `renumber_vertex_indices(g)`, but that's probably overkill since it renumbers ''all'' vertices. If we think about it long enough, we'll eventually realize that we only need to renumber vertices that are ''after'' the removed vertex. So we could implement the `remove_vertex(g)` method to do that, effectively cutting the average cost of removal in half (assuming that on average removals tend toward the middle of the list). Clearly, worst case is removing the first vertex which runs in ''theta''(n) time. Best case is removal of the back vertex which is simply constant. |
| 75 | |
| 76 | The obvious downside of the previous solution is that it hamstrings programs that performa a number of sequential vertex removals without needing to renumber indices - which is a pretty bad side-effect, but is still a useful function. As such, we could introduce an additional function: |
| 77 | |
| 78 | `remove_vertex_and_renumber_indices(v, g)` |
| 79 | Removes the target vertex and renumbers all indices that follow it, in the order in which vertices were added. |
| 80 | |
| 81 | The `remove_vertex_and_renumber_indices(g)` method will run in ''theta''(n) time for `setS`, `multisetS`, and `hashS` selected vertex storage (if implemented). Unlike lists and vectors, the order of insertion is lost with these corresponding data sets, meaning that we can't cut the time in half as with above. |
| 82 | |
| 83 | === Other Side-Effects of Indexing === |
| 84 | It should be probably be noted that any solution - even a fully automated index management suite - will still invalidate all exterior properties defined before the removal of a vertex. Once an index has been invalidated, so too are properties stored at those indices in exterior vectors. Exterior properties will need to be regenerated, which is probably a non-trivial task. |
| 85 | |