The GraphAdjMatrix and GraphAdjList classes define several functions with the same or similar signatures. If these two classes were to implement a common interface declaring the shared functions, a single type-safe abstraction invoking one or more of these shared functions could be utilized by an object of either Graph class. Without this, it seems that a separate abstraction invoking the same function(s) needs to be written for an object of each Graph class respectively. Both Graph classes might be utilized in programs with both dense and sparse graphs (example: https://replit.com/@jbasil/gamegraph), so such flexibility may be useful in some contexts.
Suggestion from a User:
Hello,
The GraphAdjMatrix and GraphAdjList classes define several functions with the same or similar signatures. If these two classes were to implement a common interface declaring the shared functions, a single type-safe abstraction invoking one or more of these shared functions could be utilized by an object of either Graph class. Without this, it seems that a separate abstraction invoking the same function(s) needs to be written for an object of each Graph class respectively. Both Graph classes might be utilized in programs with both dense and sparse graphs (example: https://replit.com/@jbasil/gamegraph), so such flexibility may be useful in some contexts.
John