graph_matrix.cc 5.58 KB
Newer Older
1 2
// graph-tool -- a general graph modification and manipulation thingy
//
Tiago Peixoto's avatar
Tiago Peixoto committed
3
// Copyright (C) 2006-2020 Tiago de Paula Peixoto <tiago@skewed.de>
4
//
5 6 7 8
// This program is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option) any
// later version.
9
//
10 11 12 13
// 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 Lesser General Public License for more
// details.
14
//
15
// You should have received a copy of the GNU Lesser General Public License
16 17 18 19 20 21 22 23 24 25 26 27 28
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#include <boost/python.hpp>
#include "graph.hh"

using namespace std;
using namespace boost;
using namespace graph_tool;

void adjacency(GraphInterface& g, boost::any index, boost::any weight,
               python::object odata, python::object oi,
               python::object oj);

29 30 31 32 33
void adjacency_matvec(GraphInterface& g, boost::any index, boost::any weight,
                      python::object ov, python::object oret);

void adjacency_matmat(GraphInterface& g, boost::any index, boost::any weight,
                      python::object ov, python::object oret);
34 35 36 37 38 39

void laplacian(GraphInterface& g, boost::any index, boost::any weight,
               string sdeg,
               python::object odata, python::object oi,
               python::object oj);

40 41 42 43 44
void laplacian_matvec(GraphInterface& g, boost::any index, boost::any weight,
                      boost::any deg, python::object ov, python::object oret);

void laplacian_matmat(GraphInterface& g, boost::any index, boost::any weight,
                      boost::any deg, python::object ov, python::object oret);
45 46 47 48 49 50

void norm_laplacian(GraphInterface& g, boost::any index, boost::any weight,
                    string sdeg,
                    python::object odata, python::object oi,
                    python::object oj);

51 52 53 54 55 56
void norm_laplacian_matvec(GraphInterface& g, boost::any index, boost::any weight,
                           boost::any deg, python::object ov, python::object oret);

void norm_laplacian_matmat(GraphInterface& g, boost::any index, boost::any weight,
                           boost::any deg, python::object ov, python::object oret);

57 58 59 60
void incidence(GraphInterface& g, boost::any vindex, boost::any eindex,
               python::object odata, python::object oi,
               python::object oj);

61 62 63 64 65 66
void incidence_matvec(GraphInterface& g, boost::any vindex, boost::any eindex,
                      python::object ov, python::object oret, bool transpose);

void incidence_matmat(GraphInterface& g, boost::any vindex, boost::any eindex,
                      python::object ov, python::object oret, bool tranpose);

67 68 69 70
void transition(GraphInterface& g, boost::any index, boost::any weight,
                python::object odata, python::object oi,
                python::object oj);

71 72 73 74 75 76 77 78
void transition_matvec(GraphInterface& g, boost::any index, boost::any weight,
                       boost::any deg, python::object ov, python::object oret,
                       bool transpose);

void transition_matmat(GraphInterface& g, boost::any index, boost::any weight,
                       boost::any deg, python::object ov, python::object oret,
                       bool transpose);

79 80 81
void nonbacktracking(GraphInterface& gi, boost::any index,
                     std::vector<int64_t>& i, std::vector<int64_t>& j);

82 83 84 85 86 87 88 89
void nonbacktracking_matvec(GraphInterface& g, boost::any index,
                            python::object ov, python::object oret,
                            bool transpose);

void nonbacktracking_matmat(GraphInterface& g, boost::any index,
                            python::object ov, python::object oret,
                            bool transpose);

90 91 92
void compact_nonbacktracking(GraphInterface& gi, std::vector<int64_t>& i,
                             std::vector<int64_t>& j, std::vector<double>& x);

93 94 95 96 97 98 99 100
void compact_nonbacktracking_matvec(GraphInterface& g, boost::any index,
                                    python::object ov, python::object oret,
                                    bool transpose);

void compact_nonbacktracking_matmat(GraphInterface& g, boost::any index,
                                    python::object ov, python::object oret,
                                    bool transpose);

101 102 103
BOOST_PYTHON_MODULE(libgraph_tool_spectral)
{
    using namespace boost::python;
104
    docstring_options dopt(true, false);
105
    def("adjacency", &adjacency);
106 107
    def("adjacency_matvec", &adjacency_matvec);
    def("adjacency_matmat", &adjacency_matmat);
108
    def("laplacian", &laplacian);
109 110
    def("laplacian_matvec", &laplacian_matvec);
    def("laplacian_matmat", &laplacian_matmat);
111
    def("norm_laplacian", &norm_laplacian);
112 113
    def("norm_laplacian_matvec", &norm_laplacian_matvec);
    def("norm_laplacian_matmat", &norm_laplacian_matmat);
114
    def("incidence", &incidence);
115 116
    def("incidence_matvec", &incidence_matvec);
    def("incidence_matmat", &incidence_matmat);
117
    def("transition", &transition);
118 119
    def("transition_matvec", &transition_matvec);
    def("transition_matmat", &transition_matmat);
120
    def("nonbacktracking", &nonbacktracking);
121 122
    def("nonbacktracking_matvec", &nonbacktracking_matvec);
    def("nonbacktracking_matmat", &nonbacktracking_matmat);
123
    def("compact_nonbacktracking", &compact_nonbacktracking);
124 125
    def("compact_nonbacktracking_matvec", &compact_nonbacktracking_matvec);
    def("compact_nonbacktracking_matmat", &compact_nonbacktracking_matmat);
126
}