In the directed graph the nodes which dont have any outgoing edge shows distance 0 from all other nodes

sir in the directed graph all the nodes which donot have any outgoing edge shows distance zero from all other node, i think this is because this node didnt included in map<T,list<pair<T,int>>> list, can we remove this error when input will be provided by the user without checking each node is included or not by separate function?

@Usha24,
You can mark all the vertices at infinity(very large) distance initially, thus afterwards, if you see a distance of vertex is very large, it would be obvious that it is unreachable.

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.