FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Algorithm-Visualiser-Platform/cpp/src/bindings.cpp at main · MJ-thunder/Algorithm-Visualiser-Platform · GitHub
MJ-thunder
/
Algorithm-Visualiser-Platform
Public
forked from
CipherYuvraj/Algorithm-Visualiser-Platform
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Algorithm-Visualiser-Platform
/
cpp
/
src
/
bindings.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
75 lines (67 loc) · 3.34 KB
Breadcrumbs
Algorithm-Visualiser-Platform
/
cpp
/
src
/
bindings.cpp
Copy path
File metadata and controls
75 lines (67 loc) · 3.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
include
<
pybind11/pybind11.h
>
#
include
<
pybind11/stl.h
>
#
include
<
pybind11/numpy.h
>
#
include
"
algorithms/sorting.h
"
#
include
"
algorithms/graph.h
"
#
include
"
algorithms/step.h
"
namespace
py
=
pybind11;
PYBIND11_MODULE
(algorithm_engine, m) {
m.
doc
() =
"
Algorithm Visualizer C++ Engine
"
;
//
SortStep structure
py::class_<SortStep>(m,
"
SortStep
"
)
.
def
(py::init<
const
std::vector<
int
>&,
const
std::vector<
int
>&,
const
std::vector<
int
>&,
const
std::string&,
int
>(),
py::arg
(
"
array
"
),
py::arg
(
"
highlighted
"
) = std::vector<
int
>(),
py::arg
(
"
comparing
"
) = std::vector<
int
>(),
py::arg
(
"
operation
"
) =
"
"
,
py::arg
(
"
time_complexity_ops
"
) =
0
)
.
def_readwrite
(
"
array
"
, &SortStep::array)
.
def_readwrite
(
"
highlighted
"
, &SortStep::highlighted)
.
def_readwrite
(
"
comparing
"
, &SortStep::comparing)
.
def_readwrite
(
"
operation
"
, &SortStep::operation)
.
def_readwrite
(
"
time_complexity_ops
"
, &SortStep::time_complexity_ops);
//
SortingAlgorithms class
py::class_<SortingAlgorithms>(m,
"
SortingAlgorithms
"
)
.
def_static
(
"
bubble_sort
"
, &SortingAlgorithms::bubbleSort)
.
def_static
(
"
merge_sort
"
, &SortingAlgorithms::mergeSort)
.
def_static
(
"
quick_sort
"
, &SortingAlgorithms::quickSort)
.
def_static
(
"
heap_sort
"
, &SortingAlgorithms::heapSort)
.
def_static
(
"
counting_sort
"
, &SortingAlgorithms::countingSort);
//
GraphNode structure
py::class_<GraphNode>(m,
"
GraphNode
"
)
.
def
(py::init<
int
,
const
std::string&,
double
,
double
>(),
py::arg
(
"
id
"
),
py::arg
(
"
label
"
) =
"
"
,
py::arg
(
"
x
"
) =
0
,
py::arg
(
"
y
"
) =
0
)
.
def_readwrite
(
"
id
"
, &GraphNode::id)
.
def_readwrite
(
"
label
"
, &GraphNode::label)
.
def_readwrite
(
"
x
"
, &GraphNode::x)
.
def_readwrite
(
"
y
"
, &GraphNode::y);
//
GraphEdge structure
py::class_<GraphEdge>(m,
"
GraphEdge
"
)
.
def
(py::init<
int
,
int
,
double
,
bool
>(),
py::arg
(
"
from
"
),
py::arg
(
"
to
"
),
py::arg
(
"
weight
"
) =
1.0
,
py::arg
(
"
directed
"
) =
false
)
.
def_readwrite
(
"
from
"
, &GraphEdge::from)
.
def_readwrite
(
"
to
"
, &GraphEdge::to)
.
def_readwrite
(
"
weight
"
, &GraphEdge::weight)
.
def_readwrite
(
"
directed
"
, &GraphEdge::directed);
//
GraphStep structure
py::class_<GraphStep>(m,
"
GraphStep
"
)
.
def
(py::init<
const
std::string&>(),
py::arg
(
"
operation
"
) =
"
"
)
.
def_readwrite
(
"
visitedNodes
"
, &GraphStep::visitedNodes)
.
def_readwrite
(
"
currentNodes
"
, &GraphStep::currentNodes)
.
def_readwrite
(
"
visitedEdges
"
, &GraphStep::visitedEdges)
.
def_readwrite
(
"
currentEdges
"
, &GraphStep::currentEdges)
.
def_readwrite
(
"
distances
"
, &GraphStep::distances)
.
def_readwrite
(
"
parents
"
, &GraphStep::parents)
.
def_readwrite
(
"
operation
"
, &GraphStep::operation);
//
Graph class
py::class_<Graph>(m,
"
Graph
"
)
.
def
(py::init<>())
.
def
(
"
add_node
"
, &Graph::addNode)
.
def
(
"
add_edge
"
, &Graph::addEdge)
.
def
(
"
build_adjacency_list
"
, &Graph::buildAdjacencyList)
.
def
(
"
bfs
"
, &Graph::bfs)
.
def
(
"
dfs
"
, &Graph::dfs)
.
def
(
"
dijkstra
"
, &Graph::dijkstra,
py::arg
(
"
start
"
),
py::arg
(
"
end
"
) = -
1
)
.
def
(
"
a_star
"
, &Graph::aStar)
.
def
(
"
kruskal
"
, &Graph::kruskal)
.
def
(
"
prim
"
, &Graph::prim)
.
def
(
"
get_nodes
"
, &Graph::getNodes)
.
def
(
"
get_edges
"
, &Graph::getEdges);
}
Back
|
FazBrowse Home
|
New Git URL