<commit_before>/*
 *            Copyright 2009-2018 The VOTCA Development Team
 *                       (http://www.votca.org)
 *
 *      Licensed under the Apache License, Version 2.0 (the "License")
 *
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *              http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
#include <list>

#include <votca/tools/graph.h>
#include <votca/tools/graph_bf_visitor.h>
#include <votca/tools/graph_df_visitor.h>
#include <votca/tools/graphalgorithm.h>
#include <votca/tools/graphvisitor.h>

using namespace std;

namespace votca {
namespace tools {

/**********************
 * Internal Functions *
 **********************/

list<int> vectorToList_(vector<int> values) {
  list<int> values_list;
  copy(values.begin(), values.end(), back_inserter(values_list));
  return values_list;
}

vector<Edge> edgeSetToVector_(set<Edge> edges) {
  vector<Edge> edges_vector;
  copy(edges.begin(), edges.end(), back_inserter(edges_vector));
  return edges_vector;
}

/********************
 * Public Functions *
 ********************/

bool singleNetwork(Graph g, GraphVisitor& gv) {
  exploreGraph(g, gv);
  return gv.getExploredVertices().size() == g.getVertices().size() &&
         g.getIsolatedNodes().size() == 0;
}

std::set<Edge> exploreBranch(Graph g, int starting_vertex, Edge edge){
  // Check if the starting vertex is in the graph
  if(!g.vertexExist(starting_vertex)){
    throw invalid_argument("Cannot explore a branch of the graph when the "
        "exploration is started from a vertex that does not exist within the "
        "graph.");
  } 
  if(!g.edgeExist(edge)){
    throw invalid_argument("Edge does not exist in the graph so exploration of"
        " the graph branch cannot continue");
  }
  if(!edge.contains(starting_vertex)){
    throw invalid_argument("The edge determining which branch to explore does "
        "not contain the starting vertex.");
  }
  Graph_BF_Visitor gv_breadth_first;
  GraphNode gn;
  pair<int,GraphNode> pr_gn(starting_vertex,gn);
  gv_breadth_first.exploreNode(pr_gn,g);
  gv_breadth_first.setStartingVertex(edge.getOtherEndPoint(starting_vertex));
  gv_breadth_first.initialize(g);

  set<Edge> branch_edges;
  branch_edges.insert(edge);
  while (!gv_breadth_first.queEmpty()) {
    Edge ed = gv_breadth_first.nextEdge(g);
    branch_edges.insert(ed);
    gv_breadth_first.exec(g, ed);
  }

  vector<Edge> neigh_edges = g.getNeighEdges(starting_vertex);
  for( auto ed : neigh_edges){
    int neigh_vertex = ed.getOtherEndPoint(starting_vertex);

    cout << "neigh vertex " << neigh_vertex << endl;
    if(gv_breadth_first.vertexExplored(neigh_vertex)){
      branch_edges.insert(ed);
    }
  }

  return branch_edges;
}
/**
 * \brief This class is to help keep track of which vertices have and have not
 * been explored.
 *
 **/
class ExplorationRecord{
  private:
    unordered_map<int,std::pair<bool,int>> vertex_explored_;
    size_t unexplored_vertex_count_;
  public:<commit_msg>Removed output<commit_after>/*
 *            Copyright 2009-2018 The VOTCA Development Team
 *                       (http://www.votca.org)
 *
 *      Licensed under the Apache License, Version 2.0 (the "License")
 *
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *              http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
#include <list>

#include <votca/tools/graph.h>
#include <votca/tools/graph_bf_visitor.h>
#include <votca/tools/graph_df_visitor.h>
#include <votca/tools/graphalgorithm.h>
#include <votca/tools/graphvisitor.h>

using namespace std;

namespace votca {
namespace tools {

/**********************
 * Internal Functions *
 **********************/

list<int> vectorToList_(vector<int> values) {
  list<int> values_list;
  copy(values.begin(), values.end(), back_inserter(values_list));
  return values_list;
}

vector<Edge> edgeSetToVector_(set<Edge> edges) {
  vector<Edge> edges_vector;
  copy(edges.begin(), edges.end(), back_inserter(edges_vector));
  return edges_vector;
}

/********************
 * Public Functions *
 ********************/

bool singleNetwork(Graph g, GraphVisitor& gv) {
  exploreGraph(g, gv);
  return gv.getExploredVertices().size() == g.getVertices().size() &&
         g.getIsolatedNodes().size() == 0;
}

std::set<Edge> exploreBranch(Graph g, int starting_vertex, Edge edge){
  // Check if the starting vertex is in the graph
  if(!g.vertexExist(starting_vertex)){
    throw invalid_argument("Cannot explore a branch of the graph when the "
        "exploration is started from a vertex that does not exist within the "
        "graph.");
  } 
  if(!g.edgeExist(edge)){
    throw invalid_argument("Edge does not exist in the graph so exploration of"
        " the graph branch cannot continue");
  }
  if(!edge.contains(starting_vertex)){
    throw invalid_argument("The edge determining which branch to explore does "
        "not contain the starting vertex.");
  }
  Graph_BF_Visitor gv_breadth_first;
  GraphNode gn;
  pair<int,GraphNode> pr_gn(starting_vertex,gn);
  gv_breadth_first.exploreNode(pr_gn,g);
  gv_breadth_first.setStartingVertex(edge.getOtherEndPoint(starting_vertex));
  gv_breadth_first.initialize(g);

  set<Edge> branch_edges;
  branch_edges.insert(edge);
  while (!gv_breadth_first.queEmpty()) {
    Edge ed = gv_breadth_first.nextEdge(g);
    branch_edges.insert(ed);
    gv_breadth_first.exec(g, ed);
  }

  vector<Edge> neigh_edges = g.getNeighEdges(starting_vertex);
  for( auto ed : neigh_edges){
    int neigh_vertex = ed.getOtherEndPoint(starting_vertex);
    if(gv_breadth_first.vertexExplored(neigh_vertex)){
      branch_edges.insert(ed);
    }
  }

  return branch_edges;
}
/**
 * \brief This class is to help keep track of which vertices have and have not
 * been explored.
 *
 **/
class ExplorationRecord{
  private:
    unordered_map<int,std::pair<bool,int>> vertex_explored_;
    size_t unexplored_vertex_count_;
  public:
{'fraction_non_alphanumeric': 0.13184340782960852, 'fraction_numerical': 0.0038998050097495125, 'mean_word_length': 4.121351766513057, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2622243', 'n_tokens_mistral': 2120, 'n_tokens_neox': 2068, 'n_words': 551}