1 | /* |
---|
2 | * Shortest path algorithm for PostgreSQL |
---|
3 | * |
---|
4 | * Copyright (c) 2005 Sylvain Pasche |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | * |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef _DIJKSTRA_H |
---|
23 | #define _DIJKSTRA_H |
---|
24 | |
---|
25 | #include "postgres.h" |
---|
26 | |
---|
27 | #define PGR_COLUMN_NOTEXIST (-1) |
---|
28 | |
---|
29 | /* |
---|
30 | * Macro definition of special functions |
---|
31 | */ |
---|
32 | #define PGR_FUNC_MAX(A, B) ((A > B) ? A : B) |
---|
33 | #define PGR_FUNC_MIN(A, B) ((A < B) ? A : B) |
---|
34 | |
---|
35 | /* |
---|
36 | * |
---|
37 | */ |
---|
38 | typedef struct edge_columns |
---|
39 | { |
---|
40 | int id; |
---|
41 | int source; |
---|
42 | int target; |
---|
43 | int cost; |
---|
44 | int bidirectional; |
---|
45 | int reverse_cost; |
---|
46 | } edge_columns_t; |
---|
47 | |
---|
48 | /* |
---|
49 | * |
---|
50 | */ |
---|
51 | typedef struct edge |
---|
52 | { |
---|
53 | int id; |
---|
54 | int source; |
---|
55 | int target; |
---|
56 | float8 cost; |
---|
57 | bool bidirectional; |
---|
58 | float8 reverse_cost; |
---|
59 | } edge_t; |
---|
60 | |
---|
61 | /* |
---|
62 | * |
---|
63 | */ |
---|
64 | typedef struct path_element |
---|
65 | { |
---|
66 | int vertex_id; |
---|
67 | int edge_id; |
---|
68 | float8 cost; |
---|
69 | } path_element_t; |
---|
70 | |
---|
71 | /** |
---|
72 | * |
---|
73 | */ |
---|
74 | #ifdef __cplusplus |
---|
75 | extern "C" |
---|
76 | #endif |
---|
77 | |
---|
78 | int boost_dijkstra(edge_t *edges, unsigned int ntuplas, int start_vertex, int end_vertex, |
---|
79 | bool directed, path_element_t **path, int *path_count, char **err_msg); |
---|
80 | |
---|
81 | #endif |
---|
82 | |
---|