开发者

Multidimensional Collections for a (CS) Graph Class Interface in C#?

开发者 https://www.devze.com 2022-12-13 12:08 出处:网络
For jollies I\'m trying to implement a graph data structure as an interface, so that I can implement graph classes either as adjacency lists (lists of lists of edges) or as adjacency matrices ( a 2 di

For jollies I'm trying to implement a graph data structure as an interface, so that I can implement graph classes either as adjacency lists (lists of lists of edges) or as adjacency matrices ( a 2 dimensional array of edges) with a minimum of additional code.

My question is, is there a way I can implement the IGraph interface s开发者_StackOverflow中文版o that either this:

LinkedList<LinkedList<IEdge>>

or this:

IEdge[,]

will be valid types? I have everything else thought out except this.


So you are using BCL Generics for the linked list. The LinkedList<LinkedList<IEdge>> structure should work just fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号