CSE 211 Data Structures Spring 2022 Lab Assignment 4 - Monday You have given a city class which holds distance between c

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

CSE 211 Data Structures Spring 2022 Lab Assignment 4 - Monday You have given a city class which holds distance between c

Post by answerhappygod »

Cse 211 Data Structures Spring 2022 Lab Assignment 4 Monday You Have Given A City Class Which Holds Distance Between C 1
Cse 211 Data Structures Spring 2022 Lab Assignment 4 Monday You Have Given A City Class Which Holds Distance Between C 1 (212.09 KiB) Viewed 52 times
main.cpp
#include "graph.h"
int main()
{

City cse;

cse.loadCity("input.txt");
cse.printCityGraph();
cse.isTherePath(2,4);
cse.isTherePath(0,4);
cse.isTherePath(1,2);
cse.isTherePath(0,5);
}
input.txt
5
0 1 10
1 0 10
0 3 20
3 4 5
2 3 7
graph.cpp
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
class City{

private:
int * * distanceGraph;
int numberOfCity;
void createCityGraph();


public:

void loadCity(string file);
void printCityGraph();
void isTherePath(int city1, int city2);
};
void City::createCityGraph()
{

}
void City::printCityGraph()
{
}
void City::isTherePath(int city1, int city2)
{

}
void City::loadCity(string filename)
{

}
CSE 211 Data Structures Spring 2022 Lab Assignment 4 - Monday You have given a city class which holds distance between cities as a graph. Specifically it is a matrix (distanceGraph) where matrix[j] is the distance from city i to city j. If there is a direct link to city j from i, it does not mean there is one from j to i. Thus, think that it is a directional graph. In your class, 4 methods are given. In this lab assignment you will implement the following functions. • void createCityGraph(): it creates and initializes the distanceGraph matrix with zeros. • void load City(string file): it reads cities and distance between them from a file. • void printCityGraph(): it prints the distanceGraph matrix • void is TherePath(int city1, int city2): o This function checks is there a path from city1 to city2 o If there, then print a suitable message o If not, then print a suitable message o Beware of loops between cities. SUBMISSION RULES: • Only upload graph.h file and change its name to NAME SURNAME. • Do your own work to stay away from punishment. • Do not change the class or main function, only implement the functions. city 1 2 3 O 0 10 0 0 0 10 0 0 Ø 0 AWNA 2 3 4 20 0 7 0 0 0 © 0 5 0 0 0 yes there is a path from 0 to 4 no, there is no path from 1 to 2 invalid city index
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply