static void benchmarkTravelLinkedListGraph() { Manager *manager = Manager::getInstance(); clock_t start = clock(); Node *node = manager->getNode(0); while(true) { set<string> rels = node->getRelations("knows", OUT); //if reach the end of the linked list, stop if(rels.empty()) break; for(set<string>::iterator it = rels.begin(); it != rels.end(); it++) { Relation *rel = manager->getRelation(Relation::getId(*it)); Node *newNode = manager->getNode(Node::getId(rel->getEndNode())); destroy(node); node = newNode; destroy(rel); } } destroy(node); double diff = (clock() - start) / (double) CLOCKS_PER_SEC; cout << "Traversal LinkedList Graph of " << count << " nodes cost: " << diff << " seconds" << endl; }
static void benchmarkTravelStarGraph() { Manager *manager = Manager::getInstance(); clock_t start = clock(); Node *node = manager->getNode(0); set<string> rels = node->getRelations("knows", OUT); for(set<string>::iterator it = rels.begin(); it != rels.end(); it++) { Relation *rel = manager->getRelation(Relation::getId(*it)); Node *node1 = manager->getNode(Node::getId(rel->getEndNode())); destroy(rel); destroy(node1); } destroy(node); double diff = (clock() - start) / (double) CLOCKS_PER_SEC; cout << "Traversal Star Graph of " << count << " nodes cost: " << diff << " seconds" << endl; }