Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The task is to use the graph data structure with the Depth First Search using this implementation in python to make an application besies the

The task is to use the graph data structure with the Depth First Search using this implementation in python to make an application besies the knights tour problem that uses the graphs ADT. State goal and objectives.

image text in transcribed

I'm not sure what applications could use this exactly, if someone could show me an example i'd know how to start and apply it to another probably similar application. Maybe something similar to the knights tour problem in which a person is on a 5x5 grid and can only move 1 space to the right and 1 space down at a time while having to visit every square in the grid. You are free to use your own application that was just a suggestion. Please implement in python and thank you! Also if you show code could it be screen shots so that i may note indentations?

from pythonds.graphs import Graph class DFSGraph(Graph) def _init__(self) superO._init__O self.time 0 def dfs(self) for aVertex in self: aVertex.setColor('white' aVertex.setPred(-1) for aVertex in self: if avertex.getColor() == 'White': self.dfsvisit(aVertex) def dfsvisit(self,startVertex): startVertex.setColor('gray') self.time += 1 startVertex.setDiscovery(self.time) for nextVertex in startVertex.getConnectionsO: if nextVertex.getColorO'white' nextVertex.setPred(startVertex) self.dfsvisit(nextVertex) startVertex.setColor('black self.time += 1 startVertex.setFinish(self.time)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

=+what information would you need about the compact disc industry?

Answered: 1 week ago