graph algorithms: reachability from adjacency map -
I have a dependency graph, which I used to call Looking at the list of nodes Example: Example For, presented as adjacent map If the Graph Algorithms rush as well as references to the online search, so if I can point to an efficient algorithm description for accessibility, so I appreciate it. (Some examples that not are helpful to me, because the algorithm is to determine whether a particular node A is accessible from a specific node B.) * Cyclic: If you are curious, that's because it represents the type of C / C + +, and can be a member of the structures that give the signal to the structure in question. In Python: map & lt; Node, collection & lt; Node & gt; & Gt; (in Java-Speech, or
f (node n) - & gt; Collection [node] as a function; it is a given node
n Mapping from is a collection of nodes which depends on
n ) graph is potentially cyclic *.
map & lt; Node, set & lt; Node & gt; & Gt; ;
(x -> y stands for node y depends on node x) n1 - & gt; N 2 N 2 - & gt; N3 N3 - & gt; N1N3 - & gt; N5N4 - & gt; N2N4 - & gt; N5 N6 - & gt; N1N7 - & gt; N1
{n1: [n2], n2: [n3], n3: [n1, n5], n4: [n2, n5] Can be done], N6: [N1], N7: [N1]} .
badlist = [n4, n5, n1] then
def accessible (article, balllist): Badmap = {} in the badge list for the root: stack = [root] visit = set () stack: V = stack.pop () if the visit is visited: Continue to visit stack.extend (article [V]) Done.ad (v) badmap [root] = visited badmeap visited
Comments
Post a Comment