code: function(state, x, y)
  	{
  		var index = -1;
  		
  		if (state.absolutePoints.length > 0)
  		{
  			var last = state.absolutePoints[0];
  			var min = null;
  			
  			for (var i = 1; i < state.absolutePoints.length; i++)
  			{
  				var current = state.absolutePoints[i];
  				var dist = mxUtils.ptSegDistSq(last.x, last.y,
  					current.x, current.y, x, y);
  				
  				if (min == null || dist < min)
  				{
  					min = dist;
  					index = i - 1;
  				}
  
  				last = current;
  			}
  		}
  		
  		return index;
  	}
docs: Function: findNearestSegment
  
  Finds the index of the nearest segment on the given cell state for
  the specified coordinate pair.