TheChickenQT's blog

By TheChickenQT, history, 106 minutes ago, In English

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.

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
75 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    16 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thank you so much, I will try it

»
71 minute(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

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!

  • »
    »
    34 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.