C# 使用QuickGraph创建自定义顶点的更好方法?

C# 使用QuickGraph创建自定义顶点的更好方法?,c#,quickgraph,C#,Quickgraph,我想制作一个具有一些自定义属性的顶点的图。例如,有一个名为“a”的顶点,该顶点也有与其关联的x,y坐标 为此,我创建了一个类,该类保存其标识符astring,和两个int。为了让类很好地使用AddEdge函数,我重写了.Equals和.GetHashCode,这样,具有相同标识符的和两个顶点是相等的,并且具有相同的哈希代码,而不考虑任何其他属性(如坐标) 这似乎很好,我成功地运行了内置的DijkstraShortestPathAlgorithm 问题: 我的问题是,这是最好的方法吗?看起来真的很

我想制作一个具有一些自定义属性的顶点的图。例如,有一个名为
“a”
的顶点,该顶点也有与其关联的
x,y
坐标

为此,我创建了一个类,该类保存其标识符a
string
,和两个
int
。为了让类很好地使用
AddEdge
函数,我重写了
.Equals
.GetHashCode
,这样,具有相同标识符的和两个顶点是相等的,并且具有相同的哈希代码,而不考虑任何其他属性(如坐标)

这似乎很好,我成功地运行了内置的
DijkstraShortestPathAlgorithm

问题: 我的问题是,这是最好的方法吗?看起来真的很不雅观。我最后写了一些非常难看的台词,比如:

Edge<CustomVertex> a_e = new Edge<CustomVertex>(new CustomVertex("A"), new CustomVertex("E"));
graph.AddEdge(a_e);
创建图形的过程如下所示

AdjacencyGraph<CustomVertex, Edge<CustomVertex>> graph = new AdjacencyGraph<CustomVertex, Edge<CustomVertex>>(true);

graph.AddVertex(new CustomVertex("A"));
AdjacencyGraph图形=新的AdjacencyGraph(true);
graph.AddVertex(新自定义顶点(“A”));
AdjacencyGraph<CustomVertex, Edge<CustomVertex>> graph = new AdjacencyGraph<CustomVertex, Edge<CustomVertex>>(true);

graph.AddVertex(new CustomVertex("A"));