-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
43 lines (42 loc) · 1.87 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "GraphTraversalAlgorithms.h"
#include "MazeGenerator.h"
namespace py = pybind11;
#define AddGTAclass(GTA /*GraphTraversalAlgorithm*/){ \
py::class_<GTA>(m, #GTA) \
.def(py::init<Grid&, Index, Index>(), \
py::arg("grid"), py::arg("start"), py::arg("end")) \
.def("solve", >A::solve) \
.def("SrcToDestPath", >A::SrcToDestPath) \
.def("SrcToDestDistance", >A::SrcToDestDistance) \
.def("TraversedNodes", >A::TraversedNodes) \
.def("TraversedNodesNo", >A::TraversedNodesNo); \
/* All GTAs have common utility functions and constructor */ \
}
PYBIND11_MODULE(MazeSolvingAlgos, m) {
py::class_<Index>(m, "Index",
" Simple class to encapsulate 2D position of a 1x1 square in the Maze.")
.def(py::init<size_t, size_t>(), py::arg("row") = 0, py::arg("col") = 0)
.def_readwrite("row", &Index::row)
.def_readwrite("col", &Index::col)
.def("__repr__", &Index::as_string)
.def("__eq__", &Index::operator==)
.def("__ne__", &Index::operator!=);
py::class_<RandomMazeGenerator>(m, "RandomMazeGenerator",
" Simple Random-Generator using BackTracking.")
.def(py::init<size_t, size_t>(), py::arg("hight") = 0, py::arg("width") = 0)
.def("generate", &RandomMazeGenerator::generate);
AddGTAclass(DepthFirstSearch);
AddGTAclass(BreadthFirstSearch);
AddGTAclass(DijkstraAlgorithm);
AddGTAclass(AStar);
AddGTAclass(BellmanFord);
AddGTAclass(FloydWarshall);
AddGTAclass(BidirectionalSearch);
#ifdef VERSION_INFO
m.attr("__version__") = VERSION_INFO;
#else
m.attr("__version__") = "dev";
#endif
}