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

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

Remove the minimum number of edges from the following directed graph so that there exists a topological order. Draw the new graph and find the topological order using a DFS.

No. of Nodes: 9 No. of Edges: 14

Edge List: 1-4, 1-5, 2-5, 3-6, 4-9, 5-1, 5-7, 6-5, 7-4, 8-5, 9-3, 9-6, 9-7, 9-8

How can I Draw the graph?

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

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

You have to break all cycles. 5 -> 1 -> 5 is one and 4 -> 7 -> 9 -> 4 is another. So you have to remove at least one edge from each. But I don't think the solution is unique.

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

    So, the total number of edges to remove is two?

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

      I didn't look closely. At least 2. Draw it and check if there are any more cycles left after you break these two.