Those aren't hierarchies; they are directed graphs. You can still use CONNECT BY in Oracle to work with them, but without a root node to START WITH, performance might be a problem if your data set is large.
Anyway, what you need to do is CONNECT BY NOCYCLE without a START WITH. That will compute a tree starting from each separate node. Then, get the CONNECT_BY_ROOT for each node and take the MIN() for each distinct node value.
Here is a working example, with data. It's more complicated than it needs to be because there is nowhere to get a complete list of all the nodes, so you have to split each vertex into two rows (one have the from_node and one have the to_node) to make sure you're including all of them.
CREATE TABLE tbl_tst ( from_node VARCHAR2(1), to_node VARCHAR2(1) );
INSERT INTO tbl_tst VALUES ( 'a', 'b');
INSERT INTO tbl_tst VALUES ( 'b', 'c');
INSERT INTO tbl_tst VALUES ( 'b', 'd');
INSERT INTO tbl_tst VALUES ( 'd', 'a');
INSERT INTO tbl_tst VALUES ( 'd', 'e');
INSERT INTO tbl_tst VALUES ( 'f', 'g');
INSERT INTO tbl_tst VALUES ( 'g', 'h');
INSERT INTO tbl_tst VALUES ( 'h', 'f');
INSERT INTO tbl_tst VALUES ( 'i', 'j');
COMMIT;
WITH groups AS (
SELECT DISTINCT
tt.from_node,
tt.to_node,
MIN(CONNECT_BY_ROOT(from_node))
OVER ( PARTITION BY tt.from_node) group_min
FROM tbl_tst tt
CONNECT BY NOCYCLE from_node = PRIOR to_node
OR to_node = PRIOR from_node
)
SELECT DENSE_RANK() OVER ( ORDER BY group_min ) group_number,
DECODE(splitter.rn,1,groups.from_node,2,groups.to_node) node
FROM groups
CROSS JOIN ( SELECT rownum rn FROM dual CONNECT BY rownum <= 2 ) splitter
GROUP BY DECODE(splitter.rn,1,groups.from_node,2,groups.to_node),
group_min
ORDER BY group_min, node;
+--------------+------+
| GROUP_NUMBER | NODE |
+--------------+------+
| 1 | a |
| 1 | b |
| 1 | c |
| 1 | d |
| 1 | e |
| 2 | f |
| 2 | g |
| 2 | h |
| 3 | i |
| 3 | j |
+--------------+------+