Create a cpp program that receives in input a weighted graph

Assignment Help Data Structure & Algorithms
Reference no: EM131965117

Programming and Data Structures Assignment: Graph based clustering

Introduction

In this assignment, you will create a C++ program that receives in input a weighted graph and groups its nodes in the required number of clusters.

Input and Output

The input is a single text file containing:

• The graph, in adjacent list format
• The weight matrix
• The required number of clusters

Example 1 of input

1 2 3 4
0 2 3
0 1 3
0 1 2
0

0 3 4 5 2
3 0 2 4 -999
4 2 0 1 -999
5 4 1 0 -999
2 -999 -999 -999 0

2

-999 represents infinite distance (no connection between two nodes). This input corresponds to the following weighted, undirected graph

62_Graph.jpg

The output of your program should be a text file containing the clusters, represented as list of nodes on different rows. As a convention, nodes should appear in numerical order. Clusters should be sorted by numerical order of their first node.

Example 1 of output
0 4
1 2 3

Handling invalid input

Your program should be able to recognize invalid input of the following nature:

• Mismatch between size of adjacency list and weight matrix. You can assume that the adjacency list and the weight matrix will always be present in the input file and contain only numbers, but it is possible that their sizes do not match.

• Request for an invalid number n of clusters (n<1, n>number of nodes in the graph or n missing)

In both cases, the output file should be left empty.

The main C++ program will become the executable to be tested by the TAs. The result should be written on another text file (output file), provided on the command line. The input and output files are specified in the command line, not inside the C++ code.

The general call to the executable (sum_rowcol, in this example) is as follows:

cluster "A=<file>;C=<file>"

Call example with one input file and another output file.

cluster "A=a.txt;C=c.out"

Requirements

• It is NOT allowed to use vector classes or other classes provided in the STL.

• Your C++ code must be clear, indented and commented.

• Your program will be tested with GNU C++. Therefore, you are encouraged to work on Unix, or at least make sure that your code compiles and runs successfully on the server.

• You can use other C++ compilers, but the TAs cannot provide support or test your programs with other compilers.

Attachment:- Graph-Type.rar

Reference no: EM131965117

Questions Cloud

What will be the firm quick ratio : What will be the firm's quick ratio after Nelson has raised the maximum amount of short-term funds? Round your answer to two decimal places.
Rapid growth in an entrepreneurial venture : What 3 strategies can most affect rapid growth in an entrepreneurial venture? Explain your reasoning.
What is the assumption of team development : What is the assumption of team development and could i get help to how to apply the models for team development.
What is the stock return for the coming year : The current price of a stock (P_0) is $20 and last year's price (P_-1) was $18.87. The last dividend (D_0) is $2. Assume a constant growth rate (g) in dividends
Create a cpp program that receives in input a weighted graph : In this assignment, you will create a C++ program that receives in input a weighted graph and groups its nodes in the required number of clusters.
Examine how the mission and vision of the organization : Examine how the mission and vision of the organization might affect or guide you as an employee or manager in the company.
Which of the given statements is correct in given problem : The current price of a non-dividend paying stock is $40. A European call option with three months maturity and strike $39 is priced at $2.
Consideration of accounting theory concepts : Assignment covers the in-depth theoretical concepts with some practical accounting task application based on the topics from the subject
Determine the minimum and maximum cycle : Determine the minimum and maximum cycle times in seconds for a desired output of 500 units in a seven-hour day. (Round your answers to 1 decimal place.)

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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