TGraph retrieve vertex index given a point

I am pretty new to Root, and have been put on a project where Root is used for displaying graphs. II hope that this request is valid for this area in the forum.

We have plots that have TCutG objects on them. I have created a dialog that displays the x,y coordinate values when given a particular TCutG, and updates the display as the user is moving any vertex or the whole cut.

What I need now is to be able to change a coordinate value in the dialog and, on losing focus in the edit box, update the TCutG with the new coordinate value. My problem is that I don’t see a method in either TCutG or TGraph for retrieving the vertex index when given a coordinate point.

I know that I could just run the vertices in the TCutG object and find the index to the vertex that has the same values as the original point before the user made the change. But that seems like too much added work if Root is already able to return this information faster. If anyone is able to help me either verify that there is indeed a better way to do this, that would be great. Otherwise I’ll go ahead and use this method.

One possible way can be the following macro.
Execute it and move the mouse over the graph points.
hlGraph1.C (644 Bytes)