In [195]:
%pylab inline
In [ ]:
In [ ]:
In [ ]:
Use "zip" function (Python Tutorial, pg. 67) to create a sequence of tuple and called it "edges".
Each tuple defines an edge between two nodes from the list nodes
and the list studid (nodes[i], stud[i]).
Then, use "list" function (Python Tutorial, pg. 12) to convert "edges" sequence into a list.
Print the list of edges using "print" function (Python Tutorial, pg. 9).
Example:
If nodes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] and studid = [2, 0, 1, 5, 2, 3, 4, 0, 3, 1]
then, edges = [(0, 2), (1, 0), (2, 1), (3, 5), (4, 2), (5, 3), (6, 4), (7, 0), (8, 3), (9, 1)]
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
Print all the nodes and a list of their respective neighbours side by side using
"for loop" (Python Tutorial, pg. 15),
"nodes" function (NetworkX Tutorial pg. 3),
"neighbors" function (NetworkX Tutorial pg. 3), and
"print" function (Python Tutorial, pg. 9).
Example:
0 [1, 2, 7]
1 [0, 9, 2]
2 [0, 1, 4]
3 [8, 5]
4 [2, 6]
5 [3]
6 [4]
7 [0]
8 [3]
9 [1]
In [ ]:
In [ ]:
In [ ]:
"G.degree()" is of type dict (Python Tutorial, pg. 31).
"G.degree().keys()" will return all the nodes.
"G.degree().values()" will return all the degrees.
Read the Python Tutorial, pg. 31 on how to convert them to a list.
Create a degree sequence in descending order using
"G.degree().values()" function and "list" function (Python Tutorial, pg. 12)
and assign it to variable called "degree_sequence"
Print "degree_sequence" using "print" function (Python Tutorial, pg. 9).
Note:
Example:
[3, 3, 3, 2, 2, 1, 1, 1, 1, 1]
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: