fix comparison to recognize small components in a static graph
This commit is contained in:
parent
59bceee258
commit
0d432f6377
@ -27,8 +27,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
#include "../algorithms/tiny_components.hpp"
|
#include "../algorithms/tiny_components.hpp"
|
||||||
#include "../data_structures/static_graph.hpp"
|
|
||||||
#include "../data_structures/coordinate_calculation.hpp"
|
#include "../data_structures/coordinate_calculation.hpp"
|
||||||
|
#include "../data_structures/dynamic_graph.hpp"
|
||||||
|
#include "../data_structures/static_graph.hpp"
|
||||||
#include "../util/fingerprint.hpp"
|
#include "../util/fingerprint.hpp"
|
||||||
#include "../util/graph_loader.hpp"
|
#include "../util/graph_loader.hpp"
|
||||||
#include "../util/make_unique.hpp"
|
#include "../util/make_unique.hpp"
|
||||||
@ -63,8 +64,8 @@ struct TarjanEdgeData
|
|||||||
unsigned name_id;
|
unsigned name_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
using TarjanGraph = StaticGraph<TarjanEdgeData>;
|
using TarjanDynamicGraph = StaticGraph<TarjanEdgeData>;
|
||||||
using TarjanEdge = TarjanGraph::InputEdge;
|
using TarjanEdge = TarjanDynamicGraph::InputEdge;
|
||||||
|
|
||||||
void DeleteFileIfExists(const std::string &file_name)
|
void DeleteFileIfExists(const std::string &file_name)
|
||||||
{
|
{
|
||||||
@ -148,6 +149,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Building an node-based graph
|
// Building an node-based graph
|
||||||
std::vector<TarjanEdge> graph_edge_list;
|
std::vector<TarjanEdge> graph_edge_list;
|
||||||
|
// DeallocatingVector<TarjanEdge> graph_edge_list;
|
||||||
for (const auto &input_edge : edge_list)
|
for (const auto &input_edge : edge_list)
|
||||||
{
|
{
|
||||||
if (input_edge.source == input_edge.target)
|
if (input_edge.source == input_edge.target)
|
||||||
@ -172,15 +174,16 @@ int main(int argc, char *argv[])
|
|||||||
"input edge vector not properly deallocated");
|
"input edge vector not properly deallocated");
|
||||||
|
|
||||||
tbb::parallel_sort(graph_edge_list.begin(), graph_edge_list.end());
|
tbb::parallel_sort(graph_edge_list.begin(), graph_edge_list.end());
|
||||||
auto graph = std::make_shared<TarjanGraph>(number_of_nodes, graph_edge_list);
|
const auto graph = std::make_shared<TarjanDynamicGraph>(number_of_nodes, graph_edge_list);
|
||||||
graph_edge_list.clear();
|
graph_edge_list.clear();
|
||||||
graph_edge_list.shrink_to_fit();
|
graph_edge_list.shrink_to_fit();
|
||||||
|
|
||||||
SimpleLogger().Write() << "Starting SCC graph traversal";
|
SimpleLogger().Write() << "Starting SCC graph traversal";
|
||||||
|
|
||||||
RestrictionMap restriction_map(restriction_list);
|
RestrictionMap restriction_map(restriction_list);
|
||||||
auto tarjan =
|
auto tarjan = osrm::make_unique<TarjanSCC<TarjanDynamicGraph>>(graph,
|
||||||
osrm::make_unique<TarjanSCC<TarjanGraph>>(graph, restriction_map, bollard_node_list);
|
restriction_map,
|
||||||
|
bollard_node_list);
|
||||||
tarjan->run();
|
tarjan->run();
|
||||||
SimpleLogger().Write() << "identified: " << tarjan->get_number_of_components()
|
SimpleLogger().Write() << "identified: " << tarjan->get_number_of_components()
|
||||||
<< " many components";
|
<< " many components";
|
||||||
@ -233,9 +236,9 @@ int main(int argc, char *argv[])
|
|||||||
percentage.printIncrement();
|
percentage.printIncrement();
|
||||||
for (const auto current_edge : graph->GetAdjacentEdgeRange(source))
|
for (const auto current_edge : graph->GetAdjacentEdgeRange(source))
|
||||||
{
|
{
|
||||||
const TarjanGraph::NodeIterator target = graph->GetTarget(current_edge);
|
const TarjanDynamicGraph::NodeIterator target = graph->GetTarget(current_edge);
|
||||||
|
|
||||||
if (source < target || graph->EndEdges(target) == graph->FindEdge(target, source))
|
if (source < target || graph->EndEdges(target) >= graph->FindEdge(target, source))
|
||||||
{
|
{
|
||||||
total_network_length +=
|
total_network_length +=
|
||||||
100 * coordinate_calculation::euclidean_distance(
|
100 * coordinate_calculation::euclidean_distance(
|
||||||
|
Loading…
Reference in New Issue
Block a user