Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
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.
- Check the condition “(g.getDegree(i) < k)”.
- 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 from 0 through size.
- 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
- Loop from 0 through size.
- Return “true”.
- Else,
- Return “false”.
- Check the condition “(vertices.contains(v))”.
- Give the “main ()” method.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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)
Ch. 28.2 - What is the famous Seven Bridges of Knigsberg...Ch. 28.2 - Prob. 28.2.2CPCh. 28.2 - Prob. 28.2.3CPCh. 28.2 - Prob. 28.2.4CPCh. 28.3 - Prob. 28.3.1CPCh. 28.3 - Prob. 28.3.2CPCh. 28.4 - Prob. 28.4.1CPCh. 28.4 - Prob. 28.4.2CPCh. 28.4 - Show the output of the following code: public...Ch. 28.4 - Prob. 28.4.4CP
Ch. 28.5 - Prob. 28.5.2CPCh. 28.6 - Prob. 28.6.1CPCh. 28.6 - Prob. 28.6.2CPCh. 28.7 - Prob. 28.7.1CPCh. 28.7 - Prob. 28.7.2CPCh. 28.7 - Prob. 28.7.3CPCh. 28.7 - Prob. 28.7.4CPCh. 28.7 - Prob. 28.7.5CPCh. 28.8 - Prob. 28.8.1CPCh. 28.8 - When you click the mouse inside a circle, does the...Ch. 28.8 - Prob. 28.8.3CPCh. 28.9 - Prob. 28.9.1CPCh. 28.9 - Prob. 28.9.2CPCh. 28.9 - Prob. 28.9.3CPCh. 28.9 - Prob. 28.9.4CPCh. 28.10 - Prob. 28.10.1CPCh. 28.10 - Prob. 28.10.2CPCh. 28.10 - Prob. 28.10.3CPCh. 28.10 - If lines 26 and 27 are swapped in Listing 28.13,...Ch. 28 - Prob. 28.1PECh. 28 - (Create a file for a graph) Modify Listing 28.2,...Ch. 28 - Prob. 28.3PECh. 28 - Prob. 28.4PECh. 28 - (Detect cycles) Define a new class named...Ch. 28 - Prob. 28.7PECh. 28 - Prob. 28.8PECh. 28 - Prob. 28.9PECh. 28 - Prob. 28.10PECh. 28 - (Revise Listing 28.14, NineTail.java) The program...Ch. 28 - (Variation of the nine tails problem) In the nine...Ch. 28 - (4 4 16 tails problem) Listing 28.14,...Ch. 28 - (4 4 16 tails analysis) The nine tails problem in...Ch. 28 - (4 4 16 tails GUI) Rewrite Programming Exercise...Ch. 28 - Prob. 28.16PECh. 28 - Prob. 28.17PECh. 28 - Prob. 28.19PECh. 28 - (Display a graph) Write a program that reads a...Ch. 28 - Prob. 28.21PECh. 28 - Prob. 28.22PECh. 28 - (Connected rectangles) Listing 28.10,...Ch. 28 - Prob. 28.24PECh. 28 - (Implement remove(V v)) Modify Listing 28.4,...Ch. 28 - (Implement remove(int u, int v)) Modify Listing...
Knowledge Booster
Similar questions
- Do it in PYTHON Language please!!arrow_forward2. 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) }arrow_forward1. This question is about type of graphs. a. Construct a graph with exactly 5 nodes such that the graph is strongly connected. b. Construct a graph with exactly 5 nodes such that the graph is weakly connected. c. Construct a graph with exactly 5 nodes such that the graph is completely connected. d. Construct a graph with exactly 5 nodes such that the graph is not connected. e. Construct a graph with exactly 5 nodes such that the graph is not a simple graph.arrow_forward
- use pythonarrow_forwardPick all statements that apply to this directed graph. A) Every node is reachable from node c. (Do not include node c.) B) From node a to node g there are at least 3 different paths, all with different lengths. C) There are no cycles in this graph. D) There is a loop in this graph. E) There is a path from node e to node f of length 3.arrow_forwardzvcxxarrow_forward
- In graph theory, graph coloring is a special case of graph labeling; it is an assignment of labels traditionally called "colors" to elements of a graph subject to certain constraints. In its simplest form, it is a way of coloring the vertices of a graph such that no two adjacent vertices share the same color; this is called a vertex coloring. The chromatic number of a graph is the least mumber of colors required to do a coloring of a graph. Example Here in this graph the chromatic number is 3 since we used 3 colors The degree of a vertex v in a graph (without loops) is the number of edges at v. If there are loops at v each loop contributes 2 to the valence of v. A graph is connected if for any pair of vertices u and v one can get from u to v by moving along the edges of the graph. Such routes that move along edges are known by different names: edge progressions, paths, simple paths, walks, trails, circuits, cycles, etc. a. Write down the degree of the 16 vertices in the graph below: 14…arrow_forwardFor each of the following statements, decide whether it is 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) There is a tree which contains exactly one leaf. b) A graph can be colored with two colors if and only if it is bipartite. c) A graph on n ≥ 2 vertices with at most n − 2 edges is always acyclic.arrow_forwardUse c++ language Implement the isNeighbor(int u, int v) method. This method should return true if v is a neighbor of u and false otherwise. bool Graph::isNeighbor(int u, int v) { code here... }arrow_forward
- 1. Input: An unweighted graph G = (V, E).2. Output: C = {C1,C2,...,Ck }, k clusters of G.3. Calculate edge betweenness value ∀(u, v) ∈ E.4. Remove all edges from G that have a higher betweenness value than a threshold τ .5. Find the components of GN which are the clusters of G.Write Python Implementation considering figurearrow_forwardGiven the directed weighted graph class by adjacency matrix, develop java method to calculate and print the out-edges of each node in the following Graph. 50 10 40 20 60 E. 30 Output: -- Print the number of connected vertices of the Graph А: 2 B: 3 C: 0 D: 1 Е: 0arrow_forwardCourse : Algorithm Show two possible solutions for the m-coloring problem to find all possible colorings of the graph below using the three colors red, green, and white.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education