aboutsummaryrefslogtreecommitdiff
path: root/PuzzleApplet.java
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2019-04-13 13:12:44 +0100
committerSimon Tatham <anakin@pobox.com>2019-04-13 13:12:44 +0100
commitbb926f4ee4c16f67d37398c1b79b54a3fdf1dedd (patch)
treeeaf86d9ed9653eed0dca3c4566d1235895bbe8d0 /PuzzleApplet.java
parent1114a2af332ecfa61a3ae0df478d26b9a3b863a4 (diff)
downloadpuzzles-bb926f4ee4c16f67d37398c1b79b54a3fdf1dedd.zip
puzzles-bb926f4ee4c16f67d37398c1b79b54a3fdf1dedd.tar.gz
puzzles-bb926f4ee4c16f67d37398c1b79b54a3fdf1dedd.tar.bz2
puzzles-bb926f4ee4c16f67d37398c1b79b54a3fdf1dedd.tar.xz
findloop: alternative query function.
This one tells you if a graph edge _is_ a bridge (i.e. it has inverted sense to the existing is_loop_edge query). But it also returns auxiliary data, telling you: _if_ this edge were removed, and thereby disconnected some connected component of the graph, what would be the sizes of the two new components? The data structure built up by the algorithm very nearly contained enough information to answer that already: because we assign sequential indices to all the vertices in a traversal of our spanning forest, and any bridge must be an edge of that forest, it follows that we already know the size of _one_ of the two new components, just by looking up the (minindex,maxindex) values for the vertex at the child end of the edge. To determine the other subcomponent's size, we subtract that from the size of the full component. That's not quite so easy because we don't already store that - but it's trivial to annotate every vertex's data with a pointer back to the topmost node of the spanning forest in its component, and then we can look at the (minindex,maxindex) pair of that. So now we know the size of the original component and the size of one of the pieces it would be split into, so we can just subtract.
Diffstat (limited to 'PuzzleApplet.java')
0 files changed, 0 insertions, 0 deletions