Data structure for relationships

后端 未结 2 799
隐瞒了意图╮
隐瞒了意图╮ 2021-01-01 08:27

I am converting a VB6 to C# and I want to make my data structure that holds values and relationships more efficient. In VB I have a collection of values and another collecti

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-01 08:39

    It sounds like what you have is a Graph. This is a structure with Nodes and Edges. There are many many libraries and tools that deal with Graphs. Microsoft even put out a paper on how to deal with them. I think graphs are great and extremely useful in many situations.

    One big benefit with graphs is the ability to assign priorities to the edges between the nodes. Then when you want to find the path between two nodes, boom, the graph can choose the path with the ideal priority.

    In your situation, your values are the nodes and your relationships are the edges.

提交回复
热议问题