Added shortest path for weighted graphs.