Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need graphl.h and graphl.cpp in c++! I need this asap!! test.cpp #include #include #include graphl.h using namespace std; int main() { // part 1

I need graphl.h and graphl.cpp in c++! I need this asap!!

image text in transcribed

test.cpp

#include  #include  #include "graphl.h" using namespace std; int main() { // part 1 ifstream infile1("data31.txt"); if (!infile1) { cout  

5 Aurora and 85th Green Lake Starbucks Woodland Park Zoo Troll under bridge PCC 1 2 50 1 3 20 1 5 30 2 4 10 3 2 20 3 4 40 5 2 20 5 4 25 0 0 0 3 aaa bbb ccc 1 2 10 1 3 5 2 3 20 3 2 4 0 0 0

expected outcome:

Description From node To node Dijkstra's Path Aurora and 85th 1 2 40 1 3 2 1 3 20 1 3 1 4 50 1 3 2 4 1 5 30 1 5 Green Lake Starbucks 2 1 --- 2 3 --- 2 4 10 2 4 2 5 --- Woodland Park Zoo 3 1 --- 3 2 20 3 2 3 4 30 3 2 4 3 5 --- Troll under bridge 4 1 --- 4 2 --- 4 3 --- 4 5 --- PCC 5 1 --- 5 2 20 5 2 5 3 --- 5 4 25 5 4 3 1 --- Description From node To node Dijkstra's Path aaa 1 2 9 1 3 2 1 3 5 1 3 bbb 2 1 --- 2 3 20 2 3 ccc 3 1 --- 3 2 4 3 2 3 1 --- 

nodedata.h

#ifndef NODEDATA_H #define NODEDATA_H #include  #include  #include  using namespace std; // simple class containing one string to use for testing // not necessary to comment further class NodeData { friend ostream & operator(const NodeData &) const; bool operator=(const NodeData &) const; private: string data; }; #endif 

nodedata.cpp

#include "nodedata.h" //---------------------------------------------------------------------------- // constructors/destructor NodeData::NodeData() { data = ""; } // default NodeData::~NodeData() { } // needed so strings are deleted properly NodeData::NodeData(const NodeData& nd) { data = nd.data; } // copy NodeData::NodeData(const string& s) { data = s; } // cast string to NodeData //---------------------------------------------------------------------------- // operator= NodeData& NodeData::operator=(const NodeData& rhs) { if (this != &rhs) { data = rhs.data; } return *this; } //---------------------------------------------------------------------------- // operator==,!= bool NodeData::operator==(const NodeData& rhs) const { return data == rhs.data; } bool NodeData::operator!=(const NodeData& rhs) const { return data != rhs.data; } //---------------------------------------------------------------------------- // operator,= bool NodeData::operator(const NodeData& rhs) const { return data > rhs.data; } bool NodeData::operator=(const NodeData& rhs) const { return data >= rhs.data; } //---------------------------------------------------------------------------- // setData // returns true if the data is set, false when bad data, i.e., is eof bool NodeData::setData(istream& infile) { getline(infile, data); return !infile.eof(); // eof function is true when eof char is read } //---------------------------------------------------------------------------- // operator 

To line up numbers use setw() (must #include ). For example, if n is an int, 10 chars are printed including n. Default is right justified, padding with blanks on the left: cout Part 1, Programming Graph ADT (emphasis on Dijkstra's shortest path algorithm) Implement Dijkstra's shortest path algorithm, including recovering the paths. You will find the lowest cost paths and display the cost and path from every node to every other node. Another display routine will output one path in detail. In the data, the first line tells the number of nodes, say n (assume nonnegative integer). Following is a text description of each of the 1 through n nodes, one description per line (assume 50 chars max length). After that, each line consists of 3 ints representing an edge. (Assume correctly formatted data, int data.) If there is an edge from node 1 to node 2 with a label of 10, the data is: 12 10. A zero for the first integer signifies the end of the data for that one graph. There are several graphs, each having at most 100 nodes. For example

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

What are the advantages and disadvantages of using credit?

Answered: 1 week ago

Question

=+1. What are the core best practices for social care?

Answered: 1 week ago

Question

How to solve maths problems with examples

Answered: 1 week ago

Question

=+ Are there additional forms of employee representation?

Answered: 1 week ago

Question

=+What is the nature of their impact?

Answered: 1 week ago

Question

=+Is it possible to operate union-free?

Answered: 1 week ago