python-igraph: Multiple weight attributes for shortest_paths_dijkstra


In my graph I have some edges with multiple weights. Is there any possibility to add multiple weights attributes for the shortest_paths_dijkstra in python-igraph?.
My sample code is given below:

import igraph
from igraph import *
g = Graph(directed=True)
g.add_edge('GO:1234567','GO:6789056', weight=4, weight1 = 3)
g.add_edge('GO:6789056','GO:5674321', weight=4, weight1 = None)["weight"]["weight1"]
print(g.shortest_paths_dijkstra(source="GO:1234567", target="GO:5674321", weights=weight1, mode=OUT))

This code doesn’t work as the 2nd edge doesn’t have any value for weight1. How can I define that if weight1 doesnt exist then use weight as the weight attribute?

Asked By: frasheed



I have found a solution through one of the developers (on github)["weight1"] = [
    w1 if w2 is None else w2
    for w1, w2 in zip(["weight"],["weight1"])
Answered By: frasheed
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.