Introduction to Java Programming and Data Structures, Comprehensive Version, Student Value Edition (11th Edition)
Question
Book Icon
Chapter 29, Problem 29.12PE
Program Plan Intro

Display weighted graphs

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 name “Displayable” to the package.
      • Declare the functions “get_X ()”, “get_Y ()”, “get_Name ()”.
    • Add a java class named “E12” to the package.
      • Declare the cities.
      • Declare an integer array.
      • Create an object for the weighted graph.
      • Create a graphview pane.
      • Declare “start ()” method that overrides the “start ()” method in the “Application” class.
        • Create a scene and place it on the stage.
        • Display the stage.
      • Declare the class “GraphView”.
        • The “Graph” class extends the interface “Displayable”.
        • Give the constructor for this class.
          • Set the graph and call the function “paint ()”.
        • Give function definition for “paint ()”.
          • Declare a list that extends Displayable.
          • Loop from 0 through size.
            • Get the vertices.
            • Get the name of the city.
            • Add the circle, text and vertices to the pane.
          • Loop from 0 through graph size.
            • Create a list.
            • Loop from 0 through neighbor’s size.
              • Get the vertices.
              • Inside the “try” block,
                • Add the line, text and vertices to the pane.
              • Inside the “catch” block,
                • Throw the exception.
      • Declare a class named “Cities”.
        • Declare required variables.
        • Give the constructor for this class which sets the name of the city, and the vertices.
        • Get and return the co-ordinate of the vertex “x”.
        • Get and return the co-ordinate of the vertex “y”.
        • Get and return the name of the city.
        • Declare function to compare cities.
          • Return the value.
      • Give the “main ()” method.
        • Launch the application.

Blurred answer
Students have asked these similar questions
Wing A Wing Wine b) Above given is the design of US Airport(having Wings: A-C and Arms: a-0). Your task is to create an adjacency matric for the graph of the airpot.
Programming Language: C++ Create a pseudocode (if you not familiar with this, you can create a program) that check if "directed graph" is actually circle graph. The meaning of circle is that let's say there is 1~6 nodes. The graph start with 1 and only can move to 2, and 2 can only move to 3....etc and after you hit 6, you move back to 1. so 1=>2=>3=>4=>5=>6=>1 this is example of circle directd graph. Please create a pseudocode/program to check if graph is circle or not. Also, include the time complexity of your pseudocode by [Worst case time complexity / Best case time complexity]
2). Write a program to implement the following graph representations and display them. i. Adjacency list ii. Adjacency matrix
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