Let us consider the main.cpp first. It starts out with constants providing ground truth as a property map on the graph edges. A one means upstream and a zero means not upstream.
Why there is an old_naperville_gt is actually something I don't remember. Maybe a different version of the dataset? Whatever...
The main is compact and simple
if (argc != 3 && argc != 1) throw(std::runtime_error("usage: ./main <dataset> <starting points>"));
Dataset ds;
std::string dataset="SampleDataset1/SampleDataset1.json";
std::string spoints="SampleDataset1/startingpoints.txt";
if (argc == 3)
{
dataset = argv[1];
spoints = argv[2];
}
//
ifstream ifs(spoints);
if (!ifs.good()) throw(std::runtime_error("Cannot read starting points"));
std::vector<std::string> sps;
std::string line;
while(std::getline(ifs, line))
sps.push_back(line);
std::cout << "Starting points:"<< sps.size() << std::endl;
for (auto &sp: sps)
std::cout << "\t" << sp << std::endl;
load(dataset,ds);
buildGraph(ds);
ds.summary();
Up to now, we have made sure the program is run with two parameters:
- The Dataset in JSON Format
- A Set of Starting Points
The following part is as well absolutely clear:
We run the baseAlgorithm on the dataset and starting points and measure wallclock of execution time.
auto started = std::chrono::high_resolution_clock::now();
auto upstream = baseAlgorithm(ds, sps);
auto done = std::chrono::high_resolution_clock::now();
std::cout << "Elapsed:" << std::chrono::duration_cast<std::chrono::milliseconds>(done-started).count() <<std::endl;
The upstream is iterable and the entries cast to unsigned seem to fit to the ground truth, I would guess this is a bool / uint8_t property map.
std::stringstream ss;
for (auto i:upstream)
ss << (unsigned) i ;
if (ss.str() == naperville_gt)
{
std::cout << "Got the right result for Naperville" << std::endl;
}else if (ss.str() == sample_gt) {
std::cout << "Got the right result for SampleDataset1" << std::endl;
}else
std::cout << "This is not naperville, result is" << std::endl << ss.str() << std::endl;
return 0;
}
Thats is. Well-done.