2023 SPRING CS 445 Project #10
GRAPH CLASS via LINKED LISTS
Background:
Development Strategy
- Start with your solution to the Graph.java you wrote for Lab#9.
- Reuse the exact same tester and input file from Lab#9.
- Copy your Edge.java definition code into your Graph.java file - just like you put Node inside your LinkedList classes.
- By doing so you don't need setters and getters in your Edge class.
- You don't need to write a LinkedList class per se. You can write the insertAtFront(), remove(), contains() etc. inside the Graph class and just treat the G[i] element as the head of that LinkedList.
- In your Graph.java file replace the int G[][] from the 2D array version with a single dimension Edge G[]. That G[] array is an array of Edge pointers (linkedList heads/fronts).
- In your loadGraphFile, after you read in the dimension value from the file, use it to dimension your G[] array of Edge pointers.
- Now you only need to to modify the following methods: 1 AT A TIME!
- addEdge(...) use the first value to index into the array. Do an insertAtFront on that list.
- removeEdge(...) use the first value to index into the array. Remove the Edge from that list - or throw Exception if NO_EDGE
- inDegree(...) figure out which list(s) to traverse to count edges INTO this node
- outDegree(...) figure out which list(s) to traverse to count edges OUT OF this node
- degree(...) actually, this one does not change... DO YOU UNDERSTAND WHY?
- toString() must be re-written by you to produce same info but this format:

- The other public methods do not need to change. DO YOU UNDERSTAND WHY?