Question: This is Data Structures. Can someone do the JAVA code for the assignment above or change the code below into JAVA format? #include #include #include

 This is Data Structures. Can someone do the JAVA code for

This is Data Structures. Can someone do the JAVA code for the assignment above or change the code below into JAVA format?

#include #include #include #include #include #include #include #include using namespace std; map name; vector name2; void bfs(vector> adj,int src,int dest) { cout> parent; vector v(adj.size()); parent.push_back(v);//parent parent.push_back(v);//weight till that node queue q; int i,n,el; n=adj.size(); for(i=0;i0&&parent[1][i]>parent[1][el]+adj[el][i]) { parent[1][i]=adj[el][i]+parent[1][el]; parent[0][i]=el; q.push(i); } } } cout> adj,int src,int dest) { cout> parent; vector v(adj.size()); parent.push_back(v);//parent parent.push_back(v);//weight till that node stack stk; int i,n,el; n=adj.size(); for(i=0;i0&&parent[1][i]>parent[1][el]+adj[el][i]) { parent[1][i]=adj[el][i]+parent[1][el]; parent[0][i]=el; stk.push(i); } } } cout> adj; vector v; cout>file; infile.open(file); getline(infile,s); ss>s) { name[s]=i; name2.push_back(s); i++; } std::map::iterator it=name.begin(); while(getline(infile,s)) { v.clear(); ss.clear(); ss>k) { v.push_back(k); } adj.push_back(v); } cout>src; cout>dest; bfs(adj,name.find(src)->second,name.find(dest)->second); dfs(adj,name.find(src)->second,name.find(dest)->second); return 0; }

BFS and DFS Assignment The paths between nodes are represented as an nxn matrix, where n is the number of nodes. Each slot in the matrix represent the weight of the path between corresponding nodes. Zero and Negative values represents non-exiting path. The matrix usually stored in a file in the following format, where the fist line representing the node names, and subsequence lines representing the weight between the any two nodes between the corresponding row and column. ABCDE F. 012021 100011 You are required to implement a program that: 1. Prompts the user to enter the name of the file containing the matrix, the name of the 2. Find and display a path (preferably shortest path ) between the starting node and the 3. Find and display a path (preferably shortest path ) between the starting node and the starting node, and the name of the ending node. ending node by Breath First Search ending node by Depth First Search Hints: it would be easier to handle your graph if each node is encapsulated with at least: node name, distance from the source node, and the preceding node name on the path for that distance BFS and DFS Assignment The paths between nodes are represented as an nxn matrix, where n is the number of nodes. Each slot in the matrix represent the weight of the path between corresponding nodes. Zero and Negative values represents non-exiting path. The matrix usually stored in a file in the following format, where the fist line representing the node names, and subsequence lines representing the weight between the any two nodes between the corresponding row and column. ABCDE F. 012021 100011 You are required to implement a program that: 1. Prompts the user to enter the name of the file containing the matrix, the name of the 2. Find and display a path (preferably shortest path ) between the starting node and the 3. Find and display a path (preferably shortest path ) between the starting node and the starting node, and the name of the ending node. ending node by Breath First Search ending node by Depth First Search Hints: it would be easier to handle your graph if each node is encapsulated with at least: node name, distance from the source node, and the preceding node name on the path for that distance

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!