Quantcast
Channel: quickgraph Work Item Rss Feed
Viewing all articles
Browse latest Browse all 25

Created Unassigned: Edge equality backwards? [65877]

$
0
0
I am using an UndirectedGraph with a default TEdge of UndirectedEdge. I set AllowParallelEdges to false. However, I was surprised to find that I could still create an edge between two existing verticies that already had an edge between them as long as I created the edge in the opposite direction as before. This seemed wrong to me since this is an undirected graph so direction shouldn't matter. I then looked at your source to see what the default edge equality was done. I was surprised to see this:

```
/// <summary>
/// Returns the most efficient comporer for the particular type of TEdge.
/// If TEdge implements IUndirectedEdge, then only the (source,target) pair
/// has to be compared; if not, (source, target) and (target, source) have to be compared.
/// </summary>
/// <typeparam name="TVertex">type of the vertices</typeparam>
/// <typeparam name="TEdge">type of the edges</typeparam>
/// <returns></returns>
public static EdgeEqualityComparer<TVertex, TEdge> GetUndirectedVertexEquality<TVertex, TEdge>()
where TEdge : IEdge<TVertex>
{
if (typeof(IUndirectedEdge<TVertex>).IsAssignableFrom(typeof(TEdge)))
return new EdgeEqualityComparer<TVertex, TEdge>(SortedVertexEquality<TVertex, TEdge>);
else
return new EdgeEqualityComparer<TVertex, TEdge>(UndirectedVertexEquality<TVertex, TEdge>);
}
```

Isn't that backwards? If an edge is IUndirectedEdge, then we should use the UndirectedVertexEquality NOT the SortedVertexEquality? If I manually set the equality to UndirectedVertexEquality, then I get the behavior I expected.

Viewing all articles
Browse latest Browse all 25

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>