I am attempting to implement some more complex data structures in c# working with no libraries other than System. Currently i am working on graphs.
I have created 3 classes already to represent nodes, directed edges, and undirected edges. Each of these can have a different data type e.g. node<string>
will be a node with information stored as a string and directedEdge<string>
will link nodes that store strings.
My graph class is declared as Graph<dataType, edgeType>
(for now I am assuming all edges in a single graph are the same type), and I would like to branch within this class based on whether a directed or undirected edge is being used. The code bellow does not work, but explains the functionality I would like to achieve.
if (edgeType == directedEdge<dataType>)
{
}
else if (edgeType == undirectedEdge<dataType>)
{
}
else
{
}
Is there any way to implement something like what is shown above? If so, how?