Cosmetics.
[mtp.git] / mtp_graph.h
1
2 /*
3  *  mtp is the ``Multi Tracked Paths'', an implementation of the
4  *  k-shortest paths algorithm for multi-target tracking.
5  *
6  *  Copyright (c) 2012 Idiap Research Institute, http://www.idiap.ch/
7  *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
8  *
9  *  This file is part of mtp.
10  *
11  *  mtp is free software: you can redistribute it and/or modify it
12  *  under the terms of the GNU General Public License version 3 as
13  *  published by the Free Software Foundation.
14  *
15  *  mtp is distributed in the hope that it will be useful, but WITHOUT
16  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  *  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
18  *  License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with selector.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #ifndef MTP_GRAPH_H
26 #define MTP_GRAPH_H
27
28 #include <iostream>
29 #include <cmath>
30
31 using namespace std;
32
33 #include "misc.h"
34 #include "path.h"
35
36 class Vertex;
37 class Edge;
38
39 class MTPGraph {
40   void update_positivized_lengths();
41   void force_positivized_lengths();
42   // Set the edge pred_edge_toward_source correspondingly to the path
43   // of shortest length.
44   void find_shortest_path();
45   // Follows the path starting on edge e and returns its length. If
46   // nodes is non-null, stores in it the nodes met along the path.
47   int retrieve_one_path(Edge *e, Path *path);
48
49   Vertex **_front, **_new_front;
50
51   int _nb_vertices, _nb_edges;
52   Vertex *_source, *_sink;
53
54   Edge *_edges;
55   Vertex *_vertices;
56
57 public:
58
59   // These variables are filled when retrieve_disjoint_paths is called
60   int nb_paths;
61   Path **paths;
62
63   MTPGraph(int nb_vertices, int nb_edges, int *vertex_from, int *vertex_to,
64            int source, int sink);
65
66   ~MTPGraph();
67
68   void find_best_paths(scalar_t *lengths);
69   void retrieve_disjoint_paths();
70
71   void print(ostream *os);
72   void print_dot(ostream *os);
73 };
74
75 #endif