Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class in java which constructs an adjacency matrix representation of a graph and performs a few graph operations. Please try to keep it

Create a class in java which constructs an adjacency matrix representation of a graph and performs a few graph operations.

Please try to keep it simple and not use to many imports. Also please attach a screenshot/sniping of the code actually working. Once again, must be in java. If you want to go above and beyond comments are nice.

Write an Adjacency Matrix Graph class which has the following:

Two constructors:

Default which makes the matrix of a pre-defined size

Parameterized which takes in a non-negative or 0 size and creates an empty matrix

addEdge: this method returns nothing and takes in two string parameters and a weight. The two integer parameters correspond to the names of vertices and the weight is the weight of the newly created edge.

printDFS: This prints out the vertices names in depth first order. You can find the algorithm the presentation provided.

printBFS: This prints out the vertices names in breadth first order. Like above you can find the algorithm in the presentation.

printDFSForAll: For every vertex in the graph it will print its DFS

printBFSForAll: For every vertex in the graph it will print its BFS

Write another file that tests each of the methods for this graph.

image text in transcribed

v1 v2 v3 V4. v7 V6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

2. What type of team would you recommend?

Answered: 1 week ago