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

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

I'm new to graphs. Currently I know how to use DSU on undirected graphs but I have a question whether DSU can be used for directed graphs or not? And of course, if possible, please share the solution, as well as some places to practice this DSU part.

P/s: I'm just a newbie so I hope everyone can help. Thank you very much.

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

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

Hello, it depends on your definition of connectivity. But generally, read about SCC (Strongly Connected Components); you might find the answer.

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

    Thank you so much, I will try it

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

It's possible just depends upon what you mean by connected components like do you mean you can travel from one point to the ultimate parent or from ultimate parent to the node. And also a point can have multiple parents and as they may no necessarily merge into one. It will be difficult to implement and will also take away lots of advantages of DSU like been able to find no. of connected components, time complexity will be much higher is edge cases even O(n) making DSU pointless. There might be a different implementation which might allow for better working but as per my knowledge that's all. So in short it is possible but i wouldn't call it DSU any longer!

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

    Yes, you're right. I tried it but the complexity is quite large, making it impossible for me to change the problem so I want to find a better solution.