Algorithm of prim

Assignment Help Data Structure & Algorithms
Reference no: EM13728142

Introduction

This coursework builds on the first coursework, and requires you to add functionality to your solution to that coursework (or you can use the example solution to the first coursework if you like).

There are two things you have to do.

1) Find an efficient way of cabling together the stations.

Suppose that you have to run cables between the stations, in such a way that every station is connected, directly or indirectly, to every other station. The cables have to run along the routes between the stations. You are required to cable up the network in such a way as to minimise the length of cable used. The appendix explains how you can do this.

2) Find the shortest route between any two points. The completed program must allow the user to find the shortest route between any two points. You can use Dijkstra's algorithm to do this (as set out in lecture 5).

Functional Requirements

In addition to the functional requirements set out in the specification of coursework, the new program must meet the following:

FR5

In addition to the elements set out in the previous specification, the GUI should contain the following elements:

  • A drop down box, or a set of radio buttons, allowing the user to select one of three options labelled "Network", "Span Tree", and "Route". We will refer to this as the Mode
  • Two drop down boxes, each of which lists the names of the stations in the network, and allows the user to select one of those names. We shall refer to these as the Start Station Selectorand the Destination Station Selector.

FR6

If "Span Tree" is selected on the mode selector, and if a network has previously been read, then the graph area should be updated to display a network of cables that cables together the stations in the most efficient way.

FR7

If "Route" is selected on the mode selector, and if a network has previously been read, then the graph area should be updated to show a shortest route between the stations selected by the Start

Station Selector, and Destination Station Selector.

FR8

If "Network" is selected on the mode selector, and if a network has previously been read, then that network is displayed.

Non-functional Requirements

In addition to the non-functional requirements set out in the specification of coursework 1, your application should meet the following:

NFR4

Prim's algorithm should be used to find a minimum spanning tree (see FR6).

NFR5

Dijkstra's  algorithm should be used to find a shortest path between two stations (FR7).

Some notes on implementation:

Some definitions of Dijkstra's algorithm refer to a priority queue of vertices. It is therefore tempting to think that you can use the java class PriorityQueue in an implementation of the algorithm. However there is a catch: The Java PriorityQueue class does not allow the priority of elements to be changed after they have been added. There are ways around this, but it might be simplest not to use a PriorityQueue. If you are tempted to use a SortedSet implementation when implementing Prim's algorithm, bear in mind that the Comparator used when creating a SortedSet must be consistent with the equals() method of the elements it contains. It might be easier to use a List implementation and sort it using the Collections.sort() method.

What you have to submit

You should submit two files:

1) A .zip file containing all of your code, preferably as a Netbeans project.

2) A .doc or .docx file containing a short reflection on the extent to which you feel that you have met the functional and non-functional requirements set out in this document.

Mark Scheme

For meeting FR5 2 marks

For meeting FR6 and NFR4 4 marks

For meeting FR7 and NFR5 4 marks

For meeting FR8 1 marks

For the quality of your code 7 marks

For the reflection on your degree of success2 marks

Appendix: Spanning trees and Prim's algorithm 

If G is a graph then:

A subgraph of G is a graph, each of whose vertices belong to G, and each of whose edges belong to G. In other words it is a part of the graph G.

A spanning tree of G is a connected subgraph of G that is connected, contains all of the vertices of G and contains no cycles.

A minimum spanning tree of G is a spanning tree such that the total length of all the arcs that it contains is as small as possible. In other words there is no other spanning tree for G where the total length of the arcs is shorter.

A minimum spanning tree for G can be obtained by using Prim's algorithm, which generates a minimum spanning tree T as follows.

1) Choose any vertex of the G and add it to T.

2) Look at all the edges in the G that connect a vertex that is in T to one that is not. Out of these edges, choose the shortest, and add it to T (if there is more than one edge that would count as shortest, then you can pick whichever you like).

3) Repeat step 2 until all of the vertices of G are also in T.

Reference no: EM13728142

Questions Cloud

How much heat is transferred from water to cylinder : If I have an aluminum cylinder whose radius is 5cm and height is 4cm and initially its T is 50°C. The aluminum's density is 2.7g/?cm?^3. If I put it into 1000mL water and initially the water is 90°C, (1) what is the final temperature of the cylinder ..
What evidence you found that would lead you to conclusion : What evidence have you found that would lead you to this conclusion? 200 word minimum with references and accompanying citations.
A ray of light traveling through water is incident : 1. Find the angle of refraction if a ray of light traveling through water is incident on glass at an angle of 23°. The index of refraction of water is 1.33 and the index of refraction of glass is 1.52.
Devise a plan to investigate the validity of patients : Devise a plan to investigate the validity of patients' claims of denial of services. This plan should include, but not be limited to, establishing mechanisms to address service denial claims, a human resources component, and a review of related po..
Algorithm of prim : NFR4: Prim's algorithm should be used to find a minimum spanning tree (see FR6). NFR5: Dijkstra's  algorithm should be used to find a shortest path between two stations (FR7).
Which did early river valley civilizations have in common : Which did the early river valley civilizations have in common? They began near rivers because they had developed complex trade networks.
Compare and contrast essay : As you move forward to reflect on the process of writing your Literary Analysis Draft, watch the video Writing the Compare and Contrast Essay, which provides an overview of the writing process. This may seem familiar if you have taken a course in..
Discuss the interactions between europe and the americas : discuss the interactions between TWO of the following three regions: Africa, Europe, and the Americas (Central and South America or the Caribbean).
Explain the importance of situating a society cultural : Explain the importance of situating a society's cultural and artistic expressions within a historical context. Examine the influences of intellectual, religious, political, and socio-economic forces on social, cultural, and artistic expressions.Use t..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  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..

  Algorithm to divide sixteen digit value by six digit integer

Divide 16 digit value N by six digit integer D obtaining quotient Q and remainder (or sign of the remainder) R by division algorithms.

  Programming language problems

Many programming languages do not permit you to ask two or more questions in a single comparison by using a logical And Operator

  Write computer program to implement algorithm

Write computer program to implement algorithm and demonstrate the results and what is the machine run time in second for sorting array A?

  Find running time of heap sort input sorted-ascending order

Determine the running time of Heap Sort if input is sorted in ascending order. Determine the running time of Heap Sort if input is sorted in descending order.

  Uml graphical notation to define the object classes

Use UML graphical notation, construct the design for the system to define the object classes and show the interaction of the data collection sub systems.

  Model of online music sharing

Since Napster is going out of business, you have decided to begin your own on line music sharing site. You will give individual music documents at your site.

  Explain two possible solution-fill in blank squares by words

The objective is to fill in blank squares using words from the list. Your task is to formulate problem as constraint satisfaction problem. Explain two possible solutions.

  Choosing computer passwords

Before logging on to computer, you must have a unique username and unique password. Analyze and explain considerations you must make when choosing a password.

  Implement iterative version of algorithm heapify

Using any programming language to implement iterative version of algorithm HEAPIFY. Show your algorithm by running it on the array that contain your name characters.

  Design an adt for a two-color

Design an ADT for a two-color, double-stack ADT that consists of two stacks one "red" and one "blue" and has as its operations color-coded versions of the regular stack ADT operations.

  Convert the following formulas from reverse polish to infix

Convert the following formulas from reverse Polish to infix.

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