Our posts crossed paths.
Your approach is somewhat similar to what I suggested, but you are not using the Dictionary correctly. By iterating through it you are defeating its purpose, which it to provide quick lookups. Use Dictionary.TryGetValue() instead. And if you use a Dictionary, you do not also need to use Graph.Vertices.Contains().
Also, I hope you are not implementing the same code twice, once for each vertex. Create one GetOrAddVertex() function instead, and call it twice.
-- Tony
Your approach is somewhat similar to what I suggested, but you are not using the Dictionary correctly. By iterating through it you are defeating its purpose, which it to provide quick lookups. Use Dictionary.TryGetValue() instead. And if you use a Dictionary, you do not also need to use Graph.Vertices.Contains().
Also, I hope you are not implementing the same code twice, once for each vertex. Create one GetOrAddVertex() function instead, and call it twice.
-- Tony