From 5d033cb9910e97ae9c336354b8a65390d89fe91c Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Wed, 10 Jun 2009 14:43:12 +0000 Subject: [PATCH] Sped up out_degree() and related functions for new interface [SVN r53786] --- .../boost/graph/compressed_sparse_row_graph.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/boost/graph/compressed_sparse_row_graph.hpp b/include/boost/graph/compressed_sparse_row_graph.hpp index c0e7e4ec..dd9ff34e 100644 --- a/include/boost/graph/compressed_sparse_row_graph.hpp +++ b/include/boost/graph/compressed_sparse_row_graph.hpp @@ -943,8 +943,14 @@ out_edges(Vertex v, const BOOST_CSR_GRAPH_TYPE& g) typedef typename BOOST_CSR_GRAPH_TYPE::out_edge_iterator it; EdgeIndex v_row_start = g.m_rowstart[v]; EdgeIndex next_row_start = g.m_rowstart[v + 1]; +#ifdef BOOST_GRAPH_USE_NEW_CSR_INTERFACE + return std::make_pair(it(ed(v, v_row_start)), + it(ed(v, next_row_start))); +#else + // Special case to allow incremental construction return std::make_pair(it(ed(v, v_row_start)), it(ed(v, (std::max)(v_row_start, next_row_start)))); +#endif } template @@ -953,7 +959,12 @@ out_degree(Vertex v, const BOOST_CSR_GRAPH_TYPE& g) { EdgeIndex v_row_start = g.m_rowstart[v]; EdgeIndex next_row_start = g.m_rowstart[v + 1]; +#ifdef BOOST_GRAPH_USE_NEW_CSR_INTERFACE + return next_row_start - v_row_start; +#else + // Special case to allow incremental construction return (std::max)(v_row_start, next_row_start) - v_row_start; +#endif } // From AdjacencyGraph @@ -964,9 +975,15 @@ adjacent_vertices(Vertex v, const BOOST_CSR_GRAPH_TYPE& g) { EdgeIndex v_row_start = g.m_rowstart[v]; EdgeIndex next_row_start = g.m_rowstart[v + 1]; +#ifdef BOOST_GRAPH_USE_NEW_CSR_INTERFACE + return std::make_pair(g.m_column.begin() + v_row_start, + g.m_column.begin() + next_row_start); +#else + // Special case to allow incremental construction return std::make_pair(g.m_column.begin() + v_row_start, g.m_column.begin() + (std::max)(v_row_start, next_row_start)); +#endif } // Extra, common functions