// -*- C++ -*- /** * \file Graph.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Dekel Tsur * * Full author contact details are available in file CREDITS. */ #ifndef GRAPH_H #define GRAPH_H #include #include namespace lyx { /// Represents a directed graph, possibly with multiple edges /// connecting the vertices. class Graph { public: Graph() : numedges_(0) {} /// typedef std::vector EdgePath; /// \return a vector of the vertices from which "to" can be reached std::vector const getReachableTo(int to, bool clear_visited); /// \return a vector of the vertices that can be reached from "from" std::vector const getReachable(int from, bool only_viewable, bool clear_visited); /// Can "from" be reached from "to"? bool isReachable(int from, int to); /// Find a path from "from" to "to". EdgePath const getPath(int from, int to); /// Called repeatedly to build the graph. void addEdge(int from, int to); /// Reset the internal data structures. void init(int size); private: /// bool bfs_init(int, bool clear_visited = true); /// struct OutEdge { OutEdge(int v, int e): vertex(v), edge(e) {} int vertex; int edge; }; /// struct Vertex { /// vertices that point at this one std::vector in_vertices; /// paths out from here std::vector out_arrows; /// bool visited; }; /// std::vector vertices_; /// std::queue Q_; int numedges_; }; } // namespace lyx #endif //GRAPH_H