Connect Close Vertices in a VBO

Hi everybody,
I want to connect vertex in a glBufferData with lines, but only if those vertices are closer than a certain amount. It would be easy if I could loop in the array of vertices and examine the distances one by one (that would be slow though). There’s a way to do that and still use the vbo?
Thank anyone for your help!

What I mean is: can I loop through a gl buffer containing all my vertices and then choose wich vertex to draw according to some parameter? I’m using openCL, so the vertices are initialized in openCL from the VBO object. I could easily loop through the vertices of an ofVbo class, but I don’t know how to do that directly in openGL.