diff --git a/docs/html/best__first_8h_source.html b/docs/html/best__first_8h_source.html index f73dcfec..69122b90 100644 --- a/docs/html/best__first_8h_source.html +++ b/docs/html/best__first_8h_source.html @@ -92,74 +92,74 @@
6#include <iostream>
7#include <unordered_map>
8#include <queue>
-
9#endif
-
10
-
-
14template <typename T> class best_first{
-
15private:
-
16 std::unordered_map<T, std::vector<std::pair<T, double> > > adj;
-
17 std::unordered_map<T, double> nodes;
-
18
-
19public:
-
20
-
-
26 explicit best_first(std::unordered_map<T, std::vector<std::pair<T, double> > > v = {}){
-
27 if(!v.empty()){
-
28 this->adj = v;
-
29 }
-
30 }
+
9#include <climits>
+
10#endif
+
11
+
+
15template <typename T> class best_first{
+
16private:
+
17 std::unordered_map<T, std::vector<std::pair<T, double> > > adj;
+
18 std::unordered_map<T, double> nodes;
+
19
+
20public:
+
21
+
+
27 explicit best_first(std::unordered_map<T, std::vector<std::pair<T, double> > > v = {}){
+
28 if(!v.empty()){
+
29 this->adj = v;
+
30 }
+
31 }
-
31
-
-
37 void insert_node(T u, double val){
-
38 nodes[u] = val;
-
39 }
+
32
+
+
38 void insert_node(T u, double val){
+
39 nodes[u] = val;
+
40 }
-
40
41
-
-
49 bool has_edge(T u, T v){
-
50 if(adj.find(u) != adj.end()){
-
51 for(std::pair<T, double> &x : adj[u]){
-
52 if(x.first == v){
-
53 return true;
-
54 }
-
55 }
-
56 }
-
57 return false;
-
58 }
+
42
+
+
50 bool has_edge(T u, T v){
+
51 if(adj.find(u) != adj.end()){
+
52 for(std::pair<T, double> &x : adj[u]){
+
53 if(x.first == v){
+
54 return true;
+
55 }
+
56 }
+
57 }
+
58 return false;
+
59 }
-
59
-
-
65 void add_edge(T u, T v){
-
66 try{
-
67 if(nodes.find(u) != nodes.end() && nodes.find(v) != nodes.end()){
-
68 adj[u].push_back(std::make_pair(v, nodes[v]));
-
69 }
-
70 else{
-
71 throw std::logic_error("One of the two nodes that passed to the function do not exist in the graph");
-
72 }
-
73 }
-
74 catch(std::logic_error &e){
-
75 std::cerr << e.what() << '\n';
-
76 }
-
77 }
+
60
+
+
66 void add_edge(T u, T v){
+
67 try{
+
68 if(nodes.find(u) != nodes.end() && nodes.find(v) != nodes.end()){
+
69 adj[u].push_back(std::make_pair(v, nodes[v]));
+
70 }
+
71 else{
+
72 throw std::logic_error("One of the two nodes that passed to the function do not exist in the graph");
+
73 }
+
74 }
+
75 catch(std::logic_error &e){
+
76 std::cerr << e.what() << '\n';
+
77 }
+
78 }
-
78
-
-
86 bool search(T start, T end){
-
87 if(adj.empty()){
-
88 return false;
-
89 }
-
90 std::unordered_map<T, bool> visited;
-
91 std::priority_queue<std::pair<T, double>, std::vector<std::pair<T, double> >, std::greater<std::pair<T, double> > > q;
-
92 q.push({start, nodes[start]});
-
93 visited[start] = true;
-
94 while(!q.empty()){
-
95 int64_t size = q.size();
-
96 for(int64_t i = 0; i<size; i++){
-
97 std::pair<T, double> current = q.top();
-
98 std::cout << current.first << " " << current.second << '\n';
+
79
+
+
87 bool search(T start, T end){
+
88 if(adj.empty()){
+
89 return false;
+
90 }
+
91 std::unordered_map<T, bool> visited;
+
92 std::priority_queue<std::pair<T, double>, std::vector<std::pair<T, double> >, std::greater<std::pair<T, double> > > q;
+
93 q.push({start, nodes[start]});
+
94 visited[start] = true;
+
95 while(!q.empty()){
+
96 int64_t size = q.size();
+
97 for(int64_t i = 0; i<size; i++){
+
98 std::pair<T, double> current = q.top();
99 if(current.first == end){
100 return true;
101 }
@@ -181,12 +181,12 @@
115
116#endif
117
-
best first class
Definition best_first.h:14
-
void add_edge(T u, T v)
add_edge function
Definition best_first.h:65
-
best_first(std::unordered_map< T, std::vector< std::pair< T, double > > > v={})
best_first constructor
Definition best_first.h:26
-
bool has_edge(T u, T v)
has_edge function
Definition best_first.h:49
-
void insert_node(T u, double val)
insert_node function
Definition best_first.h:37
-
bool search(T start, T end)
search function
Definition best_first.h:86
+
best first class
Definition best_first.h:15
+
void add_edge(T u, T v)
add_edge function
Definition best_first.h:66
+
best_first(std::unordered_map< T, std::vector< std::pair< T, double > > > v={})
best_first constructor
Definition best_first.h:27
+
bool has_edge(T u, T v)
has_edge function
Definition best_first.h:50
+
void insert_node(T u, double val)
insert_node function
Definition best_first.h:38
+
bool search(T start, T end)
search function
Definition best_first.h:87