Use BFS for solving a shortest path problem in an unweighted graph like that.
Pseudo code :
Create Queue q;
push into q starting node and mark distance to starting node as 0.
while(q is not empty){
get n : first elemnt in the queue
get all connected nodes to n that are not yet visited and push them to the queue:
mark the distance to those node as the distance to n + 1.
}
Example : assuming your start node is 1.
connections you have in the graph :
1->2, 1->3, 1->4
2->1, 2->3, 2->4
3->1, 3->2, 3->4
Set a visited array of boolean : visited 4 = {false,false,false,false}, and a distance array dist4 = {inf,inf,inf,inf} and parent array = {-1,-1,-1,-1}.
now push Node 1 into the queue Q, set it distance to 0 and parent to 1 then start:
Iteration 1 state:
Queue = {1}
Dist = {0,inf,inf,inf}
visited= {true,false,false,false}
parent= {1,-1,-1,-1}
Iteration 2 :
the only node in the Queue is 1, you pick it and push their neighbors to Queue which are nodes: 2,3,4. update their distances
Queue = {2,3,4}
Dist = {0,1,1,1}
visited= {true,false,false,false}
parent= {1,1,1,1}
and so on until you get an empty queue. (means you have visited all the nodes).
in this example you'll see that the distance to node 3 is Dist3 = 1, the parent of this node is parent3 = 1 (in case you want to reconstruct the path).
for more information check BFS and also an implementation in Python : Python BFS DFS or this