# Using ofMesh indices to establish pairs of vertices

I have an ofMesh object, and I have vertices and indices defined (as well as a way to shuffle my indices), and while in line mode, there are clear “a to b” relationships between these vertices. What I can’t figure out is how to use getVertex to select a and b (and particularly as I’m shuffling indices). I did get it to work in this way:

``````    int tempFire = ofRandom(numVerts);
int tempDest = NULL;

if(tempFire%2){
tempFire --;
}

tempDest = mesh.getIndex(tempFire+1);
ofVec3f firingNeuron = mesh.getVertex(tempFire);
ofVec3f destNeuron = mesh.getVertex(tempDest);

for (float i=0;i<10;i++){
float delta = i/10;
ofVec3f cNeuron = destNeuron-firingNeuron;
ofVec3f signal = firingNeuron + delta*(cNeuron);
pathMesh.setupIndicesAuto();
}
``````

So in that way, a is a random vertex based off of the number of vertices, and b is the vertex with the index one higher. So now I am properly selecting [0,1] [2,3] [4,5], etc. This works well initially, but when I perform this shuffling algorithm:

``````    //Fisher-Yates Shuffle
for (int i = numVerts - 1; i >= 0; i --) {
int index = (int)ofRandom(i);
int tempIndex = mesh.getIndex(index);
mesh.setIndex(index, mesh.getIndex(i));
mesh.setIndex(i, tempIndex);
}
``````

the “pairings” don’t change with the shuffle.

Would anyone have any advice? If there is any information I’m forgetting to mention, or if I can improve on something, let me know, any help is appreciated.

Thanks