What will networkX do if the duplicated nodes (same id , same other attributes )are added? thanks
If you add a node using a duplicate id with duplicate attributes it will be ignored. However if the attributes are different they will be changed. For example:
>>> import networkx as nx
>>> G = nx.Graph()
>>> G.add_node(1)
>>> G.node[1]
{}
>>> G.add_node(1,name='firstNode')
>>> G.node[1]
{'name': 'firstNode'}
>>> G.add_node(1,name='changed')
>>> G.node[1]
{'name': 'changed'}
>>> G.add_node(1,name='changed',attribute='new')
>>> G.node[1]
{'attribute': 'new', 'name': 'changed'}
>>> G.add_node(1,name='changed',attribute='new')
>>> G.node[1]
{'attribute': 'new', 'name': 'changed'}
>>> G.add_node(1)
>>> G.node[1]
{'attribute': 'new', 'name': 'changed'}
>>> nx.nodes(G)
[1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With