Although Networkx's is_negatively_weighted attribute is not true, why does Dijkstra's algorithm return "Contradictory paths found: negative weights?"

add a comment

2

This error message is caused by the fact that Dijkstra's algorithm assumes that all edge weights are non-negative. If even a single edge in the input graph has a negative weight, the algorithm may produce incorrect results or even fail to terminate at all.

In some cases, the algorithm may still work correctly if the negative weights are small and only occur in specific parts of the graph. However, if there are negative cycles (i.e., loops in the graph where the sum of edge weights is negative), the algorithm will produce incorrect results or terminate with the "Contradictory paths found: negative weights" error message.

Therefore, even if the is*negatively*weighted attribute is not true, it's important to ensure that the input graph doesn't have any negative weights or cycles before running Dijkstra's algorithm.

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Asked: ** 2022-08-05 11:00:00 +0000 **

Seen: **8 times**

Last updated: **Jan 27 '22**

How can I deal with Expression.Error related to a column in Power Query?

How can you implement pagination in Oracle for the LISTAGG() function?

What is the process for implementing a FutureBuilder on an OnTap function in Flutter?

How can we require users to be logged in before they can access the root folders in WordPress?

In SCSS, what is the method for grouping and reusing a set of classes and styles?

How can popen() be used to direct streaming data to TAR?

How does iOS retrieve information from a BLE device?

How can Django Admin accommodate a variety of formats and locales for its input fields?

Copyright QStack.ai, 2010-2023. Content on this site is licensed under the Creative Commons Attribution Share Alike 3.0 license.