Currently I have a very simple graph set up like this:
import networkx as nx
G = nx.Graph()
lat = 40.661
long = -73.944
G.add_node(12345, latlong=(lat, long))
And G.nodes[12345]['latlong'], of course, returns (40.661, -73.944).
What's the best way to set things up so that I also get:
G.nodes[12345]['longlat']returns(-73.944, 40.661)
G.nodes[(40.661, -73.944)]returns12345
I know that I could also add nodes like this: G.add_node(12345, latlong=(lat, long), longlat=(long, lat)) and have an extra dictionary d = {(40.661, -73.944): 12345}.
But is there also a nicer, not too hacky, way without duplicating data?