uses weighted graphs, an attempt at nearest neighbor algorithm