Get your own website
Python
C
Java
 
Python result:
C result:
Java result:
Adjacency Matrix:
0 0 1 0 0 0 0
0 0 1 0 0 0 0
0 0 0 0 0 1 1
1 0 0 0 1 0 0
1 0 0 0 0 0 0
0 1 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

Depth First Search starting from vertex D:
D A C F B G E

Breadth First Search starting from vertex D:
D A E C F G B
Adjacency Matrix:
0 0 1 0 0 0 0
0 0 1 0 0 0 0
0 0 0 0 0 1 1
1 0 0 0 1 0 0
1 0 0 0 0 0 0
0 1 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

Depth First Search starting from vertex D:
D A C F B G E

Breadth First Search starting from vertex D:
D A E C F G B
Adjacency Matrix:
0 0 1 0 0 0 0
0 0 1 0 0 0 0
0 0 0 0 0 1 1
1 0 0 0 1 0 0
1 0 0 0 0 0 0
0 1 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

Depth First Search starting from vertex D:
D A C F B G E

Breadth First Search starting from vertex D:
D A E C F G B