本文整理汇总了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;
}
}
示例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;
}
示例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);
}
}
}
}