diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 238646a5..7bfa80d0 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -424,46 +424,47 @@  Cavl_treeClass for AVL tree  CIteratorIterator class  Cbasic_jsonNamespace for Niels Lohmann - CbstClass for BST tree - CIteratorIterator class - Cbyte_container_with_subtypeInternal type for a backed binary type - CCatch_global_namespace_dummy - Ccircular_linked_listCircular linked list class - CIteratorIterator class - CDBSCANDBSCAN clustering algorithm class - Cdequeue_listDequeue list class - CIteratorIterator class - Cdoubly_linked_listDoubly linked list class - CIteratorIterator class - CdsuDisjoint set class - Cfrequency_listSelf-learning Frequency List that maintains a list of elements in descending order of their frequency - CIterator - CgraphClass for Unweighted Graph - Chash_tableA simple implementation of a hash table - CIteratorIterator class - Chill_climbingHill climbing class - Cinterval_treeInterval tree class - CIteratorIterator class - Cjson_pointerJSON Pointer defines a string syntax for identifying a specific value within a JSON document - Cjson_saxSAX interface - Ckmeans - Clinear_regressionClass for linear regression algorithm - Clinked_listSingle linked list class - CIteratorIterator class - CMat1dClass for 1-dimensional Matrix - CIteratorIterator class - CMat2dClass for 2-dimensional Matrix - CIteratorIterator for Mat2d class - Cmin_heapMin heap class - Cordered_mapMinimal map-like container that preserves insertion order - Cskip_listSkip_list class - CIteratorIterator class - Csplay_treeSplay tree class - CIteratorIterator class - Cstack_listStack_list class - CIteratorIterator class - CtrieTrie class - Cweighted_graphClass for weighted graph + Cbest_firstBest first class + CbstClass for BST tree + CIteratorIterator class + Cbyte_container_with_subtypeInternal type for a backed binary type + CCatch_global_namespace_dummy + Ccircular_linked_listCircular linked list class + CIteratorIterator class + CDBSCANDBSCAN clustering algorithm class + Cdequeue_listDequeue list class + CIteratorIterator class + Cdoubly_linked_listDoubly linked list class + CIteratorIterator class + CdsuDisjoint set class + Cfrequency_listSelf-learning Frequency List that maintains a list of elements in descending order of their frequency + CIterator + CgraphClass for Unweighted Graph + Chash_tableA simple implementation of a hash table + CIteratorIterator class + Chill_climbingHill climbing class + Cinterval_treeInterval tree class + CIteratorIterator class + Cjson_pointerJSON Pointer defines a string syntax for identifying a specific value within a JSON document + Cjson_saxSAX interface + Ckmeans + Clinear_regressionClass for linear regression algorithm + Clinked_listSingle linked list class + CIteratorIterator class + CMat1dClass for 1-dimensional Matrix + CIteratorIterator class + CMat2dClass for 2-dimensional Matrix + CIteratorIterator for Mat2d class + Cmin_heapMin heap class + Cordered_mapMinimal map-like container that preserves insertion order + Cskip_listSkip_list class + CIteratorIterator class + Csplay_treeSplay tree class + CIteratorIterator class + Cstack_listStack_list class + CIteratorIterator class + CtrieTrie class + Cweighted_graphClass for weighted graph diff --git a/docs/html/best__first_8h_source.html b/docs/html/best__first_8h_source.html new file mode 100644 index 00000000..f73dcfec --- /dev/null +++ b/docs/html/best__first_8h_source.html @@ -0,0 +1,196 @@ + + + + + + + +AlgoPlus: /Users/spirosmag/Documents/AlgoPlus/src/machine_learning/search_algorithms/best_first/best_first.h Source File + + + + + + + + + + + +
+
+ + + + + + + +
+
AlgoPlus v0.1.0 +
+
+
+ + + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ + +
+
+
best_first.h
+
+
+
1#pragma once
+
2#ifndef BEST_FIRST_H
+
3#define BEST_FIRST_H
+
4
+
5#ifdef __cplusplus
+
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 }
+
+
31
+
+
37 void insert_node(T u, double val){
+
38 nodes[u] = val;
+
39 }
+
+
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 }
+
+
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 }
+
+
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';
+
99 if(current.first == end){
+
100 return true;
+
101 }
+
102 q.pop();
+
103 for(std::pair<T, double> &x: adj[current.first]){
+
104 if(visited.find(x.first) == visited.end() && x.second <= nodes[current.first]){
+
105 visited[x.first] = true;
+
106 q.push({x.first, nodes[x.first]});
+
107 }
+
108 }
+
109 }
+
110 }
+
111 return false;
+
112 }
+
+
113};
+
+
114
+
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
+
+ + + + diff --git a/docs/html/classbest__first-members.html b/docs/html/classbest__first-members.html new file mode 100644 index 00000000..671b1467 --- /dev/null +++ b/docs/html/classbest__first-members.html @@ -0,0 +1,92 @@ + + + + + + + +AlgoPlus: Member List + + + + + + + + + + + +
+
+ + + + + + + +
+
AlgoPlus v0.1.0 +
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
+
best_first< T > Member List
+
+
+ +

This is the complete list of members for best_first< T >, including all inherited members.

+ + + + + + +
add_edge(T u, T v)best_first< T >inline
best_first(std::unordered_map< T, std::vector< std::pair< T, double > > > v={})best_first< T >inlineexplicit
has_edge(T u, T v)best_first< T >inline
insert_node(T u, double val)best_first< T >inline
search(T start, T end)best_first< T >inline
+ + + + diff --git a/docs/html/classbest__first.html b/docs/html/classbest__first.html new file mode 100644 index 00000000..e0a57ac6 --- /dev/null +++ b/docs/html/classbest__first.html @@ -0,0 +1,320 @@ + + + + + + + +AlgoPlus: best_first< T > Class Template Reference + + + + + + + + + + + +
+
+ + + + + + + +
+
AlgoPlus v0.1.0 +
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
+
+Public Member Functions | +List of all members
+
best_first< T > Class Template Reference
+
+
+ +

best first class + More...

+ +

#include <best_first.h>

+ + + + + + + + + + + + + + + + + +

+Public Member Functions

 best_first (std::unordered_map< T, std::vector< std::pair< T, double > > > v={})
 best_first constructor
 
void insert_node (T u, double val)
 insert_node function
 
bool has_edge (T u, T v)
 has_edge function
 
void add_edge (T u, T v)
 add_edge function
 
bool search (T start, T end)
 search function
 
+

Detailed Description

+
template<typename T>
+class best_first< T >

best first class

+

Constructor & Destructor Documentation

+ +

◆ best_first()

+ +
+
+
+template<typename T >
+ + + + + +
+ + + + + + + +
best_first< T >::best_first (std::unordered_map< T, std::vector< std::pair< T, double > > > v = {})
+
+inlineexplicit
+
+ +

best_first constructor

+
Parameters
+ + +
vunordered_map<T, pair<T, int64_t> > initializer vector. Default = {}
+
+
+ +
+
+

Member Function Documentation

+ +

◆ add_edge()

+ +
+
+
+template<typename T >
+ + + + + +
+ + + + + + + + + + + +
void best_first< T >::add_edge (T u,
T v )
+
+inline
+
+ +

add_edge function

+
Parameters
+ + + +
uthe first node
vthe second node
+
+
+ +
+
+ +

◆ has_edge()

+ +
+
+
+template<typename T >
+ + + + + +
+ + + + + + + + + + + +
bool best_first< T >::has_edge (T u,
T v )
+
+inline
+
+ +

has_edge function

+
Parameters
+ + + +
uthe first node
vthe second node
+
+
+
Returns
true if there exist an edge between u and v
+
+false otherwise
+ +
+
+ +

◆ insert_node()

+ +
+
+
+template<typename T >
+ + + + + +
+ + + + + + + + + + + +
void best_first< T >::insert_node (T u,
double val )
+
+inline
+
+ +

insert_node function

+
Parameters
+ + + +
uthe node ID
valthe heuristic value of node u
+
+
+ +
+
+ +

◆ search()

+ +
+
+
+template<typename T >
+ + + + + +
+ + + + + + + + + + + +
bool best_first< T >::search (T start,
T end )
+
+inline
+
+ +

search function

+
Parameters
+ + + +
startstarting node
endend node
+
+
+
Returns
true if search found the end node.
+
+false otherwise
+ +
+
+
The documentation for this class was generated from the following file: +
+ + + + diff --git a/docs/html/classes.html b/docs/html/classes.html index cedccde8..518955b3 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -82,7 +82,7 @@
actual_object_comparator (detail)
adl_serializer
always_false (Catch)
Approx (Catch::Detail)
ApproxMatcher (Catch::Matchers::Vector)
as (Catch::Generators)
AssertionHandler (Catch)
AssertionInfo (Catch)
AssertionReaction (Catch)
AutoReg (Catch)
avl_tree
B
-
basic_json
binary_reader (detail)
binary_writer (detail)
BinaryExpr (Catch)
boundaries (detail::dtoa_impl)
bst
byte_container_with_subtype
+
basic_json
best_first
binary_reader (detail)
binary_writer (detail)
BinaryExpr (Catch)
boundaries (detail::dtoa_impl)
bst
byte_container_with_subtype
C
cached_power (detail::dtoa_impl)
Capturer (Catch)
CasedString (Catch::Matchers::StdString)
CaseSensitive (Catch)
Catch_global_namespace_dummy
char_traits (detail)
char_traits< signed char > (detail)
char_traits< unsigned char > (detail)
is_callable_impl< true, T >::Check (matplotlibcpp::detail)
ChunkGenerator (Catch::Generators)
circular_linked_list
conjunction (detail)
conjunction< B > (detail)
conjunction< B, Bn... > (detail)
container_input_adapter_factory (detail::container_input_adapter_factory_impl)
container_input_adapter_factory< ContainerType, void_t< decltype(begin(std::declval< ContainerType >()), end(std::declval< ContainerType >()))> > (detail::container_input_adapter_factory_impl)
ContainsElementMatcher (Catch::Matchers::Vector)
ContainsMatcher (Catch::Matchers::StdString)
ContainsMatcher (Catch::Matchers::Vector)
Counts (Catch)
diff --git a/docs/html/dir_25d959d4ce8d574b2ba2fa1ac2a6ecb2.html b/docs/html/dir_25d959d4ce8d574b2ba2fa1ac2a6ecb2.html new file mode 100644 index 00000000..a8094c7a --- /dev/null +++ b/docs/html/dir_25d959d4ce8d574b2ba2fa1ac2a6ecb2.html @@ -0,0 +1,94 @@ + + + + + + + +AlgoPlus: /Users/spirosmag/Documents/AlgoPlus/src/machine_learning/search_algorithms/best_first Directory Reference + + + + + + + + + + + +
+
+ + + + + + + +
+
AlgoPlus v0.1.0 +
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ + +
+
+
best_first Directory Reference
+
+
+ + + + +

+Files

 best_first.h
 
+
+ + + + diff --git a/docs/html/dir_d8dd639a3dd403e6a6ca89cf2a46a04b.html b/docs/html/dir_d8dd639a3dd403e6a6ca89cf2a46a04b.html index e28e95b3..b010317b 100644 --- a/docs/html/dir_d8dd639a3dd403e6a6ca89cf2a46a04b.html +++ b/docs/html/dir_d8dd639a3dd403e6a6ca89cf2a46a04b.html @@ -82,6 +82,8 @@ + +

Directories

 best_first
 
 hill_climbing
 
diff --git a/docs/html/doxygen_crawl.html b/docs/html/doxygen_crawl.html index 982a8ab3..4c6d3378 100644 --- a/docs/html/doxygen_crawl.html +++ b/docs/html/doxygen_crawl.html @@ -58,6 +58,7 @@ + @@ -92,6 +93,8 @@ + + @@ -748,6 +751,7 @@ + diff --git a/docs/html/files.html b/docs/html/files.html index c4fe570c..8ba19559 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -152,8 +152,10 @@   linear_regression  lin_reg.h   search_algorithms -  hill_climbing - hill_climbing.h +  best_first + best_first.h +  hill_climbing + hill_climbing.h   visualization   graph_visual  graph_visualization.h diff --git a/docs/html/functions_a.html b/docs/html/functions_a.html index c1d84452..62a7f4bb 100644 --- a/docs/html/functions_a.html +++ b/docs/html/functions_a.html @@ -76,7 +76,7 @@

- a -