I am using networkx package of Python.
Use
shortest_path(G, source, target)
or one of the Shortest Path methods. Stay clear of the methods which return paths between all nodes however if you merely have two specific nodes to test for connectivity.