error in input file

I am using METIS 4.0.1, and I can successfully run kmetis with network up to 2 Million nodes and 3 Million edges. However, I run into the following input error when I am using a larger network with over 6 Million edges.

$ kmetis network.txt 2000
*** I detected an error in your input file ***

In the first line of the file, you specified that the graph contained
6556280 edges. However, I only found 6556280 edges in the file.
Please specify the correct number of edges in the first line of the file.

This message is a bit confusing- specified 6556280 edges and found 6556280 edges. Should not be a problem then, right? Any suggestion will be appreciated.

RE: I found the reply to a

I found the reply to a similar problem
"I believe this has to do with extra trailing spaces and/or newlines at the end of the lines/file. If you delete them, then it should be okay. "

Will check my input file.

RE: error in input file

After removing the trailing spaces and newlines, the same problem remains. Any suggestion to resolve this problem?

RE: Maybe it can help

I had a similar problem and I found what was happening which was obviously my fault
of supplying wrong information and it might be a long shot and not the most appropriate way of dealing with it
but then again it might help you to pin down the problem.
It is also posted on the post topic "Segmentation fault with integer weights and not with decimals"

I figured out the problem which was caused by incorrect information I supplied.
The number of edges is 8001.
The graph check found 4000 edges.
The problem was that graph->nedges in the io.c, at some point of the code
is assigned the value of the edges mentioned in the input file times 2.
And further down the code k has the number of the edges which is 8001.
Apparently when k is divided by 2 the result is k=4000.

And in this part of the code the condition in if is correct but so is the message printed

if (k!= graph->nedges) {
printf("*** I detected an error in your input file ***\n\n");
printf("In the first line of the file, you specified that the graph contained\n%d edges. However, I only found %d edges in the file.\n", graph->nedges/2, k/2);

I decided to change the condition to k-1!=graph->nedges.
Now the partitioning is carried out as it should