Need help for creating graph and implementing incremental_closeness centrality using networkx

Hi, I have an input file .txt format. The data in file is:

a_8358:b_5207, 0.3333333333333333
a_8357:b_5207, 0.3333333333333333
a_8358:b_5209, 0.5
a_8357:b_5209, 0.5
a_8358:b_5208, 0.0
a_8357:b_5208, 0.0
b_5207:c_1954, 0.1111111111111111
b_5207:c_1961, 0.2
b_5207:c_1957, 0.14285714285714285
b_5207:c_14167, 0.125
b_5207:c_37159, 0.14285714285714285
b_5209:c_1954, 0.125
b_5209:c_1961, 0.25
b_5209:c_1957, 0.16666666666666666
b_5209:c_14167, 0.14285714285714285
b_5209:c_37159, 0.16666666666666666
b_5208:c_1954, 0.0
b_5208:c_1961, 0.0
b_5208:c_1957, 0.0
b_5208:c_14167, 0.0
b_5208:c_37159, 0.0
d_3389:b_5207, 0.14285714285714285
d_22862:b_5207, 0.2
d_3389:b_5209, 0.16666666666666666
d_22862:b_5209, 0.25
d_3389:b_5208, 0.0
d_22862:b_5208, 0.0
e_1961:b_5207, 0.2
e_1961:b_5209, 0.25
e_1961:b_5208, 0.0
a_8358:c_1954, 0.1
a_8358:c_1961, 0.16666666666666666
a_8358:c_1957, 0.1111111111111111
a_8358:c_14167, 0.1
a_8358:c_37159, 0.1
a_8357:c_1954, 0.14285714285714285
a_8357:c_1961, 0.16666666666666666
a_8357:c_1957, 0.2
a_8357:c_14167, 0.16666666666666666
a_8357:c_37159, 0.25
d_3389:a_8358, 0.1
d_22862:a_8358, 0.125
d_3389:a_8357, 0.25
d_22862:a_8357, 0.5
e_1961:a_8358, 0.16666666666666666
e_1961:a_8357, 0.16666666666666666
d_3389:c_1954, 0.14285714285714285
d_22862:c_1954, 0.14285714285714285
d_3389:c_1961, 0.16666666666666666
d_22862:c_1961, 0.25
d_3389:c_1957, 0.2
d_22862:c_1957, 0.2
d_3389:c_14167, 0.16666666666666666
d_22862:c_14167, 0.16666666666666666
d_3389:c_37159, 0.125
d_22862:c_37159, 0.25
e_1961:c_1954, 0.16666666666666666
e_1961:c_1961, 0.5
e_1961:c_1957, 0.2
e_1961:c_14167, 0.16666666666666666
e_1961:c_37159, 0.16666666666666666
d_3389:e_1961, 0.16666666666666666
d_22862:e_1961, 0.25

I need help regarding creation of undirected weighted graph G for the entire input file. Consider a_8358:b_5207, 0.3333333333333333. Here a_8358 and b_5207 are the vertices, and 0.3333333333333333 is the edge weight between the two vertices. I need help regarding implementation of Incremental_Closeness Centrality on the above graph G.

For the above graph, I tried to implement incremental closeness centrality as shown below

import networkx as nx

# Calculate initial closeness centrality for each node
initial_closeness = nx.closeness_centrality(G)

# Print initial closeness centrality values
print("Initial closeness centrality:")
for node, value in initial_closeness.items():
    print(f"{node}: {value}")

# Make changes to the graph (e.g. add/remove edges or nodes)

# Calculate incremental closeness centrality for each node
incremental_closeness = {}
for node in G.nodes:
    # Create a copy of the graph with the current node removed
    H = G.copy()
    H.remove_node(node)
    # Calculate the closeness centrality of the remaining nodes in the new graph
    remaining_closeness = nx.closeness_centrality(H)
    # Calculate the difference in closeness centrality for the current node
    delta = initial_closeness[node] - remaining_closeness[node]
    incremental_closeness[node] = delta

# Print incremental closeness centrality values
print("Incremental closeness centrality:")
for node, value in incremental_closeness.items():
    print(f"{node}: {value}")

However, I am getting the following error:

> KeyError                                  Traceback (most recent call last)
> <ipython-input-28-5ac9eb6debea> in <module>
>      20     remaining_closeness = nx.closeness_centrality(H)
>      21     # Calculate the difference in closeness centrality for the current node
> ---> 22     delta = initial_closeness[node] - remaining_closeness[node]
>      23     incremental_closeness[node] = delta
>      24 
> 
> KeyError: 'a_8358'

How can I resolve the error