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 28, Problem 28.16PE
Program Plan Intro

Induced subgraph

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 “E16” to the package.
      • Import the required packages.
      • Declare the main class.
        • Give the “main ()” method.
          • Declare the string array that contains the names of the city.
          • Declare an integer array that contains the weight.
          • Create an object for unweighted graph.
          • Print the size of the graph, vertex of the graph, index of the vertex “Miami”, and the edges of the graph.
          • Call the function “maxInducedSubgraph ()”.
          • Print the size of the graph, vertex of the graph, index of the vertex “Miami”, and the edges of the graph.
        • Give function definition for “maxInducedSubgraph ()”.
          • Declare required variables
          • Do until the condition “(!Isdone && g.getSize() > 0)” fails.
            • Assign “true” to the variable.
            • Loop from 0 through size.
              • Check the condition “(g.getDegree(i) < k)”.
                • Call the function “remove_Vertex ()”.
                • Assign false to the variable.
                • Break the loop.
          • Return the graph.
        • Function definition for “UnweightedGraphInducedSubgraph ()”.
          • Construct the empty graph.
          • Construct a graph from vertices and edges stored in arrays.
            • Get the vertices and edges.
          • Construct a graph from vertices and edges stored in List.
            • Get the vertices and edges.
          • Construct a graph for integer vertices 0, 1, 2 and edge list.
            • Get the vertices and edges.
          • Construct a graph from integer vertices 0, 1, and edge array.
            • Get the vertices and edges.
          • Give function definition for “remove_Vertex ()”.
            • Check the condition “(vertices.contains(v))”.
              • Get the index.
              • Call the functions “vertices.remove ()”, and “neighbors.remove ()”.
              • Loop to remove the edges.
                • Loop from 0 through size.
                  • Check the condition “(list.get(i).v == index)”. If it is true then remove the edge.
                  • Else, increment the variable
              • Loop to reassign the labels.
                • Loop from 0 through size.
                  • Check the condition “(list.get(i).u >= index)”. If the condition is true then get the edge
                  • Check the condtion “(list.get(i).v >= index)”. If the condition is true then get the edge
              • Return “true”.
            • Else,
              • Return “false”.

Blurred answer
Students have asked these similar questions
2. Q1)   You are given an undirected connected planar graph. There are 10 vertices and 7 faces in the graph. What is the number of edges in the graph? Note that: A graph is said to be planar if it can be drawn in a plane so that no edge cross.   Q2) In how many ways can we pick any number of balls from a pack of three different balls? Q3) The distance between 2 points A and B is 1320Km. Two cars start moving towards each other with 50 Km/hr and 60 Km/hr. After how many hours do they meet?
Computer Science java program
(V, E) be a connected, undirected graph. Let A = V, B = V, and f(u) = neighbours of u. Select all that are true. Let G = a) f: AB is not a function Ob) f: A B is a function but we cannot always apply the Pigeonhole Principle with this A, B Odf: A B is a function but we cannot always apply the extended Pigeonhole Principle with this A, B d) none of the above

Chapter 28 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

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