1) Write a traversal algorithm operating on an undirected,unweighted graph g and a source vertex s that fills the followingtwo arrays.
• For each vertex v in g, parent[v] is the next vertex in theshortest path from v to s.
• For each vertex v in g, distance[v] is the number of edges inthe shortest path from v to s.
You may assume that g is connected and that parent and distancesare already allocated (with enough slots), and that s is a vertexof g.
public void shortestPath(Graph g, int s,
int[] parent, int[] distance) {
Expert Answer
An answer will be send to you
PayPal Gateway not configured
PayPal Gateway not configured