attribute, .
, , networkx/algorithms/shortest_paths/weighted.py
It will have a lambda declaration get_weight functionsimilar to this:
if G.is_multigraph():
get_weight = lambda u, v, data: min(
eattr.get(weight, 1) for eattr in data.values())
else:
get_weight = lambda u, v, data: data.get(weight, 1)
I wanted to give my nodespecific weight, so I changed it as follows:
if G.is_multigraph():
get_weight = lambda u, v, data: min(
eattr.get(weight, 1) for eattr in data.values())
else:
get_weight = lambda u, v, data: (data.get(weight,0) + nx.get_node_attributes(G, "node_weight").get(v,0))
I set my default weight to 0: data: data.get(weight,0)and added the value of my own node_weight attribute (default 0).
data: (data.get(weight,0) + nx.get_node_attributes(G, "node_weight").get(v,0))
vis the next achievable nodein the schedule.
Now you can install attributeafter creating the schedule.
nx.set_node_attributes(G, "node_weight", {1:3.5, 2:56})