Question: JAVA - DS 7. Graph is a mathematical structure that represents relationships among entities in the real world. It consists of a nonempty set of

JAVA - DS

JAVA - DS 7. Graph is a mathematical structure that represents relationships

among entities in the real world. It consists of a nonempty set

7. Graph is a mathematical structure that represents relationships among entities in the real world. It consists of a nonempty set of vertices (nodes) and a set of edges that connects the vertices. Write a program that creates a graph where the edges are represented using edge array (see Figure 2). (CO 4, PO 3 - 10 marks) 5 5 2 6 6 G 3 D Figure 2: Graph of linked between cities. Your program shall begin with the following code: public class TestGraph public static void main(String[] args) 1 // continue your code here } The output should be displayed as follows: The number of vertices in graph: 7 The vertex with index 5: F The index for vertex G : 6 The edges for graph: A (0) : (0, 1) (0, 4) (0, 5) B (1): (1, 2) C (2): (2, 3) D (3): (3, 2) E (4): (4, 0) F (5): (5, 0) (5, 6) G (6): (6,5)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!