ArticleslgStudy

computer science

Dynamic connectivity

Dynamic connectivity is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Dynamic connectivity rather than just read about it. In short: In computing and graph theory, a dynamic connectivity structure is a data structure that dynamically maintains information about the connected components of a graph. The set V of vertices of the graph is fixed, but the set E of edges can change.

Key takeaways

  • Dynamic connectivity belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Dynamic connectivity to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Dynamic connectivity from memory before moving on to harder problems.

Reference excerpt

In computing and graph theory, a dynamic connectivity structure is a data structure that dynamically maintains information about the connected components of a graph. The set V of vertices of the graph is fixed, but the set E of edges can change. The three cases, in order of difficulty, are:

Edges are only added to the graph (this can be called incremental connectivity); Edges are only deleted from the graph (this can be called decremental connectivity); Edges can be either added or deleted (this can be called fully dynamic connectivity). After each addition/deletion of an edge, the dynamic connectivity structure should adapt itself such that it can give quick answers to queries of the form "is there a path between x and y?" (equivalently: "do vertices x and y belong to the same connected component?").

Incremental connectivity If edges can only be added, then the dynamic connectivity problem can be solved by a disjoint-set data structure. Each set represents a connected component; there is a path between x and y if and only if they belong to the same set. The amortized time per operation is Θ(α(n)), where n is the number of vertices and α is the inverse Ackermann function.

Decremental connectivity The case in which edges can only be deleted was solved by Shimon Even and Yossi Shiloach. The structure uses a table that specifies, for each vertex, the name of the component to which it belongs. Thus a connectivity query takes constant time. The challenge is to update the table when an edge is deleted.

Acyclic graphs (forests) When edge u-v is deleted in a forest, the tree containing that edge is broken to two trees: one of them contains u and the other contains v. The table is updated in the following way.

Scan the tree starting from u (using any tree scan algorithm, such as DFS). Scan the tree starting from v. Do the above two procedures in parallel, i.e., either using two parallel processes, or by interleaving their steps (make a step of first scan, then a step of the second scan, then a step of the first scan, etc.). Suppose the first scan that terminates is the scan from u (so we know that the tree containing u is the smaller one). Assign a new component name to every node in the subtree of u. Since we always rename the smaller sub-component, the amortized time for a delete operation is O(log⁡(n)).

General graphs When an edge is deleted in a general graph, we don't know whether its component remains a single component (connected by other edges) or broken to two components. So we use two processes which run in parallel (or in an interleaved way). Process A checks whether the edge deletion breaks a component, and if it does, both processes halt. Process B checks whether the edge deletion does not break the component to which it belongs, and if it does not, again both processes halt.

Process A is similar to the acyclic-graph case: there are two sub-processes who scan from both ends of the deleted edge. If one of the sub-processes finishes before reaching the other end, this means that the component is broken into two sub-components, and the name of the smaller sub-component is updated, as before. Thus the amortized time for a delete operation is again O(log⁡(n)). Process B uses a breadth-first structure (BFS), which is initialized as follows. A vertex r is chosen and the BFS starts from it. The only vertex in level 0 is r. All the vertices of distance i from the root are in level i. If G is not connected, a new scan is started at some unscanned vertex v, v is put in level 1, and an artificial edge connects v to the root r; all vertices of distance i from v are now in level i+1, etc. Artificial edges are introduced in order to keep all the connected components in one BFS structure and are used only for this purpose. Clearly, the artificial edges are used only in process B. The structure has the following properties. A vertex v in level i, i>0, has only three types of edges: backward edges which connect it to level i−1 (there is at least one such edge, which may be artificial), local edges which connect it to other edges in level i (there are zero or more such edges), or forward edges which connect it to edges in level i+1 (there are zero or more such edges). So for each vertex v, we maintain three sets of edges (backward, local and forward). When an edge u-v is deleted, there are two options: either u and v are in the same level, or they are in levels whose number differs by 1.

Case 1 both u and v are on the same level. In this case, the edge deletion cannot change the components. The edge is simply deleted from the sets of local edges of u and v, and process B halts (and therefore process A is halted too). Our BFS structure is still valid. Case 2 u and v are on different levels. Without loss of generality, assume u is in level i−1 and v is in level i; hence the edge should be removed from forward(u) and from backward(v). Case 2.1 If the new backward(v) is not empty, then the components have not changed: there are other edges which connect v backwards. Process B halts (and process A is halted too). Case 2.2 If the new backward(v) is empty, then v is no longer connected to level i−1, and so its distance from the root is no longer i; it must be at least i+1. Additionally, there may be other vertices, connected to v, whose distance from the root increases as a result of the deletion. To calculate the updated distances, we use a queue Q, which initially contains only the vertex v. While Q is not empty:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Dynamic connectivity

Start with the simplest possible case. Write down what Dynamic connectivity claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Dynamic connectivity before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Dynamic connectivity ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Dynamic connectivity

In research
Dynamic connectivity appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Dynamic connectivity in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Dynamic connectivity is common in secondary-school and first-year university syllabi. It links to neighbouring topics Graph algorithms, Graph data structures, so understanding it makes those chapters shorter.
In everyday life
Look for Dynamic connectivity outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Dynamic connectivity” →

How to study Dynamic connectivity in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Dynamic connectivity means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Dynamic connectivity out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Dynamic connectivity in simple terms?

In computing and graph theory, a dynamic connectivity structure is a data structure that dynamically maintains information about the connected components of a graph. The set V of vertices of the graph is fixed, but the set E of edges can change.

Why does Dynamic connectivity matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Dynamic connectivity?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Dynamic connectivity.

Tags

  • Graph algorithms
  • Graph data structures

Keep exploring