Discrete Dynamics in Nature and Society

Volume 2017, Article ID 2013673, 15 pages

https://doi.org/10.1155/2017/2013673

## GPU-Based Parallel Particle Swarm Optimization Methods for Graph Drawing

^{1}College of Management Science and Engineering, Shandong Normal University, Jinan, Shandong, China^{2}College of Business, The University of Texas at San Antonio, San Antonio, TX, USA

Correspondence should be addressed to Jianhua Qu; moc.361@8791hjuq

Received 17 March 2017; Accepted 15 June 2017; Published 30 July 2017

Academic Editor: Filippo Cacace

Copyright © 2017 Jianhua Qu et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

#### Abstract

Particle Swarm Optimization (PSO) is a population-based stochastic search technique for solving optimization problems, which has been proven to be effective in a wide range of applications. However, the computational efficiency on large-scale problems is still unsatisfactory. A graph drawing is a pictorial representation of the vertices and edges of a graph. Two PSO heuristic procedures, one serial and the other parallel, are developed for undirected graph drawing. Each particle corresponds to a different layout of the graph. The particle fitness is defined based on the concept of the energy in the force-directed method. The serial PSO procedure is executed on a CPU and the parallel PSO procedure is executed on a GPU. Two PSO procedures have different data structures and strategies. The performance of the proposed methods is evaluated through several different graphs. The experimental results show that the two PSO procedures are both as effective as the force-directed method, and the parallel procedure is more advantageous than the serial procedure for larger graphs.

#### 1. Introduction

Graphs are often used to depict objects and to represent the relationship between objects. In a social network, for example, vertices represent individual users and edges represent their relationships if users are acquainted. Graph drawing is a conventional tool for the visualization of graphs. The effect of graph visualization depends on whether the drawing is aesthetic. Although there are no strict criteria for aesthetics of a drawing, it is generally agreed that a drawing with the following characteristics is aesthetic [Battista et al., 2012; [1]]:(1)Minimal edge crossings are in the graph.(2)Vertices are evenly distributed in the drawing canvas.(3)Connected vertices are close to each other.(4)Symmetry may exist in the graph.

With the development of graph theory and computer science, it is possible to visualize a graph automatically. Many automatic methods for graph drawing emerged, especially for planar graphs. For nonplanar graphs, efficient or effective drawing methods are needed. Tutte [2] proposed an algorithm to draw planar graphs by fixing vertices on a face and placing the rest of the vertices at the barycentre of their neighbors. Sugiyama et al. [3] proposed a method for the hierarchical drawing of directed graphs. Eades [4] proposed a force-directed heuristic method for graph drawing. In recent years, many other methods have been proposed [5, 6]. Among these methods, the force-directed method is popular, which uses a heuristic cost or energy function to map the layout of a graph to a real number. The layout with the minimum cost or energy is aesthetic. Due to simplicity and flexibility of implementation, some variants of the force-directed method were proposed. Kamada and Kawai [7] proposed the spring embedding algorithm in which the ideal length of a spring is proportional to the distance between the vertices. Fruchterman and Reingold [8] improved the force-directed method by introducing the attractive forces and the repulsive forces. This improved force-directed method is called the F-R method in the following. All the variants differ in the definition of the energy or in the optimization method used to find the minimum of the energy. The force-directed method is especially suitable for drawing graphs with straight-line edges.

In this study, the force-directed method is also used to draw undirected graphs with straight-line edges. In the force-directed method, the layout of a graph is obtained by finding the minimum of the cost function. Therefore, the layout problem can be converted to an optimization problem. In this study, a Particle Swarm Optimization (PSO) procedure is proposed to solve the graph drawing problem.

PSO is a stochastic global optimization approach developed by Eberhart and Kennedy [9]. As a population-based metaheuristic, PSO has the advantages of robustness, effectiveness, and simplicity compared to other swarm intelligent approaches such as genetic algorithms and ant colony optimization [10–12]. In a PSO procedure, a swarm of particles is kept and each particle in the swarm adjusts its position by keeping track of its own and the global best positions. The quality of each particle is measured by a fitness function. At the end, the search is expected to converge to the global best solution of the whole search space. In recent years, PSO has been widely applied to many complex and difficult optimization problems in practice, and many improved PSO procedures have been proposed [13–16].

Although PSO has the above advantages, it still needs a long computation time to converge for large-scale problems needing a large number of particles to search for the optimal solution. The main reason is that the serial computation of the fitness values of the particles in a swarm takes too much computation time. If the computations of the fitness values of the particles are independent of each other, the computation can be decomposed for parallel operation to improve efficiency. In recent years, many parallel PSO procedures have been proposed. Graphic Processing Units (GPUs) have high speed, parallelism, and programmable functions. Therefore, GPUs have great potential in the field of general computing. Some of the parallel PSO procedures reported in the literature are implemented on GPUs [17–20] with high-performance parallel computing capabilities using NVIDIA’s Compute Unified Device Architecture (CUDA) [21] as a handy programming environment.

Schutte et al. designed the first synchronous parallel PSO procedure and successfully applied it to the biomechanical system identification problem. Venter et al. and Koh et al. [22] implemented asynchronous parallel PSO procedures to improve computational efficiency. Some methods proposed in the literature focus on the communication strategies or the neighborhood topologies [23–25]. These methods are all more efficient than serial PSO procedures and are implemented on distributed systems. The first GPU implementation of PSO was proposed by Li et al. [26]. With the convenient programming environment in NVIDIA CUDA, more methods are implemented on GPU and in CUDA [21]. The implementation of parallel PSO procedures on GPU has higher demands on information sharing than on CPU. Prasain et al. [27] designed serial and parallel procedures for the option pricing algorithm using basic principles of PSO and evaluated the performance of these procedures on a cluster of multicore machines. Solomon et al. [28] implemented a collaborative multiswarm PSO procedure on GPU using many swarms rather than just one. They applied this PSO procedure to a real-world application, the task matching problem, in a heterogeneous distributed computing environment. Roberge and Tarbouchi [29] developed parallel implementation of PSO on CUDA-GPU and applied this parallel PSO procedure to the problem of 3D pose estimation of a bomb in free fall. Souza et al. [30] proposed a cooperative evolutionary multiswarm optimization procedure based on CUDA to solve engineering problems. The procedure used the concept of master/slave swarm with the mechanism of data sharing for the acceleration of convergence. Therefore, parallel PSO procedures and their variants based on GPU and CUDA have been used in many domains.

In this study, two PSO procedures, a serial PSO procedure for graph drawing (S-PGD) and a parallel PSO procedure for graph drawing at vertex level (V-PGD), are proposed for undirected graph drawing. These two PSO procedures have similar modules but different implementation. PSO is used to optimize the graph drawing problem. The graph is initialized as a swarm of random particles. Each particle stores the position information of all vertices in the graph and corresponds to one layout of the graph. All particles automatically update their positions and velocities in the searching process for the optimal layout until the procedure terminates. Each particle has a fitness value representing the energy of the corresponding layout. The definition of the fitness function is given on the basis of the force-directed method. The performances of the two procedures are analyzed for their effectiveness, running time, and convergence through experiments on different graphs.

The remainder of this paper is organized as follows. In Section 2, introductions to the force-directed method for graph drawing and to PSO are given. Section 3 describes the S-PGD procedure in detail including the structure of the particles, the definition of the fitness function, and a pseudocode of the procedure. In Section 4, the implementation of V-PGD is explained and its time complexity is analyzed. The performances of the two procedures are examined in Section 5 through several experiments on different graphs. Conclusions and future research directions are given in Section 6.

#### 2. Related Works

The force-directed graph drawing method is briefly discussed first. Relevant concepts in PSO are then reviewed.

##### 2.1. Force-Directed Graph Drawing

Due to its simple implementation and good flexibility, the force-directed method is often used for drawing undirected graphs with straight-line edges. The methods in Eades [4], Fruchterman and Reingold [8], Hu [31] and Kamada, and Kawai [7] are some known examples based on the force-directed method.

The spring-embedder method proposed by Eades [4] is the earliest method for drawing general graphs. This method likens a graph to a system with electrically charged rings (the vertices) and connecting springs (the edges). Any two vertices are pushed by a repulsive force and adjacent vertices connected by an edge are pulled together by an attractive force. The method seeks equilibrium of these conflicting forces as constraints and is very successful with small graphs. Let represent the Euclidean distance between the two vertices and . The attractive and repulsive forces between vertices and , represented by and , respectively, are defined by [4]where is the radius of the circle. The center of the circle is a vertex and no other points are in the circle. In the F-R method [8], the attractive force is defined as follows:and the repulsive force is defined as followswhere and are constants. The final layout has a locally minimal energy with respect to the vertex positions. It can be seen from (2) and (3) that the attractive force is proportional and the repulsive force is inversely proportional to the squared Euclidean distance.

##### 2.2. Particle Swarm Optimization

PSO is a simple but powerful heuristic optimization technique introduced by Eberhart and Kennedy [9]. It is a global optimization method using a swarm of particles with random positions searching for the best position by updating their velocities and positions. Each particle in the swarm searches the optimum of a function, termed the fitness function, by keeping track of the best position it has found and the best position found by the whole swarm of particles. The best position found by a particle is called the local best position of the particle, and the best position found by the whole swarm is called the global best position. The domain of the fitness function is called the search space. Guided by the local best position and the global best position found so far, particles move over the search space in the searching process for an optimum.

Let and be the position vector and the velocity vector, respectively, of particle at time . Let represent the local best position found by particle and let represent the global best position found by all the particles in the whole swarm up to the current time . The position vector and velocity vector of particle at time can be computed using (4) and (5), respectively, as follows:where is the inertia weight; and are two random numbers; and and are the cognitive and social scaling parameters.

#### 3. S-PGD: A Serial PSO Procedure for Graph Drawing on CPU

S-PGD is discussed in detail in this section. After the structure and the fitness function are described, a pseudocode is presented.

##### 3.1. Structure of the Particles

The key of designing a good PSO procedure is to determine the structure of the particles. A good structure makes the problem simple and intuitive. In this work, designing a PSO heuristic for the graph drawing problem is a difficult task. The following method is adopted for the structure of a particle.

Let be an undirected graph, where is a set of vertices or nodes and is the set of edges or links. A layout of a graph is a mapping of the vertices to the Euclidean space: . That is to say, a vertex is mapped to a position in the Euclidean space in the graph drawing procedure. Different distributions of the vertices correspond to different layouts. The following model is used to represent the structure of the particle swarm:

In (6),* S* is the structure of the particle swarm; is the structure of particle ; and , as defined above, represent the global best position and the global best fitness value found by the whole swarm up to the current time ; is the number of the particles in the swarm; and is the dimension of the search space, that is, the number of vertices in . In (7), as defined above, is the position vector and is the velocity vector of particle ; represents the local best position and represents the local best fitness value found by particle up to the current time . In (8) and (9), is the position and is the velocity of vertex in particle at the current time . For vertex , both and are two dimensional vectors. Furthermore, let represent the total number of vertices in the whole particle swarm.

A particle with such a structure corresponds to one layout of the graph. The energy of the layout is converted to the fitness value of the particle. Whether a layout is aesthetic can be evaluated by the fitness value . The objective of a graph drawing algorithm is to find an aesthetic layout with the best fitness value. It is evident that the particle with the best fitness value corresponds to an optimal layout of the graph. Each particle in the swarm updates its velocity and position using (4) and (5), respectively, in the searching process.

##### 3.2. Fitness Function

The selection of a fitness function is very important for the success of the PSO procedure. An efficient fitness function is helpful for the particles in the swarm to find good solutions quickly. In the PSO procedure, a particle corresponds to one layout of graph drawing. The objective of graph drawing is to find an aesthetic visual representation of the vertices and the links between the vertices. Different types of graphs need different types of representations. However, no uniform criteria can be used to evaluate the performance of different representations. Inspired by the spring-electrical model, the ideas in the F-R method [8] and the method in Hu [31] are used to define the fitness function.

The force-directed method is an iterative procedure that repeatedly calculates the attractive and repulsive forces of each vertex and then moves the vertices along the direction of the forces for a displacement until the layout reaches a stable state. The attractive and the repulsive forces between two vertices and are defined in (2) and (3), respectively.

The energy contribution by the attractive and repulsive forces of the link between two vertices and in a layout at any given time is defined as follows:The fitness function of particle at time representing a layout based on the energy contributions of the links is defined as follows:

The fitness function maps the position vector of particle into a real number representing the energy of the layout . The energy will be low if adjacent vertices in the original graph are close to each other in the layout and will be high otherwise. A particle with the minimum value of the fitness function is a global optimal particle. An aesthetic layout of a graph is obtained by searching for a minimum value of the fitness function. Therefore, the graph drawing problem reduces to the problem of finding a minimum value for the fitness function.

##### 3.3. Pseudocode

S-PGD has four basic modules: initialization, fitness value computation, local and global best position and best fitness value update, and position and velocity update of the particles. In S-PGD, the fitness value computation, the most time-consuming module, is based on the definition in (11). It computes the fitness value by adding together the energy contributions of the links. Pseudocode 1 is a detailed description of S-PGD. In the pseudocode, is the number of iterations.