Graphs OOP app
Hey there, I wanted to ask if the structure for my OOP-based graphs interface made sense or if there are some places I can change things. I want to emphasise beforehand that, althought I know i could simply represent a graph using the adjacency matrix, I want my interface to be more intuitive that hand-typing a random matrix, so I wanted to store it as a List of nodes and edges. (if there's a better way please let me know)
Anyways, the current structure for my program goes a little something like this:
Anyways, the current structure for my program goes a little something like this:
- When it comes to edges, I have an abstract class for an arbitrary edge, from which 2 different classes will inherit: Directed edges (
Arc) and undirected edges (UEdge). I'm representing the type of edge using anEdgeTypeenum. Also, for the endpoints, I'm simply representing it as aTuple<Node, Node> - The
Nodeclass is one that im not sure what to put inside, for the moment all that I have in the node class is an integer for its index in the graph. - The
Graphclass is an abstract class from which 3 classes will inherit:DiGraph(Directed Graph),UGraph(Undirected Graph) andPGraph(Ponderated graph, a graph in which each edge has a value i.e. the use case of Djikstra's algorithm). This class would have aList<Edge>calledEdgesfor all the edges in the graph, and aList<Node>calledNodesfor all the Nodes.Nodeswouldn't be taken as an argument in the constructor, since I could just extract the nodes from the edges and then set the list equal to those in the constructor.