create table graph (id int, node char, parent char);
insert into graph values (1, 'A', NULL);
insert into graph values (2, 'B', 'A');
insert into graph values (3, 'C', 'A');
insert into graph values (4, 'D', 'B');
insert into graph values (5, 'D', 'C');
insert into graph values (6, 'E', 'D');
insert into graph values (7, 'F', 'E');
insert into graph values (8, 'C', 'F');

with cte (id, node, parent, cycle, path) as (
  select 
    graph.id, graph.node, graph.parent, 0, '/' || graph.id || graph.node
  from graph where id = 1
  UNION ALL
    select graph.id, graph.node, graph.parent,
         INSTR(cte.path, graph.id || graph.node),
         cte.path || '/' || graph.id || graph.node 
    from graph, cte
    where 
      cte.node = graph.parent and 
      INSTR(cte.path, graph.id || graph.node) = 0
)
select * from cte



select 
  id, node, parent, CONNECT_BY_ISCYCLE as cycle, 
  SYS_CONNECT_BY_PATH(id || NODE, '/') "Path" 
from graph
  start with node = 'A' 
  connect by NOCYCLE prior node = parent;
