---
id: 68760b53e250f982473e1808
title: Step 13
challengeType: 20
dashedName: step-13
---

# --description--

If the conditional you just added is true, that means the current node is the best unvisited option you've found so far and you need to update your variables to reflect that.

Inside the `if` block, update `min_distance` to `distances[node_no]` and set `current` to `node_no`.

# --hints--

You should update the `min_distance` variable to `distances[node_no]`.

```js
({
    test: () => {
      assert(
        runPython(
          `_Node(_code).find_function("shortest_path").find_for_loops()[0].find_bodies()[0].find_for_loops()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_stmt("min_distance = distances[node_no]")`
        )
      );
    }
});
```

You should set `current` to `node_no`.

```js
({
    test: () => {
      assert(
        runPython(
          `_Node(_code).find_function("shortest_path").find_for_loops()[0].find_bodies()[0].find_for_loops()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_stmt("current = node_no")`
        )
      );
    }
});
```

# --seed--

## --seed-contents--

```py
INF = float('inf')
adj_matrix = [
    [0, 5, 3, INF, 11, INF],
    [5, 0, 1, INF, INF, 2],
    [3, 1, 0, 1, 5, INF],
    [INF, INF, 1, 0, 9, 3],
    [11, INF, 5, 9, 0, INF],
    [INF, 2, INF, 3, INF, 0],
]

def shortest_path(matrix, start_node, target_node=None):
    n = len(matrix)
    distances = [INF] * n
    distances[start_node] = 0
    paths = [[node_no] for node_no in range(n)]
    visited = [False] * n
    
    for _ in range(n):
        min_distance = INF  
        current = -1  
        for node_no in range(n):  
            if not visited[node_no] and distances[node_no] < min_distance:  
--fcc-editable-region--
                pass
--fcc-editable-region--
```
