Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
Question
Book Icon
Chapter 29, Problem 29.11PE
Program Plan Intro

Find shortest paths

Program Plan:

  • Create a package “main”.
    • Add a java class named “Edge” to the package which is used to get the edges from the graph.
    • Add a java class named “Graph” to the package which is used to add and remove vertices, edges.
    • Add a java class named “UnweightedGraph” to the package which is used to store vertices and neighbors.
    • Add a java class named “WeightedGraph” to the package which is used to get the weighted edges and print the edges.
    • Add a java class named “WeightedEdge” to the package which is used to compare edges.
    • Add a java class named “Test” to the package.
      • Import the required packages.
      • Declare the main class.
        • Give the “main ()” method.
          • Get the URL from the user.
          • Open the URL and read the string.
          • Get the number of vertices and store it in the variable “num”.
          • Print the number of vertices.
          • Create an array list.
          • Loop until End of file using “while” condition.
            • Read the line.
            • Split the string.
            • Loop through the length of the triplet.
              • Create an array and add the tokens.
              • Trim the edges and add the edges to the array list.
          • Create an object for the “WeightedGraph”.
          • Print the edges by calling the function “printWeightedEdges ()”.
          • Call the function “getShortestPath ()”.
          • Print the total weight of the minimum spanning tree.
          • Call the function “printPath ()”.

Blurred answer
Students have asked these similar questions
<<Write in Java>> - Challenge 7 File encryption is the science of writing the contents of a file in a secret code. Your encryption program should work like a filter, reading the contents of one file, modifying the data into a code, and then writing the coded contents out to a second file. The second file will be a version of the first file, but written in a secret code. Although there are complex encryption techniques, you should come up with a simple one of your own. For example, you could read the first file one character at a time, and add 10 to the character code of each character before it is written to the second file.   - Challenge 8 Write a program that decrypts the file produced by the program in Programming Challenge 7. The decryption program should read the contents of the coded file, restore the data to its original state, and write it to another file
3) Implement the if __name__ == "__main__" : block at the bottom of this file to do the following: 3a) The if main block at the bottom should get the name of the highway graph file from the command line arguments.  See the video in Python that explains how to get command line arguments.  3b) Call your parse_highway_graph_file function to parse that file, and to construct a WeightedGraph object from it.  3c) Write some code that outputs (with print statements) the degree of each vertex. You can have one vertex per line, indicating its id (just its 0-based index) followed by its degree.  IMPORTANT: Your parse_highway_graph_file function should NOT produce any output. You will have code in your if main block that will have the print statements. The WeightedGraph class has a degree method, inherited from Graph that will return to you the degree of a vertex.
Hi Team, urgent!! urgent!! urgent!! Write a program to count the number of triangles in a graph using the triangle counting algorithm and compute the local clustering coefficient of the vertices in a graph. Mentioning down a sample code. Please run the code solve the errors if any and also append the computation of local clustering coefficient code to the program and provide the output screen shot. Note: Use an input as a file and it should be a data set. Code: Please check if the below code is working or not. If not, please provide a working code. #include <iostream>#include <fstream>#include <omp.h> using namespace std; // Let the number of vertices in the graph equal to 0 at first.int V = 0; // Utility function for matrix// multiplicationvoid multiply(int **A, int **B, int **C){#pragma omp for // do the matrix multiplication in parallelfor (int i = 0; i < V; i++){for (int j = 0; j < V; j++){C[i][j] = 0;for (int k = 0; k < V; k++){C[i][j] +=…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education