Created
February 18, 2015 23:16
-
-
Save haluk/df1f1c89ff4ae8fa2e7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We include what we need for the test | |
#include <gatb/gatb_core.hpp> | |
/********************************************************************************/ | |
/* Graph nodes iteration */ | |
/********************************************************************************/ | |
int main (int argc, char* argv[]) | |
{ | |
// We check that the user provides at least one option (supposed to be in HDF5 format). | |
if (argc < 2) | |
{ | |
std::cerr << "You must provide a HDF5 file." << std::endl; | |
return EXIT_FAILURE; | |
} | |
try | |
{ | |
// We load the graph from the given graph file | |
Graph graph = Graph::load (argv[1]); | |
// We get an iterator for all nodes of the graph. | |
Graph::Iterator<Node> it = graph.iterator<Node> (); | |
// We loop each node. Note the structure of the for loop. | |
for (it.first(); !it.isDone(); it.next()) | |
{ | |
// The currently iterated node is available with it.item() | |
// We dump an ascii representation of the current node. | |
std::cout << graph.toString (it.item()) << std::endl; | |
} | |
} | |
catch (Exception& e) | |
{ | |
std::cerr << "EXCEPTION: " << e.getMessage() << std::endl; | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment