-int Converters::bfs_init(string const & start, bool clear_visited)
-{
- int const s = formats.getNumber(start);
- if (s < 0)
- return s;
-
- Q_ = queue<int>();
- if (clear_visited)
- fill(visited_.begin(), visited_.end(), false);
- if (visited_[s] == false) {
- Q_.push(s);
- visited_[s] = true;
- }
- return s;
-}
-
-
-vector<Format const *> const
-Converters::getReachableTo(string const & target, bool clear_visited)
-{
- vector<Format const *> result;
- int const s = bfs_init(target, clear_visited);
- if (s < 0)
- return result;
-
- while (!Q_.empty()) {
- int const i = Q_.front();
- Q_.pop();
- if (i != s || target != "lyx") {
- result.push_back(&formats.get(i));
- }
-
- vector<int>::iterator it = vertices_[i].in_vertices.begin();
- vector<int>::iterator end = vertices_[i].in_vertices.end();
- for (; it != end; ++it) {
- if (!visited_[*it]) {
- visited_[*it] = true;
- Q_.push(*it);
- }
- }
- }
-
- return result;
-}
-
-
-vector<Format const *> const
-Converters::getReachable(string const & from, bool only_viewable,
- bool clear_visited)
-{
- vector<Format const *> result;
-
- if (bfs_init(from, clear_visited) < 0)
- return result;
-
- while (!Q_.empty()) {
- int const i = Q_.front();
- Q_.pop();
- Format const & format = formats.get(i);
- if (format.name() == "lyx")
- continue;
- if (!only_viewable || !format.viewer().empty() ||
- format.isChildFormat())
- result.push_back(&format);
-
- vector<int>::const_iterator cit =
- vertices_[i].out_vertices.begin();
- vector<int>::const_iterator end =
- vertices_[i].out_vertices.end();
- for (; cit != end; ++cit)
- if (!visited_[*cit]) {
- visited_[*cit] = true;
- Q_.push(*cit);
- }
- }
-
- return result;
-}
-
-
-bool Converters::isReachable(string const & from, string const & to)
-{
- if (from == to)
- return true;
-
- int const s = bfs_init(from);
- int const t = formats.getNumber(to);
- if (s < 0 || t < 0)
- return false;
-
- while (!Q_.empty()) {
- int const i = Q_.front();
- Q_.pop();
- if (i == t)
- return true;
-
- vector<int>::const_iterator cit =
- vertices_[i].out_vertices.begin();
- vector<int>::const_iterator end =
- vertices_[i].out_vertices.end();
- for (; cit != end; ++cit) {
- if (!visited_[*cit]) {
- visited_[*cit] = true;
- Q_.push(*cit);
- }
- }
- }
-
- return false;
-}
-
-
-Converters::EdgePath const
-Converters::getPath(string const & from, string const & to)