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

Поделиться
HTML-код
  • Опубликовано: 5 ноя 2024

Комментарии • 4

  • @tomasalves5182
    @tomasalves5182 11 месяцев назад

    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.