Floyd–Warshall algorithm ,Behavior with negative cycles
Given a graph, suppose to have a cycle given by Nodes $i \ $,$\ j$,$\ k$ of negative cost. 

Example:


$w(i,j)=2,\ w(j,k)=4,\ w(k,i)-7$

+---+    +2      +---+
| i |+----------&gt;| j |
+-+-+            +-+-+
  ^                |
  | -7             |+4
  |     +---+      |
  +----+| k |&lt;-----+
        +---+



Suppose you want to find the shortest path between $i$ and $j$.

You have

$P=\{(i,j)\}$ with $cost(P)=2$

but you can loop through the negative cycle and have:

$P'=\{(i,j),(j,k),(k,i),(i,j)\}$ with $cost(P')=1$
 $P''=\{(i,j),(j,k),(k,i),(i,j),(j,k),(k,i),(i,j)\}$ with $cost(P'')=0$
and so on.

You could loop forever through the negative cycle and decrease the cost of the path.

Same if you consider an undirected graph with an edge that has negative weight.