Directed unweighted graph is given with the list of edges. Let dist[u] contains the shortest path from vertex v = 5 to t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Directed unweighted graph is given with the list of edges. Let dist[u] contains the shortest path from vertex v = 5 to t

Post by answerhappygod »

Directed Unweighted Graph Is Given With The List Of Edges Let Dist U Contains The Shortest Path From Vertex V 5 To T 1
Directed Unweighted Graph Is Given With The List Of Edges Let Dist U Contains The Shortest Path From Vertex V 5 To T 1 (49.91 KiB) Viewed 54 times
Write code in java or C++
Directed unweighted graph is given with the list of edges. Let dist contains the shortest path from vertex v = 5 to the vertex u. If there is no path from v = 5 to u, set dist = -1. Find the sum of the values dist[1] + dist[2] + ... + dist[n] (graph contains n vertices, numbered from 1 to n). Input The first line contains the number of vertices. Each next line contains an edge. Output Print the sum of the values dist[1] + dist[2] + ... + dist[n], whre n is the number of vertices. Sample input 6 53 32 Sample output 5 6 start Activate Windows
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply