Find the minimum cost path from a designated start node to

Assignment Help Data Structure & Algorithms
Reference no: EM13350607

Find the Minimum Cost Path from a designated start node to a designated destination node in a graph.

ASSUMPTIONS:

• graph is already stored, including:
1) n, which is the number of graph nodes (where node are numbered 0 to N-1, not 1 to N)
2) edgeWeight - stored as EITHER:

  • an adjacency matrix with 3 possible types of values:
  • actual edge weights, 2) 0's in the diagonal, 3) "infinity" (i.e., MaxValue) for "no edge" node-pairs [conventionally, directed graphs use rowNumber as the source ("from") & columnNumber as the sink ("to")]
  • an array of adjacency lists

• GetWeight(a,b) method returns the numeric weight value for edge <a,b> from the stored graph - for

  • internal AdjacencyMatrix: use direct address to get edgeWeight[a,b] (or edgeWeight[a][b])
  • external AdjacencyMatrix: use direct address to read weight (after calculating offset, and seek-ing) [When calculating offset, allow for: a) headerRec; b) nodeNumbers being 0 to N=1, not 1 to N; c) weights being int or short or long or double... (as specified). So at start of program, calculate sizeOfHeaderRec, sizeOfARow, sizeOfAWeight once and for all to use in individual offset calculation each seek]
  • internal AdjacencyLists: search linkedList[a]for node b to get its weight [not vice versa, so as to accommodate directed graph]

• program has already gotten "from user": startNodeNumber & destinationNodeNumber (integers from 0 to N-1) [if user instead provides startNodeName & destinationNodeName, then these have been converted into corresponding 2 Numbers]

THE ALGORITHM

A) Initialize the 3 "working storage" arrays:

• included - booleans ["Is thisNode included yet in the group of nodes already used to revise distance . . . or not?"]

- set all to false, except start's included is set to true

• distance - integers (usually) ["What's the distance from start to thisNode SO FAR?"
- set each to its corresponding edgeWeight from the graph for start to thisNode which would be either: 1) weight for an actual edge OR 2) 0 for [start] OR 3) "infinity" for no-edge cases

• path - integers ["What's the nodeNumber of thisNode's predecessor on the path from start to thisNode?"

- set all to -1's, except use startNodeNumber instead when distance[i] has an actual edge weight

B) Do the Search: [Algorithm handles "normal case" - check if changes are needed for "special case", e.g., start == destination]
while destination is NOT yet included {

1. out of nodes NOT yet included, choose target node (its node number) as the node with the minimum distance value [target is a subscript not a distance]
2. target now becomes included [as having been evaluated in step 3 below, to see it's effect]
3. check all distance values [they're ceilings] to see which ones can be lowered [i.e., loop: i = 0 to N-1]

if included[i] is false [GUARD #1 against doing the BIG TEST unnecessarily]
if edgeWeight from target to i is a valid edgeWeight [GUARD#2 against doing ...]
[as opposed to a non-edge of 0 or "infinity"]
[Finally comes the "BIG TEST" - i.e., should distance[i] ceiling be lowered?]
if distance[target] + edgeWeight from target to i < distance[i]
then: 1) distance[i] = distance[target] + edgeWeight from target to i
2) path[i] = target
}

C) Report the answer:

• TOTAL DISTANCE of the minimum path from start to destination is found in distance[destination]

• FINAL PATH itself from start to destination is gotten from following the values in path array from [destination] to -1.

However, this gives the path in reverse order, from destination to start.

To instead correctly report the path from start to destination, either use:

o recursion - printing the results on the way back UP recursion
o OR push answers on a stack instead of printing them, then pop them off the stack to print them
o OR store them to an array (incrementing, starting at 0), then print the array in reverse (decrementing, stopping at 0).

Reference no: EM13350607

Questions Cloud

Metropolis toys metropolis toys is an independent : metropolis toys metropolis toys is an independent family-owned manufacturer of wooden toys. the toys are designed by
Question 1 explain five types of information systems and : question 1. explain five types of information systems and give an example of each.question 2. describe three common
A marketing plan for lawn care a landscaping design : a marketing plan for lawn care a landscaping design servicemy project all in lawn care will offer regular services will
Select the marketing industry then write about the dream : select the marketing industry then write about the dream job within the marketing industry.what skills will you develop
Find the minimum cost path from a designated start node to : find the minimum cost path from a designated start node to a designated destination node in a graph.assumptions bull
An asynchronous sequential logic circuit is given on page : an asynchronous sequential logic circuit is given on page by its primitive flow map i.e. initial state table where x1
1 polymer diffusion the figure below shows the result of a : 1 polymer diffusion the figure below shows the result of a particle tracking experiment where lateral positions of
Part a - performance objectivereport and monitor : part a - performance objectivereport and monitor expenditure and compare with financial plans so that recommendations
Metropolitan city church managementmetropolitan city church : metropolitan city church managementmetropolitan city church management mccm has hired you as a consultant to modernize

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Identify classes, functions, and algorithms

Detailed requirements. Using guidance provided in the text, (specifically chapters 12 and 13) develop your detailed requirements. Develop as many as possible but you must cover some detailed requirements for each of your high level requirements.

  What is difference between a state graph and a search tree

Describe how the problem of traveling from one city to another could be framed as a production system. What are the states? What are the productions?

  An independent set in a graph g

An independent set in a graph G is a set of vertices I in G such that no two vertices in I are adjacent (neighbors). The maximum independent set problem is, given a graph G, to compute an independent set of maximum size (maximum number of vertices) i..

  C++ program to evaluate expressions combining set union

Create a C++ program to evaluate expressions combining set union, set intersection and parentheses

  Explain solution of towers of hanoi problem

Classical Towers of Hanoi problem starts with a stack of n > = 1disks on one of three pegs. Solving problem needs moving stack from peg A to peg B in such a way which only one disc is moved at time and no disc can be placed on top of a disc smalle..

  Propose an efficient data structure

Propose an efficient data structure that may hold the tour operator's data using a normalization process. Describe each step of the process that will enable you to have a 2nd Normal Form data structure.

  Design a representation of display screen

Create a form that lists possible potatoes and toppings in a manner that is easy for counter servers and kitchen crew to scan, and can also be used as input for the inventory reorder system.

  Question 1you are required to provide suitable examples of

question 1you are required to provide suitable examples of your own for each part of the question where appropriateai

  Powerpoint presentation with the focus on stress management

Assume you have been asked to help new students identify ways in which they can manage their time so that they can be successful in an online learning environment.

  Perform the acyclic-topological sort algorithm

Perform the acyclic-topological sort algorithm on the directed graph having vertex set a-k and edges {(j; a);(j; g);(a; b);(a; e);(b; c);(c; k);(d; e);(e; c);(e; f);(e; i);(f; k); (g; d);(g; e);(g; h);(h; e);(h; i);(i; f);(i; k)} Show the state of th..

  Creating relational database about music performers

Create a relational database having information about music performers, their recordings, and the composers of the music they recorded.

  Determine the complexity of the test algorithm

using graphs (or spreadsheets). Remember the supplied data will NOT fit exactly any one curve, so your analysis of the data and your reasoning for which curve is most likely will determine your final grade on this lab.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd