I'm wanting to represent a directed network graph that is closed, e.g. where the edges would look like:
N1->N2
N2->N3
N3->N1
Where each node has a predefined number of edges allowed to connect to it. In this case that would be 2, no more, no less.
I could define a list of nodes and then a list of edges to create the network but I'm wondering if it is possible with F# to define my types in such a way that the compiler would throw an error if the graph was open or one of the nodes had edge connection <> 2?
I'm not sure this is possible to represent due to the restriction on cyclic dependencies.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…