Good evening,
I need to a little helping seeing something through. Here is the situation:
I have a matrix of elements, for example:
Where each entry can be viewed as a node (the nodes don't have associated IDs, I just labeled them for simplicity in explaining). Then element "6" can be accessed as matrix[1][2], etc.
Now, I convert this into the follow bipartite graph structure:
Now, in adding edge from the left to right side, I have the following nested loop:
for (int i = 1; i <= 8; i++) {
for (int j = 1; j <= 8; j++) {
capacityGraph[i][j + 8] = 1; //First layer to second layer
}
}
Now, my question is:
Is there a way to access the matrix element from the bipartite traversal (doesn't have to be in the same loop)? I think the solution should be simple, I'm just not able to think it through completely. But, for example, if i=6, then I know I'm looking at the 10th node. How do I translate this to matrix[2][2]? And likewise for the jth indexing.
I've looked at few references, and I really think the answer is here:
How to map the indexes of a matrix to a 1-dimensional array (C++)?
but I'm not able to connected the dots completely for whatever reason. Any help is greatly appreciated! Thanks.