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
In python draw method from the networkx library to draw a graph. Inone of the simple ways to generate a graph, we first define a graph object usingthe Graph method from this library and then can add edges to this object using theadd_edges_from method from a list which specifies edges as vertex pairs as in the
(a) Let G be a simple undirected graph with 18 vertices and 53 edges such that the degreesof G are only 3 and 7. Suppose there are a vertices of degree 7 and b vertices ofdegree 3. Find a and b. To receive any credit for this problem you must write completesentences, explain all of your work, and not leave out any details. problem 1, continued(b) Recall that a graph G is said to be k-regular if and only if every vertex in G has degreek. Draw all 3-regular simple graphs with 12 edges (mutually non-isomorphic). Hint:there are six of them. To receive credit for this problem, you should explain, as well aspossible, why all of your graphs are mutually non-isomorphic.
Is it true or false?  If it is true, include a (short, but clear) argument why it is true, and if it is false, include a concrete graph which shows that the claim is false.a)  If all vertices in a connected graph have even degree, then for whichever two vertices u and v in the graph you choose, there is an Eulerian trail between u and v. b) Given a graph G we construct a new graph H by adding a new vertex v and edges between v and every vertex of G. If G is Hamiltonian, then so is H.c)  We know that if a graph has a walk between u and v it also has a path between u and v, for any two vertices u and v. Is it always true that if a graph has a circuit containing u and v it also has a cycle containing u and v? d) The complete bipartite graph K?,?(lowered indicies) is Hamiltonian if and only if m = n ≥ 2.

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