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
(0)URGENT!!!! Please use this graph class and SOLVE FOR ISOLATEDTRIPLETS QUESTION AND AVERAGE BALANCE RATIO Here is the graph class: public class Graph {private final int V;private int E;private final Bag<Integer>[] adj; /*** Create an empty graph with V vertices.*/@SuppressWarnings("unchecked")public Graph(int V) {if (V < 0) throw new Error("Number of vertices must be nonnegative");this.V = V;this.E = 0;this.adj = new Bag[V];for (int v = 0; v < V; v++) {adj[v] = new Bag<>();}} /*** Return the number of vertices in the graph.*/public int V() { return V; } /*** Return the number of edges in the graph.*/public int E() { return E; } /*** Add the undirected edge v-w to graph.* @throws java.lang.IndexOutOfBoundsException unless both 0 <= v < V and 0 <= w < V*/public void addEdge(int v, int w) {if (v < 0 || v >= V) throw new IndexOutOfBoundsException();if (w < 0 || w >= V) throw new IndexOutOfBoundsException();E++;adj[v].add(w);adj[w].add(v);} /***…
Application "networkx" library is used for implementing graphs. Draw a graph using this library in python. (Hint: use 'add_node()", 'add_edge()' functions to draw edges and nodes). Construct the graph shown in figure using python language. Also, plot the graph using matplotlib library, Traverse the graph using DFS, and output the DFS order. 2
2. Use the following description of an undirected graph and draw the graph: v(Graph1) = { A, B, C, D} E(Graph1) = { (A,B), (A,D), (B,C), (B,D) }

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