Cycle Detection for Directed and Undirected Graphs in Java | Check if a Graph has a Cycle | Geekific

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024

ความคิดเห็น • 4

  • @tomasalves5182
    @tomasalves5182 9 หลายเดือนก่อน

    Thanks, i've been searching for hours but only this did the trick, thank you so much

  • @tedelamater
    @tedelamater ปีที่แล้ว

    I feel like BFS is easier to find cycles.

  • @manOfPlanetEarth
    @manOfPlanetEarth ปีที่แล้ว

    Niiiice!!!
    One small remark. Boolean "onCurrentPath" instead of "beingVisited" would be more reflecting what's going on:)
    We have multiple being visited vertices in the path under exploring while function "hasCycle" at every moment works with only one vertex. It confuses. Even boolean "green" would be more self-telling:)
    2. As I get your "stream branded" approach is not applicable here because of need to return value (boolean), is it?
    Thank you for the material🥳

    • @geekific
      @geekific  ปีที่แล้ว +1

      Glad I could help :) and 2-Yup.