build grpah class for dijkstras