Click here to Skip to main content
15,892,059 members

Comments by Rawan Kawtharani (Top 3 by date)

Rawan Kawtharani 27-May-21 14:54pm View    
```
def degree_centrality(G):
top = set(G.nodes())
bottom = set(G.edges()) - top
s = 1.0/len(bottom)
centrality = dict((n,d*s) for n,d in G.edges(top))
s = 1.0/len(top)
centrality.update(dict((n,d*s) for n,d in G.edges(bottom)))
return centrality
degree_centrality(G)
```
I wrote this code but dosn't give the accurate result, plz can you help me to fix it
Rawan Kawtharani 24-May-21 8:54am View    
Deleted
import numpy as np
def closetpair(L):
distance1=[]

def distance(L):
for i in range(len(L)):
for j in range(len(L)):
distance=np.sqrt((L[j][1]-L[i][1])**2+(L[j][0]-L[i][0])**2)
distance1.append(distance)
distance2=np.array(distance1)
distance2.resize((len(L), len(L)))
distance2
return distance2
A=np.triu(distance2)
c=[]
c.append(A[(A!=0.0)])
print(c)
for i in range(len(A)):
for j in range(len(A)):
if A[i,j]==np.min(c):
print("the closet pair are: ", L[i],L[j])
Rawan Kawtharani 24-May-21 8:16am View    
Deleted
can you help me to fix it plz?