Exemplo n.º 1
0
void Graph::extendPath(std::vector<int> &path, int sink, int est_dist, bool rev = 0) const{
        bool tarfound = 0;
        while (true) {
                std::vector<int> next;
                if (rev) {
                        next = getInEdges(path.back());
                } else {
                        next = getOutEdges(path.back());
                }
                int good_next = -2;
                for (int i = 0; i < next.size(); ++i) {
                        if (std::find(path.begin(), path.end(), next[i]) != path.end()) {
                                return;
                        }
                        if (next[i] == sink || getSizeOfNode(next[i]) - (k_ - 1) < 2 * est_dist) {
                                if (good_next > -2) {
                                        good_next = -1;
                                } else {
                                        good_next = i;
                                }
                        }
                }
                if (good_next > -1) {
                        path.push_back(next[good_next]);
                        if (!tarfound && next[good_next] == sink) {
                                tarfound = 1;
                        }
                } else {
                        return;
                }
        }
}
std::vector<DirectedFlowGraph::DirectedFlowEdge> DirectedFlowGraph::getAllEdges(
    const Node& start_node)
{
  std::vector<DirectedFlowGraph::DirectedFlowEdge> out_edges, in_edges, result;

  out_edges = getOutEdges(start_node);
  in_edges = getInEdges(start_node);

  result.insert(result.end(), out_edges.begin(), out_edges.end());
  result.insert(result.end(), in_edges.begin(), in_edges.end());
  return result;
}