I have a text file which has some number of integers in each line. Example:
1 2 4
3
0 4
2 3
Here 1st line means that the 1st node is connected to nodes numbered 1, 2 and 5. Blank line means 4th node isn't connected to any node.
This gives me a directed graph.
This SO question might have been helpful but it assumes each line to have 2 integers, whereas in this case it can have any number of integers from 0 to N-1(N is no. of nodes).
I just want to know how to read this text file. If I had two integers per line, I could have done infile >> a >> b. How to know that "
" or end of line has occured.
I am not asking for code that makes directed graph.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…