Skip to content

Commit 98b6059

Browse files
authored
add function to add many vertices at once (#47)
1 parent 8bd289d commit 98b6059

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

libgalois/include/galois/graphs/LS_LC_CSR_Graph.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,21 @@ class LS_LC_CSR_Graph : private boost::noncopyable {
186186
return m_vertices.size() - 1;
187187
}
188188

189+
/**
190+
* Adds multiple vertices to the graph. The new vertices will be assigned
191+
* consecutive topology IDs, and the lowest new ID is returned.
192+
*/
193+
VertexTopologyID addVerticesTopologyOnly(size_t count) {
194+
VertexTopologyID const start = m_vertices.size();
195+
m_vertices.resize(start + count);
196+
return start;
197+
}
198+
189199
// Adds multiple vertices to the graph. The new vertices will be assigned
190200
// consecutive topology IDs, and the lowest new ID is returned.
191201
template <typename V = VertexData, typename = std::enable_if<HasVertexData>>
192202
VertexTopologyID addVertices(std::vector<V> data) {
193-
VertexTopologyID const start = m_vertices.size();
194-
m_vertices.resize(m_vertices.size() + data.size());
203+
auto const start = addVerticesTopologyOnly(data.size());
195204
m_vertex_data.resize(m_vertices.size());
196205
resetPrefixSum();
197206
galois::do_all(

0 commit comments

Comments
 (0)