Question: solve it with c++ language, and with DFS function Description: In a social networking site, people are connected with other people. The whole system appears

solve it with c++ language, and with DFS function
solve it with c++ language, and with DFS function Description: In a

Description:

In a social networking site, people are connected with other people. The whole system appears as a giant connected graph. In this question, you are required to answer the total number of people connected at t nodes away from each other (t distance connectivity). For example: Two persons directly connected are at 1 distance connectivity. While the two persons having a common contact without having direct connectivity, are at 2 distance connectivity.

Input Format:

First line of input line contains, two integers n and e, where n is the nodes and e are the edges. Next e lines will contain two integers u and v meaning that node u and node v are connected to each other in undirected fashion. Next line contains single integer, m, which is number of queries. Next m lines, each have two inputs, one as source node and other as a required t distance connectivity which should be used to process query.

Output Format:

Print a single integer represents the total number of people connected at t nodes away from the source node (t distance connectivity).

Rart Hil sob Taska (te paisfo) Nete Cepy this seption into a new file then save it. Yes will enly subent this section ef the lab maneat. Derulotien: In a social netwerking sibe, people ane connested with other perple. The whole system appears as a giant. connected graph. In this yoestion, you are required to answer the lotal number ef poople consected M t nedea awoy from each other (t diatance coneectivity). Fer evample. Twe pensei direcily cunbecied are at 1 diatance connectivity. While the hre persens baving a conunso sontast without baving direst connecsivity, ane at 2 distance cuenectivify. Inpat Fermat Next e lines will ceetain twe integens and + meaning tham bole u and bode v are connected tis each ether in undirected fashioe. Nest line contains sisgle integer, m, which is number of queries. Next ma lines. cach have two inputs, ene as souree dode and other an a required I dintance cenesctrity which shoald be used te peocess uery. Outpet Fermat Frint a wingle inseget repecsents the ootal mumber of people ceneccied at t nodes asay frum the miaret node (t diatance connectivity). Eample Run: Explanatian Afler ereafing the praph, there wim 3 qoeries. 1. Sowate aode 4 and we have to find aet thal mamber of sades at a distance of 2 thum axde 4. ii. Similarly as ahere 162-13.42+x+2.323y=3

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!