^{1}

^{2}

^{1}

^{1}

^{1}

^{1}

^{2}

Graph is an important complex network model to describe the relationship among various entities in real applications, including knowledge graph, social network, and traffic network. Shortest path query is an important problem over graphs and has been well studied. This paper studies a special case of the shortest path problem to find the shortest path passing through a set of vertices specified by user, which is NP-hard. Most existing methods calculate all permutations for given vertices and then find the shortest one from these permutations. However, the computational cost is extremely expensive when the size of graph or given set of vertices is large. In this paper, we first propose a novel exact heuristic algorithm in best-first search way and then give two optimizing techniques to improve efficiency. Moreover, we propose an approximate heuristic algorithm in polynomial time for this problem over large graphs. We prove the ratio bound is 3 for our approximate algorithm. We confirm the efficiency of our algorithms by extensive experiments on real-life datasets. The experimental results validate that our algorithms always outperform the existing methods even though the size of graph or given set of vertices is large.

Graph is an important

Shortest path routing is an important problem in

The above problem is a special case of

We propose a novel and efficient exact heuristic algorithm with two optimizing techniques to find the shortest path with vertex constraint.

We also propose an approximate algorithm in polynomial time for our problem over large graphs. We prove the ratio bound of our approximate algorithm is 3.

We conduct extensive experiments on several real-life datasets. We compare our algorithms with the state-of-the-art methods. The experimental results validate the efficiency and effectiveness of our algorithms.

The rest of this paper is organized as follows. Section

An undirected weighted graph is denoted as

In this paper, we study the problem of finding the shortest path with vertex constraint. Table

List of notations.

Symbol | Meaning |
---|---|

| An undirected weighted graph |

| |

| Starting vertex, ending vertex, vertex constraint |

| |

| Weight of edge |

| |

| Shortest path between |

| |

| Permutation of a vertex subset |

| |

| Shortest path between |

Given a graph

Figure

An example of the shortest path with vertex constraint.

Undirected graph

Shortest path

Hamilton path problem is a special case of our problem; then, we have the following theorem straightforwardly.

The problem of finding the shortest path with vertex constraint over graphs is NP-hard.

We proof it by reducing Hamilton path problem, which is NP-complete. Given a undirected graph

Contraction Hierarchies (CH) proposed in [

Given a graph

We use an example in Figure

Contraction of vertex.

Before contraction

After contraction

After contracting vertices, CH divides

In this section, we propose an algorithm to find the shortest path with vertex constraint. We first introduce the definition of permutation expanding, which is the basis of our algorithm, and then we explain the algorithm Permutation-Expanding. Two optimizing techniques are proposed in Section

Given a vertex subset

In the example of Figure

A path is called the shortest path between

Given an undirected graph

Assuming that

If

If

If

If

To sum up,

For two vertex subsets

Given a permutation

We propose an algorithm, P

The pseudocode of P

// Input:

//

//

//

//

1:

2:

3:

4:

5:

6:

7:

8:

9:

10:

11:

12:

13:

Given a graph

We give two optimizing techniques to improve the efficiency of P

For two expanded permutations

Given a shortest path

The conclusion of Theorem

In this section, we analyze the complexity of Algorithm

In this section, we propose an approximate algorithm A

Given a graph

The following theorem indicates that we only need to find the shortest path with vertex constraint over

It is identical for the weight of the shortest path between

The main idea of A

// Input:

//

//

//

//

1:

2:

3:

4:

5:

6:

7:

8:

9:

10:

11:

12:

13:

14:

15: Traverse

16:

17:

18:

Figures

An example of an approximate path.

Query graph

Minimum spanning tree

Preorder traversal of

Approximate path

Next, we prove that A

A

Let

The preorder traversal

Because

Because

This section experimentally evaluates our algorithms against the current state-of-the-art methods. Section

All methods are implemented in C++ and tested on a Linux machine with an Intel(R) Core(TM) i7-4770K and 32GB RAM. We repeat each experiment 100 times and report the average result. If a method requires more than 24 hours or more than 32GB RAM to preprocess a dataset

Datasets.

Dataset | | | | Description |
---|---|---|---|---|

NY | 264,346 | 733,846 | 2.78 | New York City Road Network |

| ||||

BAY | 321,270 | 800,172 | 2.49 | San Francisco Bay Area Road Network |

| ||||

COL | 435,666 | 1,057,066 | 2.43 | Colorado Road Network |

| ||||

FLA | 1,070,376 | 2,712,798 | 2.53 | Florida Road Network |

| ||||

265,214 | 420,045 | 1.25 | Email network of EU research institution |

For a query, if the starting vertex and ending vertex are the same, we call this starting-to-starting query (STS query); otherwise, we call this starting-to-ending query (STE query). In this paper, we present the experimental results of our algorithms for both STS query and STE query.

Query efficiency on Q1-Q5.

STE query

STS query

For each dataset, we find that AP has the minimum time cost than the other algorithms on every query. Specifically, AP outperforms ANN by one order of magnitude. When the size of

As shown in Figure

When the size of

Query efficiency on Q6-Q10.

STE query

STS query

Q11-Q15 has the same size of

Query efficiency on Q11-Q15.

Figure

Space consumption on Q1-Q5.

STE query

STS query

Optimizing effectiveness.

STE query

STS query

Relative error on Q1-Q5.

STE query

STS query

In this section, we introduce existing works and categorize them as follows.

To find the shortest path with vertex constraint, we propose an exact algorithm named P

The road network datasets used to support the findings of this study are included within the article. They can be downloaded from

The authors declare that they have no conflicts of interest.

This work is supported by the grants of the National Natural Science Foundation of China nos. 61402323, 61572353, and U1736103, the Opening Project of State Key Laboratory of Digital Publishing Technology, and the Australian Research Council Discovery Grant DP130103051.