-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements Mapping for NodeBasedGraph -> EdgeBasedGraph Translation #3645
Merged
daniel-j-h
merged 7 commits into
tools/partitionining/graph_view
from
partitioner-for-moritz-nbg-ebg-mapping
Feb 14, 2017
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
62e7e96
Implements Mapping for NodeBasedGraph -> EdgeBasedgraph Translation
daniel-j-h 387808c
Split Partitioner I/O off into separate headers
daniel-j-h 5024f6c
Loads the edge based graph edges and constructs a dynamic graph from it
daniel-j-h fd87572
First try at artificial nodes
daniel-j-h 4b2ed79
Store flag for artificial bounary edges and walk border nodes in ebg
daniel-j-h cfe6d6b
Sigh. Just randomly pick a side for border nodes for now..
daniel-j-h b023a76
Re-use the extractor edge based edge for loading the ebg in osrm-part…
daniel-j-h File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
63 changes: 63 additions & 0 deletions
63
include/extractor/node_based_graph_to_edge_based_graph_mapping_writer.hpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#ifndef NODE_BASED_GRAPH_TO_EDGE_BASED_GRAPH_MAPPING_WRITER_HPP | ||
#define NODE_BASED_GRAPH_TO_EDGE_BASED_GRAPH_MAPPING_WRITER_HPP | ||
|
||
#include "storage/io.hpp" | ||
#include "util/log.hpp" | ||
#include "util/typedefs.hpp" | ||
|
||
#include <boost/assert.hpp> | ||
|
||
#include <cstddef> | ||
|
||
#include <string> | ||
|
||
namespace osrm | ||
{ | ||
namespace extractor | ||
{ | ||
|
||
// Writes: | Fingerprint | #mappings | u v fwd_node bkw_node | u v fwd_node bkw_node | .. | ||
// - uint64: number of mappings (u, v, fwd_node bkw_node) chunks | ||
// - NodeID u, NodeID v, EdgeID fwd_node, EdgeID bkw_node | ||
|
||
struct NodeBasedGraphToEdgeBasedGraphMappingWriter | ||
{ | ||
NodeBasedGraphToEdgeBasedGraphMappingWriter(const std::string &path) | ||
: writer{path, storage::io::FileWriter::GenerateFingerprint}, num_written{0} | ||
{ | ||
const std::uint64_t dummy{0}; // filled in later | ||
writer.WriteElementCount64(dummy); | ||
} | ||
|
||
void WriteMapping(NodeID u, NodeID v, EdgeID fwd_ebg_node, EdgeID bkw_ebg_node) | ||
{ | ||
BOOST_ASSERT(u != SPECIAL_NODEID); | ||
BOOST_ASSERT(v != SPECIAL_NODEID); | ||
BOOST_ASSERT(fwd_ebg_node != SPECIAL_EDGEID || bkw_ebg_node != SPECIAL_EDGEID); | ||
|
||
writer.WriteOne(u); | ||
writer.WriteOne(v); | ||
writer.WriteOne(fwd_ebg_node); | ||
writer.WriteOne(bkw_ebg_node); | ||
|
||
num_written += 1; | ||
} | ||
|
||
~NodeBasedGraphToEdgeBasedGraphMappingWriter() | ||
{ | ||
if (num_written != 0) | ||
{ | ||
writer.SkipToBeginning(); | ||
writer.WriteOne(num_written); | ||
} | ||
} | ||
|
||
private: | ||
storage::io::FileWriter writer; | ||
std::uint64_t num_written; | ||
}; | ||
|
||
} // ns extractor | ||
} // ns osrm | ||
|
||
#endif // NODE_BASED_GRAPH_TO_EDGE_BASED_GRAPH_MAPPING_WRITER_HPP |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef OSRM_COMPRESSED_NODE_BASED_GRAPH_READER_HPP | ||
#define OSRM_COMPRESSED_NODE_BASED_GRAPH_READER_HPP | ||
|
||
#include "storage/io.hpp" | ||
#include "util/coordinate.hpp" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace osrm | ||
{ | ||
namespace partition | ||
{ | ||
|
||
struct CompressedNodeBasedGraphEdge | ||
{ | ||
NodeID source; | ||
NodeID target; | ||
}; | ||
|
||
struct CompressedNodeBasedGraph | ||
{ | ||
CompressedNodeBasedGraph(storage::io::FileReader &reader) | ||
{ | ||
// Reads: | Fingerprint | #e | #n | edges | coordinates | | ||
// - uint64: number of edges (from, to) pairs | ||
// - uint64: number of nodes and therefore also coordinates | ||
// - (uint32_t, uint32_t): num_edges * edges | ||
// - (int32_t, int32_t: num_nodes * coordinates (lon, lat) | ||
// | ||
// Gets written in Extractor::WriteCompressedNodeBasedGraph | ||
|
||
const auto num_edges = reader.ReadElementCount64(); | ||
const auto num_nodes = reader.ReadElementCount64(); | ||
|
||
edges.resize(num_edges); | ||
coordinates.resize(num_nodes); | ||
|
||
reader.ReadInto(edges); | ||
reader.ReadInto(coordinates); | ||
} | ||
|
||
std::vector<CompressedNodeBasedGraphEdge> edges; | ||
std::vector<util::Coordinate> coordinates; | ||
}; | ||
|
||
inline CompressedNodeBasedGraph LoadCompressedNodeBasedGraph(const std::string &path) | ||
{ | ||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint; | ||
storage::io::FileReader reader(path, fingerprint); | ||
|
||
CompressedNodeBasedGraph graph{reader}; | ||
return graph; | ||
} | ||
|
||
} // ns partition | ||
} // ns osrm | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
head
andtail
can be a little bit confusing here because they typically reference the start/target for anarc
(edge based edge). However there is no arc fromtail
tohead
and both can be heads and tails for different arcs (there are typically arcs both from and tohead
andtail
).{forward,backward}_edge_based_node
might be more precise but maybe you have another idea for a name.