Class CycleDetectedException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class CycleDetectedException extends GraphException
Cycle Detected Exception 检测到环异常

Exception thrown when a cycle is detected in a graph where cycles are not allowed.

当在不允许环的图中检测到环时抛出的异常。

Features | 主要功能:

Usage Examples | 使用示例:

try {
    List<String> order = TopologicalSortUtil.sort(graph);
} catch (CycleDetectedException e) {
    List<?> cycle = e.getCycle();
}

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
  • Null-safe: Yes (cycle may be null if not provided) - 空值安全: 是(未提供时cycle可能为null)
Since:
JDK 25, opencode-base-graph V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • CycleDetectedException

      public CycleDetectedException(List<?> cycle)
      Create cycle detected exception 创建检测到环异常
      Parameters:
      cycle - the detected cycle | 检测到的环
    • CycleDetectedException

      public CycleDetectedException(String message)
      Create cycle detected exception with message 使用消息创建检测到环异常
      Parameters:
      message - the error message | 错误消息
  • Method Details

    • getCycle

      public List<?> getCycle()
      Get the detected cycle 获取检测到的环
      Returns:
      the cycle vertices | 环的顶点