ppt of new graph search method

20
UNDER THE GUIDANCE OF MR.M.D.GULZAR, ASSISTANT PROFESSOR. BY…. V.Chandana (09791A0555)

Upload: amithreddy6

Post on 08-Nov-2014

12 views

Category:

Documents


1 download

DESCRIPTION

introduce new graph search meathod

TRANSCRIPT

Page 1: Ppt of New Graph Search Method

UNDER THE GUIDANCE OF MR.M.D.GULZAR, ASSISTANT PROFESSOR.

PRESENTED BY….

V.Chandana (09791A0555)

Page 2: Ppt of New Graph Search Method

ABSTRACT

The theme of this paper is to introduce a “New Graph Search Method”. Many operations requires us to visit all vertices that can be reached from a given start vertex. To fulfill those requirements we already have two standard ways to search. Those are Depth-First Search and Breadth First Search. A part from these we can do as following one .In this method we use double-ended queue.

Page 3: Ppt of New Graph Search Method

EXISTED METHODS MOSTLY IN USE

Depth-first search method Breadth-first search method

DRAWBACKS OF EXISTED METHODS Backtracking is the major drawback of DFS. DFS is less time efficient. BFS is less space effecient. Counterexamples cannot be obtained directly from the queue.These

disadvantages are due to the use of queues that store all the states at some level and do not contain any path information[4],[5].

.

Page 4: Ppt of New Graph Search Method

PROPOSED METHOD

I propose a “New Graph Search Method” which uses a double ended queue through which we can enter and delete from both the sides,two registers to keep track of number of visited nodes and number of elements in the dequeue and an array.

FEATURES OF PROPOSED METHOD We can delete the dequeue within a single instance when the count of two

registers will be same. It is space efficient. It is time efficient. We can get the path information directly from the dequeue

Page 5: Ppt of New Graph Search Method

METHODS AND OPERATIONS INVOLVED

ALGORITHM

STEP 1: Initialize the array and insert root vertex and first level child nodes in a sequential order into an array

STEP 2 :Initialize two counter registers to keep track of visited number of nodes and elements in the dequeue

STEP 3: Initialize the dequeue,select array[i++] element from the array and place it into the dequeue.

STEP 4 :Check whether the element entering into dequeue is target element .If so return search complete or else go to step 5.

STEP 5: Now mark the element in the dequeue as visited and place all the child nodes of that element into the dequeue through rightlink.

STEP 6: Check whether number of visited nodes are equal to number of elements in dequeue if true then delete the dequeue and goto step3 else goto step7

Page 6: Ppt of New Graph Search Method

STEP 7: Now select the rightmost element in the dequeue and mark it as visited and if it has any child elements insert them into dequeue through rightlink.

STEP 8: If at step7 there are no child elements for the rightmost element in the dequeue delete the respective element from dequeue through rightlink again perform step6 and if at step7 the rightmost element is already a visited vertex directly delete the element through right link and perform step6.

STEP 9: If any particular path is to be noted for any source and destination element perform 1-8 steps and after reaching the destination insert the source element into the dequeue from the leftlink and take the path from dequeue by simply ignoring all unvisited elements except destination element.

Page 7: Ppt of New Graph Search Method

PSEUDO CODE

New search(v)

{

Initialize an array with v and all first level child nodes of v in it

For(i=1;i<=n;i++)

{

Initialize DQ to be dequeue with only a[i] element in it.Mark it as visited and add child nodes related to it into the dequeue through rlink(if any)

Let u be the rightmost element in dequeue

While(no of visited nodes!=elements in dequeue)

{

If(u!visited)

{

Add those children to DQ

}

Page 8: Ppt of New Graph Search Method

Else delete u from dequeue through rlink

U=next rightmost element in dequeue

}

Delete dequeue

}

/*through rlink add v to the dequeue

Note the path from dequeue by ignoring unvisited nodes for knowing the path

}

Page 9: Ppt of New Graph Search Method

EXAMPLE OF NEW GRAPH SEARCH TRAVERSAL METHOD[2]

1

98

76

4

5

32

Page 10: Ppt of New Graph Search Method

FORMATION OF AN ARRAY

1 2 3 4

i=0 i=1 i=2 i=3

1

98

76

4

5

32

Page 11: Ppt of New Graph Search Method

FOR CASE I=1

2

1

98

76

4

5

32

2* 5

2* 5* 8

2* 5* 8*

No of elements

No of visited nodes

1 0

2 1

3 2

3 3

Page 12: Ppt of New Graph Search Method

FOR CASE I=2

3

3*

No of elements

No of visited nodes

1 0

1 1

Page 13: Ppt of New Graph Search Method

FOR CASE I=3

4

4* 6 7* 8 9

4* 6 7* 8 9*

4* 6 7

4* 6 7* 8

4* 6 7*

4* 6

4* 6 7* 8*

No ofElements

No ofVisited nodes

1 0

3 1

5 2

5 3

4 2

4 3

3 2

2 1

2 2 4* 6*

Page 14: Ppt of New Graph Search Method

WAY TO FIND PATH OF AN ELEMENT

4* 6 7* 8 9

1 4 7 9

Page 15: Ppt of New Graph Search Method

EXPECTED RESULT

1

98

76

4

5

32

Page 16: Ppt of New Graph Search Method

COMPARISION OF GRAPH SEARCH METHODS[4,5]

DEPTH FIRST SEARCH BREADTH FIRST SEARCH

NEW SEARCH METHOD

Page 17: Ppt of New Graph Search Method

LIMITATIONS

This method will be efficient only for directed graphs.

Page 18: Ppt of New Graph Search Method

FUTURE WORKS

In Future any further new method can be found.

Page 19: Ppt of New Graph Search Method

REFERENCES

[1] For “Data Content”, Data Structures and Algorithms in c++, Michael T.Goodrich, Robert Tamassia, David Mount, ISBN: 9812-53-042-8, Pgno-595.[2]For “Information regarding depth first search and breadth search”, Data Structures Algorithms and Applications in c++, SartajSahani University press pvt ltd.,Second edition universities press,ISBN:978-81-7371-522-8, pg no-644.[3] For “Breadth First Search Graph”, http://en.wikipedia.org/wiki/Breadth-first Search.[4]For “Depth First Search Graph”, http://en.wikipedia.org/wiki/Depth-first Search.

Page 20: Ppt of New Graph Search Method