# Lecture 013 - Graph Contraction

Graph partition (part, block): partition of a graph $G$ into several vertex-induced subgraphs of $G$.

• internal edge: edge such that two vertices are both within the same block

• cut edge: edge accross different blocks

Making connected component (in undirected graph) a block will result no cut edge between the blocks. Example partition. We can write (\{abc, d, ef\}, \{a \to abc, b \to abc, c \to abc, d \to d, e \to ef, f \to ef\})(\{abc, d, ef\}, \{a \to abc, b \to abc, c \to abc, d \to d, e \to ef, f \to ef\}) or simply (\{a, d, ef\}, \{a \to a, b \to a, c \to a, d \to d, e \to e, f \to e\})(\{a, d, ef\}, \{a \to a, b \to a, c \to a, d \to d, e \to e, f \to e\})

Graph contraction: a contraction technique for computing properties of graphs in parallel. As a contraction technique, it is used to solve a problem instance by reducing it to a smaller instance of the same problem.

• round: each application of the inductive step

• quotient graph: the graph after contraction step

• super-vertex: a vertex representing a block

graph partitioning problems are typically NP-hard.

General Strategy:

• Base case: If the graph is small (e.g., it has no edges), then compute the desired result.

• Inductive case:

• Contraction step: contract the graph into a smaller quotient graph.
• Partition the graph into blocks.

• Contract each block to a single super-vertex.
• Drop internal edges.
• Reroute cut edges to corresponding super-vertices.
• Recursive step: Recursively solve the problem for the quotient graph.

• Expansion step: By using the result for the quotient graph, compute the result for the input graph.

When you contract, there might be multiple edges in the quotient graph connecting two super-vertex. We can choose to remove duplicate or work with multigraph, depending on applications.

The ultimate goal of graph contraction technique is to reduce the size of the graph by a constant fraction (possibly in expectation) at each round of contraction. Graph contraction technique does not specify which contraction strategy to use.

## Edge Contraction

Edge contraction: a graph contraction where blocks being contracted correspond to edges.

Edge partition: a graph partition where each block is either a single vertex or two vertices connected by an edge.

To find edge partition, we need to solve vertex matching problem. Vertex Maching Example: There are two matched edge and two unmatched vertex. The match size is 2. This is not a maximum maching since \{(a,c), (b, d), (e,f)\}\{(a,c), (b, d), (e,f)\} is a better maching.

Vertex Matching: pick maximum edges that don't share endpoint, which can be solved in $O(|E|\sqrt{|V|})$ work.

For edge contraction, we do not need a maximum matching but one that it is sufficiently large.

We will use Vertex Matching as a way to select edges to contract in a round.

### Greedy Vertex Matching

Greedy Vertex Matching: it finds a solution within a factor $2$ of optimal.

1. initialize empty edge set $M$, copy edge list to $E$ from the original graph
2. pick arbitrary edge $(u, v)$ from $E$
3. if $u, v \not\in M$, then add $(u, v)$ to $M$
4. else remove $(u, v)$ from $E$

The greedy algorithm is sequential, because each decision depends on previous decisions.

### Randomized Parallel Vertex Macthing

Parallel Vertex Matching: method 1

1. flip a coin for each edge
2. select all edges if (1) the edge is HEAD (2) all nearby edges are TAIL

The probability of selecting an edge in a circle-graph is $\frac{1}{8}$, and so $\frac{1}{8}$ of the edge will be selected in expectation in a circle-graph.

Parallel Vertex Matching: method 2

1. each vertex $u$ pick one of its neighbor $v \in (V - \{u\})$
2. select the edge $(u, v)$ only when $u$ picked $v$ and $v$ picked $u$

The expected number of edge selected is $\frac{1}{4}$ in a circle-graph. (Of course, worse as the degree of vertex increase.)

Parallel Vertex Matching: method 3

1. each edge pick a floating point number
2. select te edge if it is local maximum

The expected number of edge selected is $\frac{1}{3}$.

Edge Partition doesn't work quiet well with vertices with high degree. If there is a vertex with high degree, then only one of its edges can be selected. Star graphs are a canonical example of such graphs, although there are many others.

Edge contraction therefore is not effective for general graphs.

### Edge Contraction

So if we guarantee a fraction of edges will be selected, then contraction will end in $O(k\log |E|)$ rounds with high probability.

• Work: $O(|E|)$ since at each round, we have to flip coins on each edge ($O(|E|)$) and remap vertices ($O(|V|)$) to create new edges/vertices. This give us root-dominated recurrence $W(|E|) = W(\frac{1}{c}|E|) + O(|E|)$.

• Span: $O(\log^2 |E|)$ since at each round we need to filter ($O(\log |E|)$) edges to create next round's graph.

## Star Contraction

Stargraph:

• center: the center vertex $v \in V$

• satellites: all edges connected from center to center's neighbors

a single vertex, and a single edge are stargraph.

star partition: partition the graph in a way that each block is a vertex-induced subgraph that is a stargraph

### Star Partition Partition a graph to stars. There are two disjoint stars: red and green. Note that the middle vertex is contained in green, but not in red, making two stars disjoint.

Sequential Construction: We can construct a star partition sequentially by iteratively adding stars until the vertices are exhausted

1. Select an arbitrary vertex $v$ from the graph and make $v$ the center of a star.
2. Attach as satellites all the neighbors of $v$ in the graph.
3. Remove $v$ and its satellites from the graph.

Parallel Construction: randomly assign "leader" (center), if no leader nearby, elect one.

1. Flip a coin for each vertex.
2. If a vertex flips heads, then it becomes the center of a star.
3. If a vertex flips tails, then there are two cases.
1. The vertex has a neighbor that flips heads. In this case, the vertex selects the neighbor (breaking ties arbitrarily) and becomes a satellite.
2. The vertex doesn't have a neighbor that flips heads. In this case, the vertex becomes a center.

In the case of all vertices are head, we left with $|V|$ many partitions with only 1 vertex. But this is unlikely to happen.

isolated vertex: if a vertex does not have a neighbor.

The parallel approach to star partition is not optimal, because it might not always create the smallest number of stars. This is acceptable for us, because we only need to reduce the size of the graph by some constant factor.

Based on the array-based cost specification for sequences starPartition is $O(|E|+|V|)$ work and $O(\log |V|)$ span.

For a graph $G$ with $n$ non-isolated vertices, the expected number of satellites in a call to starPartition(G, i) for any round $i$ is at least $n/4$. Proof: let $v, u$ be some non-isolated vertex. Then $Pr\{v \text{ is a satellite}\} \geq Pr\{T_v\} \cdot Pr\{H_u\} = \frac{1}{4}$. So by linear expectation, there must be $\geq \frac{1}{4}$ satelites which will get contracted.

### Star Contraction

Higher-order (generic) star-contraction algorithm:

• base function specifies the computation in the base case (vertex set)

• expand function computes the result for the larger graph from the quotient graph Generic Star Contraction: PP is a mapping from v \in V \to v' \in V'v \in V \to v' \in V' and E'E' is the new edge set of quotient graph.

Contract the graph into a number of isolated vertices costs $O((|V|+|E|)\log |V|)$ work and $O(\log^2|V|)$ span, assuming

• base: $O(|V|)$ work and $O(1)$ span

• expand: $O(|V|+|E|)$ work and $O((|V| + |E|)\log|E|)$ span

Span: Since non-isolated vertices after contraction is less than $\frac{3}{4}$ before contraction, the contraction will end in $O(\log^2|V|)$ steps.

Work: bounding the number of edges subtraction by $\frac{|V|}{4}$ is not enough since there can be $|V|^2$ many edges. For non-isolated vertex: $W(n, |E|) \leq W(n', |E|) + O(n + |E|)$ which solves to $O(|V| + |E| \log |V|)$ in expectation. For isolated vertex, we need additional $O(|V|\log|V|)$ work. The combined work is $O((|V|+|E|)\log |V|)$

// TODO: understand last sentence

## Graph Connectivity

Graph Connectivity: finding all of the connected components in undirected graph by specifying vertex set of each component

Throughout this chapter, we use an edge-set representation for graphs

### Sequential Graph Connectivity

BFS (and DFS) can solve the problem but with $O(|V|)$ span (which is considered to be large). This is because there can be $|V|$ components or simply a chain of $|V|$ vertices.