Graph-based Nearest Neighbor Search: From Practice to Theory