View yen.py
def path_cost(graph, path, weights=None):
pathcost = 0
if weights is None:
pathcost = len(path)-1
else:
for i in range(len(path)):
if i > 0:
edge = graph.es.find(_source=min(path[i-1], path[i]),
_target=max(path[i-1], path[i]))