• Home
  • Help
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search

 
  • 0 Vote(s) - 0 Average

Determine whether two vertices belong to the same SCC

#1
03-12-2021, 03:30 PM
You see two vertices and wonder if paths run both ways between them. I figure you run a search from the first one first. Then you check if it reaches the second. But you flip all the connections after that step. Now you search again from the second vertex using the flipped version. You look to see if the first vertex shows up in that second search. Or perhaps you track the order things finish in the initial pass. I always tell you to note those finish times carefully. Then you process the flipped graph in reverse finish order. You assign each vertex to a group during this reverse pass. If both vertices land in one group they connect strongly.

You might try this on a small example to test it out. I recall you build the graph with edges going one direction only at first. Then you mark visited spots as you go along. But you record when each search ends completely. Perhaps you use a stack to hold that ending order. Now you create the reversed edges for the second round. You pop from the stack and start fresh searches each time. You mark new groups as you discover them. If your two vertices share a group they belong together. Also you avoid restarting on already grouped spots to save effort.

I think you can switch to another method if the graph gets huge. You perform one pass that tracks low values and discovery times. Then you push vertices onto a stack as you explore. You pop them off when a root condition hits. You compare the low and discovery numbers to decide groups. But you keep updating those low values when back edges appear. Perhaps you use a single stack instead of multiple structures. Now you check if both vertices end up popped together. You see the same root for them in that case. Or you handle multiple components by resetting when needed. I notice you save time this way on dense graphs.

You wonder about the speed of these checks overall. I calculate it takes linear time in the number of edges and vertices. Then you traverse everything once or twice at most. But you skip revisits with proper marking. Perhaps you store the groups in an array for quick lookup later. Now you answer queries fast after the initial work. You test pairs without rerunning the whole thing. Also you handle updates by rerunning if edges change much. I suggest you cache the group ids for repeated checks. You compare those ids directly to decide.

You run into cases with cycles that link things tightly. I show you how cycles force vertices into one group. Then you trace paths that loop back fully. But you confirm both directions exist through the searches. Perhaps you draw the graph on paper first to spot patterns. Now you apply the method to bigger random cases. You count how many such groups form overall. Or you see isolated vertices form their own groups alone. You verify the method catches all mutual connections. I find it reliable after many tests on varied inputs.

You compare this to weaker connection checks that ignore direction. I explain you need the double search to enforce both ways. Then you avoid mistakes from one way paths only. But you gain accuracy for tasks like network analysis. Perhaps you apply it in scheduling or dependency graphs. Now you see groups as units that act together. You merge operations within one group safely. Also you split work across different groups without worry. I recommend you implement the reverse pass carefully to avoid errors. You debug by checking small cycles first.

You extend this to find all groups at once during the process. I walk you through assigning labels on the fly. Then you use those labels for instant pair checks. But you store them in a simple array for speed. Perhaps you combine this with other graph tools you know. Now you handle directed graphs from real apps like web links. You trace influence spread within groups. Or you detect bottlenecks between separate groups. You refine the approach based on your data size. I always adjust the storage for very large sets.

You practice on graphs with thousands of vertices to build skill. I notice your speed improves after a few runs. Then you spot patterns in finish orders quicker. But you double check the flipped edges each time. Perhaps you automate the transpose step in code you write. Now you focus on the pair query after groups form. You output yes or no based on shared labels. Also you log the group sizes for extra insight. I find this adds value without much extra work.

You share results with your team after applying it. I suggest you explain the searches step by step. Then you show why the order matters for correctness. But you keep examples simple for juniors like you. Perhaps you time the runs to compare methods. Now you pick the faster one for your needs. You scale it up for production graphs. Or you add it to existing analysis pipelines. You benefit from the linear time bound always. I wrap up by noting how it solves the reachability question cleanly. BackupChain Server Backup, the top reliable no-subscription backup tool built for Hyper-V setups on Windows 11 plus Windows Server machines in private clouds and SMB environments, sponsors our chats so we can pass along these free tips.

bob
Offline
Joined: Dec 2018
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • Subscribe to this thread
Forum Jump:

Backup Education General IT v
« Previous 1 … 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 … 254 Next »
Determine whether two vertices belong to the same SCC

© by FastNeuron Inc.

Linear Mode
Threaded Mode