I am trying to solve a problem. This program contains all the edge in a graph. The shortest path from source to destination is to find out. I have function named dotest as below.
public void dotest()
{
List<edge> tlist;
Int32 x;
setall();
Int32 ind;
foreach (edge e1 in alltest)
{
tlist = new List<edge>(alledge);
ind = 0;
foreach (edge e2 in tlist)
{
if (e2.s == e1.s && e2.d == e1.d)
{
break;
}
ind++;
}
tlist.RemoveAt(ind);
x=shortpath(tlist, start, destination);
if (x != -1)
Console.WriteLine("{0}", x);
else
Console.WriteLine("Infinity");
}
}
Describing the above code. The code already contains list of alledge(all the edge or path). I have got series of input that contains list of edge to cut off and I have to find the shortest path of the new updated edge list. I compiled my test case and some of test case worked. But for some test case it have error message as.
Unhandled Exception: System.ArgumentOutOfRangeException: Argument is out of range. Parameter name: index at System.Collections.Generic.List
1[ch_2_3_27.Solution+edge].RemoveAt (Int32 index) [0x00000] in :0 at ch_2_3_27.Solution.dotest () [0x00000] in :0 at ch_2_3_27.Solution.Main (System.String[] args) [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Argument is out of range. Parameter name: index at System.Collections.Generic.List1[ch_2_3_27.Solution+edge].RemoveAt (Int32 index) [0x00000] in :0 at ch_2_3_27.Solution.dotest () [0x00000] in :0 at ch_2_3_27.Solution.Main (System.String[] args) [0x00000] in :0
I really cannot locate out error and I think all other parts works fine. Anybody can help??
And Edge(edge) above is a struct with members s,d,w(source, destination, weight all Int 32)