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: 9780134700144
Author: Liang
Publisher: PEARSON
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
What did you find most interesting or surprising about the scientist Lavoiser?
1. Complete the routing table for R2 as per the table shown below when implementing RIP routing Protocol? (14 marks) 195.2.4.0 130.10.0.0 195.2.4.1 m1 130.10.0.2 mo R2 R3 130.10.0.1 195.2.5.1 195.2.5.0 195.2.5.2 195.2.6.1 195.2.6.0 m2 130.11.0.0 130.11.0.2 205.5.5.0 205.5.5.1 R4 130.11.0.1 205.5.6.1 205.5.6.0
Analyze the charts and introduce each charts by describing each. Identify the patterns in the given data. And determine how are the data points are related.   Refer to the raw data (table):
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,