- 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));
- for (vector<int>::iterator it = vertices[i].in_vertices.begin();
- it != vertices[i].in_vertices.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);
- for (vector<int>::iterator it = vertices[i].out_vertices.begin();
- it != vertices[i].out_vertices.end(); ++it)
- if (!visited[*it]) {
- visited[*it] = true;
- Q.push(*it);
- }
- }
-
- 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;
- for (vector<int>::iterator it = vertices[i].out_vertices.begin();
- it != vertices[i].out_vertices.end(); ++it)
- if (!visited[*it]) {
- visited[*it] = true;
- Q.push(*it);
- }
- }
-
- return false;
-}
-
-
-Converters::EdgePath const
-Converters::GetPath(string const & from, string const & to)
-{
- EdgePath path;
- if (from == to)
- return path;
-
- int const s = BFS_init(from);
- int t = formats.GetNumber(to);
- if (s < 0 || t < 0)
- return path;
-
- vector<int> prev_edge(formats.size());
- vector<int> prev_vertex(formats.size());
-
- bool found = false;
- while (!Q.empty()) {
- int const i = Q.front();
- Q.pop();
- if (i == t) {
- found = true;
- break;
- }
- for (vector<int>::iterator it = vertices[i].out_vertices.begin();
- it != vertices[i].out_vertices.end(); ++it)
- if (!visited[*it]) {
- int const j = *it;
- visited[j] = true;
- Q.push(j);
- int const k = it - vertices[i].out_vertices.begin();
- prev_edge[j] = vertices[i].out_edges[k];
- prev_vertex[j] = i;
- }
- }
- if (!found)
- return path;
-
- while (t != s) {
- path.push_back(prev_edge[t]);
- t = prev_vertex[t];
- }
- reverse(path.begin(), path.end());
- return path;
-}
-
-
-bool Converters::UsePdflatex(EdgePath const & path)
-{
- for (EdgePath::const_iterator cit = path.begin();