0

We deal with a directed graph which may contain or not cycles and may be or not be connected. We want to find the minimum set of vertex such that every other vertex in the graph is accessible from them.

For example, given: https://i.stack.imgur.com/wtRYB.png (SO won't let me post images :/ )

A solution could be (A, E) or (A, F).

My first approach was to look for nodes without parents (indegree = 0), but this fails to take into account the aforementioned cycles.

After a quick search, I have found relatively little regarding non-acyclic digraphs in SO. So, what is the lowest complexity algorithm you can suggest me?

Jsevillamol
  • 2,425
  • 2
  • 23
  • 46

1 Answers1

0

Second attempt.

This is what I've thought of:

let V be a copy of the set's vertex.

  1. Choose node from V. Mark it somehow
  2. While V has a parent unmarked, choose it.
  3. When the process finishes, you'll be left with one root. Note that it can be part of a cycle, the marks will make sure the process finishes.
  4. Now propagate recursively a delete message between the childs of the root. That is, it will order his childs to order his childs the same and then delete themselves from V.
  5. Choose another node from wht's left of V; rinse and repeat.

It works, but I cannot help but wonder if there is a faster method. Ideas?

Jsevillamol
  • 2,425
  • 2
  • 23
  • 46