Блог пользователя sahil070197

Автор sahil070197, история, 7 лет назад, По-английски

I need help in finding cycle with minimum weights in an undirected graph.Basically i am looking for an efficient approach , of lower time complexity than that of applying dijkstra after removing every edge and adding that back, it has time complexity of O(E^2logV). So something better than this..

  • Проголосовать: нравится
  • +15
  • Проголосовать: не нравится

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

If you use Floyd-Warshall to find the minimum cycle,the complexity is O(v^3).Maybe it can run faster in a graph that the number of edges is a lot larger than the number of vertices.And this one,as well as the one you mentioned above,is the most efficient way to find the minimum cycle in a graph.

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Why so many downvotes?

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      From what I understand, the same edge can't be used twice as otherwise the problem would be as simple as double the smallest edge. Floyd-Warshall would use the same edge twice so it wouldn't be correct.

      • »
        »
        »
        »
        7 лет назад, # ^ |
        Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

        I think he meant not just simply do Floyd-Warshall. And indeed it can find the minimum cycle without using the same edge twice.

        The main idea is before we try to update dist(u, v) with vertex w, we know that dist(u, v) doesn't contain vertex w, so we can update ans to min(ans, dist(u, v) + edge(u, w) + edge(w, v)).

      • »
        »
        »
        »
        7 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Maybe you misunderstand what I mean,it's obviously wrong that we use the minimal distance from i to i to update the answer.Instead,when we do FLoyd,before we update dis[i][j] by dis[i][k]+dis[k][j],we can update our answer by dis[i][k]+dis[k][j]+dis[j][i].And it's proved to be correct.

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks.. :)