45#include <lal/graphs/directed_graph.hpp> 
   46#include <lal/internal/graphs/traversal.hpp> 
   47#include <lal/internal/data_array.hpp> 
   61inline bool __find_cycle
 
   63    const graphs::directed_graph& g, 
node u,
 
   64    char * 
const __restrict__ visited,
 
   65    char * 
const __restrict__ in_stack
 
   68    if (visited[u]) { 
return false; }
 
   72    for (
node v : g.get_out_neighbours(u)) {
 
   76        if (visited[v] == 0 and __find_cycle(g,v,visited,in_stack)) {
 
   92inline bool has_directed_cycles(
 
   93    const graphs::directed_graph& g,
 
   94    char * 
const __restrict__ vis,
 
   95    char * 
const __restrict__ in_stack
 
   98    const uint32_t n = g.get_num_nodes();
 
   99    std::fill(&vis[0], &vis[n], 0);
 
  100    std::fill(&in_stack[0], &in_stack[n], 0);
 
  101    bool has_cycle = 
false;
 
  102    for (
node u = 0; u < n and not has_cycle; ++u) {
 
  104            has_cycle = __lal::__find_cycle(g, u, vis, in_stack);
 
  117inline bool has_directed_cycles(
const graphs::directed_graph& g) {
 
  118    const uint32_t n = g.get_num_nodes();
 
  119    data_array<char> all_mem(2*n);
 
  120    char * 
const __restrict__ vis = &all_mem.data[0];
 
  121    char * 
const __restrict__ in_stack = &all_mem.data[n];
 
  122    const bool has_cycle = __lal::has_directed_cycles(g, vis, in_stack);
 
  136inline bool has_undirected_cycles(
const G& g, BFS<G>& bfs) {
 
  137    const auto n = g.get_num_nodes();
 
  143    data_array<node> parent(n, n+1);
 
  145    bool cycle_found = 
false;
 
  148    bfs.set_use_rev_edges(g.is_directed());
 
  150    bfs.set_process_visited_neighbours(
true);
 
  153    [&](
const auto&, 
const node) -> 
bool { 
return cycle_found; }
 
  155    bfs.set_process_neighbour(
 
  156    [&](
const auto& _bfs, 
node s, 
node t, 
bool) -> 
void {
 
  163        if (_bfs.node_was_visited(t)) {
 
  169            if (parent[s] != t) {
 
  180    for (
node u = 0; u < n and not cycle_found; ++u) {
 
  181        if (not bfs.node_was_visited(u)) {
 
  182            bfs.clear_structure();
 
  199inline bool has_undirected_cycles(
const G& g) {
 
  202    return __lal::has_undirected_cycles(g, bfs);
 
Main namespace of the library.
Definition definitions.hpp:48
uint32_t node
Node type.
Definition definitions.hpp:51