PRAM Algorithm (Graph Coloring)
PRAM Algorithm (Graph Coloring)
1
Slides adapted by S Gokul Kannan
Courtesy: Illinious State University
Presentation Overview
Problem Description
Basic Algorithm
Parallel Strategy
Performance
2
Problem Description
A "graph" is a collection of vertices or 'nodes' and a
collection of edges that connect pairs of vertices.
A k-coloring of a graph G is a mapping: c : V {0,1,,k - 1}
such that
c(i) c(j) if <i, j> E
3
Sequential Algorithm
4
The idea is to color the vertices of a graph such that
no two adjacent vertices share the same color
Sequential Algorithm -Step 1
5
Sequential Algorithm -Step 2
6
Sequential Algorithm -Step 3
7
Sequential Algorithm -Step 4
8
Sequential Algorithm -Step 5
9
Sequential Algorithm -Step 6
10
Back to step 3
11
Parallel Algorithm
12
Parallel Algorithm on CREW PRAM
Assume the graph has n vertices
Represented using an n x n adjacency matrix
Consider c colors are used (c<=n).
Create a processor for every possible coloring of the
graph.
Each processor checks if the coloring it represents is
valid.
Color a 3-vertex graph with 2 colors
Parallel Code
Parallel Code
Parallel Code
Performance Analysis
Number of comparisons done by each processor = n
2
The number of elements in the candidate array = c
n
Sum of the elements in the candidate array = O(log c
n
)
Overall Runtime complexity = O(n
2
+ logc
n
)
= O(n
2
+ nlogc)
= O(n
2
) (if c<<n)
References
R1: Section 2.3
THE END