]> git.lyx.org Git - lyx.git/blob - src/graph.h
Extracted from r14281
[lyx.git] / src / graph.h
1 // -*- C++ -*-
2 /**
3  * \file graph.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Dekel Tsur
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GRAPH_H
13 #define GRAPH_H
14
15 #include <queue>
16 #include <vector>
17
18
19 class Graph {
20 public:
21         Graph() : numedges_(0) {};
22         ///
23         typedef std::vector<int> EdgePath;
24         ///
25         std::vector<int> const
26         getReachableTo(int, bool clear_visited);
27         ///
28         std::vector<int> const
29         getReachable(int, bool only_viewable,
30                      bool clear_visited);
31         ///
32         bool isReachable(int, int);
33         ///
34         EdgePath const getPath(int, int);
35         ///
36         void addEdge(int s, int t);
37         ///
38         void init(int size);
39
40 private:
41         ///
42         int bfs_init(int, bool clear_visited = true);
43
44         ///
45         class Vertex {
46         public:
47                 std::vector<int> in_vertices;
48                 std::vector<int> out_vertices;
49                 std::vector<int> out_edges;
50         };
51         ///
52         static
53         std::vector<Vertex> vertices_;
54         ///
55         std::vector<bool> visited_;
56         ///
57         std::queue<int> Q_;
58
59         int numedges_;
60
61 };
62
63
64 #endif //GRAPH_H