I am trying to create a network graph from a dict. I don't know if it's because some edges containing more than 2 nodes. So the networkX graph doesn't work.
dict =
{('Declaration SUBMITTED by EMPLOYEE#Declaration FOR_APPROVAL by ADMINISTRATION', 'Declaration FINAL_APPROVED by SUPERVISOR#Declaration REJECTED by MISSING#Declaration APPROVED by PRE_APPROVER'): 2221, ('Declaration FINAL_APPROVED by SUPERVISOR#Declaration REJECTED by MISSING#Declaration APPROVED by PRE_APPROVER', 'Payment Handled#Request Payment'): 10032, ('Declaration FINAL_APPROVED by SUPERVISOR#Declaration REJECTED by MISSING#Declaration APPROVED by PRE_APPROVER', 'Declaration SUBMITTED by EMPLOYEE#Declaration FOR_APPROVAL by ADMINISTRATION'): 61}
The value are the weights. The # hashtags in the keys separate nodes. So the nodes are: Declaration SUBMITTED by EMPLOYEE Declaration FOR_APPROVAL by ADMINISTRATION Declaration FINAL_APPROVED by SUPERVISOR Declaration REJECTED by MISSING ...
My main goal is to calculate modularity using nx_comm.modularity(G, partition)
I have tried
g1 = nx.Graph()
for k,v in dict.items():
g1.add_edge(k[0], k[1], weight = v)
But it kept giving the error "NotAPartition: Graph with 8 nodes and 16 edges is not a valid partition of the graph".