FubarDevelopment / QuickGraph

Fork of https://quickgraph.codeplex.com/
Microsoft Public License
9 stars 2 forks source link

CP-12469: BidirectionalGraph KeyNotFoundException errror #42

Closed fubar-coder closed 6 years ago

fubar-coder commented 6 years ago

From unknown CodePlex user on Monday, 26 January 2009 05:54:38

I am getting this error for trying to add an edge to a Bidirectional graph.

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
 at System.ThrowHelper.ThrowKeyNotFoundException()
 at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
 at QuickGraph.BidirectionalGraph`2.AddEdge(TEdge e)

My code is:

this.graph = new BidirectionalGraph<Vertex<int>, Edge<Vertex<int>>>(true);

  I created a Vertex class for the X and Z values for the Key, and am using Edge<> for the value. I created the two verteces I want to use for the edge (Target and Source then addEdge(Edge<Vertex> e)), yet I get a Key not found error.   For QuickGraph v3.2.40122

fubar-coder commented 6 years ago

Form unknown CodePlex user on Monday, 26 January 2009 11:45:23

Thanks. Also I have accidentally added repeat posts.

fubar-coder commented 6 years ago

Form unknown CodePlex user on Monday, 26 January 2009 11:46:24

I do add the vertices first but i will try AddVerticesAndEdge.

fubar-coder commented 6 years ago

Form unknown CodePlex user on Monday, 26 January 2009 18:54:32

I have tried AddVerticesAndEdge() and it works to a point. There seems to be a bug. It retains the amount of edges and vertices added but labels them all with the last edge only.

fubar-coder commented 6 years ago

Form unknown CodePlex user on Tuesday, 27 January 2009 08:40:58

"It retains the amount of edges and vertices added but labels them all with the last edge only." I'm not sure what you mean. Please provide a repro test case that I can investigate.

fubar-coder commented 6 years ago

Form unknown CodePlex user on Thursday, 29 January 2009 10:32:56

Here is a link to an unstable source release of this on the SmartMap page. http://www.codeplex.com/smartmap/Release/ProjectReleases.aspx?ReleaseId=22524

It should give a readout of what to do in the console. The log file is in the bin directory. I hope this helps.

fubar-coder commented 6 years ago

Form unknown CodePlex user on Thursday, 29 January 2009 14:49:52

It does not help. Please provide a self-contained repro test case.

fubar-coder commented 6 years ago

Form unknown CodePlex user on Friday, 30 January 2009 11:54:51

There are two project test cases along with the QuickGraph projects here (ErrorKeyNotFound and ErrorRepeatEdges projects):

http://www.thinkresults.com/mark1/testcase/quickgraph_errors.zip

fubar-coder commented 6 years ago

Form unknown CodePlex user on Friday, 30 January 2009 18:19:14

Please post the repro test cases only, not the full 5Mb source. The problem is that Vertex is a class, if you want your sample to work as is you need to either (1) turn vertex into a struct, (2) have Vertex implement IEquatable<Vertex>.

fubar-coder commented 6 years ago

Form unknown CodePlex user on Sunday, 01 February 2009 14:43:30

It worked great. Just brushing up on my .NET skills. Thanks.

fubar-coder commented 6 years ago

Form unknown CodePlex user on Sunday, 01 February 2009 22:54:34

No problem. I suspected that from the beginning. Providing a isolated repro test case would have caught this much earlier ;)