Any binary tree can convert to a graph, because a tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any acyclic connected graph is a tree.

So the only problem is how to convert the binary tree data structure to the graph data structure. Let’s figure out it.