GithubHelp home page GithubHelp logo

daa_assign_6's Introduction

Assignment - 3

Team Members

Enrollment No. Name GithubId
IIB2019007 Aditya Raj Adityahulk
IIB2019008 Shyam Tayal shyamTayal
IIB2019009 Abhijeet Sonkar Abhijeet-sonkar

Group No-"22"

Faculty Name-"Dr. Rahul Kala"

Mentor Name- "Md. Meraz"


Problem Statement

Given a directed graph, find out if a vertex v is reachable from another vertex u for all vertex pairs (u, v) in the given graph. Here reachable mean that there is a path from vertex u to v. The reach-ability matrix is called transitive closure of a graph.


How to use code

First Step is to Download/clone the repository

git clone https://github.com/shyamTayal/daa_assign_6

Run the Code

Change directory to the solution folder

cd daa_assign_6/Solution/
g++ closure_dfs.cpp -o dfs
./dfs

Output (by Solution files)

Testcase - 1

Enter the number of node : 4
Enter the number of edges : 5
0 1
0 2
1 2
2 0
2 3

****************** Reachability matrix ********************
1 1 1 1
1 1 1 1
1 1 1 1
0 0 0 1

***********************************************************

Enter the number of queries to check if v can reach u : 3
Enter the pair (v,u) to check if node v can reach node u : 2 1
Yes, 2 can reach 1
Enter the pair (v,u) to check if node v can reach node u : 3 0
No, 3 cannot reach 0
Enter the pair (v,u) to check if node v can reach node u : 1 3
Yes, 1 can reach 3

Personalised Initialization Method (optional)

Change Directory to Testing Directory

cd daa_assign_6/testing/
g++ testcase_gen.cpp -o inp
./inp

Above commands will create 1 testing file :

  • input_testcase.txt

Above testing file contains graph input for 100 testcases with with value of No. of nodes ranging from 20 to 220 and No. of edges ranging from 10 to 2010


Testing

Testing files have already been added so above step can be skipped. To be run in Testing Directory

Test Flloyd Warshal Algorithm

g++ test_flloyd -o flloyd
./floyyd

Test DFS Algorithm

g++ test_dfs -o dfs
./floyyd
  • Both Above commands create two files one containing the reachability matrix generated by the input graph and other containing the Time complexity calculation data.

Theory

  • Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking.

  • The Floyd Warshall Algorithm is for solving the All Pairs Shortest Path problem. The problem is to find shortest distances between every pair of vertices in a given edge weighted directed Graph.


Analysis-

oie_Qi4jYrf3sVDA

DFS   Flloyd

Time Complexity

DFS vs  N Flloyd vs  N

Space Complexity

Both algorithms have space complexity O(N2)
Since for the purpose of storing the graph elements (nodes and edges) and reachability matrix in form of a 2D - array


References

https://en.wikipedia.org/wiki/Floyd\%E2\%80\%93Warshall\_algorithm

https://www.geeksforgeeks.org/depth-first-search-or-dfs-for-a-graph/

daa_assign_6's People

Contributors

abhijeet-sonkar avatar adityahulk avatar shyamtayal avatar

Watchers

 avatar

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.