Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!