What if I do not add edge between two vertices

Let’s say there is a graph having 5 nodes but I add edge between 1&2 and 2&3 and we have to print the shortest distance between 0 &4 but there is no edge between it and in the code also we did not clarify the no of nodes in the graph.
How will I print the distance

hello @aditya001tomar,
it will be mentioned in question that whether graph can be disconneted or not.

if they will mention that graph can be disconnected then they will also tell u what to print in that case.

for now u can assume graph is always connected.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.