G.add_edge('a', 'b', weight=1)
G.add_edge('a', 'c', weight=1)
G.add_edge('c', 'd', weight=1)
print(G.has_edge('a', 'd'))
print('d' in G['a'])
print(not 'd' in G['a'])
How to check whether two nodes are connected?