Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ #ifndef NETWORK #define NETWORK struct Node{ int x; int y; string label; Node()=default; Node(int i, int j, string l) : x(i), y(j), label(l) {}

c++

#ifndef NETWORK #define NETWORK struct Node{ int x; int y; string label;

Node()=default; Node(int i, int j, string l) : x(i), y(j), label(l) {} ; string to_string () const; bool equal_nodes(const Node&); double distance(const Node &)const; };

struct Network{ string label; map nodes; vector route;

Network()=default; Network(ifstream &); string to_string () const; Node get_node(string); void put_node(Node); bool in_route(const Node&); Node closest(Node &); string calculate_route(const Node&, const Node&); };

#endif

1. Network(ifstream & )constructor.

oreads in a text description of the network from the provided (open) file stream

ofor each line, creates a new Node and initializes it according to the provided Node constructor (see test cases for format)

o adds the new node to the map nodes , where the string is the Node label.

2. Node get_node(string) and void put_node(Node). Either return a Node (based on a string, the label of a node in the map nodes) or adds a Node to the map nodes in a network.

o If get_node cannot find the indicated label in the nodes map, it throws an out_of_range error.

 input for above methods: network.txt 

ouput for first method: A:(1,1)

output for second method:

Error:Node not found:X A:(1,1) 

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

Define the term sabbatical.

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago

Question

Explain methods of metal extraction with examples.

Answered: 1 week ago