This notebook contains some guidelines for the students to prepare programming environments for the upcomming seminars and home assignments. During our seminars we will mostly work in IPython Notebook, however sometimes we may switch to MatLab. Homeworks also can be submitted only as IPython Notebooks or $\LaTeX$ reports with Python source code.
(We are using Python 2.7.8, not 3.x.x)
I suggest you to install free Anaconda Python distribution which already includes all necessary Python packages and modules - IPython, NumPy, SciPy, IPython, Matplotlib and NetworkX. Simply download appropriate installer for your OS and follow the proposed steps.
A small tutorial for the NetworkX and other useful Python modules will be just in a minute.. Now let's deal with MatLab.
MatLab is a great computational environment, however it does not poses good instruments to operate with networks and graphs. Fortunately you can download MatLab Boost Graph Library which contains almost all graph utilities that will help you with assignments. To start using MatLabBGL algorithms simply set path to the downloaded folder.
Matlab is also sick in graph visualisation. To this purpose you can download GraphViz software and Matlab interface for it. All install instructions are presented on the corresponding web-pages.
During this course you will mostly operate with graph structures and matrices. Also you should be able to plot some figures and make conclusions based on them.
import networkx as nx
import matplotlib.pyplot as plt
plt.xkcd()
import numpy as np
%matplotlib inline
Networks can be described in several formats e.g. adjacency matrix, edge list, etc. One of the most complete graph representations is GML format which look more or less like XML. See an example:
graph
[
node
[
id A
label "Node A"
]
node
[
id B
label "Node B"
]
node
[
id C
label "Node C"
]
edge
[
source B
target A
label "Edge B to A"
]
edge
[
source C
target A
label "Edge C to A"
]
]
Thankfully, NetworkX supports almost all of recent network representations. Let's load a very famous Zachary's Karate Club network. Nodes in this network represent members of the club and edges between them occur if two persons also frequently communicate outside club's activities. Sadly, the organisation has splitted out into two groups due to conflict and misunderstanding between its leaders.
G = nx.read_gml(path = 'karate.gml')
nx.draw_networkx(G)
draw_network command has several options to improve the view of the network. For instance, let's make nodes with greater degree bigger and more colorfull:
k = nx.degree(G)
plt.figure(1, figsize=(10,7))
coord = nx.spring_layout(G)
nx.draw_networkx(G,
pos=coord,
nodelist=k.keys(),
node_size = [d*100 for d in k.values()],
node_color=k.values(),
font_size=8,
cmap=plt.cm.Reds,
)
Now we can clearly observe two nodes with highest degree centrality: 1 and 34. Exactly these two most important club members are responsible for the breakdown.
We also might be interested in node degree distribution and network's adjacency matrix:
# load adjacency matrix
A = nx.to_numpy_matrix(G, dtype=np.bool)
k = G.degree()
# alternatevly you can find k as k = np.sum(A, axis=0)
# sort nodes according to degree
id_sort = np.array(sorted(k, key = k.get, reverse=True))
k_sort = np.array(k.values())
k_sort = k_sort[id_sort-1]
# show adjacency matrix
plt.figure(1, figsize=(6, 6))
plt.imshow(A,
cmap="Greys",
interpolation="none"
)
plt.title('Zachary\'s club adjacency matrix', fontsize=14)
<matplotlib.text.Text at 0x7fa8afa03890>
# show node degrees
plt.figure(1, figsize=(10, 5))
plt.bar(np.arange(34), k_sort)
plt.xticks(np.arange(34), id_sort)
plt.margins(0.2)
plt.ylabel('Degree')
plt.xlabel('Node id')
<matplotlib.text.Text at 0x7fa8adedf990>
Now we have meet some basics of plotting and data manipulations in networkX. For more details visit the following web-pages:
Download dataset and import it with NumPy. There you will find a table D with 2901 rows and 5 columns. Set y = D[:,0] and X = D[:, 1:].
For this task you have to fit a least-squares linear regression model $\hat{y} = X\hat{\beta}$, where
$$ \hat{\beta} = (X^T X)^{-1} X^T y $$The residuals of the model are agreed to be calculated as $$ \text{res} = y - \hat{y} $$
1. Download dataset
2. Fit the model
3. Make two plots:
3.1. Choose two features of dataset and plot fitted line against them
3.2. Make residuals against prediction plot
hint: DO NOT USE NUMPY's MATRICES. Use arrays and np.dot(A,B) instead of matrix multiplication A*B
# Write your code here
#
#
#
# load data
D = np.loadtxt('bikinis.txt')
y = D[:,0]
X = D[:,1:]
# Find regression coefs
Beta = np.dot(np.dot(np.linalg.inv(np.dot(X.T, X)), X.T), y)
# Make predictions
yt = X.dot(Beta)
# Calculate residuals
res = y - yt
# Plot <resuduals against preditions>
plt.figure(figsize=(10,10))
plt.plot(yt, res, '+b')
[<matplotlib.lines.Line2D at 0x7fa8a7b23a10>]
# Choose 2 dims and plot predictions agains the line
X1 = X[:,0]
idx = np.argsort(X1)
yt1 = X1[idx].dot(Beta[0])
fig, ax = plt.subplots()
fig.set_size_inches(7,7)
ax.plot(X1, y, '.r', label='Data')
ax.plot(X1[idx], yt1, 'b', label='Line')
plt.xlabel('$x_1$')
plt.ylabel('$y$')
ax.legend(loc='upper left', shadow=True)
<matplotlib.legend.Legend at 0x7fa8ae0cb150>
To download .gml file with your facebook friend network you may use getnet app.
1. Import your Facebook network
2. Now play with it!
2.1. Draw your network
2.2. Output your network's order and size
2.3. Draw the degree distribution (histogram)
2.4 Find nodes with the highest degrees. Who are these people?
2.5 Find connected components of your network. Interpret them.
# Write your code here
#
#
#
# Loading network
G = nx.read_gml('network.gml')
# Draw it!
pos = nx.spring_layout(G, dim = 2, iterations=100)
plt.figure(figsize =(7,7))
nx.draw(G, pos)
print 'Network order {0:d}, Network size {1:d}'.format(G.order(), G.size())
Network order 142, Network size 713
# Degree distr
k = G.degree()
k = np.array(k.values())
n, bins, patches = plt.hist(k, bins = 10, facecolor='g')
# Find nodes with highest degree
idx = np.argsort(k)
idx = idx[::-1]
k_sorted = k[idx]
v1 = G.node[idx[0]]
print v1['label']
Дмитрий Игнатов
# Find connected components
CC = nx.connected_components(G)
for v in CC[0]:
print G.node[v]
{'label': u'Copa Damianito', 'agerank': 141, 'id': 1, 'sex': u'male'} {'label': u'Dmitry Chetverikov', 'agerank': 140, 'id': 2, 'sex': u'male'} {'label': u'Guilherme De Castro Martino', 'agerank': 139, 'id': 3, 'sex': u'male'} {'label': u'Clara Cunha', 'agerank': 138, 'id': 4, 'sex': u'female'} {'label': u'Rak Smey Phan', 'agerank': 137, 'id': 5, 'sex': u'male'} {'label': u'Sergei Obiedkov', 'agerank': 136, 'id': 6, 'sex': u'male'} {'label': u'Zineb Lhamdi', 'agerank': 135, 'id': 7, 'sex': u''} {'label': u'Diana Kalajainen', 'agerank': 134, 'id': 8, 'sex': u'female'} {'label': u'Tatiana Pak', 'agerank': 133, 'id': 9, 'sex': u'female'} {'label': u'Lenka Kov\xe1\u010dikov\xe1', 'agerank': 132, 'id': 10, 'sex': u'female'} {'label': u'Oleg Muratov', 'agerank': 131, 'id': 11, 'sex': u'male'} {'label': u'Julia Muranyiova', 'agerank': 129, 'id': 13, 'sex': u'female'} {'label': u'\u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0430 \u041a\u043e\u0440\u0447\u0430\u0448\u043a\u0438\u043d\u0430', 'agerank': 128, 'id': 14, 'sex': u'female'} {'label': u'\u0410\u043b\u0435\u043d\u0430 \u041f\u0442\u0443\u0448\u043a\u0438\u043d\u0430', 'agerank': 127, 'id': 15, 'sex': u'female'} {'label': u'Gicu Speian', 'agerank': 126, 'id': 16, 'sex': u'male'} {'label': u'Saad Abbad', 'agerank': 125, 'id': 17, 'sex': u'male'} {'label': u'Bernard Fenal', 'agerank': 124, 'id': 18, 'sex': u'male'} {'label': u'Guillermo Sanchez', 'agerank': 123, 'id': 19, 'sex': u'male'} {'label': u'\u0428\u043c\u0430\u0432\u043e\u043d \u0413\u0430\u0437\u0430\u043d\u0447\u044f\u043d', 'agerank': 122, 'id': 20, 'sex': u'male'} {'label': u'\u041e\u043b\u0435\u0433 \u041b\u0430\u0432\u0440\u043e\u0432', 'agerank': 121, 'id': 21, 'sex': u'male'} {'label': u'Klimushkin Mikhail', 'agerank': 120, 'id': 22, 'sex': u''} {'label': u'Ekaterina Kovaleva', 'agerank': 118, 'id': 24, 'sex': u'female'} {'label': u'Sofian Gherab', 'agerank': 117, 'id': 25, 'sex': u'male'} {'label': u'Ricardo Cervantes', 'agerank': 116, 'id': 26, 'sex': u'male'} {'label': u'\u0410\u043b\u0438\u0441\u0430 \u0421\u0438\u043c\u0430', 'agerank': 115, 'id': 27, 'sex': u'female'} {'label': u'Irina Dolgopolova', 'agerank': 114, 'id': 28, 'sex': u'female'} {'label': u'\u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0418\u0433\u043d\u0430\u0442\u043e\u0432', 'agerank': 113, 'id': 29, 'sex': u'male'} {'label': u'\u042d\u043c\u0438\u043b\u0438\u044f \u0413\u0430\u043b\u0438\u0435\u0432\u0430', 'agerank': 112, 'id': 30, 'sex': u'female'} {'label': u'Massyl Ould Rabah', 'agerank': 111, 'id': 31, 'sex': u'male'} {'label': u'Irina Buzdugan', 'agerank': 110, 'id': 32, 'sex': u'female'} {'label': u'\u0410\u043b\u0435\u043a\u0441\u0435\u0439 \u041d\u0435\u0437\u043d\u0430\u043d\u043e\u0432', 'agerank': 109, 'id': 33, 'sex': u'male'} {'label': u'\u0410\u043d\u0430\u0441\u0442\u0430\u0441\u0438\u044f \u041b\u043e\u0432\u044f\u0433\u0438\u043d\u0430', 'agerank': 108, 'id': 34, 'sex': u'female'} {'label': u'\u041a\u0430\u0442\u044f \u0427\u0435\u0440\u043d\u044f\u043a', 'agerank': 107, 'id': 35, 'sex': u'female'} {'label': u'Mikhail Orlov', 'agerank': 106, 'id': 36, 'sex': u'male'} {'label': u'\u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0415\u0433\u0443\u0440\u043d\u043e\u0432', 'agerank': 105, 'id': 37, 'sex': u'male'} {'label': u'\u0421\u043e\u0444\u044c\u044f \u041a\u0438\u0441\u0435\u043b\u044c\u0433\u043e\u0444', 'agerank': 104, 'id': 38, 'sex': u'female'} {'label': u'Igor Kiselev', 'agerank': 103, 'id': 39, 'sex': u'male'} {'label': u'Bianca Atzm\xfcller', 'agerank': 102, 'id': 40, 'sex': u'female'} {'label': u'\u041c\u0430\u0440\u0438\u043d\u0430 \u0417\u0430\u0433\u043e\u0440\u043e\u0434\u043d\u0430\u044f', 'agerank': 101, 'id': 41, 'sex': u'female'} {'label': u'\u041a\u0438\u0440\u0438\u043b\u043b \u0413\u0430\u0435\u0432\u043e\u0439', 'agerank': 99, 'id': 43, 'sex': u'male'} {'label': u'\u0424\u0435\u0434\u043e\u0440 \u0421\u0442\u0440\u043e\u043a', 'agerank': 98, 'id': 44, 'sex': u'male'} {'label': u'Doina Sirbu', 'agerank': 97, 'id': 45, 'sex': u'female'} {'label': u'\u041c\u0430\u0440\u0438\u044f \u041c\u0430\u043b\u0438\u043d\u043e\u0432\u0441\u043a\u0430\u044f', 'agerank': 96, 'id': 46, 'sex': u'female'} {'label': u'Popa Serghei', 'agerank': 95, 'id': 47, 'sex': u'male'} {'label': u'\u0410\u043b\u0435\u043a\u0441 \u042f\u0445\u0438\u043d\u0441', 'agerank': 94, 'id': 48, 'sex': u'female'} {'label': u'\u0410\u043d\u0442\u043e\u043d \u0411\u0430\u0440\u0441\u043a\u043e\u0432', 'agerank': 93, 'id': 49, 'sex': u'male'} {'label': u'\u0410\u043d\u043d\u0430 \u041a\u043e\u0440\u043e\u043b\u044c\u0447\u0443\u043a', 'agerank': 92, 'id': 50, 'sex': u'female'} {'label': u"Gloria D'Andrea", 'agerank': 91, 'id': 51, 'sex': u'female'} {'label': u'\u041c\u0430\u0440\u0438\u044f \u0417\u0440\u044f\u043d\u0438\u043d\u0430', 'agerank': 90, 'id': 52, 'sex': u'female'} {'label': u'\u0421\u0432\u0435\u0442\u043b\u0430\u043d\u0430 \u0413\u0430\u043b\u0438\u043c\u043e\u0432\u0430', 'agerank': 89, 'id': 53, 'sex': u'female'} {'label': u'\u0418\u0440\u0438\u043d\u0430 \u0413\u0443\u043b\u044c\u043a\u0438\u043d\u0430', 'agerank': 88, 'id': 54, 'sex': u'female'} {'label': u'\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0421\u0435\u043c\u0435\u043d\u043e\u0432', 'agerank': 87, 'id': 55, 'sex': u'male'} {'label': u'\u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0430 \u0417\u0430\u0433\u0430\u0439\u043d\u0430\u044f', 'agerank': 85, 'id': 57, 'sex': u'female'} {'label': u'Av\u0103d\u0103nii Maria', 'agerank': 84, 'id': 58, 'sex': u'female'} {'label': u'Valeria Vorozhko', 'agerank': 83, 'id': 59, 'sex': u'female'} {'label': u'\u0410\u043b\u0435\u043a\u0441\u0435\u0439 \u041c\u0430\u043a\u0430\u0440\u044c\u0438\u043d', 'agerank': 82, 'id': 60, 'sex': u'male'} {'label': u'\u041a\u043e\u0441\u0442\u044f \u0412\u043e\u0440\u043e\u0432\u0438\u0447', 'agerank': 79, 'id': 63, 'sex': u'male'} {'label': u'\u041a\u0430\u0442\u0435\u0440\u0438\u043d\u0430 \u0420\u044b\u0436\u0430\u043a\u043e\u0432\u0430', 'agerank': 78, 'id': 64, 'sex': u'female'} {'label': u'\u0410\u043b\u0438\u0441\u0430 \u041a\u0443\u043b\u0438\u043a', 'agerank': 76, 'id': 66, 'sex': u'female'} {'label': u'Anton Petrov', 'agerank': 75, 'id': 67, 'sex': u'male'} {'label': u'\u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0413\u043d\u0430\u0442\u044b\u0448\u0430\u043a', 'agerank': 73, 'id': 69, 'sex': u'male'} {'label': u'\u0410\u043d\u0430\u0441\u0442\u0430\u0441\u0438\u044f \u0411\u0430\u0448\u043a\u0435\u0435\u0432\u0430', 'agerank': 72, 'id': 70, 'sex': u'female'} {'label': u'Diana Semenkevich', 'agerank': 71, 'id': 71, 'sex': u'female'} {'label': u'Yulia Khakimova', 'agerank': 69, 'id': 73, 'sex': u'female'} {'label': u'\u0410\u0440\u0442\u0451\u043c \u0411\u043e\u0447\u0430\u0440\u043e\u0432', 'agerank': 68, 'id': 74, 'sex': u'male'} {'label': u'Dmitry Zhivotvorev', 'agerank': 67, 'id': 75, 'sex': u'male'} {'label': u'Anastasia Musteata', 'agerank': 66, 'id': 76, 'sex': u'female'} {'label': u'\u041c\u0438\u0445\u0430\u0438\u043b \u041a\u043e\u043d\u044c\u043a\u043e\u0432', 'agerank': 65, 'id': 77, 'sex': u'male'} {'label': u'\u0410\u043d\u0430\u0441\u0442\u0430\u0441\u0438\u044f \u0410\u0433\u0435\u0435\u0432\u0430', 'agerank': 64, 'id': 78, 'sex': u'female'} {'label': u'Annie Semenova', 'agerank': 63, 'id': 79, 'sex': u'female'} {'label': u'Ivan Shamshurin', 'agerank': 62, 'id': 80, 'sex': u'male'} {'label': u'\u041d\u0438\u043a\u0438\u0442\u0430 \u0427\u0435\u043a\u0443\u0448\u043a\u0438\u043d', 'agerank': 61, 'id': 81, 'sex': u'male'} {'label': u'Katya Kovaleva', 'agerank': 60, 'id': 82, 'sex': u'female'} {'label': u'Gabriel Horikava', 'agerank': 59, 'id': 83, 'sex': u'male'} {'label': u'Alexander Ivanov', 'agerank': 58, 'id': 84, 'sex': u'male'} {'label': u'Ion Sirbu', 'agerank': 57, 'id': 85, 'sex': u'male'} {'label': u'\u042d\u043b\u0435\u043d \u0422\u0435\u0432\u0430\u043d\u044f\u043d', 'agerank': 56, 'id': 86, 'sex': u'female'} {'label': u'\u0422\u0430\u0442\u044c\u044f\u043d\u0430 \u0411\u0435\u0441\u043f\u0435\u043b\u044e\u0445\u0438\u043d\u0430', 'agerank': 55, 'id': 87, 'sex': u'female'} {'label': u'Anastasia Goltseva', 'agerank': 54, 'id': 88, 'sex': u'female'} {'label': u'Natalie Strelnikova', 'agerank': 53, 'id': 89, 'sex': u'female'} {'label': u'\u0421\u0435\u0440\u0433\u0435\u0439 \u041a\u0443\u043b\u0438\u043a', 'agerank': 52, 'id': 90, 'sex': u'male'} {'label': u'\u041f\u043e\u043b\u0438\u043d\u0430 \u0411\u043e\u043d\u0434\u0430\u0440\u0435\u0432\u0430', 'agerank': 50, 'id': 92, 'sex': u'female'} {'label': u'\u0412\u0438\u0442\u0430\u043b\u0438\u0439 \u041a\u043e\u043d\u043e\u0432\u0430\u043b\u043e\u0432', 'agerank': 49, 'id': 93, 'sex': u'male'} {'label': u'\u041c\u0430\u0440\u0438\u044f \u0425\u0440\u0430\u043f\u043e\u0432\u0430', 'agerank': 48, 'id': 94, 'sex': u'female'} {'label': u'\u041b\u0430\u0440\u0430 \u0413\u0440\u044f\u0437\u0435\u0432\u0430', 'agerank': 47, 'id': 95, 'sex': u'female'} {'label': u'\u0418\u0441\u0443\u0444 \u0410\u0446\u043a\u0430\u043d\u043e\u0432', 'agerank': 46, 'id': 96, 'sex': u'male'} {'label': u'Ksenia Kiseleva', 'agerank': 45, 'id': 97, 'sex': u'female'} {'label': u'Arsen Pozdeev', 'agerank': 43, 'id': 99, 'sex': u'male'} {'label': u'Dasha Buraya', 'agerank': 42, 'id': 100, 'sex': u'female'} {'label': u'\u0410\u043d\u043d\u0430 \u041f\u0440\u043e\u0441\u043a\u0443\u0440\u0438\u043d\u0430', 'agerank': 41, 'id': 101, 'sex': u'female'} {'label': u'Nikita Ivkin', 'agerank': 39, 'id': 103, 'sex': u'male'} {'label': u'\u0410\u043d\u0434\u0440\u0435\u0439 \u0420\u0443\u0434\u0435\u043d\u043a\u043e', 'agerank': 38, 'id': 104, 'sex': u'male'} {'label': u'\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0443\u0447\u043a\u043e\u0432\u0441\u043a\u0438\u0439', 'agerank': 37, 'id': 105, 'sex': u'male'} {'label': u'\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0440\u043e', 'agerank': 36, 'id': 106, 'sex': u'male'} {'label': u'Anghel Olea', 'agerank': 32, 'id': 110, 'sex': u'female'} {'label': u'\u0422\u0430\u0442\u044c\u044f\u043d\u0430 \u0412\u0443\u043a\u043e\u043b\u043e\u0432\u0430', 'agerank': 31, 'id': 111, 'sex': u'female'} {'label': u'\u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0430 \u0421\u0430\u043c\u043e\u0442\u0435\u0441\u043e\u0432\u0430', 'agerank': 30, 'id': 112, 'sex': u'female'} {'label': u'Sadykov Farit', 'agerank': 29, 'id': 113, 'sex': u'male'} {'label': u'Phaedra Vandersteen', 'agerank': 28, 'id': 114, 'sex': u'female'} {'label': u'Anastasia Lomakina', 'agerank': 27, 'id': 115, 'sex': u'female'} {'label': u'\u041c\u0430\u043a\u0441\u0438\u043c \u0420\u0430\u0445\u0443\u0431\u0430', 'agerank': 26, 'id': 116, 'sex': u'male'} {'label': u'Mihai Sirbu', 'agerank': 25, 'id': 117, 'sex': u'male'} {'label': u'\u0411\u043e\u0440\u0438\u0441 \u041c\u0438\u0440\u043a\u0438\u043d', 'agerank': 23, 'id': 119, 'sex': u'male'} {'label': u'Constantine Sorokin', 'agerank': 22, 'id': 120, 'sex': u'male'} {'label': u'\u0422\u0430\u0442\u044c\u044f\u043d\u0430 \u0420\u0430\u0442\u043e\u0432\u0430', 'agerank': 21, 'id': 121, 'sex': u'female'} {'label': u'\u0410\u043b\u0443\u0430 \u041d\u044e\u0441\u0443\u043f\u043e\u0432\u0430', 'agerank': 20, 'id': 122, 'sex': u'female'} {'label': u'Vanel Siyou', 'agerank': 19, 'id': 123, 'sex': u'male'} {'label': u'\u041b\u044e\u0431\u043e\u0432\u044c \u0421\u0430\u043c\u043e\u0445\u0438\u043d\u0430', 'agerank': 18, 'id': 124, 'sex': u'female'} {'label': u'\u0410\u043b\u0435\u043d\u043a\u0430 \u0422\u0435\u0440\u043b\u0435\u0435\u0432\u0430', 'agerank': 17, 'id': 125, 'sex': u'female'} {'label': u'Denis Kornilov', 'agerank': 15, 'id': 127, 'sex': u'male'} {'label': u'\u0421\u0435\u0440\u0433\u0435\u0439 \u041c\u043e\u0440\u0434\u0430\u0448\u043e\u0432', 'agerank': 14, 'id': 128, 'sex': u'male'} {'label': u'WorldTop Erasmus SN Clermont', 'agerank': 13, 'id': 129, 'sex': u'male'} {'label': u'Bogdan Tric\u0103', 'agerank': 12, 'id': 130, 'sex': u'male'} {'label': u'\u0421\u0435\u0440\u0433\u0435\u0439 \u0413\u0440\u0438\u0448\u0430\u043a\u043e\u0432', 'agerank': 11, 'id': 131, 'sex': u'male'} {'label': u'\u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0430 \u041f\u043e\u043b\u0435\u0441\u0441\u043a\u0430\u044f', 'agerank': 10, 'id': 132, 'sex': u'female'} {'label': u'\u041c\u0430\u0440\u0438\u044f \u0413\u0430\u0440\u0438\u0431\u043e\u0432\u0430', 'agerank': 9, 'id': 133, 'sex': u'female'} {'label': u'Bernard Fenal', 'agerank': 8, 'id': 134, 'sex': u'male'} {'label': u'Zheng Olivia', 'agerank': 7, 'id': 135, 'sex': u'female'} {'label': u'\u0410\u043b\u0435\u043a\u0441\u0435\u0439 \u041b\u0435\u0432\u0430\u043d\u043e\u0432', 'agerank': 6, 'id': 136, 'sex': u'male'} {'label': u'Igor Nemteanu', 'agerank': 2, 'id': 140, 'sex': u'male'}
SG = G.subgraph(CC[0])
nx.radius(SG)
7