Connected components and graph edition
In general, what you are looking for is known as dynamic connectivity: it comes with different flavors depending on whether vertices/edges can be added, deleted, or if both operations are allowed.

Many relevant papers are summarized in this answer on TCS.SE. If you are looking for a practical implementation, a possible starting point is [1]. Here, the authors perform experiments and provide some C++ code (these are for fully dynamic algorithms).



[1] Iyer, R., Karger, D., Rahul, H., &amp; Thorup, M. "An experimental study of polylogarithmic, fully dynamic, connectivity algorithms." Journal of Experimental Algorithmics (JEA) 6 (2001): 4.