2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-31 08:12:14 +00:00

Make vertices and edges support len()

[SVN r30189]
This commit is contained in:
Douglas Gregor
2005-07-20 17:05:47 +00:00
parent 034950f993
commit 64f732195e
2 changed files with 35 additions and 4 deletions

View File

@@ -441,6 +441,13 @@ basic_graph<DirectedS>::vertices() const
return std::make_pair(vertices_begin(), vertices_end());
}
template<typename DirectedS>
simple_python_iterator<typename basic_graph<DirectedS>::vertex_iterator>
basic_graph<DirectedS>::py_vertices() const
{
return simple_python_iterator<vertex_iterator>(vertices());
}
template<typename DirectedS>
typename basic_graph<DirectedS>::Edge
basic_graph<DirectedS>::add_edge(Vertex u, Vertex v)
@@ -507,6 +514,13 @@ basic_graph<DirectedS>::edges() const
return std::make_pair(edges_begin(), edges_end());
}
template<typename DirectedS>
simple_python_iterator<typename basic_graph<DirectedS>::edge_iterator>
basic_graph<DirectedS>::py_edges() const
{
return simple_python_iterator<edge_iterator>(edges());
}
template<typename DirectedS>
void basic_graph<DirectedS>::renumber_vertices()
{
@@ -565,11 +579,10 @@ void export_basic_graph(const char* name)
.def("is_directed", &Graph::is_directed)
// Vertex List Graph concept
.def("num_vertices", &Graph::num_vertices)
.add_property("vertices", range(&Graph::vertices_begin,
&Graph::vertices_end))
.add_property("vertices", &Graph::py_vertices)
// Edge List Graph concept
.def("num_edges", &Graph::num_edges)
.add_property("edges", range(&Graph::edges_begin, &Graph::edges_end))
.add_property("edges", &Graph::py_edges)
// Mutable Graph concept
.def("add_vertex", &Graph::add_vertex)
.def("clear_vertex", &Graph::clear_vertex)
@@ -623,6 +636,10 @@ void export_basic_graph(const char* name)
.def(self != self);
// Iterators
simple_python_iterator<typename Graph::vertex_iterator>
::declare("vertex_iterator");
simple_python_iterator<typename Graph::edge_iterator>
::declare("edge_iterator");
simple_python_iterator<typename Graph::out_edge_iterator>
::declare("out_edge_iterator");
simple_python_iterator<typename Graph::in_edge_iterator>