graph is built in-place, so memory peak usage is halved.

This commit is contained in:
DennisOSRM
2011-12-15 17:48:00 +01:00
parent a098e38c5a
commit ad77d6cfec
4 changed files with 112 additions and 28 deletions
+18 -14
View File
@@ -49,12 +49,18 @@ public:
}
};
struct _StrNode {
//index of the first edge
EdgeIterator firstEdge;
};
struct _StrEdge {
NodeID target;
EdgeDataT data;
};
StaticGraph( const int nodes, std::vector< InputEdge > &graph ) {
#ifdef _GLIBCXX_PARALLEL
__gnu_parallel::sort( graph.begin(), graph.end() );
#else
std::sort( graph.begin(), graph.end() );
#endif
_numNodes = nodes;
_numEdges = ( EdgeIterator ) graph.size();
_nodes.resize( _numNodes + 1);
@@ -79,6 +85,14 @@ public:
}
}
StaticGraph( std::vector<_StrNode> & nodes, std::vector<_StrEdge> & edges) {
_numNodes = nodes.size();
_numEdges = edges.size();
_nodes.swap(nodes);
_edges.swap(edges);
}
unsigned GetNumberOfNodes() const {
return _numNodes;
}
@@ -142,16 +156,6 @@ public:
private:
struct _StrNode {
//index of the first edge
EdgeIterator firstEdge;
};
struct _StrEdge {
NodeID target;
EdgeDataT data;
};
NodeIterator _numNodes;
EdgeIterator _numEdges;