I'm trying to solve a problem which seems very complex but im having a feeling that it has a simple solution. I'm reading graph edges from a text file along with their weights and storing it in a 2d array;
1 2 3 4 5 6 7
FILE *fin = fopen("somefile.txt", "r");
for (int i = 0; i <=edges; i++) {
fscanf(fin, "%d%d%d", &u, &v, &w);
graph[u][v]=w;
}
fclose(fin);
The test file contains edges in the following format;
1 2 3 4 5
1 2 10
1 3 10
1 4 10
3 5 10
4 3 10
Now I would like to generate N possible graph edges. I dont care whether its a valid combination or not at the moment. So if N=2, possible combination is;
If N=3..you can all guess what that means. We can clearly see that we have some duplicates but I will check for duplicates later. My question, how can I accomplish this as i thought lot about it but nothing makes sense. :(