作者:dxj20101118 | 来源:互联网 | 2023-09-10 10:58
更全面的NetworkX中文使用手册,请收藏:NetworkX中文使用手册
Football数据集是非常复杂网络领域一个非常经典的数据集,作为一个tony数据集还是不错的。
本文通过实例讲解如何用NetworkX结合其他工具对Football下载,解压,以及加载到NetworkX graph中。
下载地址:http://www-personal.umich.edu/~mejn/netdata/football.zip
try : import urllib. request as urllibexcept ImportError: import urllibimport ioimport zipfileimport matplotlib. pyplot as pltimport networkx as nxurl = "http://www-personal.umich.edu/~mejn/netdata/football.zip" sock = urllib. urlopen( url) s = io. BytesIO( sock. read( ) ) sock. close( ) zf = zipfile. ZipFile( s) txt = zf. read( 'football.txt' ) . decode( ) gml = zf. read( 'football.gml' ) . decode( ) gml = gml. split( '\n' ) [ 1 : ] G = nx. parse_gml( gml) print ( txt) for n, d in G. degree( ) : print ( '%s %d' % ( n, d) ) options = { 'node_color' : 'black' , 'node_size' : 50 , 'line_color' : 'grey' , 'linewidths' : 0 , 'width' : 0.1 , } nx. draw( G, ** options) plt. show( )
Out:
The file football.gml contains the network of American football games between Division IA colleges during regular season Fall 2000, as compiled by M. Girvan and M. Newman. The nodes have values that indicate to which conferences they belong. The values are as follows:0 = Atlantic Coast1 = Big East2 = Big Ten3 = Big Twelve4 = Conference USA5 = Independents6 = Mid-American7 = Mountain West8 = Pacific Ten9 = Southeastern10 = Sun Belt11 = Western AthleticIf you make use of these data, please cite M. Girvan and M. E. J. Newman, Community structure in social and biological networks, Proc. Natl. Acad. Sci. USA 99, 7821-7826 (2002).Correction: Two edges were erroneously duplicated in this data set, and have been removed (21 SEP 2014)BrighamYoung 12 FloridaState 12 Iowa 12 KansasState 12 NewMexico 11 TexasTech 12 PennState 12 SouthernCalifornia 12 ArizonaState 11 SanDiegoState 11 Baylor 10 NorthTexas 10 NorthernIllinois 10 Northwestern 11 WesternMichigan 10 Wisconsin 12 Wyoming 11 Auburn 11 Akron 11 VirginiaTech 11 Alabama 11 UCLA 11 Arizona 11 Utah 11 ArkansasState 10 NorthCarolinaState 11 BallState 10 Florida 11 BoiseState 9 BostonCollege 11 WestVirginia 11 BowlingGreenState 11 Michigan 11 Virginia 10 Buffalo 11 Syracuse 11 CentralFlorida 8 GeorgiaTech 11 CentralMichigan 11 Purdue 11 Colorado 11 ColoradoState 10 Connecticut 7 EasternMichigan 11 EastCarolina 11 Duke 11 FresnoState 11 OhioState 11 Houston 11 Rice 11 Idaho 9 Washington 11 Kansas 10 SouthernMethodist 12 Kent 10 Pittsburgh 11 Kentucky 10 Louisville 10 LouisianaTech 10 LouisianaMonroe 8 Minnesota 11 MiamiOhio 11 Vanderbilt 11 MiddleTennesseeState 9 Illinois 11 MississippiState 11 Memphis 11 Nevada 12 Oregon 11 NewMexicoState 11 SouthCarolina 11 Ohio 10 IowaState 11 SanJoseState 11 Nebraska 11 SouthernMississippi 10 Tennessee 11 Stanford 11 WashingtonState 11 Temple 11 Navy 11 TexasA&M 11 NotreDame 11 TexasElPaso 11 Oklahoma 11 Toledo 9 Tulane 11 Mississippi 11 Tulsa 12 NorthCarolina 11 UtahState 9 Army 11 Cincinnati 11 AirForce 10 Rutgers 10 Georgia 10 LouisianaState 10 LouisianaLafayette 8 Texas 11 Marshall 10 MichiganState 11 MiamiFlorida 10 Missouri 10 Clemson 10 NevadaLasVegas 12 WakeForest 10 Indiana 11 OklahomaState 10 OregonState 10 Maryland 11 TexasChristian 11 California 11 AlabamaBirmingham 10 Arkansas 10 Hawaii 11