I need to read the following kind of file:
dl
format=edgelist1
n=10
data:
1 10 25.8
1 7 53.6
1 3 56.6
2 10 -19.8
2 8 -72.6
2 7 -96.7
2 6 -71.7
2 5 27.1
2 3 2.7
3 9 27.5
3 8 22.5
3 4 -78.2
4 7 5.3
4 6 -41.5
5 10 -61.6
5 9 5.2
5 7 83.8
5 6 -29.5
6 10 -87.4
6 9 -96.0
6 7 78.0
7 10 70.2
8 10 52.0
8 9 8.0
After data:
, each line represents a weighted edge.
I am using this loop to read it:
while(u!=0)
{
u=0;
v=0;
weight=0;
fscanf(fp,"%d",&u);
fscanf(fp,"%d",&v);
fscanf(fp,"%f",&weight);
fscanf(fp,"\n");
if (u==0)
{
break;
}
}
It works fine for most graphs. However, in one case I tested, it never leaves the loop.
At first, I thought it was because it wasn't recognizing the floats as it should, but that would mean no graph would be read correctly, as the format is the same.
Furthermore, it successfully read a bunch of connected 1000-vertex graphs. However, it doesn't perform well with one of them. The absurd number of edges makes it impossible for me to analyze edge by edge, so I need help.