Given nodes and edges
edges = [ [ ] for i in range ( 5 ) ] NEW_LINE dist = [ [ 10 ** 18 for i in range ( 1000005 ) ] for i in range ( 2 ) ] NEW_LINE N , M = 5 , 4 NEW_LINE K = 2 NEW_LINE selected = [ 1 , 3 ] NEW_LINE