public static boolean hasCycle(Network<?, ?> network) {
    """
	Returns true if {@code network} has at least one cycle. A cycle is defined as a non-empty
	subset of edges in a graph arranged to form a path (a sequence of adjacent outgoing edges)
	starting and ending with the same node.
	
	<p>This method will detect any non-empty cycle, including self-loops (a cycle of length 1).
    """
    // In a directed graph, parallel edges cannot introduce a cycle in an acyclic graph.
    // However, in an undirected graph, any parallel edge induces a cycle in the graph.
    if (!network.isDirected()
        && network.allowsParallelEdges()
        && network.edges().size() > network.asGraph().edges().size()) {
      return true;
    }
    return hasCycle(network.asGraph());
  }
public static boolean hasCycle(Network<?, ?> network) {
    // In a directed graph, parallel edges cannot introduce a cycle in an acyclic graph.
    // However, in an undirected graph, any parallel edge induces a cycle in the graph.
    if (!network.isDirected()
        && network.allowsParallelEdges()
        && network.edges().size() > network.asGraph().edges().size()) {
      return true;
    }
    return hasCycle(network.asGraph());
  }
public static boolean hasCycle ( Network < ? , ? > network ) { // In a directed graph, parallel edges cannot introduce a cycle in an acyclic graph. // However, in an undirected graph, any parallel edge induces a cycle in the graph. if ( ! network . isDirected ( ) && network . allowsParallelEdges ( ) && network . edges ( ) . size ( ) > network . asGraph ( ) . edges ( ) . size ( ) ) { return true ; } return hasCycle ( network . asGraph ( ) ) ; }
Returns true if {@code network} has at least one cycle. A cycle is defined as a non-empty
subset of edges in a graph arranged to form a path (a sequence of adjacent outgoing edges)
starting and ending with the same node.

<p>This method will detect any non-empty cycle, including self-loops (a cycle of length 1).
Returns true if { @code network } has at least one cycle . A cycle is defined as a non - empty subset of edges in a graph arranged to form a path ( a sequence of adjacent outgoing edges ) starting and ending with the same node .