Get your own website
Python
C
Java
 
Python result:
C result:
Java result:
Adjacency Matrix:
0 0 1 0 0 0 0
0 0 0 0 0 1 0
0 1 0 0 1 0 1
1 0 0 0 0 0 0
1 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

Vertex Data:
Vertex 0: A
Vertex 1: B
Vertex 2: C
Vertex 3: D
Vertex 4: E
Vertex 5: F
Vertex 6: G

Current vertex: A
Current vertex: C
Current vertex: B
Current vertex: F
Current vertex: E

Graph has cycle: True
Adjacency Matrix:
0 0 1 0 0 0 0
0 0 0 0 0 1 0
0 1 0 0 1 0 1
1 0 0 0 0 0 0
1 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

Vertex Data:
Vertex 0: A
Vertex 1: B
Vertex 2: C
Vertex 3: D
Vertex 4: E
Vertex 5: F
Vertex 6: G

Current vertex: A
Current vertex: C
Current vertex: B
Current vertex: F
Current vertex: E

Graph has cycle: Yes
Adjacency Matrix:
0 0 1 0 0 0 0
0 0 0 0 0 1 0
0 1 0 0 1 0 1
1 0 0 0 0 0 0
1 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

Vertex Data:
Vertex 0: A
Vertex 1: B
Vertex 2: C
Vertex 3: D
Vertex 4: E
Vertex 5: F
Vertex 6: G

Current vertex: A
Current vertex: C
Current vertex: B
Current vertex: F
Current vertex: E

Graph has cycle: true