© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
8 replies
BigBoyConst

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:
- When it comes to edges, I have an abstract class for an arbitrary edge, from which 2 different classes will inherit: Directed edges (
Arc
Arc
) and undirected edges (
UEdge
UEdge
). I'm representing the type of edge using an
EdgeType
EdgeType
enum. Also, for the endpoints, I'm simply representing it as a
Tuple<Node, Node>
Tuple<Node, Node>

- The
Node
Node
class 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
Graph
Graph
class is an abstract class from which 3 classes will inherit:
DiGraph
DiGraph
(Directed Graph),
UGraph
UGraph
(Undirected Graph) and
PGraph
PGraph
(Ponderated graph, a graph in which each edge has a value i.e. the use case of Djikstra's algorithm). This class would have a
List<Edge>
List<Edge>
called
Edges
Edges
for all the edges in the graph, and a
List<Node>
List<Node>
called
Nodes
Nodes
for all the Nodes.
Nodes
Nodes
wouldn'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.

I don't wanna try and plan out everything beforehand because I feel like i'll get overwhelmed, so I would appreciate if you guys told me if this structure makes sense so far or if there are some things i could fix so they dont bite me in the ass later down the line. Thanks in advance!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

OOP help
C#CC# / help
9mo ago
❔ OOP Help
C#CC# / help
4y ago
OOP - Properties and Fields
C#CC# / help
13mo ago
OOP guidance (for myself)
C#CC# / help
17mo ago