2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-29 19:42:11 +00:00

Sped up out_degree() and related functions for new interface

[SVN r53786]
This commit is contained in:
Jeremiah Willcock
2009-06-10 14:43:12 +00:00
parent cef1982db1
commit 5d033cb991

View File

@@ -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<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
@@ -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