use indexes on nodes and edges
handle Inf