Featured post
algorithm - How to find the minimum set of vertices in a Directed Graph such that all other vertices can be reached -
given directed graph, need find minimum set of vertices other vertices can reached.
so result of function should smallest number of vertices, other vertices can reached following directed edges.
the largest result possible if there no edges, nodes returned.
if there cycles in graph, each cycle, 1 node selected. not matter one, should consistent if algorithm run again.
i not sure there existing algorithm this? if have name? have tried doing research , closest thing seems finding mother vertex if algorithm, actual algorithm elaborated answer given in link kind of vague.
given have implement in javascript, preference .js library or javascript example code.
from understanding, finding connected components in graph. kosaraju's algorithm 1 of neatest approaches this. uses 2 depth first searches against later algorithms use one, simple concept.
edit: expand on that, minimum set of vertices found suggested in comments post : 1. find connected components of graph - reduce each component single vertex. 2. remaining graph dag (or set of dags if there disconnected components), root(s) of form required set of vertices.
- Get link
- X
- Other Apps
Comments
Post a Comment