32 using Edge = std::pair<Node, Node>;
36 const std::vector<std::string>& input_path) {
37 auto edges =
ReadLines(ctx, input_path).template FlatMap<Edge>(
41 unsigned long src = std::strtoul(input.c_str(), &endptr, 10);
44 while (*endptr != 0) {
45 unsigned long tgt = std::strtoul(endptr + 1, &endptr, 10);
48 emit(std::make_pair(src, tgt));
63 const size_t& num_vertices) {
68 rng = std::default_random_engine(std::random_device { } ())](
69 size_t index)
mutable {
70 return std::make_pair(index, graph_gen.GenerateOutgoing(rng));
73 auto edges = edge_lists.template FlatMap<Edge>(
74 [](std::pair<Node, std::vector<Node> > neighbors,
auto emit) {
75 for (
auto neighbor : neighbors.second) {
76 if (neighbors.first > neighbor) {
77 emit(std::make_pair(neighbor, neighbors.first));
80 if (neighbors.first < neighbor) {
86 }).Keep().Cache().Execute();
91 const bool use_detection =
true;
93 size_t triangles = examples::triangles::CountTriangles<use_detection>(edges);
99 LOG1 <<
"RESULT " <<
"benchmark=triangles " <<
"detection=ON" 100 <<
" vertices=" << num_vertices
106 LOG1 <<
"RESULT " <<
"benchmark=triangles " <<
"detection=OFF" 107 <<
" vertices=" << num_vertices
117 int main(
int argc,
char* argv[]) {
121 bool generate =
false;
122 clp.
add_bool(
'g',
"generate", generate,
123 "generate graph data, set input = #pages");
127 clp.
add_size_t(
'n',
"vertices", num_vertices,
"Number of vertices");
133 "generated: mean of number of outgoing links, " 137 "generated: variance of number of outgoing links, " 141 "generated: Zipf scale parameter for outgoing links, " 145 "generated: Zipf exponent parameter for outgoing links, " 148 std::vector<std::string> input_path;
150 "input file pattern(s)");
152 if (!clp.
process(argc, argv)) {
156 die_unless(!generate || input_path.size() == 1);
167 ctx, gg, num_vertices);
net::FlowControlChannel & net
auto Generate(Context &ctx, size_t size, const GenerateFunction &generate_function)
Generate is a Source-DOp, which creates a DIA of given size using a generator function.
std::pair< Node, Node > Edge
size_t num_hosts() const
Returns the total number of hosts.
int Run(const std::function< void(Context &)> &job_startpoint)
Runs the given job startpoint with a Context instance.
void Barrier()
A trivial global barrier.
void add_size_t(char key, const std::string &longkey, size_t &dest, const std::string &desc)
add size_t option -key, –longkey with description and store to dest
The Context of a job is a unique instance per worker which holds references to all underlying parts o...
void enable_consume(bool consume=true)
Sets consume-mode flag such that DIA contents may be consumed during PushData().
DIA< std::string > ReadLines(Context &ctx, const std::string &filepath)
ReadLines is a DOp, which reads a file from the file system and creates an ordered DIA according to a...
static by_string to_string(int val)
convert to string
double size_mean
Gaussian mean and variance of content length.
void print_result(std::ostream &os)
print nicely formatted result of processing
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
double link_zipf_exponent
Command line parser which automatically fills variables and prints nice usage messages.
net::Traffic Traffic() const
calculate overall traffic for final stats
size_t my_rank() const
Global rank of this worker among all other workers in the system.
void add_double(char key, const std::string &longkey, double &dest, const std::string &desc)
add double option -key, –longkey with description and store to dest
size_t CountTriangles(const DIA< Edge, Stack > &edges)
void add_param_stringlist(const std::string &name, std::vector< std::string > &dest, const std::string &desc)
void add_bool(char key, const std::string &longkey, bool &dest, const std::string &desc)
net::Manager & net_manager()
static size_t CountTrianglesGenerated(api::Context &ctx, const ZipfGraphGen &base_graph_gen, const size_t &num_vertices)
int main(int argc, char *argv[])
bool process(int argc, const char *const *argv, std::ostream &os)
static size_t CountTrianglesPerLine(api::Context &ctx, const std::vector< std::string > &input_path)