<s>
In	O
computing	O
and	O
graph	O
theory	O
,	O
a	O
dynamic	B-Algorithm
connectivity	I-Algorithm
structure	O
is	O
a	O
data	O
structure	O
that	O
dynamically	O
maintains	O
information	O
about	O
the	O
connected	O
components	O
of	O
a	O
graph	O
.	O
</s>
<s>
Edges	O
can	O
be	O
either	O
added	O
or	O
deleted	O
(	O
this	O
can	O
be	O
called	O
fully	O
dynamic	B-Algorithm
connectivity	I-Algorithm
)	O
.	O
</s>
<s>
After	O
each	O
addition/deletion	O
of	O
an	O
edge	O
,	O
the	O
dynamic	B-Algorithm
connectivity	I-Algorithm
structure	O
should	O
adapt	O
itself	O
such	O
that	O
it	O
can	O
give	O
quick	O
answers	O
to	O
queries	O
of	O
the	O
form	O
"	O
is	O
there	O
a	O
path	O
between	O
x	O
and	O
y	O
?	O
"	O
</s>
<s>
If	O
edges	O
can	O
only	O
be	O
added	O
,	O
then	O
the	O
dynamic	B-Algorithm
connectivity	I-Algorithm
problem	O
can	O
be	O
solved	O
by	O
a	O
Disjoint-set	B-Algorithm
data	I-Algorithm
structure	I-Algorithm
.	O
</s>
<s>
The	O
amortized	B-General_Concept
time	I-General_Concept
per	O
operation	O
is	O
,	O
where	O
n	O
is	O
the	O
number	O
of	O
vertices	O
and	O
α	O
is	O
the	O
inverse	O
Ackermann	O
function	O
.	O
</s>
<s>
Scan	O
the	O
tree	O
starting	O
from	O
u	O
(	O
using	O
any	O
tree	O
scan	O
algorithm	O
,	O
such	O
as	O
DFS	B-Algorithm
)	O
.	O
</s>
<s>
Since	O
we	O
always	O
rename	O
the	O
smaller	O
sub-component	O
,	O
the	O
amortized	B-General_Concept
time	I-General_Concept
for	O
a	O
delete	O
operation	O
is	O
.	O
</s>
<s>
Thus	O
the	O
amortized	B-General_Concept
time	I-General_Concept
for	O
a	O
delete	O
operation	O
is	O
again	O
.	O
</s>
<s>
Process	O
B	O
uses	O
a	O
breadth-first	B-Algorithm
structure	O
(	O
BFS	O
)	O
,	O
which	O
is	O
initialized	O
as	O
follows	O
.	O
</s>
<s>
Hence	O
the	O
amortized	B-General_Concept
time	I-General_Concept
per	O
deletion	O
operation	O
is	O
.	O
</s>
<s>
A	O
forest	O
can	O
be	O
represented	O
using	O
a	O
collection	O
of	O
either	O
Link-cut	B-Data_Structure
trees	I-Data_Structure
or	O
Euler	O
tour	O
trees	O
.	O
</s>
<s>
Then	O
the	O
dynamic	B-Algorithm
connectivity	I-Algorithm
problem	O
can	O
be	O
solved	O
easily	O
,	O
as	O
for	O
every	O
two	O
nodes	O
x	O
,	O
y	O
,	O
x	O
is	O
connected	O
to	O
y	O
if	O
and	O
only	O
if	O
FindRoot(x )	O
=	O
FindRoot(y )	O
.	O
</s>
<s>
The	O
amortized	B-General_Concept
update	O
time	O
and	O
query	O
time	O
are	O
both	O
O(log(n )	O
)	O
.	O
</s>
<s>
In	O
total	O
,	O
each	O
inserted	O
edge	O
takes	O
time	O
until	O
it	O
is	O
deleted	O
,	O
so	O
the	O
amortized	B-General_Concept
time	I-General_Concept
for	O
deletion	O
is	O
.	O
</s>
<s>
In	O
total	O
,	O
the	O
amortized	B-General_Concept
time	I-General_Concept
per	O
update	O
is	O
.	O
</s>
<s>
For	O
each	O
vertex	O
v	O
,	O
calculate	O
and	O
keep	O
xor(v )	O
,	O
which	O
is	O
the	O
xor	B-Application
of	O
the	O
numbers	O
of	O
all	O
edges	O
adjacent	O
to	O
it	O
.	O
</s>
<s>
Now	O
for	O
each	O
subset	O
T⊆V	O
,	O
it	O
is	O
possible	O
to	O
calculate	O
xor(T )	O
=	O
the	O
xor	B-Application
of	O
the	O
values	O
of	O
all	O
vertices	O
in	O
T	O
.	O
Consider	O
an	O
edge	O
e	O
=	O
uv	O
which	O
is	O
an	O
internal	O
edge	O
of	O
T	O
(	O
i.e.	O
</s>
<s>
The	O
number	O
of	O
e	O
is	O
included	O
twice	O
in	O
xor(T )	O
-	O
once	O
for	O
u	O
and	O
once	O
for	O
v	O
.	O
Since	O
the	O
xor	B-Application
of	O
every	O
number	O
with	O
itself	O
is	O
0	O
,	O
e	O
vanishes	O
and	O
does	O
not	O
affect	O
xor(T )	O
.	O
</s>
<s>
Thus	O
,	O
xor(T )	O
is	O
actually	O
the	O
xor	B-Application
of	O
all	O
edges	O
in	O
cutset(T )	O
.	O
</s>
<s>
If	O
xor(T )	O
=	O
0	O
,	O
then	O
we	O
can	O
confidently	O
reply	O
that	O
cutset(T )	O
is	O
empty	O
.	O
</s>
<s>
If	O
xor(T )	O
is	O
the	O
number	O
of	O
a	O
real	O
edge	O
e	O
,	O
then	O
probably	O
e	O
is	O
the	O
only	O
edge	O
in	O
cutset(T )	O
,	O
and	O
we	O
can	O
return	O
e	O
.	O
We	O
can	O
also	O
read	O
the	O
endpoints	O
of	O
e	O
from	O
the	O
number	O
of	O
e	O
by	O
splitting	O
it	O
to	O
the	O
lg(n )	O
leftmost	O
bits	O
and	O
the	O
lg(n )	O
rightmost	O
bits	O
.	O
</s>
<s>
The	O
third	O
option	O
is	O
that	O
xor(T )	O
is	O
a	O
nonzero	O
number	O
which	O
does	O
not	O
represent	O
a	O
real	O
edge	O
.	O
</s>
<s>
This	O
can	O
only	O
happen	O
if	O
there	O
are	O
two	O
or	O
more	O
edges	O
in	O
cutset(T )	O
,	O
since	O
in	O
that	O
case	O
xor(T )	O
is	O
the	O
xor	B-Application
of	O
several	O
numbers	O
of	O
edges	O
.	O
</s>
<s>
If	O
in	O
the	O
first	O
level	O
xor(T )	O
returns	O
an	O
illegal	O
value	O
,	O
meaning	O
that	O
cutset(T )	O
has	O
two	O
or	O
more	O
edges	O
,	O
then	O
there	O
is	O
a	O
chance	O
that	O
in	O
the	O
next	O
level	O
,	O
which	O
contains	O
fewer	O
edges	O
,	O
xor(T )	O
will	O
return	O
a	O
legal	O
value	O
since	O
cutset(T )	O
will	O
contain	O
a	O
single	O
edge	O
.	O
</s>
<s>
If	O
xor(T )	O
still	O
returns	O
an	O
illegal	O
value	O
,	O
continue	O
to	O
the	O
next	O
level	O
,	O
etc	O
.	O
</s>
<s>
We	O
can	O
add	O
a	O
cutset	O
structure	O
to	O
a	O
dynamic	B-Algorithm
connectivity	I-Algorithm
structure	O
.	O
</s>
<s>
When	O
an	O
edge	O
is	O
deleted	O
from	O
the	O
spanning	O
forest	O
used	O
for	O
the	O
dynamic	B-Algorithm
connectivity	I-Algorithm
structure	O
,	O
the	O
cutset	O
structure	O
is	O
used	O
to	O
find	O
a	O
replacement	O
edge	O
.	O
</s>
<s>
This	O
is	O
in	O
contrast	O
to	O
The	O
Level	O
structure	O
,	O
in	O
which	O
the	O
query	O
time	O
is	O
O(polylog(n )	O
)	O
amortized	B-General_Concept
,	O
but	O
the	O
worst-case	O
time	O
is	O
O(n )	O
.	O
</s>
<s>
If	O
the	O
order	O
in	O
which	O
edges	O
will	O
be	O
deleted	O
is	O
known	O
ahead	O
of	O
time	O
,	O
then	O
we	O
can	O
solve	O
the	O
dynamic	B-Algorithm
connectivity	I-Algorithm
problem	O
in	O
log(n )	O
per	O
query	O
.	O
</s>
<s>
This	O
requires	O
us	O
to	O
do	O
the	O
following	O
operations	O
:	O
add	O
an	O
edge	O
,	O
cut	O
an	O
edge	O
,	O
and	O
query	O
the	O
minimum	O
edge	O
on	O
a	O
path	O
which	O
can	O
be	O
done	O
rather	O
easily	O
with	O
a	O
link-cut	B-Data_Structure
tree	I-Data_Structure
in	O
log(n )	O
per	O
operation	O
.	O
</s>
