I'm finally back to the civilisation if you want us to deal with this patch :-)
Nathann
It is 20:20, it is almost dark outside and I am getting home by bike.
Worst of all, I am being assaulted by hungry mosquitoes. I re-read it
the following enough times to be sure that if I miswrote "v" instead
of "x" somewhere, reading it again wouldn't have changed anything.
When v is considered for removal, it is a leaf of the lex-BFS tree.
Its father (and first discoverer) is named x, and we suppose that
there is a vertex y which is not a neighbor of x, otherwise v is
removed without any problem.
Why should there be a x-y path avoiding all of v's neighbors ? Well,
first note that v is the furthest vertex from the source. Not
strictly, of course, but a lex-BFS is a BFS, and as we are testing for
removal the vertices in the reverse of the discovery order, it means
that in the lex-BFS exploration the vertex v is the last one to be
discovered (without considering the vertices that have been deleted
since the beginning of the elimination algorithm). Hence, it is the
one which is the further away from the source, even if other vertices
may be at equal distance from the source.
Now, how can v be adjacent to the other vertices of the graph ? Well,
for instance v can not be connected to any of x's ancestors, as its
distance from the source is strictly greater than the distance between
x and the source. Hence there is a path from x to the source of the
lex-BFS which does not touch any of x's neighbors. By the same reason,
the vertex y can not be closer than v from the source. If it were,
there would be a path from y to the source (from ancestor to ancestor)
which would avoid all of v's neighbors.
Hence, at some point, when the lex-BFS algorithm was processing all
the vertices at distance d(source, y) = d(source, v), it picked y
before v (we are removing the vertices in reverse order). But then, we
know that y and v have different sets of neighbors among the vertices
at distance "d(source, { v or y} ) - 1" from the source. We know that
because by assumption y is not adjacent to x. In this case, because y
was picked before v in the lex-BFS ordering, it means that the lex-BFS
code of y at this moment was strictly greater than the lex-BFS code of
v.
Hence there is a neighbor of y at distance d(source, y) - 1 which is
not a neighbor of v. Hence there is a path from y to the source going
through this vertex which avoids all of v's neighbors, hence
connectedness, hence certificate, hence I can jump on my bike to
escape the mosquitoes.
Nathann
I am trying to write the patch corresponding to your modifications,
but the file has changed much since and I have some trouble dealing
with your diff file... Could you copy/paste the totality of the code ?
:-)
Thaaaaaaaaaanks !
Nathann
I finally wrote this patch, available there :
http://trac.sagemath.org/sage_trac/ticket/11961
Though the two algorithms are very similar, I thought it better to
split it into two different parts, so that one can understand better
how each of them works without having to bear with "if algorithm == A"
every second line. Two implementations are now available, two are
checked before being returned, both pass all tests. We should be on
the safe side, now :-D
Thank you for your help !! :-)
Nathann
> Thanks for fixing it! :) I forgot the issue so my reply is late.
Well, it took me a month to write it ;-)
> I looked at the patch you produced.
> I think it's fine except for that I would prefer the "algorithm"
> keyword-argument to be placed at the end of the argument list for
> backward compatibility.
Right ! I just updated the patch. Thank you again !
Nathann