franktakes / teexgraph

C++ library for large-scale network analysis and computation
GNU General Public License v3.0
24 stars 8 forks source link

loadDirected stuck when reading files start with a newline '\n' #20

Closed tadshi closed 6 months ago

tadshi commented 7 months ago

Hello!

I was using this nice library in my research when I happened to find that the function Graph::loadDirected will fall into a non-terminating loop when reading a file starts with a newline. This is due to the line 147 in graph.cpp, which will cause line 149 to peek forever if the first character it get from fin at line 141 is '\n'.

Even though the fix is rather easy, I reckon this is an unexpected behavior so I try to report it here. Maybe there can be a patch? :)

franktakes commented 6 months ago

Hi @tadshi, great to hear that teexGraph is useful for your research. I did a little fix so that now it's possible to have files start with new lines (or in fact, "whitespace" in general). Happy coding!