当前位置: 首页>>代码示例>>C++>>正文


C++ GraphType::end方法代码示例

本文整理汇总了C++中GraphType::end方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphType::end方法的具体用法?C++ GraphType::end怎么用?C++ GraphType::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphType的用法示例。


在下文中一共展示了GraphType::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: breadth_first_search

static void breadth_first_search(const GraphType& graph, 
                                 const VertexIndexType& source,
                                 const int& k_steps,
                                 AssociativeContainer& visited_vertices) {
  /* CHECK: AssociativeContainer::value_type == VertexIndexType */

  std::queue<VertexIndexType> even_epoch_queue;
  std::queue<VertexIndexType> odd_epoch_queue;
  std::queue<VertexIndexType>& current_queue = even_epoch_queue;
  std::queue<VertexIndexType>& next_queue = odd_epoch_queue;

  current_queue.push (source);
  int step_number = 0;
  while (step_number<k_steps) {
    while (!current_queue.empty ()) {
      const int vertex = current_queue.front ();
      current_queue.pop ();
      visited_vertices.insert (vertex);
      for (int target_index=graph.begin(vertex); 
           target_index<graph.end(vertex);
           ++target_index) {
        const int target = graph.get_target (target_index);
        if (visited_vertices.end()==visited_vertices.find (target)) {
          next_queue.push (target);
        }
      }
    }
    ++step_number;
    current_queue = (step_number&0x10)?even_epoch_queue:odd_epoch_queue;
    next_queue = (step_number&0x01)?even_epoch_queue:odd_epoch_queue;
  }
}
开发者ID:pkambadu,项目名称:EffectiveResistance,代码行数:32,代码来源:effective_resistance.cpp

示例2: outputTextEdgeData

bool outputTextEdgeData(const char* ofile, GraphType& G) {
  std::ofstream file(ofile);
  for (typename GraphType::iterator ii = G.begin(),
         ee = G.end(); ii != ee; ++ii) {
    unsigned src = G.getData(*ii).id;
    // FIXME: Version in include/Galois/Graphs/Serialize.h is wrong.
    for (typename GraphType::edge_iterator jj = G.edge_begin(*ii),
           ej = G.edge_end(*ii); jj != ej; ++jj) {
      unsigned dst = G.getData(G.getEdgeDst(jj)).id;
      file << src << ' ' << dst << ' ' << G.getEdgeData(jj) << '\n';
    }
  }
  return true;
}
开发者ID:Surtr04,项目名称:UT_Internship,代码行数:14,代码来源:Cholesky.cpp

示例3: while

static void construct_adjacency_matrix 
                        (const GraphType& graph,
                         const AssociativeContainer& vertices,
    __gnu_cxx::hash_map<VertexIndexType, VertexIndexType>& label_map,
    __gnu_cxx::hash_map<VertexIndexType, VertexIndexType>& reverse_label_map,
                         std::vector<EdgeWeightType>& adjacency_matrix) {
  typedef typename AssociativeContainer::const_iterator 
                              AssociativeContainerConstIterator;
                                        
  /* resize the adjacency matrix to hold the adjacencies */
  const int num_vertices = vertices.size ();
  adjacency_matrix.resize (num_vertices*num_vertices, 0.0);

  /* Create a map, which remaps the old vertices into new vertices */
  VertexIndexType new_label=0;
  AssociativeContainerConstIterator iter = vertices.begin();
  AssociativeContainerConstIterator end = vertices.end();

  while (iter!=end) {
    const VertexIndexType current_vertex = *iter++;
    label_map [current_vertex] = new_label;
    reverse_label_map [new_label] = current_vertex;
    ++new_label;
  }
  assert (new_label==num_vertices);
  
  /* now do the adjacencies */
  iter = vertices.begin();
  while (iter!=end) {
    const VertexIndexType old_vertex = *iter++;
    const VertexIndexType new_vertex = label_map [old_vertex];
    for (int target_index=graph.begin(old_vertex); 
         target_index<graph.end(old_vertex);
         ++target_index) {
      const VertexIndexType adjacent_vertex=graph.get_target (target_index);

      /* only add the adjacency if the target is one of "vertices". */
      if (vertices.end()!=vertices.find (adjacent_vertex)) {
        const int element_offset = 
          (num_vertices*new_vertex) + label_map [adjacent_vertex];
        adjacency_matrix [element_offset] = graph.get_weight (target_index);
      }
    }
  }
}
开发者ID:pkambadu,项目名称:EffectiveResistance,代码行数:45,代码来源:effective_resistance.cpp


注:本文中的GraphType::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。