Question: Use c + + to write code for these two functions. int Related ( int id _ 1 , int id _ 2 ) const:

"Use c++ to write code for these two functions.
int Related(int id_1, int id_2) const: Returns the length of the shortest path between node id_1 and node id_2(i.e. shortest length between person1 and person2) if such path exists; otherwise, return -1.
int Related (int id_1, int id_2, const std::string& relationship): Returns the length* of the shortest path between node with id_1 and node with id_2 where all edges in XQ09 the path are relationship (i.e. shortest length between person1 and person2 for the only given relationship) if such path exists; otherwise, return -1.
We have a vector relation that store the relationship between two people. And a map> graph_ that stores vertices and adjacency list."

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 Programming Questions!