Minimum distance in an undirected weighted graph to cover k nodes using teleportations I have been practicing problems on graphs and shortest paths and
I encountered a problem that I'm struggling to understand.
Can you give me any tips and/or can you confirm that I got the general
concept of the problem right?

In a given undirected weighted graph $G=(V,E)$ and an integer $k$ and
edges with positive weights, the starting point is node $v_0$.  You
have to visit every node from $v_0, v_1, v_2, \dots, v_{k-1}$.  If you
visit any of those $k$ nodes you are allowed to create a portal in
them.  You can only make portals in those $k$ nodes.  From one portal
you can teleport to any other without any cost to the path.
You have to create a function double shortestPath(int k) that
returns a shortest path to visit all $k$ nodes using teleportation
system (if necessary).

I sketched this graph and tried to understand the problem here. Lets say we have to visit nodes 0,1 and 2.

Edited (Please check the reply to see better example of the problem)
My approach is this: If I take this route $0 \to 5$ (cost 1) then $5
\to 4$ (cost 2), $4 \to 2$ (cost 3) and then jump from $2 \to 0$ and go
$0 \to 1$ (cost 9). This is the shortest path using teleportations.
Can someone tell me if I understood this problem correctly and maybe
give some tips on how to implement the algorithm?
You can do this in polynomial time with a greedy algorithm by always
traveling to the nearest un-visited terminal, and dropping a portal in
every terminal.
The crucial observations are these:

Since it's free to drop a portal and use one, you always put a portal in each of the terminals.
There is no point traveling anywhere but to a terminal.
When you move to a terminal, you always travel from the closest portal.

Let $G = (V, E, w)$ be the input graph and $T \subseteq V$ be your $k$
terminals, with $v_0 \in T$.
Start with $T' = \{v_0\}$.  While $|T'|&lt;k$, pick a terminal not in
$T'$ that is of shortest distance from $T'$ and add it to $T'$.  Sum up
the distances traveled in total.
Notice that you can preprocess your graph in $O(t^2 (n+m))$ time to get
a new (complete) graph $G' = (T, E', w')$ with only vertices from $T$ and
where the edge $t_1t_2$ has $w'(t_1, t_2) = \text{dist}_G(t_1, t_2)$.
Edit: This answer is updated.  The previous answer was based on Steiner Tree.