August 26, 2024

P81 - Path from one node to another one.

Write a method namedfindPathsto find acyclic paths from one node to another in a graph. The method should return all paths.

> Digraph.fromStringLabel("[p>q/9, m>q/7, k, p>m/5]").findPaths("p", "q")
  res0: List[List[String]] = List(List(p, q), List(p, m, q))
      
  > Digraph.fromStringLabel("[p>q/9, m>q/7, k, p>m/5]").findPaths("p", "k")
  res1: List[List[String]] = List()
Be first to comment
Leave a reply