I have
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 and Vertexes are collected into lists
Some example:
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
So I would like to make IDictionary<Edge, bool> which would hold edges (A–>B and B–>A would be like 1), and bool – if it is two way or no.
I need it because when I draw them now, it draws 2 arrows under one another. I would better make 1 arrow.
So I’m pretty stuck right here… May anybody help me a bit ?
I think you should implement the
IEquatableinterface for yourEdgeclass:and add your edges to a
HashSet<Edge>collection. Then you can call itsContainsmethod to check if it contains the edge or not.EDIT: like Henk said, you can also implement a custom
IEqualityComparerclass:and initialize your hashset with