<commit_before>#include "descartes_planner/ladder_graph_dag_search.h"

namespace descartes_planner
{

DAGSearch::DAGSearch(const LadderGraph &graph)
  : graph_(graph)
{
  // On creating an object, let's allocate everything we need
  solution_.resize(graph.size());

  for (size_t i = 0; i < graph.size(); ++i)
  {
    const auto n_vertices = graph.rungSize(i);
    solution_[i].distance.resize(n_vertices);
    solution_[i].predecessor.resize(n_vertices);
  }
}

double DAGSearch::run()
{
  // Cost to the first rung should be set to zero
  std::fill(solution_.front().distance.begin(), solution_.front().distance.end(), 0.0);
  // Other rows initialize to zero
  for (size_t i = 1; i < solution_.size(); ++i)
  {
    std::fill(solution_[i].distance.begin(), solution_[i].distance.end(), std::numeric_limits<double>::max());
  }

  // Now we iterate over the graph in 'topological' order
  for (size_t rung = 0; rung < solution_.size() - 1; ++rung)
  {
    const auto n_vertices = graph_.rungSize(rung);
    const auto next_rung = rung + 1;
    // For each vertex in the out edge list
    for (size_t index = 0; index < n_vertices; ++index)
    {
      const auto u_cost = distance(rung, index);
      const auto& edges = graph_.getEdges(rung)[index];
      // for each out edge
      for (const auto& edge : edges)
      {
        auto dv = u_cost + edge.cost; // new cost
        if (dv < distance(next_rung, edge.idx))<commit_msg>Use size_type in main loop of search.<commit_after>#include "descartes_planner/ladder_graph_dag_search.h"

namespace descartes_planner
{

DAGSearch::DAGSearch(const LadderGraph &graph)
  : graph_(graph)
{
  // On creating an object, let's allocate everything we need
  solution_.resize(graph.size());

  for (size_t i = 0; i < graph.size(); ++i)
  {
    const auto n_vertices = graph.rungSize(i);
    solution_[i].distance.resize(n_vertices);
    solution_[i].predecessor.resize(n_vertices);
  }
}

double DAGSearch::run()
{
  // Cost to the first rung should be set to zero
  std::fill(solution_.front().distance.begin(), solution_.front().distance.end(), 0.0);
  // Other rows initialize to zero
  for (size_type i = 1; i < solution_.size(); ++i)
  {
    std::fill(solution_[i].distance.begin(), solution_[i].distance.end(), std::numeric_limits<double>::max());
  }

  // Now we iterate over the graph in 'topological' order
  for (size_type rung = 0; rung < solution_.size() - 1; ++rung)
  {
    const auto n_vertices = graph_.rungSize(rung);
    const auto next_rung = rung + 1;
    // For each vertex in the out edge list
    for (size_t index = 0; index < n_vertices; ++index)
    {
      const auto u_cost = distance(rung, index);
      const auto& edges = graph_.getEdges(rung)[index];
      // for each out edge
      for (const auto& edge : edges)
      {
        auto dv = u_cost + edge.cost; // new cost
        if (dv < distance(next_rung, edge.idx))
{'fraction_non_alphanumeric': 0.13984806629834254, 'fraction_numerical': 0.0055248618784530384, 'mean_word_length': 3.389393939393939, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5210358', 'n_tokens_mistral': 997, 'n_tokens_neox': 972, 'n_words': 265}