You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From unknown CodePlex user on Sunday, 05 February 2017 06:34:15
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.
The text was updated successfully, but these errors were encountered:
From unknown CodePlex user on Sunday, 05 February 2017 06:34:15
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:
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.
The text was updated successfully, but these errors were encountered: