OP, you don't understand what Graphs are. I strongly encourage you to either re-read the textbook material or find more resources online, Wikipedia as well as university websites are a good choice. Once you understand what graphs are, you can start tackling their traversal.
Oh i think iam getting it. If you traverse a graph like this you don't get the edge weight. So because of that its useless. You need to do a BFS or DFS so that edge weights are also considered.