Create a new project: AdjacencyMatrixDynamic_LastName. Create 2 more java files:
MatrixManipulation.java and UserInterface.java. Use your Last Name as usual.
In this lab we will be creating an adjacency matrix for the following graph:
To implement the input to represent the graph, you will need to implement an arraylist that will
contain rows with vertex1, vertex2, edge. Here is a small example of what the contents should look like.
Note that the … are there because there should be more rows.
0 1 2
0 A B a
1 A E e
2 A D d
… … … …
AdjacencyMatrixDynamic_LastName.java
In your java class file add the following code in main:
MatrixManipulation.java
In MatrixManipulation.java, we need a method to populate the matrix, you will be completing
this given the graph above. We also need a method to populate the graph, you will be completing this
given the graph above. You will be adding the code in both of these yourself.
Next, we need a method to initialize our arraylist with the character ‘0’, this will represent null
for our list.
UserInterface.java
In UserInterface.java, we need a method to print the array itself.
Participation Assignment:
For the in-class participation assignment, complete all of the code above. Also in the two
methods: PopulateMatrix and PopulateGraph, you need to add pseudocode for how you plan to
implement the code in comments.
Submit: Zip of the project – make sure it can be run in netbeans if you want me to be able to grade it.
Grading:
• Working code – 50%
• Logical and Easily Readable Pseudocode – 50%
Lab Assignment:
For the completed Lab due Friday, complete the code in PopulateMatrix and PopulateGraph.
Complete the test run and add the screenshots to the screenshot document. USE THE
DEBUGGER. Add breakpoints and show the contents of the arraylists at the following parts of the code:
• After initializing matrix arraylist.
• After adding the graph information to the graph arraylist.
• After populating the matrix using the information provided in the graph.
Grading:
• Working code – 75%
• Screenshot document – 30%
Sample Solution