【发布时间】:2012-03-27 17:18:54
【问题描述】:
我有
class Vertex{
Graph _graph;
float x;
float y;
string key;
//and some similar atributes
public IEnumerable<Edge> Edges{
get{
return _graph.Edges.Where(s => s.Source == this);
}
}
}
class Edge{
Graph _graph;
Vertex source;
Vertex target;
}
class Graph
{
private VertexCollection _vertexCollection; // extends List<Vertex>
private EdgeCollection _edgeCollection; //extends List<Edge>
public IEnumerable<Vertex> Vertexes
{
get
{
return _vertexCollection;
}
}
public IEnumerable<Edge> Edges
{
get
{
return _edgeCollection;
}
}
public IDictionary<Edge, bool> DrawableEdges
{
get
{
//want to return my uniq dictionary
}
}
Edges 和 Vertexes 被收集到列表中
一些例子:
A-->B // edge from vertex A to B
B-->C // edge from vertex B to C
C-->A // edge from vertex C to A
A-->C // edge from vertex A to C -- this is two way edge
所以我想制作IDictionary<Edge, bool>,它将保持边缘(A-->B 和 B-->A 就像 1)和 bool - 如果它是两种方式或没有。
我需要它,因为当我现在绘制它们时,它会在彼此下方绘制 2 个箭头。我最好做 1 个箭头。
所以我被困在这里了......有人可以帮帮我吗?
【问题讨论】:
-
请显示 Edge 和 Vertex 类的定义
标签: c# linq ienumerable