예제 #1
0
Totals
sage_time_vertex_traversal()
{
    GraphType *g = new GraphType;
    sage_random_graph(g, MAX_VERTICES, 2, 4.0);
    size_t niter=0;
    start_deadman(2);
    Sawyer::Stopwatch t;
    while (!had_alarm && niter<MAX_COUNT) {
        std::set<SgGraphNode*> vertex_set = g->computeNodeSet();
        for (std::set<SgGraphNode*>::iterator vi=vertex_set.begin(); vi!=vertex_set.end() && !had_alarm; ++vi)
            ++niter;
    }
    t.stop();
    return report("vert iter", sage_size(g), niter, t, "verts/s");
}
예제 #2
0
Totals
sage_time_edge_traversal()
{
    GraphType *g = new GraphType;
    sage_random_graph(g, MAX_VERTICES, 2, 4.0);
    size_t niter=0;
    start_deadman(2);
    Sawyer::Stopwatch t;
    while (!had_alarm && niter<MAX_COUNT) {
        // SgGraph doesn't have a graph-wide edge iterator, so we have to iterator over the vertices and then each edge.
        std::set<SgGraphNode*> vertex_set = g->computeNodeSet();
        for (std::set<SgGraphNode*>::iterator vi=vertex_set.begin(); vi!=vertex_set.end() && !had_alarm; ++vi) {
            std::set<SgGraphEdge*> edge_set = g->computeEdgeSet(*vi);
            for (std::set<SgGraphEdge*>::iterator ei=edge_set.begin(); ei!=edge_set.end() && !had_alarm; ++ei)
                ++niter;
        }
    }
    t.stop();
    return report("edge iter", sage_size(g), niter, t, "edges/s");
}