Give a linear-time algorithm that takes as input a directed acyclic graph G = (V, E) and

Question:

Give a linear-time algorithm that takes as input a directed acyclic graph G = (V, E) and two vertices s and t, and returns the number of simple paths from s to t in G. For example, the directed acyclic graph of Figure 22.8 contains exactly four simple paths from vertex p to vertex ?: po?, pory?, posry?, and psry?. (Your algorithm needs only to count the simple paths, not list them.)

image

Figure 22.8 A dag for topological sorting.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Introduction to Algorithms

ISBN: 978-0262033848

3rd edition

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

Question Posted: