Answered step by step
Verified Expert Solution
Question
1 Approved Answer
write in java Problem Description Given a graph consisting of N vertices and M edges. There is a treasure on every vertex of the graph
write in java
Problem Description Given a graph consisting of N vertices and M edges. There is a treasure on every vertex of the graph which has a price of A[i] and weight of B[i]. For each vertex v you have to determine the minimum cost to collect the treasure from any vertex u (u may or may not be eqaul to v ). The cost for vertex v to collect the treasure from u has mainly four components. 1. The price A[u] of the treasure at vertex u. 2. The sum of weights of all the edges in the path from v to u. 3. The sum of weights of all the edges in the path from u to v. 4. An additional cost of XB[u] is also added, where X is the number of edges traversed on the path from u to v. Notes 1. The ith bidirectional edge goes from C[i][0] to C[i][1] and has a weight of C[i][2]. 2. The path to go from v to u and to comeback to v from u may or may not be same. 3. There might be multiple edges and self loops. Problem Constraints 1N=5001M=1031A[=10151B[cStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started