]> git.lyx.org Git - features.git/blob - src/Graph.h
Just some style, and some comments, as I try to figure this out.
[features.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 namespace lyx {
20
21
22 class Graph {
23 public:
24         Graph() : numedges_(0) {};
25         ///
26         typedef std::vector<int> EdgePath;
27         /// \return a vector of the vertices from which "to" can be reached
28         std::vector<int> const getReachableTo(int to, bool clear_visited);
29         /// \return a vector of the vertices that can be reached from "from"
30         std::vector<int> const
31                 getReachable(int from, bool only_viewable, bool clear_visited);
32         /// Can "from" be reached from "to"?
33         bool isReachable(int from, int to);
34         /// Find a path from "from" to "to".
35         EdgePath const getPath(int from, int to);
36         /// Called repeatedly to build the graph.
37         void addEdge(int from, int to);
38         /// Reset the internal data structures.
39         void init(int size);
40
41 private:
42         ///
43         int bfs_init(int, bool clear_visited = true);
44
45         ///
46         class Vertex {
47         public:
48                 std::vector<int> in_vertices;
49                 std::vector<int> out_vertices;
50                 std::vector<int> out_edges;
51         };
52         ///
53         static 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
65 } // namespace lyx
66
67 #endif //GRAPH_H