Author: Satwik Srivastava
Profiles:
- LinkedIn : https://www.linkedin.com/in/satwiksrivastava/
- Twitter : @Satwik_9
- Github : https://github.com/Satwik-S9
Description:
In this script I have created all the basic search strategies employed in Artificial Intelligence.
These include but are not limited to the following:
- Uninformed Search Strategies:
- BFS
- DFS
- Uniform Cost Search
- Informed Search Strategies:
- A Star Search
- Game Search Strategies:
- Alpha-Beta Search
- Backtracking Search
- Breadth First Search (BFS)
- Depth First Search (DFS)
- Uniform Cost Search
- A Star Search
- Alpha-Beta Search
All These algorithms are implemented on the tree and the graph data-structures and are used to solve the shortest path problem.
!NOTE! : Currently I have not packaged this as a module so you have to clone it directly into your working directory.
Just clone
or download
the SearchStrategies.py
file and import it as shown below.
import SearchStrategies as ss
print(ss.__version__)
This should print the current version of the module. If not it is either not downloaded or not placed in your working directory.
BFS
andDFS
classes are now fully available and all the methods required are now completed. Some handy functions have been added too.- The
find
function is added to find a value in a Binary Tree. - Added
create_adjacency_list
for trees to convert them into graphs for interoperability. - All shortest path methods are now available and return
path, cost
as there return parameters and across the board a little homogeniety has been introduced.
- Added
create_adjacency_list
for trees to convert them into graphs for interoperability. - Creating a tree can now initialize the keys and the parents (uses
initialize_parents
andinitialize_keys
) - The
DFS
class now supports the shortest path calculation for trees.
- Changed the verbose functionality across
BFS
class to introduce more homogeniety between outputs. DFS
Class has been added to the module with thetraverse()
method for bothtrees
andgraphs
.- NOTE: The traverse method for tree currently does preorder traversal.
- Fixed some bugs in the implementation of
BFS
.
- The
BFS
Class has been added into the module along with relevant supporting data-structures such asGraph
andTree
. This class supports methods for traversal of the data structure and to find the shortest path given a source and a target.
- Added Basic Data Structures such as
Tree
andGraphs
and added traversal Methods for the same to theBFS
Class.
The Tree Data Structure is a fundamental datastructure for proper and efficient storage and organisation of data.
Source: GeeksForGeeks
A binary tree is a data-structure that in which each node has atmost two children. It can be represented as tuple
(L, S, R)
The binary tree can be created using this module as follows:
import SearchStrategies as ss
root_single = ss.TreeNode(4)
tree_tuple = ((1, 3, None), 2, ((None, 3, 4), 5, (6, 7, 8)))
root = ss.create_tree(tree_tuple)
NOTE: Currently Working on Documentation. Please refer to the test.ipynb
for an onhande demo.
- Package the file into a python Module.
- Add BSTs to the project.
- Add Informed Search Strategies such as
Astar
search.