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);
55 double dist = distfunction(graph.
getVertex(minindex)->getValue());
57 for (
int i = 1; i < graph.
getVertices()->size(); ++i) {
58 double locdist = distfunction(graph.
getVertex(i)->getValue());
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;
98 for (
double radius = 0.02; radius < 0.15; radius += 0.02) {
99 std::cerr <<
"*" << std::flush;
103 reflat + radius, reflong + radius);
107 long vertexCount = countVertices(graph);
108 long edgeCount = countEdges(graph);
111 int root = getCenter(osm_data, graph, reflat, reflong);
113 std::unordered_map<int, double> level;
114 std::unordered_map<int, int> parent;
116 std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now();
118 spalgo(graph, root, level, parent);
120 std::chrono::time_point<std::chrono::system_clock> end = std::chrono::system_clock::now();
122 std::chrono::duration<double> elapsed_seconds = end - start;
125 time.push_back ((
double)elapsed_seconds.count() );
126 vtxCounts.push_back ( (
double)vertexCount );
127 edgeCounts.push_back ( (
double)edgeCount );
129 if (elapsed_seconds.count() > time_cap) {
133 plot.
setXData(algoName, edgeCounts);
135 std::cerr <<
"\n" << std::flush;
void setXLabel(string xaxisName)
Change the label for the X-axis.
Definition: LineChart.h:184
ShortestPathBenchmark(LineChart &p)
Definition: ShortestPathBenchmark.h:69
Benchmarks Shortest Path algorithms.
Definition: ShortestPathBenchmark.h:42
This class provides methods to represent adjacency list based graphs.
Definition: Element.h:19
Show series of data or functions using a line chart.
Definition: LineChart.h:43
const Element< E1 > * getVertex(const K &key) const
Return the vertex corresponding to a key.
Definition: GraphAdjList.h:383
void setXData(string series, vector< double > xdata)
Changes the X data for a series.
Definition: LineChart.h:217
Base class for a variety of graph based benchmark.
Definition: GraphBenchmark.h:15
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
This class provides an API to various data sources used in BRIDGES.
Definition: DataSource.h:59
void getGraph(GraphAdjList< int, OSMVertex, double > *gr) const
Definition: OSMData.h:143
unordered_map< K, Element< E1 > * > * getVertices()
Return the graph nodes.
Definition: GraphAdjList.h:366
Class that hold Open Street Map Data.
Definition: OSMData.h:34
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:593
void setYData(string series, vector< double > ydata)
Changes the Y data for a series.
Definition: LineChart.h:237
void setYLabel(string yaxisName)
Change the label for the Y-axis.
Definition: LineChart.h:166
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
Class that hold Open Street Map vertices.
Definition: OSMVertex.h:28