Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
html
US airports http://konect.uni-koblenz.de/networks/opsahl-
usairport (http://konect.uni-koblenz.de/networks/opsahl-
usairport)
In [38]: #for creating the graph and calculating the attribute values
import networkx as nx
import operator
l = []
with open('out.txt') as f:
for line in f:
il = line.split(" ")
il[-1] = il[-1][:-1]
il = map(int, il)
l.append(il)
print l[:10]
[[1, 2, 1], [1, 3, 7], [4, 5, 3], [6, 7, 5], [6, 8, 14137], [9, 10, 8], [11,
2, 8], [12, 5, 413], [13, 14, 2], [13, 15, 2]]
In [4]: nodes = []
for i in l:
nodes.append(i[0])
nodes.append(i[1])
nodes = sorted(set(nodes))
new_l = []
for i in l:
new_l.append((i[0],i[1],i[2]))
Creating a graph. First adding all the nodes and then the edges between them
node_dict = {}
for i in l:
if i[0] in node_dict:
node_dict[i[0]]+=i[2]
else:
node_dict[i[0]] = i[2]
if i[1] in node_dict:
node_dict[i[1]]+=i[2]
else:
node_dict[i[1]] = i[2]
1 of 3 17/02/19, 11:58 pm
airport file:///home/segatron/Downloads/airport.html
(46, 0.19961856325492688)
(4, 0.0006357279084551812)
(88, 0.11825493026777034)
(1487, 9.827749622790314e-18)
(32, 0.21612697041610068)
(1, 0.0)
(46, 0.49777999457856403)
(1487, 0.0006357279084551812)
0.50415253921
2 of 3 17/02/19, 11:58 pm
airport file:///home/segatron/Downloads/airport.html
0.384143446645
0.0
return count
37
29
39
Inferences:- The degree centrality would be good measure to determine the importance of a node.
1. The node with highest in degree of centrality denotes that the airport has highest number of flights scheduled.
2. It also gives the highest accuracy.
In [ ]:
In [ ]:
3 of 3 17/02/19, 11:58 pm