G = nx.DiGraph()
G.add_nodes_from(map(chr, range(65, 78)))
edges = [
'GHK',
'CDM',
'BD',
'BCM',
'BGJ',
'IJL',
'AEHK',
'AGK',
'FJL',
'FIL',
'AGH',
'FIJ',
'BD'
]
for n, es in zip(G, edges):
ess = list(es)
print(f'{n} -> {ess}')
for e in ess:
G.add_edge(n, e)
pos = nx.spring_layout(G, k=1)
plt.figure(3,figsize=(12,8))
nx.draw_networkx(G, pos, arrowsize=20, node_color='#ddd', node_size=500)
plt.show()
density = nx.density(G)
print(f'Densitet: {density}')
degrees = [d for _, d in G.degree()]
mean_degree = sum(degrees) / len(degrees)
print('Snittligt antal kopplingar: ' + str(mean_degree))
plt.hist(degree_list,label='Degree Distribution')
plt.axvline(av_degree,color='r',linestyle='dashed',label='Average Degree')
plt.legend()
plt.ylabel('Number of Nodes')
plt.title('Fulingar: Node Degree')