







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document from portland state university covers parallel strategies for traversing graphs, finding connected components using hirshberg's algorithm, and solving single-source shortest paths problems using moore's algorithm. The document also discusses the parallelization of these algorithms.
Typology: Study notes
1 / 13
This page cannot be seen from the preview
Don't miss anything!








Jingke Li
Portland State University
Jingke Li (Portland State University) CS 415/515 Graph Algorithms 1 / 25
Graph algorithms are frequently used in non-numerical applications. We’d like to examine parallel algorithms for a few common graph problems.
Graph Basics:
Common strategies include
6 5
7
1
4
2 3
9 8
6 5
7
1
4
2 3
9 8
(1) (2)
(3)
(4)
1
2 3 4
7 8
6 9
5
(1) (9) (10)
(2) (8)
(3) (6)
(4)
(7)
(5)
Jingke Li (Portland State University) CS 415/515 Graph Algorithms 3 / 25
6 5
7
1
4
2 3
9 8
6 5
7
1
4
2 3
9 8
(1) (2)
(4) (3)
1
2 3 4 5
7 8 9 6
(1) (2) (3) (4)
(5) (6) (7) (8)
(9) (^) (10)
Traversing a graph with p processors.
6 5
7
1
4
2 3
9 8
6 5
7
1
4
2 3
9 8
(1) (1)
(2) (2)
(3) (4) (3)
(4) (5)
(5)
1
2 3 4 5
7 8 9 6
(1) (1) (2) (2)
(3) (3) (4) (4)
(5) (^) (5)
Jingke Li (Portland State University) CS 415/515 Graph Algorithms 7 / 25
1 8
4 6
3 2
5 7
Common Approaches:
Based on the 3rd approach.
It iterates over three stages:
Complexity: O(log^2 n) with n^2 processors.
Jingke Li (Portland State University) CS 415/515 Graph Algorithms 9 / 25
1 8
4 6
3 2
5 7
node 1 2 3 4 5 6 7 8 root 1 2 3 4 5 6 7 8
Iteration 1:
1 8
4 6
3 2
5 7
node 1 2 3 4 5 6 7 8 min nbr rt 8 6 3 6 7 2 2 1
1 8
4 6
3 2
5 7
4 6
3 2
5 7
1 8
4 6
3 2
5 7
node 1 2 3 4 5 6 7 8 root 1 1 3 1 1 1 1 1
Jingke Li (Portland State University) CS 415/515 Graph Algorithms 13 / 25
forall (i in V) R(i) = i for (t = 0; t < log n; t++) { forall (i in V) { T(i) = min_j { R(j) | A(i,j)=1 && R(j) != R(i) } if none then R(i) } forall (i in V) { T(i) = min_j { T(j) | R(j)=i, T(j) != i } if none then R(i) } forall (i in V) R(i) = T(i) for (k = 0; k < log n; k++) { forall (i in V) T(i) = T(T(i)) } forall (i in V) R(i) = min { R(T(i)), T(i) } }
Given an n-node weighted graph G , the goal is to produce an n × n matrix A, where aij is the length of the shortest path from node i to node j.
Matrix-Multiplication Based Algorithm:
A = An−^1 = A^1 ◦ A^1 ◦ · · · ◦ A^1
With optimization, the number of matrix multiplications can be reduced to O(log n).
Complexity: O(log^2 n) with O(n^3 ) processors.
Jingke Li (Portland State University) CS 415/515 Graph Algorithms 15 / 25
The problem is to find the shortest path from a specified node, s, to all other nodes in a weighted directed graph.
Moore’s Algorithm:
Find the min-cost spanning tree for a weighted, undirected, connected graph.
Jingke Li (Portland State University) CS 415/515 Graph Algorithms 19 / 25
Start the tree with any node, then repeat the following step until all nodes are on the tree: Find the edge of lowest weight that connects a node already on the tree to a node not on the tree; then add the edge and the node to the tree.
Complexity: O(n^2 )
The step of finding the edge of lowest weight can be parallelized:
Parallel Complexity: Θ(
n^2 p
) + Θ(n log p)
Jingke Li (Portland State University) CS 415/515 Graph Algorithms 21 / 25
Start with a forest of n trees (each containing a single node); then iterate the following step until there is only one tree remaining:
A
B C
D
G F E
H
I
4 3 1
6
5 5 2 1
7
2 4
3
1
A
B C
D
G F E
H
I
4 3 1
6
5 5 2 1
7
2 4
3
1
The algorithm’s complexity is O(n^2 log n).
Comments: Can be parallelized with domain decomposition.
A
B
C D E
7 5 3
8 9 1 6