| 1 | // graph-tool -- a general graph modification and manipulation thingy |
|---|
| 2 | // |
|---|
| 3 | // Copyright (C) 2007 Tiago de Paula Peixoto <tiago@forked.de> |
|---|
| 4 | // |
|---|
| 5 | // This program is free software; you can redistribute it and/or |
|---|
| 6 | // modify it under the terms of the GNU General Public License |
|---|
| 7 | // as published by the Free Software Foundation; either version 3 |
|---|
| 8 | // of the License, or (at your option) any later version. |
|---|
| 9 | // |
|---|
| 10 | // This program is distributed in the hope that it will be useful, |
|---|
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | // GNU General Public License for more details. |
|---|
| 14 | // |
|---|
| 15 | // You should have received a copy of the GNU General Public License |
|---|
| 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | |
|---|
| 18 | #include "graph_filtering.hh" |
|---|
| 19 | |
|---|
| 20 | #include <boost/python.hpp> |
|---|
| 21 | #include <boost/lambda/bind.hpp> |
|---|
| 22 | |
|---|
| 23 | #include "graph.hh" |
|---|
| 24 | #include "graph_selectors.hh" |
|---|
| 25 | #include "graph_pagerank.hh" |
|---|
| 26 | |
|---|
| 27 | using namespace std; |
|---|
| 28 | using namespace boost; |
|---|
| 29 | using namespace graph_tool; |
|---|
| 30 | |
|---|
| 31 | size_t pagerank(GraphInterface& g, boost::any rank, double d, double epslon, |
|---|
| 32 | size_t max_iter) |
|---|
| 33 | { |
|---|
| 34 | if (!belongs<writable_vertex_scalar_properties>()(rank)) |
|---|
| 35 | throw ValueException("vertex property must be writable"); |
|---|
| 36 | |
|---|
| 37 | size_t iter; |
|---|
| 38 | run_action<>() |
|---|
| 39 | (g, bind<void>(get_pagerank(), |
|---|
| 40 | _1, g.GetVertexIndex(), _2, d, |
|---|
| 41 | epslon, max_iter, ref(iter)), |
|---|
| 42 | writable_vertex_scalar_properties())(rank); |
|---|
| 43 | return iter; |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | void export_pagerank() |
|---|
| 48 | { |
|---|
| 49 | using namespace boost::python; |
|---|
| 50 | def("get_pagerank", &pagerank); |
|---|
| 51 | } |
|---|