10 std::vector<flow_element> sum_flows(const std::vector<flow_element> &a, const std::vector<flow_element> &b)
12 std::vector<flow_element> ret;
13 std::vector<flow_element>::const_iterator ia = a.begin(), ib = b.begin();
15 double last_xa = 0.0, last_y1a = 0.0, last_y2a = 0.0;
16 double last_xb = 0.0, last_y1b = 0.0, last_y2b = 0.0;
18 while (ia != a.end() && ib != b.end()) {
20 flow_element fea = *ia, feb = *ib, fe;
31 fe.y1 = fea.y1 + feb.y1;
32 fe.y2 = fea.y2 + feb.y2;
37 } else if (ia->x < ib->x) {
38 flow_element fe = *ia;
44 double t = (fe.x - last_xb) / (ib->x - last_xb);
45 fe.y1 += last_y1b + t * (ib->y1 - last_y1b);
46 fe.y2 += last_y2b + t * (ib->y2 - last_y2b);
52 flow_element fe = *ib;
58 double t = (fe.x - last_xa) / (ia->x - last_xa);
59 fe.y1 += last_y1a + t * (ia->y1 - last_y1a);
60 fe.y2 += last_y2a + t * (ia->y2 - last_y2a);
67 while (ia != a.end()) {
71 while (ib != b.end()) {
79 std::vector<flow_element> filter_flow(const std::vector<flow_element> &flow)
81 unsigned long long last_y1 = 0, last_y2 = 0;
82 std::vector<flow_element> ret;
84 for (std::vector<flow_element>::const_iterator i = flow.begin(); i != flow.end(); ++i) {
85 /* if ((i->y1 > 100000 && last_y1 < 10000 && i->y2 > 100000 && last_y2 < 1000) ||
86 (last_y1 > 10000 && last_y2 > 10000 && i->y1 / last_y1 > 10 && i->y2 / last_y2 > 10)) {
87 printf("yoyo: %llu %llu (%llu %llu)\n", i->y1, i->y2, last_y1, last_y2);
93 if (!(i->x >= 1145056800 && i->x <= 1145070800)) {
101 void make_graph(int port, unsigned width, unsigned height, unsigned min_x, unsigned max_x, unsigned long long min_y, unsigned long long max_y, std::vector<flow_element> &flow)
104 graph *g = mygraph_new(width, height);
105 g = mygraph_make_graph(g, min_x, max_x, min_y, max_y, 5);
107 int *x = new int[flow.size()];
108 unsigned long long *y1 = new unsigned long long[flow.size()];
109 unsigned long long *y2 = new unsigned long long[flow.size()];
112 for (unsigned i = 0; i < flow.size(); ++i) {
118 mygraph_plot_series(g, x, y1, flow.size(), 1.0f, 0.0f, 0.0f);
119 mygraph_plot_series(g, x, y2, flow.size(), 0.0f, 0.0f, 1.0f);
120 sprintf(filename, "port-%u-500-250.png", port);
121 mygraph_to_file(g, filename);