
Proceedings of the 13th WSEAS International Conference on APPLIED MATHEMATICS (MATH'08) Parallel Algorithm for Finding an Eulerian Path in an Undirected Graph AKIO TADA DAISABURO YOSHIOKA Sojo University Sojo University Faculty of Computer and Information Sciences Faculty of Computer and Information Sciences Ikeda 4-22-1, Kumamoto City Ikeda 4-22-1, Kumamoto City JAPAN JAPAN [email protected] [email protected] EIICHI MUKAI YOSHIMI MATSUMOTO Sojo University Sojo University Faculty of Computer and Information Science Faculty of Computer and Information Science Ikeda 4-22-1, Kumamoto City Ikeda 4-22-1, Kumamoto City JAPAN JAPAN [email protected] Abstract: There is Fleury’s algorithm as a sequential algorithm for finding an Eulerian path in an undirected graph. However, we cannot find a parallel algorithm for this problem. In this paper, we proposed an efficient parallel algorithm for finding an Eulerian path in an undirected graph with n vertices and m edges on a CREW-PRAM model. Namely, the proposed algorithm initially determines whether or not a given graph has an Eulerian path. Next, we divide each vertex into several new vertices which have a maximum of 2 edge degrees, and connect between new vertices by edges. Consequently, we find one Eulerian path in the given graph. The proposed algorithm requires O(n + m) processors and O(log(n + m)) time on a CREW-PRAM model. Key–Words: Parallel algorithm, Eulerian Path, Undirected graph, CREW PRAM model,Fleury’s algorithm 1 Introduction As a result, we find one Eulerian path in the given graph. The proposed algorithm requires O(n + m) An Eulerian path is a path in which every edge is used processors and O(log(n + m)) time on a CREW- precisely once on a connected graph. The conditions PRAM model. of a graph with an Eulerian path are that the num- ber of vertices with odd-degree is just 2 or degrees of all vertices are even [1, 2]. There is Fleury’s al- 2 The Proposed Algorithm gorithm as a sequential algorithm for finding an Eu- lerian path in an undirected graph [1]. However, we A given graph is an undirected connected graph, cannot find a parallel algorithm for this problem. As which contains self-loop and/or multiple edges. Each one of important applications for this problem, there vertex in a given graph is serially numbered in order is a sequence design on information theory. Finding of a large number of degrees. If each vertex num- an Eulerian path is identical to the design of maxi- ber is given arbitrarily, then a given graph is recon- mum length sequences with finite precisions, such as structed by renumbering the vertex numbers in order De Bruijn sequences. of a large number of degrees. The following theorem In this paper, we proposed an efficient parallel determines whether or not an undirected graph is an algorithm for finding an Eulerian path in an undi- Eulerian path [2]. rected graph with n vertices and m edges on a CREW- PRAM model using only the basic parallel algorithms Theorem 1 An undirected graph has an Eulerian [6, 7]. Namely, the proposed algorithm initially deter- path if and only if it is connected and the number of mines whether or not a given graph has an Eulerian vertices with odd-degree is 2 or 0. path. Next, we divide each vertex into several new vertices which have a maximum of 2 edge degrees The proposed parallel algorithm is composed of the [3, 4, 5] and connect between new vertices by edges. following two stages: ISSN: 1790-2769 82 ISBN: 978-960-474-034-5 Proceedings of the 13th WSEAS International Conference on APPLIED MATHEMATICS (MATH'08) 5 procedure Stage-1(V1[1..m],V2[1..m]); { Parallel algorithm for Stage-1 } begin 2 1 { Step[1.1] Calculate the number of degrees for each vertex } for e := 1 to m in parallel do begin V1V2[2(e-1)+1] ← V1[e]; 6 V1V2[2e] ← V2[e] 3 end; { Sort vertex numbers with index in ascending order } Para_Sort( V1V2[1..2m]); 4 { Find the boundaries of different vertex numbers } for e := 1 to 2m-1 in parallel do 1 2 3 4 5 6 7 8 9 if V1V2[e] ≠ V1V2[e+1] then B[V1V2[e]] ← e; V1 1 1 1 1 2 2 2 3 4 B[V1V2[2m]] ← 2m; V2 2 3 5 6 3 4 5 4 6 D[1] ← B[1]; for v := 2 to n in parallel do D[v] ← B[v] - B[v-1]; Figure 1: Example of given undirected connected {Find the number of degrees for each vertex } graph and array representation of edges. { Step[1.2] Determine whether or not a given graph has an Eulerian path } for v := 1 to n in parallel do DD[v] ← D[v] mod 2; ² Stage 1: Determine whether or not a given graph Para_Prefixsum( DD[1..n]); { Calculate partial sum in DD[n] } if ( DD[n] ≠ 0 AND DD[n] ≠ 2 ) then exit(0); is an Eulerian path if ( DD[n] = 0) then begin Delete the head edge and decrease the number of degrees ² Stage 2: Divide each vertex into several new ver- for vertices of the deleted edge tices and find one Eulerian path end; DD[0] ← 0; for v := 1 to n in parallel do An undirected connected graph with n vertices if ( DD[v] = 1 AND DD[v-1] ≠ 1) then odd ← v and m edges is given in the form of two arrays end; V1[1..m] and V2[1..m], which indicate the vertex numbers. Each i-th undirected edge is represented by Figure 2: Stage-1 Algorithm a pair of V1[i] and V2[i], where V1[i] ≦ V2[i] (1 ≦ i ≦ m). Moreover vertices in the array V1 are sorted in order of the vertex number. An example of an undi- rected connected graph and its array representation of Parallel Merge Sort [8]. At this time, the values undirected edges is shown in Figure 1. in V1 and V2 are placed alternately in V1V2 be- In the following subsections the details of Stages fore sorted. Next, in the array V1V2 we find the 1 and 2 are respectively described. boundaries of different vertex numbers and store an index number every vertex number in an array B[1..n]. Subsequently, we can obtain the num- 2.1 Stage 1: Determine whether or not a ber of degrees for each vertex in an array D[1..n] given graph is an Eulerian path by calculating the difference between B[v] and In this stage, we initially examine the number of de- B[v-1] where v is each vertex number. This step grees for each vertex in order to determine whether requires O(log m) time and O(m) processors be- or not a given graph is an Eulerian path. Subse- cause the vertex numbers are sorted. quently, we decide if a given graph satisfies Theorem 1. Namely we examine the number of vertices with Step 1.2 Determine whether or not a given graph odd-degree 2 or 0. If so, a given graph has an Eulerian has an Eulerian path path, otherwise our algorithm stops. In the case that A graph which has an Eulerian path contains 0 degrees of all vertices are even, one edge is deleted or 2 vertices with odd-degree. So, we divide the then two vertices with odd-degree appear. In the fol- number of degrees for each vertex by 2 and find lowing, we proceed with the processing based on a the remainder. Subsequently, we calculate the graph having two vertices with odd-degree. This stage sum of the remainders using Parallel Prefixsum is composed of the following two steps: Algorithm [6]. If the sum of the remainders is 0 or 2, then a given graph has an Eulerian path. If Step 1.1 Calculate the number of degrees for each the sum of the remainders is 0, namely, the de- vertex grees of all vertices are even, we delete the head At first, we concatenate two input arrays V1 and edge in the input array temporally and store the V2 into a single array V1V2[1..2m] and sort this vertex number of which the vertex has a smaller array with index numbers in ascending order by number of vertices with odd-degree in the vari- ISSN: 1790-2769 83 ISBN: 978-960-474-034-5 Proceedings of the 13th WSEAS International Conference on APPLIED MATHEMATICS (MATH'08) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ray D by 2, in order to divide each given ver- V1V2 1 1 1 1 2 2 2 2 3 3 3 4 4 4 5 5 6 6 tex (we call it the old vertex) into some new ver- 1 2 3 4 5 6 tices with a maximum of 2 edge degrees. When B 4 8 11 14 16 18 vertices have odd degrees, round up fractions. These values also represent the number of new 1 2 3 4 5 6 vertices generated from each old vertex. Subse- D 4 4 3 3 2 2 quently, we calculate the prefix sum in the array D and store the values in an array S[1..n]. The Figure 3: The number of degrees for each vertex. newly generated vertices are serially numbered to retain the same order of the old vertex num- ber in the given graph.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages5 Page
-
File Size-