Research Article  Open Access
Shortest Paths Based Web Service Selection in Internet of Things
Abstract
The connecting of things to the Internet makes it possible for smart things to access all kinds of Web services. However, smart things are energylimited, and suitable selection of Web services will consume less resources. In this paper, we study the problem of selecting some Web service from the candidate set. We formulate this selection of Web services for smart things as singlesource manytarget shortest path problem. We design algorithms based on the Dijkstra and breadthfirst search algorithms, propose an efficient pruning algorithm for breadthfirst search, and analyze their performance of number of iterations and cost. Our empirical evaluation on reallife graphs shows that our pruning algorithm is more efficient than the breadthfirst search algorithm.
1. Introduction
Recently, development of RFID, sensor, and networking technologies make it possible for various physical world things connecting to the internet, and people usually call it Internet of Things (IoT). In IoT, more and more devices are getting connected to the Internet, and the next step is to use the World Wide Web and its associated technologies, such as Web services, as a platform for smart things.
In Internet, there are a lot of Web services. These Web services connect with each other and construct a topology of graph. In IoT, all smart things are connecting to the Internet, so they can access all kinds of Web services. However, smart things are usually energylimited, so the selection of suitable Web service is extremely important. Guinard et al. [1] give an overall view of Web service access in Internet of Things. They propose a process and a suitable system architecture that enables developers and business process designers to dynamically query, select, and use running instances of realworld services.
In this paper, we study the problem of Web services selection in IoT setting; that is, given a smart thing and a graph of Web services, how to select several suitable Web services from the candidate set while providing satisfactory quality of service. If the selected Web services are nearest, the smart thing would take less accessing and waiting time and then consume less power. Here, we formulate the selection of Web services as singlesource manytarget shortest path problem.
The shortest path problem can be classified as SSSTSP (singlesource singletarget shortest path), SSMTSP (singlesource manytarget shortest paths), APSP (allpairs shortest paths), and SP ( shortest paths). The MSSTSP (manysources singletarget shortest paths) is the same as SSMTSP if we reverse all edges in the graph.
1.1. Our Contribution
In this paper, we study the problem of SSMTSP (singlesource manytarget shortest paths) on MapReduce, which is finding shortest paths from a candidate set for one source node on MapReduce. In our work, we do not care about the exact paths, but rather the nearest neighbors of the source node, so the SSMTSP problem can also be considered as singlesource manytarget nearest neighbors problem. The SSMTSP can be used in recommending friends or ads in social networks, and in searching malls or hotels in road networks.
We design algorithms based on the Dijkstra and breadthfirst search algorithms, propose an efficient pruning algorithm for breadthfirst search, and analyze their performance of number of iterations and cost. Our empirical evaluation on reallife graphs and Hadoop platform shows that the pruning algorithm is more efficient than the breadthfirst search shortest path algorithm.
The rest of the paper is organized as follows. Section 2 gives the background for shortest path for graphs, MapReduce, Dijkstra algorithm, and breadthfirst search. The SSMTSP problem and its corresponding algorithms are presented in Section 3. We analyze the performance of our algorithms in Section 4, show experimental results in Section 5, and review the related work in Section 6. Finally, conclusion and future work is given in Section 7.
2. Background
In this section, we provide some background for shortest path for graphs, MapReduce, Dijkstra algorithm, and breadthfirst search.
2.1. Shortest Path for Graphs
We consider a Weighted Directed Graph , where is the set of nodes, is the set of edges, and the number of nodes and edges is and , respectively. We use to represent the diameter of . For an edge , the weight is denoted with , and is ’s parent node and is ’s child node. A path in a graph is a sequence of nodes , where and . and are called start and target of and linked by . The length of between source and target is the sum of weights of edges in it; that is, , and the number of hops from source to target in is the number of edges, that is, .
Definition 1. A path in graph from start to target is a shortest path, if there does not exist any path between and , such that .
For the sake of simplifying the presentation, we assume for the rest of the paper that the weight on each edge of equals 1; that is, . This degrades to an unweighted graph but does not affect the result of our algorithms.
2.2. MapReduce
MapReduce [2], proposed by Google, is a programming model for processing huge amounts of data in parallel using a large number of commodity machines, and its opensource implementation is Hadoop (http://hadoop.apache.org/docs/current/hadoopprojectdist/hadoophdfs/Federation.html). By automatically handling the lower level issues, such as job distribution, data storage, and fault tolerance, it allows programmers without any experience with parallel and distributed systems to easily utilize the resources of a large distributed system.
In the MapReducelike systems, programs are done iteratively in three phases: Map, Shuffle, and Reduce. In the Map phase, they read a collection of values or key/value pairs from input sources in parallel and emit zero or more key/value pairs for each input element by invoking a user defined Mapper function. In the Shuffle phase, they group together all the Mapperemitted key/value pairs sharing the same key and output all groups to the next phase. In the Reduce phase, they invoke a user defined Reducer function for each distinct group independently and in parallel and emit zero or more key/value pairs that will be written on disks or be the input of the next Map phase in the following iteration. In our work, we will use two basic primitives: Map and Reduce.
2.3. Dijkstra Algorithm
Dijkstra algorithm [3] is a classical algorithm for singlesource shortest path problem for graphs with positive weights. It computes the shortest paths between the source and any other node in a graph. The main idea is that starting from , expand one node that has the shortest path to ; repeat the expanding process until all nodes are reached from . In each expanding process, the algorithm expands a nearest neighbor, and it requires that the weight of each edge is positive.
Example 2. Given the graph in Figure 1, if we choose as the source, the distances between and other nodes will be , which can be done in 6 expanding processes.
2.4. BreadthFirst Search
To find the shortest paths between the source and other nodes in graph , we can conduct a breadthfirst search (BFS for short) starting from and obtain a BFStree [4]. In order to construct BFStree of , we first initialize as a tree having only the root node and then add children of in to . That is, if , we add to as a child of . Then iteratively, for each leaf node in current , we search all its children , such that and has not been added to yet and add to as a child of .
Example 3. Also considering the graph in Figure 1, the BFStree of can be seen in Figure 2. If we choose as the source, the distances between and other nodes are also , and , but the BFS can finish in only 3 expanding processes.
(a)
(b)
(c)
(d)
(e)
(f)
(g)
3. SSMTSP
3.1. Problem Statement
Definition 4. Given a (weighted) directed graph and a candidate node set which is chosen from , the SSMTSP problem is that, for a source node , find nearest neighbors with shortest paths, such that those nearest neighbors are in .
In our work, we do not care about the exact paths, but rather the target nodes, or called nearest neighbors, so the SSMTSP problem can also be considered as singlesource manytarget nearest neighbors problem. The candidate set could be chosen from according to nodes’ importance on the graph, such as PageRank scores [5].
3.2. DijkstraKNN Algorithm on MapReduce
On MapReduce, we keep a root set for source . At the beginning, contains only (, 0), and at each iteration, we add a nearest neighbor and the shortest distance between and to . As long as contains nodes coming from , or there is no outlink from , the expanding process terminates. Then we can get the nearest neighbors through another Map phase. Details of the DijkstraKNN algorithm can be seen in Algorithms 1 and 2.


3.3. BFSKNN and PruningBFSKNN Algorithms on MapReduce
The DijkstraKNN algorithm expands one nearest neighbor in each iteration for the source . However, we can expand all its neighbors of the same hops at the same time, that is, BFSKNN algorithm. In BFSKNN algorithm, iteratively we expand all neighbors of the same hops from and update the shortest distances between and these nodes. While all distances do not change any more, we obtain the shortest distances between and other nodes in a graph. Details of the BFSKNN algorithm can be seen in Algorithm 3.

Different from the Dijkstra algorithm, which expands the nearest neighbor in each iteration, the BFSKNN algorithm expands all nodes that have the same hops from (see Algorithm 4 for details). The conditions that terminate them are also different. In the Dijkstra algorithm, if we have found nearest neighbors or has not any outlink, the algorithm terminates. However, in the BFSKNN algorithm, the termination condition is that all distances between and other nodes in do not change.

Theorem 5. The BFSKNN Algorithm terminates in a limited number of iterations, and the output is a valid solution to the SSMTSP problem.
Proof. Given the graph , construct a BFStree rooted at source in the following steps: (1)let be the root of ;(2)find all outlinks for each leaf node of in and add them to as children of that leaf node;(3)repeat Step 2 until that the path from root to leaf node forms a loop in .
So, we have that there is a simple path from to in if and only if there is a path from root to leaf node in . The above steps finish in a limited number () of iterations, so the BFSKNN algorithm terminates in a limited number of iterations. After iterations, we can find all the shortest paths between and other nodes in , so since the th iteration, all the shortest paths between and other nodes will not change any more, and the nearest neighbors from construct a valid solution to the SSMTSP problem.
However, in each expanding process of BFSKNN, all nodes expand along with their outlinks, and this causes the problem of path expansion because all edges have to be accessed. In order to prune edges that are not necessarily accessed, we keep a list cList for each node, which records nodes from the candidate set for the current path. In cList, if a path contains nodes from , then we prune paths derived from that path, because they do not contain any useful information about nearest neighbors. Details can be seen in in Algorithms 5 and 6.


Example 6. Given the graph in Figure 1, candidate set and , we can prune the BFStree of in Figure 2, and the results are in Figure 3.
(a)
(b)
(c)
(d)
(e)
(f)
(g)
Theorem 7. The PruningBFSKNN algorithm terminates in a limited number of iterations, and the output is a valid solution to the SSMTSP problem.
Proof. Constructing a BFStree the same as Proof of Theorem 5, we have that there is a simple path from source to target in if and only if there is a path from root to leaf node in . Prune paths have candidate nodes from after the th candidate node. There are two kinds of pruned nodes, normal nodes (not belonging to ) and candidate nodes. If a node is a candidate node, it cannot be one of the nearest neighbors in the pruned paths, because we have found nearest neighbors in those paths. Otherwise, if a node is a normal node, then whether it appears in pruned paths or not does not affect the termination of the algorithm and does not affect the correctness of the algorithm either. So we have that the PruningBFSKNN algorithm terminates in a limited number of time, and the output is a valid solution to the SSMTSP problem.
4. Performance Analysis
In this section, we analyze and compare the number of iterations and cost of the DijkstraKNN, BFSKNN, and PruningBFSKNN algorithms. Realistic analysis of the efficiency of MapReduce algorithms is not straightforward, because the algorithms’ efficiency in practice depends on many other factors, such as distribution of data, scheduling of jobs, and proximity of the communicating machines. However, these factors are all controlled by the system, and only the number of iterations and cost can be controlled by users’ MapReduce programs.
4.1. The Number of Iterations
Theorem 8. The Dijkstra algorithm with parameters and finishes in MapReduce iterations.
Proof. Since is chosen from , so when we expand a node, the probability that it belongs to is . In order to obtain nearest neighbors, we need expanding processes, so the Dijkstra algorithm finished in MapReduce iterations.
Theorem 9. The BFSKNN and PruningBFSKNN algorithms with parameters and finish in () MapReduce iterations.
Proof. Construct a BFStree the same as Proof of Theorem 5, so the depth of equals the diameter of , and the BFSKNN and PruningBFSKNN algorithms terminate in at most expanding processes, so the BFSKNN and PruningBFSKNN algorithms finish in at most MapReduce iterations.
4.2. Cost Analysis
We now start by analyzing the cost of the DijkstraKNN algorithm. The DijkstraKNN algorithm terminates in expanding processes. In each expanding process, the input is and , so the total cost is Next, we analyze the cost of the BFSKNN algorithm. The BFSKNN algorithm terminates in at most expanding processes. In each expanding process, the input is and , so the total cost is At last, we analyze the cost of the PruningBFSKNN algorithm. The PruningBFSKNN algorithm also terminates in at most expanding processes. In the th () expanding process, the input is the same as BFSKNN, but in the th () expanding process, we prune unnecessary paths, so the total cost that we save is
5. Experiments
In this section, we present the results of the experiments that we did to test the performance of our algorithms.
5.1. Experimental Setup
Dataset. In order to demonstrate the robustness of our methods and to show their performance on realistic data, we present experiments with two realworld datasets, Epinions social network [6] and LiveJournal social network [7, 8]. Summary statistics about these datasets are presented in Table 1.
 
Here , and represent the number of nodes, the number of edges and the diameter of a graph respectively. 
Experimental Platform. We implement the Dijkstra, BFSKNN, and PruningBFSKNN algorithms in Java on top of Hadoop platform. Our experiments are executed on a cluster of 20 nodes, where each node is a commodity machine with a 2.16 GHz Intel Core 2 Duo CPU and 1 GB of RAM, running CentOS v6.0.
5.2. Experimental Results
For choosing the candidate sets, we compute the PageRank scores [5] of each graph using Pegasus [9] and select 5,000 top ones as the candidate set. As can be seen from Figure 4 that PageRank scores of the two graphs all conform to the power law, that means only a small number of nodes are important. In the ads, the candidate sets usually contain the entities in which we gain profit from business.
(a) Epinions
(b) LiveJournal
We choose top 50, 500, and 5000 PageRank score nodes from Epinions social network and top 5000 PageRank score nodes from LiveJournal social network and compare the performance of the above algorithms. We select randomly 20 source nodes from each graph and compute the average execution time.
As you can see from Figure 5, the execution time of the DijkstraKNN algorithm changes greatly as we change the size of the candidate set, and bigger candidate set has smaller execution time. Moreover, the BFSKNN and PruningBFSKNN algorithms have more stable execution time. We also print all results for candidate sets size of 500 and 5000 in Figures 6(a) and 6(b), which show that the execution time grows linearly as the growth of iterations. This is because the inputs are and in each iteration, and the processing time is about 37 seconds. However, the execution time also grows nearly linearly as the growth of , which is against our intuition that it should grow exponentially as the number of nodes grows exponentially. The reason is that when we search in a graph, we usually find high PageRank score nodes instead of those fringe nodes.
(a)
(b)
We also compare the stability of the above algorithms; details are in Figure 7. The execution time of the DijkstraKNN algorithm changes greatly as we choose different sources because some nodes having more influential neighbors need less iterations. The BFSKNN and PruningBFSKNN algorithms have more stable execution time because their execution time depends on the radius of a graph for the source, and the radius of a graph is more stable in practice.
For LiveJournal social network, we choose the top 5000 PageRank score nodes as the candidate set and compare the performance of the above algorithms. The result is in Figure 8. The DijkstraKNN algorithm is efficient for small , but if the candidate set is smaller and is bigger, the PruningBFS algorithm is a better choice.
6. Related Work
In this section, we review some related work about MapReduce, the shortest paths and entity recommendation for graphs.
MapReduce. MapReduce algorithms have been designed or proposed in the literature for a wide range of applications, such as machine learning [10], text processing [11], and bioinformatics [12, 13]. MapReduce provides an excellent tool for large graph processing as well; a number of graph processing systems have been designed on it in the literature, such as Pegasus [9] and Giraph (http://incubator.apache.org/giraph/). In this paper, we study one of the most wellknown graph computation problems, that is, computing the shortest paths or the nearest neighbors.
The Shortest Paths. Computing the shortest paths is a basic and important primitive that lies at the core of graph related problems. The shortest path problem can be classified as SSSTSP, SSMTSP, APSP, and SP and classical algorithms such as Dijkstra algorithm [3] and FloydWarshall algorithm [14] can only handle small graphs in serial computation model. As the graphs become larger and larger, in order to answer questions timely, researchers deal with this problem by approximation [15–17], preprocessing [18, 19], or parallelization. Current parallel algorithms for the shortest path problem are mainly based on searching the BFStree of the graph [18, 20, 21], but they either study the problem of SP or focus on APSP. In this paper, we study the problem of SSMTSP, which is a composition of the above two, design BFSbased parallel algorithm on MapReduce, and propose corresponding pruning strategy.
Entity Recommendation. As complex networks, such as social networks and webpage graphs, become more and more popular, entity recommendation on graphs becomes a hotspot among researchers. Current entity recommendation methods are mainly contentbased or linkbased. Contentbased entity recommendation algorithms consider only the content of entities and recommend the most similar ones for some entity (refer to [22, 23] for details). Rankbased entity recommendation algorithms consider the structure of the graphs and recommend the most influential ones for some entity. The influence of entities can be defined as PageRank [5], HITS [24], SimRank [25], or some methods that derive from them. In this paper, from the perspective of influence, we consider the nearest neighbors as the most influential entities and recommend the nearest neighbors from the selected candidate set for some entity.
7. Conclusion and Future Work
In this paper, we study the problem of singlesource manytarget shortest paths for graphs, which is finding nearest neighbors from a candidate set for one source. To the best of our knowledge, this is the first study of recommending nearest neighbors from selected candidate set. As MapReduce programming model becomes more and more popular in data intensive computing, we evaluate algorithms on its opensource implementationHadoop. We design algorithms based on the Dijkstra and breadthfirst search algorithms, propose an efficient pruning algorithm for breadthfirst search, and evaluate their performance.
As graphs become bigger and bigger, precise algorithms need much time to compute several nearest neighbors and some fringe nodes may even waste more computing sources. In the future, we plan to seek approximation algorithms that can handle this problem.
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
References
 D. Guinard, V. Trifa, S. Karnouskos, P. Spiess, and D. Savio, “Interacting with the SOAbased internet of things: discovery, query, selection, and ondemand provisioning of web services,” IEEE Transactions on Services Computing, vol. 3, no. 3, pp. 223–235, 2010. View at: Publisher Site  Google Scholar
 J. Dean and S. Ghemawat, “MapReduce: simplified data processing on large clusters,” Communications of the ACM, vol. 51, no. 1, pp. 107–113, 2008. View at: Publisher Site  Google Scholar
 E. W. Dijkstra, “A note on two problems in connexion with graphs,” Numerische Mathematik, vol. 1, no. 1, pp. 269–271, 1959. View at: Publisher Site  Google Scholar
 T. Cormen, C. Leiserson, R. Rivest, and C. Stein, Introduction to Algorithms, The MIT Press, Cambridge, Mass, USA, 2001.
 L. Page, S. Brin, R. Motwani, and T. Winograd, “The pagerank citation ranking: bringing order to the web,” Tech. Rep., 1999. View at: Google Scholar
 M. Richardson, R. Agrawal, and P. Domingos, “Trust management for the semantic web,” in The Semantic Web—ISWC 2003, vol. 2870 of Lecture Notes in Computer Science, pp. 351–368, 2003. View at: Publisher Site  Google Scholar
 L. Backstrom, D. Huttenlocher, J. Kleinberg, and X. Lan, “Group formation in large social networks: membership, growth, and evolution,” in Proceedings of the 12th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD '06), pp. 44–54, ACM, 2006. View at: Google Scholar
 J. Leskovec, K. Lang, A. Dasgupta, and M. Mahoney, “Community structure in large networks: natural cluster sizes and the absence of large welldefined clusters,” Internet Mathematics, vol. 6, no. 1, pp. 29–123, 2009. View at: Google Scholar
 U. Kang, C. E. Tsourakakis, and C. Faloutsos, “PEGASUS: a petascale graph mining system—implementation and observations,” in Proceedings of the 9th IEEE International Conference on Data Mining (ICDM '09), pp. 229–238, IEEE, Miami, Fla, USA, December 2009. View at: Publisher Site  Google Scholar
 D. Gillick, A. Faria, and J. DeNero, “Mapreduce: distributed computing for machine learning,” Tech. Rep., 2006. View at: Google Scholar
 J. Lin and C. Dyer, “Dataintensive text processing with mapreduce,” Synthesis Lectures on Human Language Technologies, vol. 3, no. 1, pp. 1–177, 2010. View at: Google Scholar
 S. Leo, F. Santoni, and G. Zanetti, “Biodoop: bioinformatics on hadoop,” in Proceedings of the 38th International Conference Parallel Processing Workshops (ICPPW '09), pp. 415–422, IEEE, September 2009. View at: Publisher Site  Google Scholar
 R. Taylor, “An overview of the hadoop/mapreduce/hbase framework and its current applications in bioinformatics,” BMC Bioinformatics, vol. 11, supplement 12, article S1, 2010. View at: Publisher Site  Google Scholar
 R. Floyd, “Algorithm 97: shortest path,” Communications of the ACM, vol. 5, no. 6, p. 345, 1962. View at: Publisher Site  Google Scholar
 U. Kang, C. Tsourakakis, A. Appel, C. Faloutsos, and J. Leskovec, HADI: Fast Diameter Estimation and Mining in Massive Graphs with Hadoop, Citeseer, 2008.
 M. Potamias, F. Bonchi, C. Castillo, and A. Gionis, “Fast shortest path distance estimation in large networks,” in Proceedings of the ACM 18th International Conference on Information and Knowledge Management (CIKM '09), pp. 867–876, ACM, November 2009. View at: Publisher Site  Google Scholar
 X. Zhao, A. Sala, C. Wilson, H. Zheng, and B. Zhao, “Orion: shortest path estimation for large social graphs,” in Proceedings of the 3rd conference on Online social networks, p. 9, USENIX Association, 2010. View at: Google Scholar
 Y. Xiac, W. Wu, J. Pei, W. Wang, and Z. He, “Efficiently indexing shortest paths by exploiting symmetry in graphs,” in Proceedings of the 12th International Conference on Extending Database Technology: Advances in Database Technology (EDBT '09), pp. 493–504, ACM, March 2009. View at: Publisher Site  Google Scholar
 F. Wei, “TEDI: efficient shortest path query answering on graphs,” in Proceedings of the International Conference on Management of Data (SIGMOD '10), pp. 99–110, ACM, June 2010. View at: Publisher Site  Google Scholar
 D. A. Bader and K. Madduri, “Designing multithreaded algorithms for breadthfirst search and siconnectivity on the Cray MTA2,” in Proceedings of the International Conference on Parallel Processing (ICPP '06), pp. 523–530, IEEE, August 2006. View at: Publisher Site  Google Scholar
 J.H. Wen, H.L. Jiang, Z. Mei, and J.L. Song, “Scene shortest path solutions based on the breadth first search,” Advanced Materials Research, vol. 267, pp. 25–29, 2011. View at: Publisher Site  Google Scholar
 S. Debnath, N. Ganguly, and P. Mitra, “Feature weighting in content based recommendation system using social network analysis,” in Proceedings of the 17th International Conference on World Wide Web (WWW ’08), pp. 1041–1042, ACM, New York, NY, USA, 2008. View at: Publisher Site  Google Scholar
 O. Phelan, K. McCarthy, M. Bennett, and B. Smyth, “Terms of a feather: contentbased news recommendation and discovery using twitter,” Advances in Information Retrieval, vol. 6611, pp. 448–459, 2011. View at: Google Scholar
 J. M. Kleinberg, “Authoritative sources in a hyperlinked environment,” Journal of the ACM, vol. 46, no. 5, pp. 604–632, 1999. View at: Google Scholar
 G. Jeh and J. Widom, “SimRank: a measure of structuralcontext similarity,” in Proceedings of the 8th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD '02), pp. 538–543, July 2002. View at: Google Scholar
Copyright
Copyright © 2014 Xiangdong Yin and Jie Yang. 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.