本文整理汇总了C++中GraphType::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphType::clear方法的具体用法?C++ GraphType::clear怎么用?C++ GraphType::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphType
的用法示例。
在下文中一共展示了GraphType::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void load(GraphType& g, std::string prefix,
line_parser_type<GraphType> line_parser) {
if (prefix.length() == 0)
return;
g.dc().full_barrier();
g.clear();
std::string directory_name; std::string original_path(prefix);
boost::filesystem::path path(prefix);
std::string search_prefix;
if (boost::filesystem::is_directory(path)) {
// if this is a directory
// force a "/" at the end of the path
// make sure to check that the path is non-empty. (you do not
// want to make the empty path "" the root path "/" )
directory_name = path.native();
} else {
directory_name = path.parent_path().native();
search_prefix = path.filename().native();
directory_name = (directory_name.empty() ? "." : directory_name);
}
std::vector<std::string> graph_files;
fs_util::list_files_with_prefix(directory_name, search_prefix, graph_files);
if (graph_files.size() == 0) {
logstream(LOG_WARNING) << "No files found matching " << original_path << std::endl;
}
parallel_for(0, graph_files.size(), [&](size_t i) {
if (i % g.numprocs() == g.procid()) {
logstream(LOG_EMPH) << "Loading graph from file: " << graph_files[i] << std::endl;
general_ifstream fin(graph_files[i]);
if(!fin.good()) {
log_and_throw_io_failure("Cannot open file: " + graph_files[i]);
}
const bool success = load_from_stream(g, graph_files[i], fin, line_parser);
if(!success) {
log_and_throw_io_failure("Fail parsing file: " + graph_files[i]);
}
}
});
g.dc().full_barrier();
g.finalize();
} // end of load