// graph-tool -- a general graph modification and manipulation thingy // // Copyright (C) 2007-2012 Tiago de Paula Peixoto // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 3 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #include "graph.hh" #include "graph_filtering.hh" #include "graph_geometric.hh" #include using namespace std; using namespace boost; using namespace graph_tool; typedef graph_tool::detail::get_all_graph_views ::apply, mpl::bool_,mpl::bool_, mpl::bool_,mpl::bool_ >::type graph_views; typedef property_map_types::apply >, GraphInterface::vertex_index_map_t, mpl::bool_ >::type prop_types; void geometric(GraphInterface& gi, python::object opoints, double r, python::object orange, bool periodic, boost::any pos) { python::object shape = opoints.attr("shape"); size_t size = python::extract(shape[0]); vector > points(size); vector > range(python::len(orange)); size = python::extract(shape[1]); for(size_t i = 0; i < points.size(); ++i) { points[i].resize(size); for (size_t j = 0; j < points[i].size(); ++j) points[i][j] = python::extract(opoints[i][j]); } for(size_t i = 0; i < range.size(); ++i) { range[i].first = python::extract(orange[i][0]); range[i].second = python::extract(orange[i][1]); } run_action()(gi, bind(get_geometric(), _1, _2, ref(points), ref(range), r, periodic), prop_types())(pos); gi.ReIndexEdges(); }