I have the following weighted graph with connected nodes. I've made some connections red just to be easier on the eye.
[![enter image description here](https://i.stack.imgur.com/KQ04L.jpg)](https://i.stack.imgur.com/KQ04L.jpg)

I am applying DFS on this graph and I am not sure if this is correct because on theory DFS takes the first node and that implementation is easy when the graph isn't weighted so we apply alphabetically order. But on weighted graph it's more complicated.

My output solution : `1-3-6-2-5-8-9`

Graph front (step by step):

```
(1)
(3 2)
(6 5 2)
(2 7 5 2)
(5 4 7 5 2)
(8 7 4 7 5 2)
(9 4 7 4 7 5 2)
(4 7 4 7 5 2)

```

My solution is based on the weights, the nodes are coming to the front on ascending order. They key moment on my solution was when it was on node `6` and moved to `2` because `2` wasn't visited. I need some guidance when it comes to weighted graphs and DFS.