Question: Need Help Python only Using a linked list, and the list of nodes (A-N), what is the shortest possible route that visits each city and
Need Help
Python only
Using a linked list, and the list of nodes (A-N), what is the shortest possible route that visits each city and returns to the origin city (without visiting each city)?
Construct a linked list resembling the node A through N and then plot the fastest course.
You will have to create an abstract node class.
class Node: ##A simple example class def init (self, name): self.name name # instance variable unique to each instance self.nextNodes # [] self.paths def add_nextNodes(self, nextNode, path): self.nextNodes.append(nextNode) self.paths.appendlpath) def f(self) return 'hello world strNode input('Enter the starting node:1 a Routes = [m start Nodel"Start") A Node("A B - Nodel"B") C Node("C") D Node("D") E Node("E") F Node("F" G Node("G" H Nodel"H") I Node("l") J Node("") K- Node("K") Node("L") class Node: ##A simple example class def init (self, name): self.name name # instance variable unique to each instance self.nextNodes # [] self.paths def add_nextNodes(self, nextNode, path): self.nextNodes.append(nextNode) self.paths.appendlpath) def f(self) return 'hello world strNode input('Enter the starting node:1 a Routes = [m start Nodel"Start") A Node("A B - Nodel"B") C Node("C") D Node("D") E Node("E") F Node("F" G Node("G" H Nodel"H") I Node("l") J Node("") K- Node("K") Node("L")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
