Giter Club home page Giter Club logo

tree-search-library's Introduction

TREE SEARCH LIBRARY

Overview

A Generic Tree Search Library is made for exploring a Tree, created with the given input node information, using the corresponding comparator functions written based on their seen time or value, for each of the exploration strategy.

The Algorithms that can be implemeneted using this Tree Search Library are DFS, BFS, A-star, Greedy-Search where the next node in each of the strategy is picked from the Priority Queue.

In each of the traversal, the information at that particular iteration like average depth, max depth, branching factor are stored in an array and their variation for each of the traversal is analysed and plotted.


Input-Output Format

  • We need to enter the exploration strategy in CLI terminal
        ./a.out <Name of exploration strategy>
        Ex. ./a.out DFS
FOR VECTOR IMPLEMENTATION

Download entire repository or download the Vector_Implementation_TSL folder.

Enter your input in input.txt file as per the format specified below for DFS, BFS & GREEDY strategies

For A-STAR strategy, along with the format specified below...You'll also need to enter the ID for starting node as well as the target node.

For this implementation, first compile by gcc final.c main.c and after compiling run the program as per this format ./a.out [strategy name]

You can choose from the 4 strategies available DFS BFS GREEDY and A-STAR. For eg. if you want to use dfs traversal type ./a.out DFS

After entering strategy give the input in below specified format and press enter

FOR LINKEDLIST IMPLEMENTATION

Download entire repository or download the Linked-List Implementation folder.

Enter your input in input.txt file as per the format specified below for DFS, BFS & GREEDY strategies

For this implementation, first compile by gcc final.c main.c and after compiling run the program as per this format ./a.out [strategy name]

for this we have 3 strategy available DFS BFS and GREEDY for eg. if you want to do dfs traversal type ./a.out DFS

after entering strategy give the input in below specified format and press enter

  • Input format should be as shown:

       <number_of_nodes>:n
       <state_number> <value> <parent_state_number>
       
       ...
       ...
       n times
    
  • The information of the node including the iteration, state number, max depth, average depth and branching factor for each iteration in the tree traversal is printed. Also tree that was created is printed with each parent along with corresponding children in the ascending order of their state values.

  • Global array Output Format:

      <iteration> <state_number> <max_depth> <avg_depth> <Branching_Factor>
    
      ...
      ...
      n times
    

Algorithms Implemented

DFS:

  • In Depth First Traversal(DFS) starting with root node, we explore all the branches as far as possible before backtracking the nodes.

  • DFS is widely used algorithm in graphs and has many applications like detecting a cycle in graph, finding strongly connected components,topological Sorting, finding the existence of path between two nodes and so on.

BFS:

  • In Breadth First Traversal(BFS) starting with root node, we explore all the neighbouring nodes and then go to next depth level and explore all the nodes at that level and continue this till all the nodes at the maximum depth are explored.

  • BFS algorithm is also extensively used like in Social Networking Websites, GPS Navigation systems, MST in graphs and so on.

Greedy Search:

  • In our Greedy Search algorithm always the nodes with more data value are explored at each level till it reaches the maximum depth and followed by backtracking the nodes with the same strategy.

  • Greedy Search Algorithm is useful where we need to select the best option available at that moment without worrying about the future result it would bring like in case of Kruskal's algorithm,Dijkshtra algorithm,single source shortest path problem in graphs, and in many more.

A-STAR:

  • A-STAR search algorithm one of the best techniques used in path-finding and graph traversals. Since here we have a tree search library, we made certain modifications to A* search. A* Search algo is a smart algorithm which decides the next point of traversal based on certain parameters and heuristics which are not only predefined but also get updated as the traversal through the Tree takes place. We have modified this algo to traverse only those nodes which lie on shortest path from starting node to destination node. Edge length over here is defined as |val(parent_node) - val(current node)|. To predefine the heuristic h, we have also made use of Floyd Warshall algorithm to precompute the shortest path between all pairs of nodes.
  • The algorithm efficiently plots a walkable path between multiple nodes, or points, on the graph. On a map with many obstacles, pathfinding from points start to end can be difficult. For example, a robot will continue on its path until it encounters an obstacle. With A*, a robot would instead find a best possible path and simultaneously avoiding the obstacles on its intended path. A* is an extension of Dijkstra's algorithm with some characteristics of breadth-first search (BFS). This algorithm is also put into use in many games which makes use of maps and best possible route to destination node.

Graphs for vector implementation

DFS

DFS

BFS

BFS

GREEDY

GREEDY


Graphs for linked list implementation

DFS

DFS

BFS

BFS

GREEDY

GREEDY


Contributers TEAM 58

  • Greeshma

  • Yash

  • Nikhil

  • Sanyam

  • Astitva

THANK YOU !!!

Go to Top

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.