Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Data Structure Expert

Using a linked implementation of graph prepare a method "checkPath" that takes two nodes as input. The method must return:

True: If adding an edge between these two nodes form multiple paths to one of the input nodes within the graph.

False: Otherwise.

Use the subsequent implementation steps towards completion of your project:

Step 1: Create a graph (the input file format for graph is given in a section below)

Step 2: Give the two input nodes after the graph has been built from the command prompt.

Your program should print true or false based on the input provided at command prompt.

Use the subsequent assumptions:

1. Consider that no edge exists between the two input nodes given at command prompt.

2. Every node has no more than one incoming edge in sample input graph.

Hint: Add a parent field in node class. See if a general ancestor exists for input nodes given at command prompt. Note that your graph here is a directed graph.

Use the subsequent node and edge class definitions towards your implementation (make changes as needed, changes must not include deleting any members or classes):

Class Node {

Edge firstEdge;

Node nextNode;

int info;

}

Class Edge {

Node srcNode;

Edge nextEdge;

}

Sample graph input file:

5

1 2

1 3

1 4

The first line of the input shows the number of nodes in the graph.

After first line every other line represents an edge. Provide the source and destination nodes of the edge using two numbers.

For this sample graph, if the user inputs nodes 1 and 5, the "checkPath" function must print false.

In the same graph if the user inputs nodes 3 and 4 the "checkPath" function must print true. (If you add an edge from node 3 to node 4, two paths exists between node 1 and node 4)

Note that the "checkPath" function does not add an edge between input nodes provided at command prompt.

320_Implementation of graph.png

Data Structure, Computer Science

  • Category:- Data Structure
  • Reference No.:- M9719963
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Data Structure

Problem regarding the management program

Problem: Looks like its just adding a save and load feature to the same file you sent me for python 3.5 Until now, you have had to leave your team management program running on your computer indefinitely since you did no ...

Data Communication Delivering Information anywhere

Topic: Data Communication Delivering Information anywhere. Write a 9-12 pages paper in which you: Present an overview of the origin and history of the concept. Describe the current use of and attitude toward the concept. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As