I am planning a graph. I would like to build a simplified graph. Then expand it. This expansion will include changing some of the nodes in to other graphs. Since a dictionary key is immutable, are there ways to change the node from one object type to another?
I think the best approach is to make a new graph whose edges have the data type that you’re after. For example, consider the following.
G = nx.path_graph(5) # graph with edges [(0, 1), (1, 2), (2, 3), (3, 4)] G_new = nx.Graph() for a,b in G.edges: G_new.add_edge(float(a),float(b))
The graph G_new has edges
[(0.0, 1.0), (1.0, 2.0), (2.0, 3.0), (3.0, 4.0)].