2003-02-28 09:49:49 +00:00
|
|
|
// -*- 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
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-28 09:49:49 +00:00
|
|
|
*/
|
|
|
|
|
2003-08-23 00:17:00 +00:00
|
|
|
#ifndef GRAPH_H
|
|
|
|
#define GRAPH_H
|
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
#include <queue>
|
|
|
|
#include <vector>
|
|
|
|
|
2003-09-07 21:25:37 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
class Graph {
|
2003-03-04 09:27:27 +00:00
|
|
|
public:
|
2003-02-28 09:49:49 +00:00
|
|
|
Graph() : numedges_(0) {};
|
|
|
|
///
|
|
|
|
typedef std::vector<int> EdgePath;
|
|
|
|
///
|
|
|
|
std::vector<int> const
|
|
|
|
getReachableTo(int, bool clear_visited);
|
|
|
|
///
|
|
|
|
std::vector<int> const
|
|
|
|
getReachable(int, bool only_viewable,
|
|
|
|
bool clear_visited);
|
|
|
|
///
|
|
|
|
bool isReachable(int, int);
|
|
|
|
///
|
|
|
|
EdgePath const getPath(int, int);
|
|
|
|
///
|
|
|
|
void addEdge(int s, int t);
|
|
|
|
///
|
|
|
|
void init(int size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
int bfs_init(int, bool clear_visited = true);
|
|
|
|
|
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
class Vertex {
|
|
|
|
public:
|
2003-02-28 09:49:49 +00:00
|
|
|
std::vector<int> in_vertices;
|
|
|
|
std::vector<int> out_vertices;
|
|
|
|
std::vector<int> out_edges;
|
|
|
|
};
|
|
|
|
///
|
|
|
|
static
|
|
|
|
std::vector<Vertex> vertices_;
|
|
|
|
///
|
|
|
|
std::vector<bool> visited_;
|
|
|
|
///
|
|
|
|
std::queue<int> Q_;
|
|
|
|
|
|
|
|
int numedges_;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
#endif //GRAPH_H
|