1 #ifndef SHORTESTPATH_BENCHMARK_H
2 #define SHORTESTPATH_BENCHMARK_H
48 double latc,
double lonc) {
50 auto distfunction = [ = ](
const OSMVertex & v) ->
double {
51 return (v.getLatitude() - latc) * (v.getLatitude() - latc) + (v.getLongitude() - lonc) * (v.getLongitude() - lonc);
57 for (
int i = 1; i < graph.
getVertices()->size(); ++i) {
71 p.setXLabel(
"Number of Edges");
72 p.setYLabel(
"Runtime (in s)");
82 void run(std::string algoName,
85 std::unordered_map<int, double>& distance,
86 std::unordered_map<int, int>& parent)) {
87 std::vector<double> time;
88 std::vector<double> vtxCounts;
89 std::vector<double> edgeCounts;
94 double reflat = 40.74;
95 double reflong = -73.98;
97 for (
double radius = 0.02; radius < 0.15; radius += 0.02) {
98 std::cerr <<
"*" << std::flush;
102 reflat + radius, reflong + radius);
106 long vertexCount = countVertices(graph);
107 long edgeCount = countEdges(graph);
109 int root = getCenter(osm_data, graph, reflat, reflong);
111 std::unordered_map<int, double> level;
112 std::unordered_map<int, int> parent;
114 std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now();
116 spalgo(graph, root, level, parent);
118 std::chrono::time_point<std::chrono::system_clock> end = std::chrono::system_clock::now();
120 std::chrono::duration<double> elapsed_seconds = end - start;
122 time.push_back ((
double)elapsed_seconds.count() );
123 vtxCounts.push_back ( (
double)vertexCount );
124 edgeCounts.push_back ( (
double)edgeCount );
126 if (elapsed_seconds.count() > time_cap) {
130 plot.
setXData(algoName, edgeCounts);
132 std::cerr <<
"\n" << std::flush;
This class provides an API to various data sources used in BRIDGES.
Definition: DataSource.h:64
OSMData getOSMData(double lat_min, double long_min, double lat_max, double long_max, string level="default")
Get OpenStreetMap data given a bounding rectangle of lat/long values.
Definition: DataSource.h:1008
Base class for a variety of graph based benchmark.
Definition: GraphBenchmark.h:15
Benchmarks Shortest Path algorithms.
Definition: ShortestPathBenchmark.h:42
void run(std::string algoName, void(*spalgo)(const GraphAdjList< int, OSMVertex, double > &gr, int source, std::unordered_map< int, double > &distance, std::unordered_map< int, int > &parent))
benchmark one implementation
Definition: ShortestPathBenchmark.h:82
ShortestPathBenchmark(LineChart &p)
Definition: ShortestPathBenchmark.h:69
Class that hold Open Street Map Data.
Definition: OSMData.h:38
void getGraph(GraphAdjList< int, OSMVertex, double > *gr) const
Definition: OSMData.h:146
Class that hold Open Street Map vertices.
Definition: OSMVertex.h:33
E const & getValue() const
Gets the object held in the generic object E.
Definition: Element.h:207
This class provides methods to represent adjacency list based graphs.
Definition: GraphAdjList.h:110
const Element< E1 > * getVertex(const K &key) const
Return the vertex corresponding to a key.
Definition: GraphAdjList.h:405
unordered_map< K, Element< E1 > * > * getVertices()
Return the graph nodes.
Definition: GraphAdjList.h:388
Show series of data or functions using a line chart.
Definition: LineChart.h:43
void setYData(string series, vector< double > ydata)
Changes the Y data for a series.
Definition: LineChart.h:234
void setXData(string series, vector< double > xdata)
Changes the X data for a series.
Definition: LineChart.h:214
Support for drawing Bar charts.
Definition: alltypes.h:4