From unknown CodePlex user on Sunday, 13 May 2012 08:24:35
Both properties "VertexCount" and "Vertices" rely on the "GetVertexCounts()" method.
The latter always fails with a KeyNotFoundException, since the vertices dictionary is initially empty.
private Dictionary<TVertex, int> GetVertexCounts( )
{
var vertices = new Dictionary<TVertex, int>( this.EdgeCount * 2 );
foreach ( var e in this.Edges )
{
vertices[e.Source]++;
vertices[e.Target]++;
}
return vertices;
}
so a solution would be e.g.:
foreach ( var e in this.Edges )
{
if ( !vertices.ContainsKey( e.Source ) )
vertices[e.Source] = 1;
else
vertices[e.Source]++;
if ( !vertices.ContainsKey( e.Target ) )
vertices[e.Target] = 1;
else
vertices[e.Target]++;
}
From unknown CodePlex user on Sunday, 13 May 2012 08:24:35
Both properties "VertexCount" and "Vertices" rely on the "GetVertexCounts()" method. The latter always fails with a KeyNotFoundException, since the vertices dictionary is initially empty.
so a solution would be e.g.: