Suggestions and Clarifications for Project 1
On this page we will post suggestions and clarifications
related to Project 1.
- You can use the String type or the int type
for the array of vertices in myGraph.
For this project, it is not important that myGraph be very
flexible.
In later projects, we will modify the myGraph class
so that it permits vertices of any kind.
- This is with regards to the modified myGraph class.
One of our TAs, Yan Wang, has pointed out that it is easier to
access elements in the adjacency matrix, if the portion below
the main diagonal is stored, rather than the portion above
the main diagonal.
If, as suggested in the project handout, only the portion above the
main diagonal is stored, then to determine whether there is an edge
connecting vertices with indices i and j, i < j, we would have to consult
slot [i][j-i-1].
On the other hand, if the portion below the main diagonal is
stored, then to determine whether there is an edge
connecting vertices with indices i and j, i > j, we would have to consult
slot [i][j].
The latter may seem simpler to you.
So you are free to store either the portion above the main diagonal or the
portion below the main diagonal.