So i know that it cannot be used if the directed graph has negative cycle, but what about the undirected graphs with negative edges?
is it going to always work, or sometimes or never?
So i know that it cannot be used if the directed graph has negative cycle, but what about the undirected graphs with negative edges?
is it going to always work, or sometimes or never?
Floyd–Warshall can be used to detect the presence of negative cycles in directed graphs. This aspect has been widely used in the scheduling community in the form of detecting consistency of a simple temporal network. To answer your question, the values output by Floyd–Warshall will be correct even in the presence of negative edges as long as there are no negative cycles.