私は自分のノードにエンティティを作成し、アプローチでOOPを使用すると信じています。
要件が変更されることはなく、それについて完全に確信している場合は、アプローチは問題ないかもしれませんが、たとえばノードと別のノード間のすべてのパスに「重み」を割り当てるなど、要件が変更される可能性がある場合は、難しいかもしれません。それをするために。(次のようなことを行うことでそれを解決します。
Dictionary<Int32, List<Int32, Dictionary<Int32, Int32>>
???)
私のクラスは少しこのように見えると思います。
public class GraphNode
{
private Int32 value;
public Int32 Value
{
get { return this.value; }
}
private List<GraphNode> siblings;
public ReadOnlyCollection<GraphNode> Siblings
{
get { return new ReadOnlyCollection<GraphNode>(siblings); }
}
public void AddSibling(GraphNode node)
{
if (this == node)
throw new Exception("Can't assing a node to itself as a sibling");
if (this.siblings.Contains(node))
throw new Exception("This node is already contained in the siblings list");
this.siblings.Add(node);
}
public GraphNode(Int32 value)
{
this.value = value;
this.siblings = new List<GraphNode>();
}
}