[Solved] Reading adjacency list from file


It sounds like you’re having trouble reading two numbers in at once (the weight and destination). Are you ready to have your mind blown? You can chain the input operator!

That means that you can do:

int dest, weight;
while( is >> dest >> weight ) {
    edge++;
    E[edge].beg = row;
    E[edge].end = dest;
    E[edge].weight = weight;
}

solved Reading adjacency list from file