, v - . ( ) e = O(v). ( ) e = O(v^2).
O(e + vlogv) . -, - .
, node . , node .
, .
, , e = O (v ^ 2), O(v^2 + vlogv)= O (v ^ 2).
, ?
1:
Dijkstra .
?
v * O (v ^ 2) = O (v ^ 3).
, . ( ), , ( -) .
2:
- v * v. , , , . ( 2D-), v ^ 2 .
This needs to be done for each vertex. Therefore, the time complexity is O (v ^ 3) , but with a very small constant value, which makes it extremely viable during implementation.
So, all you need is a graph in the form of an adjacency matrix, another adjacency matrix for storing new values and 3 nested loops that run throughout v * v * v times. I guess this is what is meant by stress and simple!
source
share