Hi,
Thanks for the response Tiago!
I also wonder if the performance differences between those two graphs
are expected to be much different, i.e., it takes 9 minutes to obtain
shortest path between 400,000 pairs in the normal graph, and it takes
52 hours for the weighted one.
Here is how I'm doing it:
path = []
for item in pairs:
vpath, epath = gt.shortest_path(weighted_graph,
weighted_graph.vertex(item[0]),
weighted_graph.vertex(item[1]),
weights=weights,
negative_weights=True)
Alıntı Tiago de Paula Peixoto <ti...@skewed.de>:
Am 23.10.18 um 20:43 schrieb Ozgun Altunkaya:
When I return the above function, it is reasonably fast, however the edge
indices don't match with those of graph (no weights), hence the weights are
wrong.
This is because you are using the edge descriptors of the wrong graph. What
you probably want to do is:
for e in graph.edges():
weight = get_weight(int(e.source()))
ne = weighted_graph.add_edge(int(e.source()), int(e.target()))
weights[ne] = weight
Also, I need to generate weighted_graph for at least 5-10 times, each with
different weights (however the edges and vertices are remain the same,
only weights change.) Is there a faster/better way to do this?
You can access the weights as a numpy array via:
weights.fa
It can be faster to just update this array, than to re-generate the whole
thing from scratch.
Best,
Tiago
--
Tiago de Paula Peixoto <ti...@skewed.de>
_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool