index
int64 0
731k
| package
stringlengths 2
98
⌀ | name
stringlengths 1
76
| docstring
stringlengths 0
281k
⌀ | code
stringlengths 4
8.19k
| signature
stringlengths 2
42.8k
⌀ | embed_func_code
listlengths 768
768
|
---|---|---|---|---|---|---|
30,351 | networkx.classes.function | add_star | Add a star to Graph G_to_add_to.
The first node in `nodes_for_star` is the middle of the star.
It is connected to all other nodes.
Parameters
----------
G_to_add_to : graph
A NetworkX graph
nodes_for_star : iterable container
A container of nodes.
attr : keyword arguments, optional (default= no attributes)
Attributes to add to every edge in star.
See Also
--------
add_path, add_cycle
Examples
--------
>>> G = nx.Graph()
>>> nx.add_star(G, [0, 1, 2, 3])
>>> nx.add_star(G, [10, 11, 12], weight=2)
| def add_star(G_to_add_to, nodes_for_star, **attr):
"""Add a star to Graph G_to_add_to.
The first node in `nodes_for_star` is the middle of the star.
It is connected to all other nodes.
Parameters
----------
G_to_add_to : graph
A NetworkX graph
nodes_for_star : iterable container
A container of nodes.
attr : keyword arguments, optional (default= no attributes)
Attributes to add to every edge in star.
See Also
--------
add_path, add_cycle
Examples
--------
>>> G = nx.Graph()
>>> nx.add_star(G, [0, 1, 2, 3])
>>> nx.add_star(G, [10, 11, 12], weight=2)
"""
nlist = iter(nodes_for_star)
try:
v = next(nlist)
except StopIteration:
return
G_to_add_to.add_node(v)
edges = ((v, n) for n in nlist)
G_to_add_to.add_edges_from(edges, **attr)
| (G_to_add_to, nodes_for_star, **attr) | [
0.01094355620443821,
-0.008316040970385075,
0.013712621293962002,
-0.003916943911463022,
-0.02853994444012642,
-0.002775699831545353,
-0.015614693984389305,
0.023054897785186768,
0.03444964066147804,
0.05035628378391266,
0.011952097527682781,
0.014031107537448406,
0.05290417745709419,
0.07289806008338928,
-0.006825346499681473,
0.008758383803069592,
0.008740689605474472,
-0.01635782979428768,
0.009147644974291325,
0.05569978058338165,
-0.03747526556253433,
0.005993742495775223,
0.02850455790758133,
-0.010368511080741882,
-0.02457655593752861,
0.021427076309919357,
0.027248304337263107,
0.019498461857438087,
0.007254418917000294,
-0.0023466276470571756,
0.06090173125267029,
-0.08740690350532532,
-0.037369102239608765,
0.002293546451255679,
0.03303414583206177,
0.025585096329450607,
-0.017242515459656715,
0.06323730200529099,
-0.0007923461962491274,
-0.004817110951989889,
0.02025929093360901,
0.0382537879049778,
0.029353855177760124,
-0.026363618671894073,
0.06635139137506485,
0.037970688194036484,
0.02204635553061962,
0.061007894575595856,
-0.029141530394554138,
-0.011447826400399208,
0.037970688194036484,
-0.009678456000983715,
-0.011536295525729656,
-0.01536698266863823,
0.023355690762400627,
0.04536665976047516,
-0.0016598906368017197,
-0.006754571571946144,
0.011076259426772594,
0.02600974589586258,
0.051665615290403366,
0.007015553768724203,
0.023621095344424248,
0.0011158091947436333,
0.00951036624610424,
-0.005210795905441046,
-0.04738374054431915,
-0.06061863154172897,
0.010067718103528023,
0.025868196040391922,
-0.0029194613453000784,
0.02056008391082287,
-0.014438062906265259,
0.00505597610026598,
0.0168001726269722,
0.018932264298200607,
0.025461239740252495,
-0.011890169233083725,
-0.01283678226172924,
-0.00007844669744372368,
-0.025496628135442734,
-0.042252566665410995,
-0.023231834173202515,
-0.007732148747891188,
-0.00004454528243513778,
0.08733612298965454,
-0.05810612440109253,
-0.013181809335947037,
-0.0098111592233181,
-0.043384961783885956,
-0.024187294766306877,
-0.016322441399097443,
-0.002368744695559144,
-0.022028662264347076,
0.014561918564140797,
0.018843796104192734,
0.012624458409845829,
-0.0847882330417633,
0.024629635736346245,
0.050002407282590866,
-0.00420004315674305,
-0.008935321122407913,
-0.033405713737010956,
-0.025655871257185936,
0.008815888315439224,
-0.044588133692741394,
-0.003711254568770528,
0.02105550840497017,
-0.03349418193101883,
0.037899915128946304,
-0.012642151676118374,
0.03213176876306534,
0.04108478128910065,
-0.015092729590833187,
-0.047206804156303406,
0.02464733086526394,
0.0675191730260849,
0.06097250431776047,
0.034998148679733276,
0.004487565718591213,
-0.020595472306013107,
0.05124096944928169,
0.011164727620780468,
0.06030014529824257,
0.03478582203388214,
-0.006723607890307903,
0.010598529130220413,
-0.0055292826145887375,
-0.03462658077478409,
-0.06359117478132248,
-0.016702856868505478,
0.0006519024027511477,
-0.039987772703170776,
0.04150943085551262,
-0.01162476371973753,
-0.015464297495782375,
-0.061751026660203934,
-0.037864528596401215,
0.018047578632831573,
-0.014234584756195545,
0.018543003126978874,
-0.06037091836333275,
0.03473274037241936,
0.017649469897150993,
-0.09497980773448944,
-0.01709211803972721,
-0.023798031732439995,
0.02760217897593975,
0.007440202869474888,
-0.012217503041028976,
0.0032777588348835707,
0.061644867062568665,
0.04434042423963547,
0.03722755238413811,
-0.036201320588588715,
-0.01253598928451538,
-0.012376746162772179,
-0.0008581446600146592,
0.02597435750067234,
0.02174556255340576,
0.026434393599629402,
-0.02464733086526394,
0.041686367243528366,
0.016048189252614975,
-0.04267721623182297,
0.002691654721274972,
0.0279383584856987,
0.06688220053911209,
-0.029884666204452515,
-0.007369427941739559,
0.009775771759450436,
-0.04104939475655556,
0.01935691200196743,
0.0017914875643327832,
0.016472838819026947,
-0.009244960732758045,
-0.02162170596420765,
0.007223454769700766,
0.0033109344076365232,
-0.0681561529636383,
0.033706508576869965,
-0.008125834167003632,
0.03542279452085495,
0.007320770062506199,
0.016172045841813087,
0.012137881480157375,
-0.024098824709653854,
0.00423985393717885,
0.012341358698904514,
0.012633305042982101,
0.057256828993558884,
0.025850502774119377,
-0.08117871731519699,
0.038996923714876175,
-0.01969309337437153,
-0.027743728831410408,
0.029176918789744377,
0.025567403063178062,
-0.052833400666713715,
0.13609997928142548,
0.026894431561231613,
0.009749230928719044,
0.003859439166262746,
0.00612644525244832,
0.08627450466156006,
-0.046711381524801254,
-0.015057342126965523,
-0.03719216585159302,
-0.0442342609167099,
-0.035670507699251175,
0.02291334792971611,
0.042252566665410995,
0.04526049643754959,
0.04020009562373161,
-0.040058545768260956,
0.07045633345842361,
0.01024465449154377,
0.01985233649611473,
0.01652592048048973,
-0.02744293585419655,
-0.021568626165390015,
-0.03223792836070061,
-0.04713602736592293,
0.007895815186202526,
0.03248564153909683,
-0.017145199701189995,
0.03705061599612236,
-0.03600668907165527,
0.023054897785186768,
-0.04087245836853981,
0.030557027086615562,
-0.013606458902359009,
0.03462658077478409,
-0.03296337276697159,
0.015552766621112823,
0.024204988032579422,
0.043986547738313675,
0.013942639343440533,
-0.036201320588588715,
0.007515401113778353,
-0.03765220195055008,
-0.006073364056646824,
-0.05371808633208275,
-0.004100515972822905,
-0.013411828316748142,
0.04441119730472565,
-0.019533850252628326,
0.0087318429723382,
-0.016278207302093506,
0.024435006082057953,
0.028309926390647888,
0.03807685151696205,
-0.0036603850312530994,
-0.024169599637389183,
0.007581752259284258,
0.01902073249220848,
-0.025125060230493546,
-0.015588153153657913,
0.0072057610377669334,
0.008983978070318699,
-0.015623540617525578,
0.011615917086601257,
0.008037365041673183,
0.008891086094081402,
0.02041853405535221,
0.036236707121133804,
-0.015950875356793404,
0.03981083631515503,
-0.03519277647137642,
-0.006383003666996956,
0.052798014134168625,
0.0018324042903259397,
0.07629525661468506,
0.01886148937046528,
0.03073396533727646,
-0.01972847990691662,
-0.039563123136758804,
0.07438433170318604,
-0.010952402837574482,
-0.05467354506254196,
0.007816193625330925,
-0.015039648860692978,
-0.025355078279972076,
0.030185459181666374,
-0.004469871986657381,
0.03853688761591911,
0.0661744549870491,
0.035865139216184616,
-0.0013270277995616198,
-0.05180716514587402,
0.014128423295915127,
0.03165403753519058,
-0.013889557681977749,
0.034998148679733276,
0.0449066236615181,
0.06889928132295609,
-0.03236178681254387,
0.06992551684379578,
0.028646107763051987,
0.020294679328799248,
0.07038555294275284,
-0.01802103780210018,
-0.018082965165376663,
-0.017870642244815826,
-0.012420980259776115,
-0.001272840891033411,
0.016136659309267998,
0.03966928645968437,
-0.041721753776073456,
0.02740754745900631,
-0.03609515726566315,
0.035670507699251175,
-0.03651980683207512,
0.022701023146510124,
-0.0415802039206028,
0.022488698363304138,
0.01642860472202301,
-0.04037703201174736,
0.006091057788580656,
0.01474770251661539,
-0.035935912281274796,
-0.03195482864975929,
-0.05315188691020012,
-0.008590293116867542,
-0.01298717875033617,
0.04851613566279411,
-0.040624745190143585,
0.05251491442322731,
-0.06306036561727524,
-0.014783089980483055,
0.02291334792971611,
0.00012986901856493205,
-0.03613054379820824,
0.038466114550828934,
-0.031211694702506065,
0.020630858838558197,
-0.02174556255340576,
-0.06638678163290024,
-0.03644903004169464,
0.002616456476971507,
-0.021303219720721245,
0.011615917086601257,
-0.01087278127670288,
0.050533220171928406,
-0.009722691029310226,
-0.0025058710016310215,
0.009315735660493374,
-0.07877237349748611,
-0.03641364350914955,
-0.0611848309636116,
0.012297124601900578,
0.033812668174505234,
-0.02385111339390278,
-0.03881998732686043,
0.05470893532037735,
0.0698547437787056,
-0.0018301925156265497,
-0.009519212879240513,
-0.023921888321638107,
-0.003560858080163598,
0.008010825142264366,
0.019799254834651947,
0.07799384742975235,
-0.016711704432964325,
-0.0655020922422409,
0.043314188718795776,
0.004248700570315123,
0.05729221552610397,
0.024718105792999268,
-0.0595216229557991,
0.011801701039075851,
-0.005401003174483776,
-0.0032777588348835707,
0.020135436207056046,
-0.07459665834903717,
0.047277577221393585,
-0.012916403822600842,
0.0008957437821663916,
-0.03273335471749306,
0.01958693005144596,
-0.02052469737827778,
-0.037262942641973495,
0.01818912848830223,
0.042889539152383804,
0.07792307436466217,
-0.015030802227556705,
0.08577907830476761,
-0.04607440531253815,
-0.004653444048017263,
-0.02450578100979328,
-0.02091395854949951,
-0.03609515726566315,
0.05074554309248924,
0.02491273544728756,
-0.0755167305469513,
-0.0771445482969284,
0.03482120856642723,
0.004328322596848011,
-0.06412198394536972,
0.01925075054168701,
0.04653444141149521,
-0.025195835158228874,
0.05240875110030174,
0.01481847744435072,
0.03945695981383324,
-0.035705894231796265,
-0.04487123340368271,
-0.009758077561855316,
-0.030150072649121284,
0.059415459632873535,
-0.011748619377613068,
-0.04819764941930771,
-0.016348982229828835,
0.04713602736592293,
0.03395421802997589,
-0.028946900740265846,
0.02034776099026203,
-0.005847769323736429,
-0.0038616510573774576,
0.03273335471749306,
-0.011890169233083725,
-0.06458202004432678,
-0.02756679058074951,
0.050002407282590866,
0.024594249203801155,
-0.04848074913024902,
0.04193408042192459,
-0.025726646184921265,
-0.06504205614328384,
0.02094934694468975,
-0.01054544746875763,
0.03032700903713703,
0.06493589282035828,
-0.0033551687374711037,
0.008767230436205864,
-0.04681754112243652,
0.01506618969142437,
-0.03092859499156475,
0.009315735660493374,
0.0007846052176319063,
0.047879163175821304,
-0.012580223381519318,
-0.02684134989976883,
-0.04826842620968819,
-0.0884685218334198,
-0.04819764941930771,
0.0103950509801507,
0.015110423788428307,
0.053824249655008316,
0.02381572686135769,
-0.03252102807164192,
-0.0322556234896183,
0.018666857853531837,
0.053399600088596344,
-0.0229487344622612,
-0.0021619494073092937,
0.08507133275270462,
-0.0821695625782013,
-0.02930077537894249,
-0.0038262635935097933,
-0.0008581446600146592,
0.016853254288434982,
0.000928919471334666,
-0.005303687881678343,
0.023090284317731857,
-0.003021199954673648,
0.05704450234770775,
-0.045543596148490906,
-0.02018851600587368,
-0.0011368205305188894,
0.05796457454562187,
-0.012633305042982101,
-0.010235807858407497,
-0.08606217801570892,
0.08570830523967743,
-0.005843346007168293,
-0.05980472266674042,
-0.03473274037241936,
-0.06129099056124687,
-0.047277577221393585,
-0.008864546194672585,
-0.032078687101602554,
0.03439656272530556,
0.030680883675813675,
0.002121032914146781,
0.023072591051459312,
0.03220254182815552,
-0.024098824709653854,
-0.016870947554707527,
0.0073605808429419994,
0.012279430404305458,
-0.04660521820187569,
-0.027283692732453346,
0.05347037315368652,
-0.003815205069258809,
0.059415459632873535,
0.004487565718591213,
-0.03743987902998924,
0.0014929063618183136,
0.0019131317967548966,
0.009501519612967968,
0.0039036734960973263,
-0.028593026101589203,
-0.006542247254401445,
0.01902073249220848,
0.053328823298215866,
-0.03579436242580414,
-0.0027115601114928722,
-0.011032024398446083,
0.06139715388417244,
0.04472968354821205,
0.04441119730472565,
-0.006940355524420738,
0.006325499154627323,
0.03988160938024521,
-0.05591210722923279,
0.012075953185558319,
0.0059583550319075584,
0.023125670850276947,
-0.046746768057346344,
0.01134166494011879,
0.017313290387392044,
-0.005016165319830179,
-0.003195925382897258,
-0.027743728831410408,
0.006369733717292547,
-0.011987484991550446,
-0.055522844195365906,
0.02813299000263214,
-0.008607987314462662,
-0.012642151676118374,
0.10425130277872086,
-0.035334326326847076,
-0.0037001960445195436,
-0.01323489099740982,
-0.013208350166678429,
0.08733612298965454,
0.014393828809261322,
0.007241148501634598,
-0.033441100269556046,
0.008006401360034943,
-0.01845453307032585,
0.008165644481778145,
-0.010129645466804504,
-0.015004261396825314,
0.05746915191411972,
-0.0498962476849556,
-0.06578519195318222,
0.011881322599947453,
-0.06953626126050949,
0.0038528041914105415,
0.011952097527682781,
-0.05746915191411972,
0.07254418730735779,
0.07735687494277954,
-0.016835559159517288,
0.003030046820640564,
-0.008121410384774208,
0.0001997453364310786,
0.07445510476827621,
-0.04593285545706749,
-0.03455580398440361,
0.012111340649425983,
0.008267383091151714,
-0.0036670202389359474,
-0.03552895784378052,
-0.010775466449558735,
-0.04572053253650665,
0.022099437192082405,
0.02208174392580986,
0.032344091683626175,
0.011509754694998264,
0.02733677253127098,
-0.036767516285181046,
-0.03761681541800499,
-0.05145329236984253,
-0.0748089849948883,
0.009386510588228703,
-0.021427076309919357,
-0.06712991744279861,
-0.07579983025789261,
0.024718105792999268,
0.033971913158893585,
0.000211080361623317,
0.029389243572950363,
0.023267220705747604,
-0.10481750220060349,
0.02181633748114109,
-0.021427076309919357,
-0.010651609860360622,
0.056159816682338715,
-0.040624745190143585,
0.023461852222681046,
-0.011102799326181412,
-0.04929466173052788,
-0.019215362146496773,
0.00912995170801878,
-0.027460629120469093,
-0.0010041177738457918,
0.02105550840497017,
-0.03637825697660446,
0.03322877734899521,
0.026257457211613655,
-0.01117357425391674,
0.042217180132865906,
0.02937154844403267,
-0.017985651269555092,
0.02155093289911747,
-0.023054897785186768,
-0.04193408042192459,
0.029053062200546265,
0.11387667804956436,
0.020436229184269905,
-0.0037599122151732445,
-0.0608663447201252,
-0.017932569608092308,
-0.06511282920837402,
0.05463815852999687,
0.019073814153671265,
0.005489471834152937,
-0.01049236673861742,
0.007055364549160004,
-0.003231312846764922,
0.0007193596684373915,
-0.05909697338938713,
-0.013022566214203835,
-0.00852836575359106,
-0.042854152619838715,
-0.011943250894546509,
0.011952097527682781,
-0.03740449249744415,
-0.09752769768238068,
0.056619852781295776,
-0.08308963477611542,
0.008108139969408512,
-0.057716865092515945,
-0.0008343687513843179,
-0.03186636045575142,
-0.014995414763689041,
0.02903536893427372,
-0.02650516852736473,
-0.0013889557449147105,
-0.07208415120840073,
-0.03361803665757179,
-0.0037001960445195436,
-0.03662596642971039,
-0.015251973643898964,
-0.05145329236984253,
0.005661985371261835,
-0.025921277701854706,
-0.00554697634652257,
0.009545753709971905,
-0.0030057181138545275,
0.04299570247530937,
0.043951161205768585,
0.046251341700553894,
-0.04441119730472565,
-0.012845629826188087,
0.015641234815120697,
-0.03761681541800499,
0.027230611070990562,
-0.03331724554300308,
0.06536054611206055,
0.03860766440629959,
-0.00903263594955206,
-0.02823915146291256,
-0.0169594157487154,
-0.0771445482969284,
0.04313725233078003,
0.02105550840497017,
-0.02577972784638405,
0.024151906371116638,
0.01789718121290207,
0.03850150108337402,
-0.011730926111340523,
-0.03489198535680771,
0.004666714463382959,
-0.0002813022583723068,
-0.030981676653027534,
-0.027885278686881065,
-0.02733677253127098,
-0.004728642292320728,
0.044977396726608276,
-0.0012352417688816786,
-0.06040630862116814,
0.04713602736592293,
-0.022966427728533745,
-0.007586175575852394,
0.02008235454559326,
0.0009515895508229733,
0.000508417550008744,
-0.021692480891942978,
0.010554295033216476,
0.01087278127670288,
-0.030574720352888107,
0.042854152619838715,
-0.011607070453464985,
0.03556434437632561,
0.026982899755239487,
-0.04957776144146919,
0.024452699348330498,
0.06231722608208656,
0.0034989300183951855,
0.031512487679719925,
0.03945695981383324,
0.000593844975810498,
-0.04112016782164574,
0.006024706177413464,
-0.08740690350532532,
-0.015508531592786312,
-0.051099419593811035,
-0.009289194829761982,
-0.021657094359397888,
0.02155093289911747,
-0.06309574842453003,
-0.027920665219426155,
0.05916774645447731,
-0.036272093653678894,
-0.028309926390647888,
0.018613776192069054,
0.013694927096366882,
-0.09023789316415787,
0.03740449249744415,
0.03444964066147804,
-0.02620437555015087,
-0.020542390644550323,
-0.016313595697283745,
-0.028681494295597076,
0.023497238755226135,
-0.03878460079431534,
-0.018171435222029686,
0.08040019124746323,
0.02025929093360901,
0.05410734936594963,
-0.010828547179698944,
-0.014013414271175861,
-0.03285720944404602,
0.014128423295915127,
-0.019976193085312843,
0.019976193085312843,
-0.006201643496751785,
-0.022541780024766922,
-0.0037355832755565643,
-0.006387427449226379,
-0.04087245836853981,
-0.08691147714853287,
-0.01802103780210018,
0.03308722749352455,
-0.03768759220838547,
0.02937154844403267,
0.027478322386741638,
0.007541941478848457,
0.010881627909839153,
-0.023568013682961464,
-0.002102233236655593,
0.013889557681977749,
0.051771778613328934,
-0.018153740093111992,
0.0007177008665166795,
-0.06302497535943985,
-0.02378033846616745,
-0.008992825634777546,
0.06267110258340836,
-0.016517072916030884,
0.000508417550008744,
0.06826230883598328,
-0.05035628378391266,
0.030875513330101967
]
|
30,353 | networkx.readwrite.json_graph.adjacency | adjacency_data | Returns data in adjacency format that is suitable for JSON serialization
and use in JavaScript documents.
Parameters
----------
G : NetworkX graph
attrs : dict
A dictionary that contains two keys 'id' and 'key'. The corresponding
values provide the attribute names for storing NetworkX-internal graph
data. The values should be unique. Default value:
:samp:`dict(id='id', key='key')`.
If some user-defined graph data use these attribute names as data keys,
they may be silently dropped.
Returns
-------
data : dict
A dictionary with adjacency formatted data.
Raises
------
NetworkXError
If values in attrs are not unique.
Examples
--------
>>> from networkx.readwrite import json_graph
>>> G = nx.Graph([(1, 2)])
>>> data = json_graph.adjacency_data(G)
To serialize with json
>>> import json
>>> s = json.dumps(data)
Notes
-----
Graph, node, and link attributes will be written when using this format
but attribute keys must be strings if you want to serialize the resulting
data with JSON.
The default value of attrs will be changed in a future release of NetworkX.
See Also
--------
adjacency_graph, node_link_data, tree_data
| def adjacency_data(G, attrs=_attrs):
"""Returns data in adjacency format that is suitable for JSON serialization
and use in JavaScript documents.
Parameters
----------
G : NetworkX graph
attrs : dict
A dictionary that contains two keys 'id' and 'key'. The corresponding
values provide the attribute names for storing NetworkX-internal graph
data. The values should be unique. Default value:
:samp:`dict(id='id', key='key')`.
If some user-defined graph data use these attribute names as data keys,
they may be silently dropped.
Returns
-------
data : dict
A dictionary with adjacency formatted data.
Raises
------
NetworkXError
If values in attrs are not unique.
Examples
--------
>>> from networkx.readwrite import json_graph
>>> G = nx.Graph([(1, 2)])
>>> data = json_graph.adjacency_data(G)
To serialize with json
>>> import json
>>> s = json.dumps(data)
Notes
-----
Graph, node, and link attributes will be written when using this format
but attribute keys must be strings if you want to serialize the resulting
data with JSON.
The default value of attrs will be changed in a future release of NetworkX.
See Also
--------
adjacency_graph, node_link_data, tree_data
"""
multigraph = G.is_multigraph()
id_ = attrs["id"]
# Allow 'key' to be omitted from attrs if the graph is not a multigraph.
key = None if not multigraph else attrs["key"]
if id_ == key:
raise nx.NetworkXError("Attribute names are not unique.")
data = {}
data["directed"] = G.is_directed()
data["multigraph"] = multigraph
data["graph"] = list(G.graph.items())
data["nodes"] = []
data["adjacency"] = []
for n, nbrdict in G.adjacency():
data["nodes"].append({**G.nodes[n], id_: n})
adj = []
if multigraph:
for nbr, keys in nbrdict.items():
for k, d in keys.items():
adj.append({**d, id_: nbr, key: k})
else:
for nbr, d in nbrdict.items():
adj.append({**d, id_: nbr})
data["adjacency"].append(adj)
return data
| (G, attrs={'id': 'id', 'key': 'key'}) | [
-0.016919098794460297,
0.015325945802032948,
-0.026235783472657204,
-0.004979767836630344,
0.016974998638033867,
0.04535362124443054,
-0.028229553252458572,
0.012652057223021984,
0.07393720746040344,
-0.06003671512007713,
-0.016136497259140015,
0.003367981407791376,
0.013825959526002407,
0.03119225986301899,
-0.035254333168268204,
-0.05142809823155403,
0.010965737514197826,
0.05068276450037956,
0.017906667664647102,
0.014114776626229286,
-0.015307312831282616,
-0.02919849008321762,
-0.01723586581647396,
0.01513961236923933,
-0.012642741203308105,
-0.019881805405020714,
0.044310152530670166,
0.012717274017632008,
0.05098089948296547,
0.04315488412976265,
0.014170677401125431,
-0.10673193633556366,
-0.0106862373650074,
0.023627111688256264,
0.012242123484611511,
-0.008897433988749981,
-0.03208666294813156,
0.006027895025908947,
-0.10889340937137604,
-0.019714104011654854,
0.009605501778423786,
-0.056459106504917145,
-0.0316394604742527,
-0.043862950056791306,
0.04893122613430023,
0.03804934024810791,
-0.01136635523289442,
0.035254333168268204,
-0.02813638746738434,
-0.0962972491979599,
-0.002795005450025201,
-0.033651866018772125,
0.01267069112509489,
0.054185837507247925,
-0.0009957206202670932,
0.009801152162253857,
0.001213498180732131,
0.029235756024718285,
-0.007276330608874559,
0.011804238893091679,
-0.030838225036859512,
-0.04382568225264549,
0.024167479947209358,
-0.025825848802924156,
-0.053552303463220596,
0.027484219521284103,
-0.07982535660266876,
-0.048223160207271576,
-0.03942820802330971,
-0.029906557872891426,
-0.01029493659734726,
0.010285619646310806,
0.044943686574697495,
0.008566691540181637,
0.008971966803073883,
0.022658176720142365,
0.015838364139199257,
0.04881942644715309,
-0.015167562291026115,
0.046807024627923965,
-0.011962623335421085,
-0.05500570684671402,
-0.008068248629570007,
-0.01934143714606762,
-0.005063618067651987,
-0.007802723441272974,
-0.0330183282494545,
0.03568290174007416,
-0.012642741203308105,
-0.030074257403612137,
-0.025024615228176117,
0.00005007717845728621,
-0.00019171989697497338,
0.03383819758892059,
-0.0067825461737811565,
-0.017478100955486298,
-0.0061723035760223866,
-0.03285063058137894,
0.0541113018989563,
0.04173874482512474,
-0.04393748566508293,
0.01881970278918743,
-0.05262063443660736,
0.00835240725427866,
-0.04259588196873665,
-0.11500515043735504,
-0.02161470800638199,
-0.01645326428115368,
-0.02988792397081852,
-0.01917373761534691,
-0.038422007113695145,
-0.009931585751473904,
0.07684401422739029,
-0.03957727551460266,
0.09100537747144699,
0.0321984626352787,
0.04296854883432388,
-0.028788555413484573,
-0.010518536902964115,
-0.03642823547124863,
-0.009782519191503525,
0.049080293625593185,
0.015912897884845734,
0.03812387213110924,
-0.005804294254630804,
-0.03132269158959389,
0.0007895890157669783,
-0.017850767821073532,
-0.03165809437632561,
0.004632721189409494,
0.033707763999700546,
0.010332203470170498,
0.004562846384942532,
0.07699307799339294,
0.07475707679986954,
-0.01213963981717825,
-0.023906612768769264,
0.02139110676944256,
0.034285400062799454,
0.038869209587574005,
0.01757126674056053,
-0.08273215591907501,
0.015363212674856186,
-0.012642741203308105,
-0.0034774525556713343,
-0.030428292229771614,
-0.02025447227060795,
-0.05325416848063469,
-0.03203076124191284,
-0.03776983916759491,
0.05150263383984566,
0.0056505692191421986,
0.03939094394445419,
-0.0062235454097390175,
0.001568696810863912,
-0.028453154489398003,
-0.08079428970813751,
-0.009391218423843384,
0.007709556259214878,
-0.00918625108897686,
-0.012484357692301273,
0.014701727777719498,
0.027931420132517815,
0.0054409438744187355,
0.012298023328185081,
0.04192508012056351,
0.036651838570833206,
-0.06525405496358871,
-0.020459439605474472,
-0.011822872795164585,
-0.0016176094068214297,
-0.02789415419101715,
-0.009433142840862274,
-0.01029493659734726,
-0.008897433988749981,
0.00981046911329031,
0.04166421294212341,
0.018521569669246674,
0.06473232060670853,
0.03784437105059624,
-0.005599327385425568,
0.0029813391156494617,
-0.035533834248781204,
0.015167562291026115,
0.013024725019931793,
-0.02806185372173786,
0.03784437105059624,
-0.04803682491183281,
0.08802403509616852,
-0.012158273719251156,
-0.005394360516220331,
0.0047095841728150845,
-0.015186196193099022,
0.05042189732193947,
0.03654003515839577,
-0.04393748566508293,
-0.01006201934069395,
0.006149011664092541,
-0.027875520288944244,
0.08355202525854111,
0.013145841658115387,
-0.05757711082696915,
0.0012973482953384519,
0.0031839769799262285,
0.011999889276921749,
0.031676728278398514,
-0.02297494374215603,
-0.05955224856734276,
-0.018391136080026627,
-0.035012099891901016,
-0.008347749710083008,
-0.02999972365796566,
0.059514980763196945,
0.0127638578414917,
-0.026850685477256775,
0.007192480377852917,
0.0217824075371027,
0.041366077959537506,
-0.01171107217669487,
-0.05347776785492897,
-0.029161222279071808,
-0.022024642676115036,
-0.0020939249079674482,
0.007239063736051321,
0.001604798948392272,
-0.09152711182832718,
0.05403677001595497,
0.015027811750769615,
-0.01917373761534691,
-0.02386934496462345,
0.03270156309008598,
0.04144061356782913,
0.04192508012056351,
0.015521596185863018,
0.019434604793787003,
-0.002055493416264653,
0.010509219951927662,
0.009302709251642227,
0.025415915995836258,
0.0035589735489338636,
-0.002715813461691141,
-0.02444698102772236,
-0.01570793054997921,
-0.02267681062221527,
-0.02114887349307537,
-0.023049477487802505,
0.04043441265821457,
0.020198572427034378,
0.041366077959537506,
-0.04598715528845787,
-0.07028506696224213,
0.01757126674056053,
0.01329490914940834,
-0.0010708364425227046,
-0.03152766078710556,
-0.01928553730249405,
-0.02688795141875744,
0.016574380919337273,
-0.02830408699810505,
-0.038533806800842285,
0.011645855382084846,
-0.018111634999513626,
-0.07412353903055191,
0.06454598903656006,
0.026552550494670868,
0.022602276876568794,
0.06260812282562256,
0.0013229692121967673,
-0.046471621841192245,
-0.011329088360071182,
0.0582851767539978,
-0.013080624863505363,
0.042894016951322556,
-0.05519203841686249,
0.037676673382520676,
0.008650541305541992,
0.02653391659259796,
0.011636539362370968,
0.0031327351462095976,
-0.002222029259428382,
-0.02772645279765129,
-0.009093084372580051,
-0.038981009274721146,
-0.007723531685769558,
-0.04453375190496445,
-0.027484219521284103,
-0.02983202412724495,
0.015726562589406967,
-0.010453320108354092,
-0.030372392386198044,
0.07330367714166641,
-0.00952165201306343,
-0.028844455257058144,
0.040285345166921616,
0.00019186547433491796,
0.02575131691992283,
0.014813528396189213,
-0.019360071048140526,
0.037061769515275955,
0.035012099891901016,
0.04594988748431206,
-0.00924215093255043,
0.09137804061174393,
-0.03057735785841942,
-0.05336596816778183,
-0.007830672897398472,
0.016304198652505875,
0.015093028545379639,
-0.024912813678383827,
0.027092918753623962,
-0.04937842860817909,
0.017794867977499962,
-0.0007593097980134189,
0.059179581701755524,
-0.07721668481826782,
-0.03417360037565231,
-0.02858358807861805,
-0.024242013692855835,
0.05985037982463837,
0.014226577244699001,
-0.0357947014272213,
0.03208666294813156,
-0.004695609211921692,
0.011422255076467991,
-0.010136553086340427,
0.03572016954421997,
0.10076925903558731,
0.05392497032880783,
0.06663292646408081,
-0.005822927691042423,
-0.033092863857746124,
-0.019304171204566956,
-0.027409685775637627,
0.05057096481323242,
-0.05042189732193947,
0.07706761360168457,
0.025788582861423492,
-0.04032260924577713,
-0.0009270100854337215,
0.006838446483016014,
-0.03154629468917847,
-0.013034041970968246,
-0.0011581802973523736,
-0.007103972136974335,
0.0038081947714090347,
-0.02172650769352913,
-0.0032748146913945675,
-0.014226577244699001,
0.01684456504881382,
0.01911783590912819,
-0.015419112518429756,
0.06819812953472137,
-0.021502908319234848,
0.03939094394445419,
-0.026738883927464485,
-0.03503073379397392,
0.04960202798247337,
-0.0702105313539505,
-0.016369415447115898,
0.05858331173658371,
0.0019378704018890858,
0.014580611139535904,
0.029105322435498238,
-0.0076163895428180695,
-0.01171107217669487,
0.01834455132484436,
0.019993605092167854,
0.007001488469541073,
0.05068276450037956,
-0.03704313933849335,
0.0010166831780225039,
-0.03085685893893242,
0.005208026617765427,
0.032925162464380264,
0.011562005616724491,
0.033707763999700546,
0.03685680404305458,
-0.012698641046881676,
-0.0004099341167602688,
-0.024689214304089546,
-0.0851917639374733,
-0.02789415419101715,
0.02966432273387909,
0.022844510152935982,
0.030130157247185707,
0.004292662255465984,
0.10464499890804291,
-0.0034285399597138166,
-0.05019829794764519,
-0.0018563494086265564,
-0.04837222769856453,
-0.05090636387467384,
0.022993577644228935,
0.02783825248479843,
-0.06171371787786484,
-0.04021080955862999,
0.051912564784288406,
-0.024186113849282265,
0.01389117632061243,
0.0011133437510579824,
-0.007630364503711462,
-0.03566426783800125,
-0.009642768651247025,
0.006083794869482517,
0.024409713223576546,
-0.004891259595751762,
0.051688965409994125,
-0.0213724747300148,
0.04949022829532623,
0.013080624863505363,
0.04367661848664284,
0.04997469484806061,
-0.004243749659508467,
0.034676700830459595,
0.09868232160806656,
0.03622326999902725,
0.027018385007977486,
0.024968715384602547,
0.02694385126233101,
0.01136635523289442,
0.04404928535223007,
0.023012211546301842,
0.021521540358662605,
0.010266986675560474,
-0.01089120376855135,
-0.008086882531642914,
-0.03957727551460266,
0.014096143655478954,
-0.054409436881542206,
0.06380065530538559,
0.006605529226362705,
-0.03763940557837486,
0.07099313288927078,
-0.07654587924480438,
-0.025490449741482735,
0.05593737214803696,
0.007178505416959524,
-0.021596074104309082,
0.039502743631601334,
0.023012211546301842,
-0.00029988077585585415,
0.022415943443775177,
-0.022080542519688606,
-0.010341519489884377,
-0.016723448410630226,
-0.025769948959350586,
0.01770170032978058,
0.036148734390735626,
0.07736574858427048,
-0.00679186312481761,
0.04457101970911026,
0.021763775497674942,
0.0657757893204689,
-0.050161030143499374,
-0.09965125471353531,
0.007579122669994831,
0.029161222279071808,
-0.018409768119454384,
-0.04252134636044502,
0.0391300767660141,
0.005729760974645615,
-0.040471676737070084,
-0.021763775497674942,
-0.031210893765091896,
-0.023403512313961983,
0.014841478317975998,
0.005585352424532175,
0.024875547736883163,
-0.07788748294115067,
0.024018412455916405,
0.030689159408211708,
0.05351503565907478,
-0.04076981171965599,
-0.031509026885032654,
0.04621075466275215,
0.0022907399106770754,
-0.028844455257058144,
-0.01792530156672001,
-0.07412353903055191,
-0.029533889144659042,
0.00007882788486313075,
-0.01695636659860611,
0.040285345166921616,
-0.010704870335757732,
0.04457101970911026,
0.021409740671515465,
0.01820480078458786,
-0.017478100955486298,
0.002070633228868246,
-0.008287190459668636,
0.0056505692191421986,
-0.008012348785996437,
0.006554287392646074,
0.01261479128152132,
0.054409436881542206,
0.07337820529937744,
0.029962457716464996,
-0.017627166584134102,
-0.007798064965754747,
-0.012540257535874844,
-0.02142837457358837,
-0.04013627767562866,
-0.0038012072909623384,
-0.004110986832529306,
-0.028285454958677292,
-0.0016991302836686373,
-0.015884947031736374,
0.03460216522216797,
0.008962650783360004,
0.004269370809197426,
-0.03011152520775795,
0.03277609497308731,
0.08042161911725998,
0.037956174463033676,
0.014347693882882595,
0.038422007113695145,
-0.014058876782655716,
0.009596184827387333,
-0.015540230087935925,
-0.052322499454021454,
0.0057530528865754604,
-0.012270073406398296,
0.017971884459257126,
0.021353840827941895,
-0.07155213505029678,
0.08899296820163727,
0.017412884160876274,
-0.00534777669236064,
-0.047030624002218246,
0.02267681062221527,
-0.06052118167281151,
0.05206163227558136,
-0.013993659988045692,
0.07989988476037979,
-0.04557722061872482,
0.004036453552544117,
0.07721668481826782,
0.019881805405020714,
0.023328978568315506,
-0.0007272837101481855,
0.06361432373523712,
-0.008650541305541992,
0.015037128701806068,
-0.03998721018433571,
0.03799343854188919,
0.010285619646310806,
0.03417360037565231,
0.014384960755705833,
0.0018330577295273542,
-0.036726370453834534,
-0.058434244245290756,
-0.00472588837146759,
-0.010136553086340427,
-0.015894263982772827,
0.02467058040201664,
-0.05496843904256821,
-0.011720389127731323,
-0.024875547736883163,
0.01890355348587036,
0.011701756156980991,
-0.02047807164490223,
-0.01108685415238142,
-0.05403677001595497,
-0.051912564784288406,
0.013825959526002407,
-0.009857052005827427,
0.04937842860817909,
0.0402480773627758,
-0.061378318816423416,
-0.01886628568172455,
-0.010099286213517189,
-0.017273133620619774,
0.023179911077022552,
-0.0552293062210083,
-0.04706789180636406,
0.006926954723894596,
-0.08310482650995255,
0.019192369654774666,
0.05880691111087799,
-0.019304171204566956,
-0.03704313933849335,
0.03823567181825638,
-0.0016665218863636255,
0.05042189732193947,
0.03011152520775795,
0.057651642709970474,
-0.005459577310830355,
0.061564650386571884,
0.02528548240661621,
-0.04870762676000595,
-0.03791890665888786,
-0.03475123271346092,
0.039279140532016754,
-0.02539728209376335,
0.027707818895578384,
0.01757126674056053,
-0.01457129418849945,
-0.0021882562432438135,
0.006936271674931049,
-0.09204884618520737,
-0.022527743130922318,
0.01934143714606762,
-0.007192480377852917,
0.011916039511561394,
0.018978087231516838,
0.025378648191690445,
-0.02347804419696331,
0.013173791579902172,
-0.027316518127918243,
-0.08124148845672607,
-0.051912564784288406,
0.010304252617061138,
-0.013276275247335434,
-0.07002419978380203,
-0.007579122669994831,
-0.018130268901586533,
-0.027707818895578384,
0.018409768119454384,
-0.06171371787786484,
-0.009568234905600548,
0.034285400062799454,
-0.050943631678819656,
0.013527825474739075,
-0.0033982605673372746,
-0.00424607889726758,
0.008277874439954758,
-0.03780710697174072,
0.008944016881287098,
-0.043639350682497025,
-0.011058904230594635,
-0.021763775497674942,
-0.048744894564151764,
0.022136442363262177,
0.041999612003564835,
0.036092836409807205,
-0.07032233476638794,
0.014152043499052525,
0.007635022979229689,
0.042558614164590836,
0.019434604793787003,
-0.06499318778514862,
0.008142782375216484,
-0.04758962616324425,
-0.014366327784955502,
-0.004341574851423502,
0.019099203869700432,
0.029422089457511902,
-0.01650916412472725,
-0.004665329586714506,
-0.051465366035699844,
0.014133410528302193,
-0.026217149570584297,
0.004956476390361786,
-0.004858651198446751,
0.03514253348112106,
0.06842172890901566,
0.006894346326589584,
-0.000028969065169803798,
-0.013863226398825645,
-0.031229525804519653,
0.012400506995618343,
0.040397144854068756,
-0.0007144732517190278,
-0.03532886877655983,
0.05839698016643524,
0.039092808961868286,
-0.032123927026987076,
-0.020552605390548706,
0.08355202525854111,
-0.026794783771038055,
-0.03654003515839577,
0.06294351816177368,
0.035925135016441345,
0.03752760589122772,
-0.0024013754446059465,
-0.026571184396743774,
0.03516116738319397,
0.04878215864300728,
0.006377270445227623,
-0.01890355348587036,
0.0026040133088827133,
0.05239703506231308,
0.03430403396487236,
-0.0552293062210083,
-0.026328951120376587,
-0.04229774698615074,
0.05008649453520775,
-0.04878215864300728,
-0.018270017579197884,
-0.008249924518167973,
0.02392524667084217,
-0.0507945641875267,
0.06767639517784119,
0.006656771060079336,
0.041142478585243225,
-0.05899324640631676,
0.023999778553843498,
0.0446828193962574,
-0.010462637059390545,
-0.02789415419101715,
-0.014962594956159592,
0.006680062972009182,
0.02461468055844307,
0.052434299141168594,
0.03735990449786186,
-0.02120477333664894,
-0.014729678630828857,
0.022714076563715935,
0.007947131991386414,
-0.04021080955862999,
-0.07434714585542679,
0.02705565094947815,
0.011487471871078014,
0.026794783771038055,
0.02336624450981617,
0.019937705248594284,
-0.005245293490588665,
-0.014757628552615643,
-0.042111415416002274,
0.044496484100818634,
-0.024484246969223022,
0.03696860373020172,
0.038981009274721146,
0.03924187645316124,
-0.053626835346221924,
-0.021540174260735512,
0.01895945332944393,
-0.02139110676944256,
0.006726646330207586,
-0.07013600319623947,
-0.022546377032995224,
0.036092836409807205,
-0.012968825176358223,
0.019192369654774666,
-0.029925189912319183,
-0.029906557872891426,
-0.037676673382520676,
-0.011235921643674374,
-0.012353924103081226,
0.060073982924222946,
-0.04781322553753853,
0.020664406940340996,
-0.056049175560474396,
-0.0016653573838993907,
0.007448689080774784,
-0.0020578226540237665,
-0.00045360607327893376,
0.04166421294212341,
-0.024372447282075882,
-0.02800595387816429,
0.023887978866696358,
0.04732875898480415,
-0.055490173399448395,
-0.04073254391551018,
0.06890619546175003,
0.00910240039229393,
-0.015260729007422924,
0.015242096036672592,
0.02409294620156288,
-0.07106766849756241,
-0.06473232060670853,
-0.01890355348587036,
-0.0014603902818635106,
-0.027148818597197533,
-0.0627199187874794,
0.006032553035765886,
0.03430403396487236,
0.05530383810400963
]
|
30,362 | networkx.classes.function | all_neighbors | Returns all of the neighbors of a node in the graph.
If the graph is directed returns predecessors as well as successors.
Parameters
----------
graph : NetworkX graph
Graph to find neighbors.
node : node
The node whose neighbors will be returned.
Returns
-------
neighbors : iterator
Iterator of neighbors
| def all_neighbors(graph, node):
"""Returns all of the neighbors of a node in the graph.
If the graph is directed returns predecessors as well as successors.
Parameters
----------
graph : NetworkX graph
Graph to find neighbors.
node : node
The node whose neighbors will be returned.
Returns
-------
neighbors : iterator
Iterator of neighbors
"""
if graph.is_directed():
values = chain(graph.predecessors(node), graph.successors(node))
else:
values = graph.neighbors(node)
return values
| (graph, node) | [
-0.01226970087736845,
-0.03425834700465202,
-0.028505178168416023,
-0.013023757375776768,
-0.05075448378920555,
0.016551993787288666,
-0.010351978242397308,
0.009430354461073875,
0.09756181389093399,
-0.011487717740237713,
-0.0158724132925272,
-0.02360846847295761,
-0.00996098667383194,
0.029845722019672394,
0.0008669316885061562,
-0.030031908303499222,
-0.07082540541887283,
0.04926499351859093,
0.007233351934701204,
0.0333460308611393,
-0.01667301543056965,
-0.019828880205750465,
-0.03135383501648903,
-0.019177226349711418,
-0.028505178168416023,
0.027108779177069664,
0.02655021846294403,
0.00660031707957387,
-0.026699168607592583,
0.06367584317922592,
0.007233351934701204,
-0.03265714272856712,
-0.044237952679395676,
-0.05343557149171829,
0.03492861986160278,
0.05328662320971489,
0.024576639756560326,
0.0442751906812191,
-0.101360023021698,
0.05287701264023781,
-0.008448219858109951,
-0.052318453788757324,
-0.036678772419691086,
-0.026159226894378662,
0.03716285899281502,
-0.08274135738611221,
0.06605903059244156,
0.04900433123111725,
-0.02506072446703911,
-0.040812116116285324,
0.01762256771326065,
-0.005590254440903664,
0.014457394368946552,
-0.02366432547569275,
0.008843866176903248,
0.007098366506397724,
0.00972825288772583,
-0.00484550790861249,
0.007359027862548828,
0.08095396310091019,
-0.0031558640766888857,
-0.02332918904721737,
-0.006139505188912153,
-0.014317754656076431,
0.03042290173470974,
-0.010240267030894756,
-0.016551993787288666,
-0.06769747287034988,
-0.04505717381834984,
-0.002183038741350174,
-0.04200371354818344,
0.022156212478876114,
0.04598810523748398,
0.0032838673796504736,
-0.05116409435868263,
-0.014029165729880333,
0.04531783610582352,
0.04554125666618347,
-0.014969407580792904,
-0.015593132935464382,
0.00403792317956686,
0.0020620173308998346,
-0.0455784946680069,
0.0015337126096710563,
0.01622616872191429,
-0.030534613877534866,
-0.0016512429574504495,
0.021355610340833664,
-0.021914171054959297,
0.06825602799654007,
-0.0034141980577260256,
-0.043567679822444916,
0.015881722792983055,
0.037609707564115524,
0.019679930061101913,
0.04286016896367073,
-0.014085020869970322,
0.002816073363646865,
-0.01986611634492874,
-0.004065851215273142,
-0.03457486256957054,
0.07991131395101547,
-0.05674969404935837,
0.026568837463855743,
0.006954072043299675,
-0.07588968425989151,
-0.05585600063204765,
-0.05194608122110367,
0.06069685146212578,
0.021560415625572205,
-0.08914617449045181,
-0.003304813290014863,
0.0025996314361691475,
-0.0345190092921257,
0.021281136199831963,
0.008629752323031425,
0.021448703482747078,
-0.00022109666315373033,
-0.04241332411766052,
-0.011822853237390518,
-0.005273737479001284,
0.06840498000383377,
0.016039980575442314,
-0.008606478571891785,
0.026066133752465248,
0.011422552168369293,
0.04889261722564697,
0.02278924733400345,
-0.05254187807440758,
-0.010891919955611229,
0.04569020867347717,
0.018227674067020416,
-0.004680267535150051,
0.08073053508996964,
-0.01811596192419529,
-0.01700815185904503,
0.0039634485729038715,
0.017306050285696983,
0.035952646285295486,
-0.017538784071803093,
-0.018767615780234337,
-0.042897406965494156,
0.004182218108326197,
0.01891656592488289,
-0.002557739382609725,
-0.045243360102176666,
-0.007615034468472004,
0.011981111951172352,
-0.010417143814265728,
-0.023180240765213966,
0.043493203818798065,
0.011645975522696972,
-0.0017198993591591716,
0.03405354171991348,
-0.05805300176143646,
0.013386821374297142,
0.002669451292604208,
-0.03783313184976578,
-0.024651113897562027,
-0.007549869362264872,
-0.025991657748818398,
0.01216729823499918,
-0.0019247046438977122,
-0.00576713215559721,
-0.022714773193001747,
-0.014988026581704617,
-0.006260526832193136,
-0.030404282733798027,
0.010417143814265728,
-0.010184410959482193,
-0.01775289885699749,
-0.05585600063204765,
-0.040625929832458496,
-0.027201872318983078,
-0.033122606575489044,
0.06583560258150101,
-0.005473888013511896,
-0.03187515586614609,
0.03154002130031586,
0.021448703482747078,
-0.003123281290754676,
-0.030776655301451683,
0.011580810882151127,
-0.06330346316099167,
0.060212768614292145,
-0.0015383673598989844,
-0.006213979795575142,
-0.004549936857074499,
-0.03429558500647545,
0.0021923480089753866,
-0.01899104006588459,
-0.04755207523703575,
-0.00009207512630382553,
0.07518217712640762,
-0.0031814647372812033,
-0.03207996115088463,
-0.0006755085196346045,
0.02185831405222416,
-0.058946698904037476,
0.024502165615558624,
0.03723733499646187,
0.008671644143760204,
0.005511125084012747,
0.03639949485659599,
0.020238490775227547,
0.044237952679395676,
-0.013461295515298843,
-0.006674792151898146,
-0.01314477901905775,
-0.030515994876623154,
-0.009118491783738136,
-0.0063629294745624065,
0.005999865476042032,
-0.012018349021673203,
-0.06095751374959946,
0.02835622988641262,
-0.016812656074762344,
0.021765220910310745,
-0.009560685604810715,
-0.0023692252580076456,
-0.029398875311017036,
-0.05410584434866905,
0.047030750662088394,
-0.01264207437634468,
0.036734629422426224,
-0.018255602568387985,
-0.02574961632490158,
-0.020610863342881203,
0.0028579654172062874,
-0.08996539562940598,
0.0003566638333722949,
0.0668410137295723,
-0.02681088075041771,
-0.002171402098610997,
0.05704759433865547,
-0.011906636878848076,
0.009528102353215218,
0.007861731573939323,
0.006390857510268688,
-0.0017885556444525719,
-0.034872762858867645,
-0.03671601042151451,
-0.019754406064748764,
0.010342669673264027,
0.01788323000073433,
-0.00532959308475256,
-0.024502165615558624,
0.021113567054271698,
0.019158607348799706,
-0.0027090159710496664,
-0.07060198485851288,
-0.06319175660610199,
0.03943433612585068,
-0.050717249512672424,
0.03470519557595253,
-0.06572389602661133,
-0.012949282303452492,
0.04293464496731758,
0.04595087096095085,
0.04151962697505951,
0.027239108458161354,
0.007438157219439745,
0.03103731758892536,
0.015676917508244514,
0.03541270270943642,
0.013349584303796291,
-0.0015430219937115908,
0.0220631193369627,
-0.0002855347120203078,
-0.00036393673508428037,
0.03800069913268089,
-0.012791023589670658,
0.009258131496608257,
0.004603465087711811,
0.044908225536346436,
-0.023236095905303955,
-0.015053192153573036,
0.06996894627809525,
0.010240267030894756,
-0.00838770903646946,
-0.03965776041150093,
0.005846261512488127,
0.001856048358604312,
-0.021225279197096825,
-0.07723022997379303,
-0.05585600063204765,
0.020015066489577293,
0.029715392738580704,
0.007661581505089998,
-0.026177845895290375,
0.07250108569860458,
-0.009155728854238987,
-0.018590738996863365,
-0.009569994173943996,
0.010742970742285252,
0.02280786633491516,
0.0016849893145263195,
-0.026103369891643524,
0.008783356286585331,
0.028170041739940643,
0.12198950350284576,
-0.046434953808784485,
-0.05027040094137192,
-0.013563698157668114,
0.000381973572075367,
0.048706430941820145,
0.05254187807440758,
0.05328662320971489,
0.018897946923971176,
-0.009681706316769123,
-0.03096284344792366,
-0.033327411860227585,
0.000326117587974295,
-0.053658995777368546,
-0.027853524312376976,
-0.10478585213422775,
0.004591828677803278,
-0.03181930258870125,
-0.012902735732495785,
-0.01184147223830223,
-0.025116581469774246,
0.08028369396924973,
0.0036562406457960606,
0.09614679217338562,
-0.09026329219341278,
0.0586860366165638,
0.020238490775227547,
0.05931907147169113,
-0.0035957300569862127,
0.02515381947159767,
0.03531961143016815,
-0.002850983291864395,
-0.04662114009261131,
0.0655377060174942,
-0.029045119881629944,
0.03101869858801365,
0.04014184698462486,
0.036008499562740326,
-0.010798826813697815,
-0.0030534614343196154,
0.02494901232421398,
0.06557494401931763,
-0.011776306666433811,
-0.012390722520649433,
-0.006209325511008501,
0.06211187317967415,
-0.019624074921011925,
0.009323297068476677,
-0.005618182476609945,
0.012381413020193577,
0.025488954037427902,
0.05596771091222763,
-0.02131837233901024,
-0.009062635712325573,
0.04174305126070976,
0.06483019888401031,
0.007340409327298403,
-0.037013910710811615,
-0.030441520735621452,
0.07279898971319199,
0.062484245747327805,
0.03809379041194916,
0.015993434935808182,
0.008220141753554344,
0.019139988347887993,
0.01002615224570036,
-0.027965236455202103,
0.0851990208029747,
0.020089540630578995,
-0.014261898584663868,
-0.007121639791876078,
-0.009281405247747898,
-0.01738983392715454,
-0.04900433123111725,
0.03023671545088291,
0.0063722385093569756,
0.05421755835413933,
-0.004282293375581503,
0.03457486256957054,
0.04386558011174202,
-0.03435143828392029,
-0.0572337806224823,
0.017352597787976265,
-0.022174831479787827,
0.01932617649435997,
-0.007121639791876078,
0.0649419054389,
0.009765490889549255,
0.03476104885339737,
0.0220631193369627,
-0.05764339119195938,
-0.03008776530623436,
-0.01297721080482006,
0.005357521120458841,
-0.01679403707385063,
-0.015239378437399864,
0.10292398929595947,
-0.02146732248365879,
0.006525842472910881,
-0.0605851411819458,
0.026457125321030617,
0.007475394755601883,
0.0015546586364507675,
0.02815142460167408,
0.0021551107056438923,
0.02260306105017662,
-0.02595442160964012,
-0.0787941962480545,
0.08542244136333466,
-0.011022250168025494,
-0.00738695589825511,
-0.00015796774823684245,
0.03425834700465202,
-0.00025455208378843963,
0.0492277555167675,
-0.05142475664615631,
0.03129797801375389,
0.07056474685668945,
0.06639416515827179,
0.025321386754512787,
0.04915327951312065,
-0.09138041734695435,
0.0007447466487064958,
0.03733042627573013,
0.047514837235212326,
-0.03410939872264862,
0.04103554040193558,
-0.02306852862238884,
-0.022845104336738586,
0.01635649800300598,
0.022044500336050987,
-0.07328306883573532,
0.005059622693806887,
-0.053994134068489075,
-0.02200726419687271,
-0.016784727573394775,
0.014885623939335346,
0.02020125277340412,
-0.0051852986216545105,
0.04963736608624458,
0.0016163330292329192,
-0.005157370585948229,
0.014950789511203766,
-0.07026685029268265,
-0.004005340859293938,
0.010379906743764877,
0.047030750662088394,
-0.0020224526524543762,
0.05049382522702217,
-0.04070040583610535,
-0.04371662810444832,
-0.082145556807518,
0.025526192039251328,
-0.03777727484703064,
-0.043232545256614685,
0.01357300765812397,
-0.059877630323171616,
-0.022025883197784424,
-0.030851131305098534,
0.05202055349946022,
0.05943078547716141,
0.04025355726480484,
-0.034370057284832,
-0.006172087974846363,
0.0030813892371952534,
-0.06401097774505615,
0.03368116915225983,
-0.0042706565000116825,
-0.011627357453107834,
-0.010426453314721584,
0.03383011743426323,
-0.01597481593489647,
-0.017901847139000893,
-0.07436295598745346,
0.03602711856365204,
0.005427341442555189,
-0.07648548483848572,
0.006604971829801798,
-0.017166411504149437,
-0.032117199152708054,
-0.04695627838373184,
-0.03692081570625305,
0.045764680951833725,
-0.02381327375769615,
-0.018330076709389687,
-0.031391073018312454,
-0.025302767753601074,
0.008606478571891785,
-0.0021236916072666645,
-0.017836682498455048,
0.043828342109918594,
-0.04006737098097801,
-0.018618667498230934,
-0.020164016634225845,
0.022118976339697838,
-0.005027039907872677,
0.022361017763614655,
-0.0012846880126744509,
0.07078816741704941,
0.04058869183063507,
-0.00309302587993443,
0.038075171411037445,
0.0016640432877466083,
0.05310043692588806,
0.004975838586688042,
0.02280786633491516,
0.014820458367466927,
0.007405574433505535,
0.03461210057139397,
0.0623352974653244,
0.039694998413324356,
0.009192966856062412,
-0.023161621764302254,
0.020778432488441467,
-0.016933677718043327,
-0.0541803203523159,
-0.05741996690630913,
0.012288319878280163,
0.029901579022407532,
-0.0042706565000116825,
-0.005641455762088299,
0.0586860366165638,
0.07678338140249252,
0.03610159456729889,
-0.030199477449059486,
0.029938815161585808,
-0.015220760367810726,
-0.07216595113277435,
-0.05000973865389824,
-0.027965236455202103,
-0.014085020869970322,
-0.004410296678543091,
-0.028244517743587494,
0.04379110410809517,
-0.03070218116044998,
0.015630370005965233,
0.09063567221164703,
0.002249367767944932,
-0.01852557249367237,
0.031186265870928764,
0.06025000661611557,
-0.033122606575489044,
0.00005167407289263792,
0.03511480614542961,
0.01103155966848135,
-0.0037027872167527676,
0.006684101186692715,
0.0044382247142493725,
-0.009784108959138393,
-0.019493743777275085,
-0.010082008317112923,
-0.026252320036292076,
-0.050680011510849,
0.017529474571347237,
-0.010286813601851463,
-0.01657061278820038,
-0.006544461473822594,
0.016216859221458435,
0.0048780906945466995,
0.014401538297533989,
-0.028765840455889702,
-0.049376703798770905,
-0.07477256655693054,
0.0018769942689687014,
-0.01667301543056965,
-0.03973223268985748,
-0.007293862756341696,
0.015434874221682549,
0.014382920227944851,
0.039546046406030655,
0.035207897424697876,
0.0030232060234993696,
-0.012427959591150284,
-0.03805655613541603,
0.028188660740852356,
0.017557403072714806,
-0.029194070026278496,
-0.05782957747578621,
-0.018981730565428734,
-0.05216950550675392,
-0.049711838364601135,
-0.08497559279203415,
-0.015202141366899014,
0.03338326886296272,
0.015732772648334503,
0.085050068795681,
-0.0522812157869339,
0.030944224447011948,
0.004363750107586384,
0.03472381457686424,
-0.010240267030894756,
-0.040625929832458496,
0.017473619431257248,
-0.004030941519886255,
-0.05872327461838722,
-0.015406946651637554,
-0.0423760861158371,
-0.005804369226098061,
0.014764602296054363,
-0.02200726419687271,
-0.02066672034561634,
0.016579922288656235,
0.045429546386003494,
-0.014429466798901558,
0.0013521806104108691,
-0.016002744436264038,
-0.04520612210035324,
0.0184231698513031,
0.015127666294574738,
-0.03504033014178276,
-0.04472203552722931,
-0.01563967950642109,
-0.002795127220451832,
-0.02975262887775898,
-0.05015868693590164,
0.01778082735836506,
-0.015555895864963531,
0.05809023976325989,
-0.03196825087070465,
0.02414841018617153,
0.0064187850803136826,
-0.044573087245225906,
0.030906986445188522,
0.01849764585494995,
-0.02005230449140072,
-0.00962585024535656,
-0.00273228925652802,
-0.08259240537881851,
-0.038615114986896515,
0.025730997323989868,
-0.05715930461883545,
-0.0002212421240983531,
-0.035878170281648636,
0.048780906945466995,
0.005864880047738552,
-0.05909564718604088,
0.026903973892331123,
-0.05287701264023781,
-0.05611666291952133,
0.006428094580769539,
-0.08877380192279816,
0.11513783782720566,
-0.01816250942647457,
-0.057196542620658875,
0.0159468874335289,
0.037553850561380386,
0.002233076374977827,
-0.00002901893822127022,
0.012716549448668957,
-0.07332030683755875,
0.02239825576543808,
0.06862840801477432,
-0.017976323142647743,
0.047701023519039154,
0.06267043203115463,
-0.01712917350232601,
-0.00010589366866042838,
0.019363412633538246,
0.00862044282257557,
0.0001997142971958965,
0.07261279970407486,
0.04174305126070976,
0.05343557149171829,
-0.026364032179117203,
0.005310974549502134,
0.04025355726480484,
-0.01002615224570036,
0.007466085255146027,
-0.01938203163444996,
0.010044770315289497,
-0.01016579195857048,
0.04721693694591522,
-0.02185831405222416,
-0.020443296059966087,
0.006879597436636686,
-0.020424677059054375,
-0.030720800161361694,
0.027052922174334526,
-0.02921268716454506,
-0.005143406800925732,
0.028858933597803116,
0.007009928114712238,
-0.0031000080052763224,
0.01695229671895504,
0.013424058444797993,
-0.01039852574467659,
0.00149531161878258,
-0.012213845737278461,
0.014522559940814972,
0.00608364911749959,
0.011748378165066242,
-0.057271018624305725,
0.08095396310091019,
0.026978448033332825,
0.03800069913268089,
0.07328306883573532,
-0.039694998413324356,
0.004221782553941011,
0.011766997165977955,
0.0015511676901951432,
-0.014745984226465225,
0.0013882543426007032,
-0.018572119995951653,
0.07737918198108673,
-0.011012941598892212,
-0.0336439311504364,
-0.005041004158556461,
-0.024762826040387154,
-0.03883853927254677,
0.07723022997379303,
-0.021988645195961,
-0.021039092913269997,
-0.032787472009658813,
-0.0359712652862072,
0.009542066603899002,
0.020033685490489006,
0.006288454867899418,
-0.07518217712640762,
-0.0003473545075394213,
0.019903354346752167,
0.039136435836553574,
-0.036883577704429626,
0.005431996192783117,
0.07391610741615295,
-0.017641186714172363,
0.022118976339697838,
-0.02928716316819191,
-0.013684719800949097,
-0.01816250942647457,
0.04032803326845169,
-0.021299755200743675,
0.028188660740852356,
0.008885758928954601,
0.04613705724477768,
0.03563612699508667,
-0.0179856326431036,
0.027462532743811607,
0.04561573266983032,
-0.03228476643562317,
-0.03245233744382858,
0.013275109231472015,
-0.004016977269202471,
0.009118491783738136,
0.00046023016329854727,
0.06445782631635666,
-0.02020125277340412,
0.0039681033231318,
0.016887130215764046,
-0.000651653332170099,
-0.030720800161361694,
0.015928268432617188,
0.022435493767261505,
0.061553310602903366,
-0.03943433612585068,
0.05849985033273697,
-0.007736056111752987,
-0.01620754972100258,
-0.03410939872264862,
-0.04338149353861809,
-0.02131837233901024,
-0.07521941512823105,
0.03168896958231926,
-0.0423760861158371,
0.005227190442383289,
-0.026252320036292076,
0.013712648302316666,
0.038615114986896515,
0.013284418731927872
]
|
30,365 | networkx.algorithms.shortest_paths.weighted | all_pairs_bellman_ford_path | Compute shortest paths between all nodes in a weighted graph.
Parameters
----------
G : NetworkX graph
weight : string or function (default="weight")
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number.
Returns
-------
paths : iterator
(source, dictionary) iterator with dictionary keyed by target and
shortest path as the key value.
Examples
--------
>>> G = nx.path_graph(5)
>>> path = dict(nx.all_pairs_bellman_ford_path(G))
>>> path[0][4]
[0, 1, 2, 3, 4]
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
See Also
--------
floyd_warshall, all_pairs_dijkstra_path
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, weight='weight', *, backend=None, **backend_kwargs) | [
0.008706215769052505,
-0.004100472200661898,
-0.03420298919081688,
-0.044230684638023376,
-0.03898363560438156,
-0.021765539422631264,
-0.010688434354960918,
0.04053831845521927,
0.07361416518688202,
-0.010581550188362598,
-0.052859168499708176,
0.029694415628910065,
0.02866443805396557,
0.02551620826125145,
-0.027284659445285797,
0.035874273627996445,
0.00006410783680621535,
0.03597144037485123,
-0.001286255894228816,
0.013700629584491253,
-0.015041542239487171,
-0.05647380277514458,
0.05550212785601616,
0.04959433525800705,
-0.02098819799721241,
-0.009264929220080376,
0.014915225096046925,
-0.040033046156167984,
-0.025807710364460945,
-0.01634358800947666,
0.01778166927397251,
-0.01869504339993,
-0.0063596186228096485,
-0.005499685648828745,
0.01651849038898945,
0.058611489832401276,
0.007802557200193405,
-0.0030559205915778875,
-0.023359088227152824,
-0.04399748519062996,
-0.030180253088474274,
-0.030394021421670914,
0.005747462622821331,
-0.03781762346625328,
0.08014382421970367,
0.08379732817411423,
-0.01751931570470333,
0.008618764579296112,
-0.019404366612434387,
-0.018840795382857323,
0.015138709917664528,
0.0014720889739692211,
-0.009313513524830341,
0.009561290964484215,
-0.007899724878370762,
0.03941117227077484,
-0.033270180225372314,
0.05421951413154602,
0.027362393215298653,
-0.03820629417896271,
0.03950834274291992,
0.01052324939519167,
0.07085460424423218,
0.04014964774250984,
-0.06378080695867538,
-0.02365059033036232,
-0.04656270891427994,
-0.03754555433988571,
-0.040033046156167984,
0.021435169503092766,
0.001010542968288064,
-0.009488414973020554,
-0.013438276946544647,
-0.03556333854794502,
-0.001875334419310093,
0.03801196068525314,
-0.00007496327452827245,
-0.03478599712252617,
0.011125688441097736,
-0.03983871266245842,
0.0438808836042881,
-0.056434933096170425,
-0.025807710364460945,
-0.07101007550954819,
0.07299229502677917,
0.025108104571700096,
-0.004027596674859524,
0.0026478166691958904,
-0.009060877375304699,
-0.03408639132976532,
-0.03669048100709915,
0.030802125111222267,
-0.003330419072881341,
0.0004044600937049836,
0.05682360380887985,
0.026779387146234512,
0.009070593863725662,
-0.05705680698156357,
0.05002187564969063,
0.031074194237589836,
0.06852257996797562,
0.0048097954131662846,
-0.014477971009910107,
0.03612690791487694,
0.02646845020353794,
-0.06720110028982162,
-0.010989653877913952,
0.015886900946497917,
-0.013885248452425003,
-0.05561872571706772,
-0.022659480571746826,
0.012427734211087227,
0.025866011157631874,
-0.026779387146234512,
0.02349512279033661,
0.0032453974708914757,
0.006767722312361002,
0.04399748519062996,
-0.0005830055451951921,
-0.021124234423041344,
-0.025224706158041954,
0.052548229694366455,
-0.08309771865606308,
-0.0039012786000967026,
0.04038285091519356,
-0.05639606714248657,
0.024738868698477745,
-0.01991935633122921,
0.06630716472864151,
0.01788855344057083,
0.026196381077170372,
0.0048097954131662846,
-0.02790653146803379,
0.06560755521059036,
0.03202643617987633,
-0.02460283227264881,
-0.056590404361486435,
0.04687364399433136,
0.06502454727888107,
0.010387214832007885,
0.04255940392613411,
-0.07547978311777115,
0.007734539918601513,
0.0287616066634655,
0.005868922453373671,
-0.028528403490781784,
0.011125688441097736,
0.014021283015608788,
0.0313073955476284,
0.05977749824523926,
0.0154496468603611,
0.0028494393918663263,
0.00686974823474884,
0.011698977090418339,
0.0016506343381479383,
-0.0682116448879242,
-0.04201526567339897,
0.020424626767635345,
0.0058349138125777245,
-0.0004894817247986794,
0.01661565713584423,
-0.0446193553507328,
0.005762037821114063,
0.014895791187882423,
-0.04986640438437462,
0.03494146466255188,
0.022134777158498764,
0.05215956270694733,
-0.027129190042614937,
0.012388867326080799,
-0.005898072384297848,
-0.0640917420387268,
-0.047806452959775925,
-0.029150275513529778,
-0.0244473647326231,
0.0033085562754422426,
0.0251469723880291,
-0.0022882965859025717,
0.011883595958352089,
-0.019462667405605316,
0.009862510487437248,
-0.026604484766721725,
0.023145319893956184,
-0.01358402892947197,
0.030083084478974342,
0.029169710353016853,
0.022251376882195473,
-0.021610071882605553,
0.0029514655470848083,
0.03478599712252617,
-0.048233989626169205,
-0.09328088164329529,
-0.06059370934963226,
0.08325318992137909,
-0.009094886481761932,
0.0067239971831440926,
-0.03727348521351814,
-0.022115342319011688,
-0.027284659445285797,
0.06378080695867538,
-0.009162903763353825,
-0.029305744916200638,
0.03987757861614227,
-0.008881117217242718,
0.009245496243238449,
-0.028839340433478355,
-0.03245397284626961,
0.008623623289167881,
0.0010111501906067133,
0.018559008836746216,
-0.035135798156261444,
-0.04543556272983551,
0.02998591773211956,
-0.02977214939892292,
0.0011933394707739353,
0.013778364285826683,
-0.03175436705350876,
0.04007191210985184,
0.014011566527187824,
-0.059039026498794556,
-0.004404121078550816,
-0.01528446190059185,
-0.009546715766191483,
0.02114366739988327,
0.0618763193488121,
-0.0502939447760582,
0.04702911153435707,
0.030646657571196556,
0.025846578180789948,
-0.0733032301068306,
0.07718992978334427,
-0.03280377760529518,
0.096312515437603,
-0.014818057417869568,
0.07380849868059158,
-0.04784531891345978,
0.00343487411737442,
0.04073265194892883,
0.04562989994883537,
0.027925964444875717,
-0.021687805652618408,
-0.02343682199716568,
-0.014633438549935818,
-0.058145083487033844,
0.005820338614284992,
-0.00011994124361081049,
0.031501732766628265,
-0.012281983159482479,
0.026138080283999443,
-0.006500511430203915,
0.00507214805111289,
0.027731629088521004,
-0.042326200753450394,
-0.05748434364795685,
-0.012942722998559475,
-0.0431424081325531,
-0.021027065813541412,
-0.03756498917937279,
-0.036515578627586365,
-0.06591849029064178,
-0.03225963935256004,
-0.02784823067486286,
-0.06094351038336754,
0.10152069479227066,
-0.003925570752471685,
0.03260944411158562,
0.031171362847089767,
-0.01430306863039732,
-0.08022156357765198,
0.0066559799015522,
0.042637135833501816,
0.04310354217886925,
-0.006860031746327877,
-0.0035879132337868214,
-0.025049803778529167,
0.005208182614296675,
-0.03222077339887619,
0.03482486307621002,
0.012845555320382118,
-0.0230092853307724,
-0.04368654638528824,
-0.00833697896450758,
-0.04123792424798012,
-0.006515086628496647,
0.018024588003754616,
0.029636114835739136,
0.01211679819971323,
-0.034747131168842316,
0.01641160622239113,
0.006651121191680431,
0.07011613249778748,
-0.012165381573140621,
0.010562117211520672,
-0.03777875751256943,
0.06226499006152153,
0.04761211946606636,
-0.0034907455556094646,
-0.07287569344043732,
0.016363020986318588,
0.05363650992512703,
0.015381629578769207,
-0.025749411433935165,
0.025632809847593307,
-0.005737746134400368,
-0.042637135833501816,
0.008307828567922115,
0.031132495030760765,
-0.01677112653851509,
-0.0025506492238491774,
-0.03093815967440605,
-0.021396303549408913,
-0.025166405364871025,
0.001787883578799665,
0.007307002786546946,
0.0036122051533311605,
-0.03727348521351814,
-0.03511636704206467,
0.0073798783123493195,
-0.006792014464735985,
0.032201338559389114,
-0.038964200764894485,
0.07641258835792542,
-0.06832824647426605,
0.029208576306700706,
-0.03047175519168377,
0.029228011146187782,
0.031773801892995834,
0.02567167580127716,
0.035135798156261444,
0.022445712238550186,
0.03791479393839836,
0.02248458005487919,
0.026196381077170372,
0.030821558088064194,
-0.01982218772172928,
0.08970511704683304,
0.07439150661230087,
-0.005402517970651388,
0.00004873561920248903,
-0.003102075308561325,
0.0474177822470665,
0.021687805652618408,
-0.022037608548998833,
0.023728324100375175,
0.006106982938945293,
-0.043803147971630096,
0.03398922085762024,
-0.03898363560438156,
0.007418745197355747,
-0.0474177822470665,
0.021804407238960266,
0.06797844171524048,
0.01831609010696411,
0.02646845020353794,
0.050566013902425766,
0.0031166502740234137,
-0.01092163659632206,
-0.04069378599524498,
0.0223096776753664,
-0.00496526388451457,
0.008385563269257545,
0.018092604354023933,
0.009085169062018394,
-0.002927173627540469,
-0.04629063978791237,
0.013642329722642899,
0.019355783239006996,
-0.013360543176531792,
-0.018257789313793182,
-0.05060487985610962,
-0.008458438329398632,
-0.06055483967065811,
-0.02508867159485817,
0.055424392223358154,
0.012039064429700375,
0.0004293592646718025,
0.016431039199233055,
-0.0074333203956484795,
-0.003546616993844509,
0.044075217097997665,
-0.021959874778985977,
0.05748434364795685,
0.005203324370086193,
0.0460185706615448,
0.024855468422174454,
-0.041199058294296265,
0.06638489663600922,
0.007418745197355747,
0.03375602141022682,
0.006369335576891899,
-0.024641700088977814,
-0.0177913848310709,
0.04442502185702324,
0.028586704283952713,
-0.002633241703733802,
-0.04170432686805725,
0.07186514884233475,
0.030277419835329056,
-0.05060487985610962,
-0.025069236755371094,
0.015828600153326988,
-0.021240834146738052,
-0.05519118905067444,
0.0691055878996849,
0.009716758504509926,
-0.047650985419750214,
0.045940835028886795,
0.027867663651704788,
0.025963179767131805,
0.04858379438519478,
-0.041782062500715256,
-0.0024389063473790884,
-0.014623722061514854,
0.01720838062465191,
-0.04395861551165581,
-0.05880582332611084,
-0.06852257996797562,
0.04224846884608269,
0.05666813626885414,
0.002980615710839629,
0.03659331426024437,
-0.029364045709371567,
0.06397514045238495,
-0.08286451548337936,
0.012233398854732513,
-0.043220143765211105,
-0.013030173256993294,
-0.02802313305437565,
-0.0009400963899679482,
0.05079921334981918,
-0.02487490326166153,
-0.023631157353520393,
0.03941117227077484,
-0.05511345714330673,
-0.0070980922318995,
-0.005188749171793461,
0.016158970072865486,
0.0024571253452450037,
0.0719817504286766,
-0.03412525728344917,
-0.009381530806422234,
-0.027770496904850006,
-0.0262546818703413,
-0.027032023295760155,
-0.05200409144163132,
-0.0790555477142334,
0.020521795377135277,
-0.022814949974417686,
0.030860425904393196,
-0.03589370846748352,
0.007000924553722143,
-0.038750432431697845,
0.021163100376725197,
0.023145319893956184,
-0.026079781353473663,
0.024913769215345383,
0.0159840676933527,
0.010280330665409565,
-0.11986593902111053,
0.027070889249444008,
0.05079921334981918,
-0.03185153380036354,
0.028567271307110786,
-0.011961329728364944,
-0.04784531891345978,
0.05923335999250412,
0.034377891570329666,
0.0010311909718438983,
-0.0007220766274258494,
-0.025982612743973732,
0.045357830822467804,
-0.01083418633788824,
-0.08550747483968735,
-0.005873780697584152,
0.022348545491695404,
-0.004219502676278353,
-0.06350873410701752,
0.014769473113119602,
0.0021595496218651533,
-0.016712825745344162,
0.04073265194892883,
-0.04007191210985184,
0.06700676679611206,
-0.00783170759677887,
0.005480251740664244,
-0.05511345714330673,
0.03908080235123634,
-0.019637569785118103,
0.014448820613324642,
0.00295632379129529,
0.04065492004156113,
-0.06284799426794052,
0.06945539265871048,
-0.031190795823931694,
-0.003937716595828533,
0.04267600551247597,
0.03323131427168846,
-0.01656707376241684,
0.08076570183038712,
-0.01341884396970272,
0.002659962745383382,
-0.010445515625178814,
-0.054724786430597305,
0.05954429879784584,
0.033950354903936386,
0.01531361136585474,
0.014545988291501999,
0.04901133105158806,
-0.025710543617606163,
0.02646845020353794,
0.017286114394664764,
0.002963611390441656,
0.047106847167015076,
0.05507458746433258,
0.04582423344254494,
-0.007768548559397459,
-0.0066559799015522,
0.0689501166343689,
0.002219064859673381,
-0.022387411445379257,
0.043375611305236816,
0.062187254428863525,
-0.015546813607215881,
0.027712196111679077,
-0.07435263693332672,
0.03531070053577423,
0.004353107884526253,
-0.047534383833408356,
0.023028718307614326,
0.0040664635598659515,
0.010882769711315632,
0.03365885093808174,
-0.0004454526642803103,
0.02689598873257637,
0.018403541296720505,
0.014448820613324642,
0.056123998016119,
-0.01863674260675907,
-0.014672305434942245,
-0.017062628641724586,
0.059466563165187836,
0.00024884010781534016,
-0.004644610919058323,
-0.005674587097018957,
0.06999953091144562,
-0.005169315729290247,
-0.0021425453014671803,
-0.007996892556548119,
-0.0002564313472248614,
-0.05095468461513519,
-0.02194044180214405,
-0.0024291896261274815,
0.007224410306662321,
0.052120693027973175,
0.06964972615242004,
-0.00964388344436884,
0.01413788367062807,
0.009337805211544037,
0.006651121191680431,
0.08504107594490051,
-0.025419041514396667,
-0.08527427166700363,
-0.04617403820157051,
-0.016907161101698875,
-0.015410779044032097,
-0.030607789754867554,
0.01571199856698513,
-0.01283583790063858,
0.001370062935166061,
-0.006369335576891899,
-0.029733281582593918,
0.04057718440890312,
-0.0057523213326931,
0.026332415640354156,
-0.028431236743927002,
-0.007909441366791725,
-0.02631298266351223,
-0.04516349360346794,
0.023242486640810966,
-0.050993550568819046,
-0.017830252647399902,
0.021240834146738052,
0.06300346553325653,
0.05192635953426361,
0.025341307744383812,
-0.002137686824426055,
-0.052276160567998886,
0.00408832635730505,
-0.04800078645348549,
0.010503816418349743,
0.01081475242972374,
-0.05332557111978531,
0.014312786050140858,
0.03791479393839836,
0.011310307309031487,
-0.05589079484343529,
-0.019579268991947174,
0.017237529158592224,
0.03148229792714119,
-0.0031263672281056643,
-0.09320314973592758,
-0.00985765177756548,
0.006962057668715715,
-0.006165283266454935,
0.031229661777615547,
-0.014866640791296959,
-0.0063013178296387196,
-0.08713988959789276,
-0.0150998430326581,
-0.050993550568819046,
0.01997765526175499,
0.013545162044465542,
0.025963179767131805,
-0.024777734652161598,
-0.02961667999625206,
-0.007622797042131424,
-0.00980420969426632,
0.016120102256536484,
-0.029966484755277634,
-0.035932574421167374,
0.015235877595841885,
-0.03972211107611656,
0.019997090101242065,
-0.012602635659277439,
0.0028324350714683533,
0.03849779814481735,
-0.0024121853057295084,
0.01933635026216507,
-0.0603993721306324,
0.032998111099004745,
-0.02178497239947319,
-0.04901133105158806,
0.0446193553507328,
0.053830843418836594,
-0.022504013031721115,
-0.015945201739668846,
0.06929992139339447,
-0.010503816418349743,
-0.015216444618999958,
-0.011951613239943981,
-0.034960899502038956,
0.04403635114431381,
-0.02129913493990898,
-0.03332848101854324,
-0.035932574421167374,
-0.004357966128736734,
-0.003889132756739855,
-0.02248458005487919,
0.009556432254612446,
0.0007645874284207821,
-0.005694020539522171,
-0.01528446190059185,
-0.030491188168525696,
0.0067968727089464664,
0.020327460020780563,
0.07283682376146317,
-0.01879221200942993,
-0.0341058224439621,
0.012155665084719658,
0.012583202682435513,
0.03253170847892761,
0.05402517691254616,
0.06926105916500092,
-0.04384201392531395,
-0.03742895647883415,
-0.013039890676736832,
0.01762619987130165,
-0.062070656567811966,
-0.01794685423374176,
0.007700531277805567,
-0.06420834362506866,
-0.0115046426653862,
0.008531314320862293,
0.016285287216305733,
-0.03280377760529518,
-0.06055483967065811,
0.026818254962563515,
-0.004161201883107424,
-0.07582958787679672,
-0.06770637631416321,
0.042948074638843536,
0.046096302568912506,
0.02493320219218731,
-0.013049607165157795,
-0.011601810343563557,
0.05375310778617859,
-0.05188749358057976,
-0.08403053134679794,
0.03494146466255188,
0.014196184463799,
0.019938789308071136,
-0.03453335911035538,
0.04038285091519356,
0.008798524737358093,
-0.038128562271595,
-0.05138222128152847,
-0.0025069238618016243,
-0.020016523078083992,
0.030821558088064194,
-0.03597144037485123,
0.020424626767635345,
0.053403306752443314,
0.00801146775484085,
-0.030102519318461418,
-0.011135405860841274,
-0.03140456601977348,
-0.0804547592997551,
0.03871156647801399,
0.0230092853307724,
0.009809068404138088,
-0.036243509501218796,
-0.030277419835329056,
-0.013914398849010468,
0.026779387146234512,
0.011524075642228127,
-0.014895791187882423,
0.020793864503502846,
-0.013088474050164223,
-0.012466601096093655,
-0.002659962745383382,
0.01448768749833107,
-0.023631157353520393,
-0.0032478265929967165,
0.028625572100281715,
-0.08846136927604675,
-0.000771267747040838,
0.023417389020323753,
-0.08356412500143051,
0.0020453776232898235,
-0.017927419394254684,
-0.0262546818703413,
0.08822816610336304,
0.009862510487437248,
0.0320458710193634,
0.004790361970663071,
-0.014633438549935818,
0.02524413913488388,
-0.014944374561309814,
-0.009813926182687283,
0.05985523387789726,
-0.02652675099670887,
0.018345240503549576,
-0.039916444569826126,
-0.017703933641314507,
-0.001303260214626789,
-0.010970220901072025,
0.010192879475653172,
0.012583202682435513,
-0.02753729373216629,
-0.010960503481328487,
0.031015893444418907,
-0.0007336153066717088,
0.024136429652571678,
-0.018345240503549576,
0.011660110205411911,
-0.011854445561766624,
-0.04014964774250984,
-0.05192635953426361,
-0.026079781353473663,
-0.0481562577188015,
-0.06121557950973511,
-0.008691640570759773,
-0.018782494589686394,
0.022776082158088684,
0.022037608548998833,
0.04660157486796379,
0.025691110640764236,
0.08504107594490051
]
|
30,366 | networkx.algorithms.shortest_paths.weighted | all_pairs_bellman_ford_path_length | Compute shortest path lengths between all nodes in a weighted graph.
Parameters
----------
G : NetworkX graph
weight : string or function (default="weight")
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number.
Returns
-------
distance : iterator
(source, dictionary) iterator with dictionary keyed by target and
shortest path length as the key value.
Examples
--------
>>> G = nx.path_graph(5)
>>> length = dict(nx.all_pairs_bellman_ford_path_length(G))
>>> for node in [0, 1, 2, 3, 4]:
... print(f"1 - {node}: {length[1][node]}")
1 - 0: 1
1 - 1: 0
1 - 2: 1
1 - 3: 2
1 - 4: 3
>>> length[3][2]
1
>>> length[2][2]
0
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
The dictionary returned only has keys for reachable node pairs.
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, weight='weight', *, backend=None, **backend_kwargs) | [
0.008706215769052505,
-0.004100472200661898,
-0.03420298919081688,
-0.044230684638023376,
-0.03898363560438156,
-0.021765539422631264,
-0.010688434354960918,
0.04053831845521927,
0.07361416518688202,
-0.010581550188362598,
-0.052859168499708176,
0.029694415628910065,
0.02866443805396557,
0.02551620826125145,
-0.027284659445285797,
0.035874273627996445,
0.00006410783680621535,
0.03597144037485123,
-0.001286255894228816,
0.013700629584491253,
-0.015041542239487171,
-0.05647380277514458,
0.05550212785601616,
0.04959433525800705,
-0.02098819799721241,
-0.009264929220080376,
0.014915225096046925,
-0.040033046156167984,
-0.025807710364460945,
-0.01634358800947666,
0.01778166927397251,
-0.01869504339993,
-0.0063596186228096485,
-0.005499685648828745,
0.01651849038898945,
0.058611489832401276,
0.007802557200193405,
-0.0030559205915778875,
-0.023359088227152824,
-0.04399748519062996,
-0.030180253088474274,
-0.030394021421670914,
0.005747462622821331,
-0.03781762346625328,
0.08014382421970367,
0.08379732817411423,
-0.01751931570470333,
0.008618764579296112,
-0.019404366612434387,
-0.018840795382857323,
0.015138709917664528,
0.0014720889739692211,
-0.009313513524830341,
0.009561290964484215,
-0.007899724878370762,
0.03941117227077484,
-0.033270180225372314,
0.05421951413154602,
0.027362393215298653,
-0.03820629417896271,
0.03950834274291992,
0.01052324939519167,
0.07085460424423218,
0.04014964774250984,
-0.06378080695867538,
-0.02365059033036232,
-0.04656270891427994,
-0.03754555433988571,
-0.040033046156167984,
0.021435169503092766,
0.001010542968288064,
-0.009488414973020554,
-0.013438276946544647,
-0.03556333854794502,
-0.001875334419310093,
0.03801196068525314,
-0.00007496327452827245,
-0.03478599712252617,
0.011125688441097736,
-0.03983871266245842,
0.0438808836042881,
-0.056434933096170425,
-0.025807710364460945,
-0.07101007550954819,
0.07299229502677917,
0.025108104571700096,
-0.004027596674859524,
0.0026478166691958904,
-0.009060877375304699,
-0.03408639132976532,
-0.03669048100709915,
0.030802125111222267,
-0.003330419072881341,
0.0004044600937049836,
0.05682360380887985,
0.026779387146234512,
0.009070593863725662,
-0.05705680698156357,
0.05002187564969063,
0.031074194237589836,
0.06852257996797562,
0.0048097954131662846,
-0.014477971009910107,
0.03612690791487694,
0.02646845020353794,
-0.06720110028982162,
-0.010989653877913952,
0.015886900946497917,
-0.013885248452425003,
-0.05561872571706772,
-0.022659480571746826,
0.012427734211087227,
0.025866011157631874,
-0.026779387146234512,
0.02349512279033661,
0.0032453974708914757,
0.006767722312361002,
0.04399748519062996,
-0.0005830055451951921,
-0.021124234423041344,
-0.025224706158041954,
0.052548229694366455,
-0.08309771865606308,
-0.0039012786000967026,
0.04038285091519356,
-0.05639606714248657,
0.024738868698477745,
-0.01991935633122921,
0.06630716472864151,
0.01788855344057083,
0.026196381077170372,
0.0048097954131662846,
-0.02790653146803379,
0.06560755521059036,
0.03202643617987633,
-0.02460283227264881,
-0.056590404361486435,
0.04687364399433136,
0.06502454727888107,
0.010387214832007885,
0.04255940392613411,
-0.07547978311777115,
0.007734539918601513,
0.0287616066634655,
0.005868922453373671,
-0.028528403490781784,
0.011125688441097736,
0.014021283015608788,
0.0313073955476284,
0.05977749824523926,
0.0154496468603611,
0.0028494393918663263,
0.00686974823474884,
0.011698977090418339,
0.0016506343381479383,
-0.0682116448879242,
-0.04201526567339897,
0.020424626767635345,
0.0058349138125777245,
-0.0004894817247986794,
0.01661565713584423,
-0.0446193553507328,
0.005762037821114063,
0.014895791187882423,
-0.04986640438437462,
0.03494146466255188,
0.022134777158498764,
0.05215956270694733,
-0.027129190042614937,
0.012388867326080799,
-0.005898072384297848,
-0.0640917420387268,
-0.047806452959775925,
-0.029150275513529778,
-0.0244473647326231,
0.0033085562754422426,
0.0251469723880291,
-0.0022882965859025717,
0.011883595958352089,
-0.019462667405605316,
0.009862510487437248,
-0.026604484766721725,
0.023145319893956184,
-0.01358402892947197,
0.030083084478974342,
0.029169710353016853,
0.022251376882195473,
-0.021610071882605553,
0.0029514655470848083,
0.03478599712252617,
-0.048233989626169205,
-0.09328088164329529,
-0.06059370934963226,
0.08325318992137909,
-0.009094886481761932,
0.0067239971831440926,
-0.03727348521351814,
-0.022115342319011688,
-0.027284659445285797,
0.06378080695867538,
-0.009162903763353825,
-0.029305744916200638,
0.03987757861614227,
-0.008881117217242718,
0.009245496243238449,
-0.028839340433478355,
-0.03245397284626961,
0.008623623289167881,
0.0010111501906067133,
0.018559008836746216,
-0.035135798156261444,
-0.04543556272983551,
0.02998591773211956,
-0.02977214939892292,
0.0011933394707739353,
0.013778364285826683,
-0.03175436705350876,
0.04007191210985184,
0.014011566527187824,
-0.059039026498794556,
-0.004404121078550816,
-0.01528446190059185,
-0.009546715766191483,
0.02114366739988327,
0.0618763193488121,
-0.0502939447760582,
0.04702911153435707,
0.030646657571196556,
0.025846578180789948,
-0.0733032301068306,
0.07718992978334427,
-0.03280377760529518,
0.096312515437603,
-0.014818057417869568,
0.07380849868059158,
-0.04784531891345978,
0.00343487411737442,
0.04073265194892883,
0.04562989994883537,
0.027925964444875717,
-0.021687805652618408,
-0.02343682199716568,
-0.014633438549935818,
-0.058145083487033844,
0.005820338614284992,
-0.00011994124361081049,
0.031501732766628265,
-0.012281983159482479,
0.026138080283999443,
-0.006500511430203915,
0.00507214805111289,
0.027731629088521004,
-0.042326200753450394,
-0.05748434364795685,
-0.012942722998559475,
-0.0431424081325531,
-0.021027065813541412,
-0.03756498917937279,
-0.036515578627586365,
-0.06591849029064178,
-0.03225963935256004,
-0.02784823067486286,
-0.06094351038336754,
0.10152069479227066,
-0.003925570752471685,
0.03260944411158562,
0.031171362847089767,
-0.01430306863039732,
-0.08022156357765198,
0.0066559799015522,
0.042637135833501816,
0.04310354217886925,
-0.006860031746327877,
-0.0035879132337868214,
-0.025049803778529167,
0.005208182614296675,
-0.03222077339887619,
0.03482486307621002,
0.012845555320382118,
-0.0230092853307724,
-0.04368654638528824,
-0.00833697896450758,
-0.04123792424798012,
-0.006515086628496647,
0.018024588003754616,
0.029636114835739136,
0.01211679819971323,
-0.034747131168842316,
0.01641160622239113,
0.006651121191680431,
0.07011613249778748,
-0.012165381573140621,
0.010562117211520672,
-0.03777875751256943,
0.06226499006152153,
0.04761211946606636,
-0.0034907455556094646,
-0.07287569344043732,
0.016363020986318588,
0.05363650992512703,
0.015381629578769207,
-0.025749411433935165,
0.025632809847593307,
-0.005737746134400368,
-0.042637135833501816,
0.008307828567922115,
0.031132495030760765,
-0.01677112653851509,
-0.0025506492238491774,
-0.03093815967440605,
-0.021396303549408913,
-0.025166405364871025,
0.001787883578799665,
0.007307002786546946,
0.0036122051533311605,
-0.03727348521351814,
-0.03511636704206467,
0.0073798783123493195,
-0.006792014464735985,
0.032201338559389114,
-0.038964200764894485,
0.07641258835792542,
-0.06832824647426605,
0.029208576306700706,
-0.03047175519168377,
0.029228011146187782,
0.031773801892995834,
0.02567167580127716,
0.035135798156261444,
0.022445712238550186,
0.03791479393839836,
0.02248458005487919,
0.026196381077170372,
0.030821558088064194,
-0.01982218772172928,
0.08970511704683304,
0.07439150661230087,
-0.005402517970651388,
0.00004873561920248903,
-0.003102075308561325,
0.0474177822470665,
0.021687805652618408,
-0.022037608548998833,
0.023728324100375175,
0.006106982938945293,
-0.043803147971630096,
0.03398922085762024,
-0.03898363560438156,
0.007418745197355747,
-0.0474177822470665,
0.021804407238960266,
0.06797844171524048,
0.01831609010696411,
0.02646845020353794,
0.050566013902425766,
0.0031166502740234137,
-0.01092163659632206,
-0.04069378599524498,
0.0223096776753664,
-0.00496526388451457,
0.008385563269257545,
0.018092604354023933,
0.009085169062018394,
-0.002927173627540469,
-0.04629063978791237,
0.013642329722642899,
0.019355783239006996,
-0.013360543176531792,
-0.018257789313793182,
-0.05060487985610962,
-0.008458438329398632,
-0.06055483967065811,
-0.02508867159485817,
0.055424392223358154,
0.012039064429700375,
0.0004293592646718025,
0.016431039199233055,
-0.0074333203956484795,
-0.003546616993844509,
0.044075217097997665,
-0.021959874778985977,
0.05748434364795685,
0.005203324370086193,
0.0460185706615448,
0.024855468422174454,
-0.041199058294296265,
0.06638489663600922,
0.007418745197355747,
0.03375602141022682,
0.006369335576891899,
-0.024641700088977814,
-0.0177913848310709,
0.04442502185702324,
0.028586704283952713,
-0.002633241703733802,
-0.04170432686805725,
0.07186514884233475,
0.030277419835329056,
-0.05060487985610962,
-0.025069236755371094,
0.015828600153326988,
-0.021240834146738052,
-0.05519118905067444,
0.0691055878996849,
0.009716758504509926,
-0.047650985419750214,
0.045940835028886795,
0.027867663651704788,
0.025963179767131805,
0.04858379438519478,
-0.041782062500715256,
-0.0024389063473790884,
-0.014623722061514854,
0.01720838062465191,
-0.04395861551165581,
-0.05880582332611084,
-0.06852257996797562,
0.04224846884608269,
0.05666813626885414,
0.002980615710839629,
0.03659331426024437,
-0.029364045709371567,
0.06397514045238495,
-0.08286451548337936,
0.012233398854732513,
-0.043220143765211105,
-0.013030173256993294,
-0.02802313305437565,
-0.0009400963899679482,
0.05079921334981918,
-0.02487490326166153,
-0.023631157353520393,
0.03941117227077484,
-0.05511345714330673,
-0.0070980922318995,
-0.005188749171793461,
0.016158970072865486,
0.0024571253452450037,
0.0719817504286766,
-0.03412525728344917,
-0.009381530806422234,
-0.027770496904850006,
-0.0262546818703413,
-0.027032023295760155,
-0.05200409144163132,
-0.0790555477142334,
0.020521795377135277,
-0.022814949974417686,
0.030860425904393196,
-0.03589370846748352,
0.007000924553722143,
-0.038750432431697845,
0.021163100376725197,
0.023145319893956184,
-0.026079781353473663,
0.024913769215345383,
0.0159840676933527,
0.010280330665409565,
-0.11986593902111053,
0.027070889249444008,
0.05079921334981918,
-0.03185153380036354,
0.028567271307110786,
-0.011961329728364944,
-0.04784531891345978,
0.05923335999250412,
0.034377891570329666,
0.0010311909718438983,
-0.0007220766274258494,
-0.025982612743973732,
0.045357830822467804,
-0.01083418633788824,
-0.08550747483968735,
-0.005873780697584152,
0.022348545491695404,
-0.004219502676278353,
-0.06350873410701752,
0.014769473113119602,
0.0021595496218651533,
-0.016712825745344162,
0.04073265194892883,
-0.04007191210985184,
0.06700676679611206,
-0.00783170759677887,
0.005480251740664244,
-0.05511345714330673,
0.03908080235123634,
-0.019637569785118103,
0.014448820613324642,
0.00295632379129529,
0.04065492004156113,
-0.06284799426794052,
0.06945539265871048,
-0.031190795823931694,
-0.003937716595828533,
0.04267600551247597,
0.03323131427168846,
-0.01656707376241684,
0.08076570183038712,
-0.01341884396970272,
0.002659962745383382,
-0.010445515625178814,
-0.054724786430597305,
0.05954429879784584,
0.033950354903936386,
0.01531361136585474,
0.014545988291501999,
0.04901133105158806,
-0.025710543617606163,
0.02646845020353794,
0.017286114394664764,
0.002963611390441656,
0.047106847167015076,
0.05507458746433258,
0.04582423344254494,
-0.007768548559397459,
-0.0066559799015522,
0.0689501166343689,
0.002219064859673381,
-0.022387411445379257,
0.043375611305236816,
0.062187254428863525,
-0.015546813607215881,
0.027712196111679077,
-0.07435263693332672,
0.03531070053577423,
0.004353107884526253,
-0.047534383833408356,
0.023028718307614326,
0.0040664635598659515,
0.010882769711315632,
0.03365885093808174,
-0.0004454526642803103,
0.02689598873257637,
0.018403541296720505,
0.014448820613324642,
0.056123998016119,
-0.01863674260675907,
-0.014672305434942245,
-0.017062628641724586,
0.059466563165187836,
0.00024884010781534016,
-0.004644610919058323,
-0.005674587097018957,
0.06999953091144562,
-0.005169315729290247,
-0.0021425453014671803,
-0.007996892556548119,
-0.0002564313472248614,
-0.05095468461513519,
-0.02194044180214405,
-0.0024291896261274815,
0.007224410306662321,
0.052120693027973175,
0.06964972615242004,
-0.00964388344436884,
0.01413788367062807,
0.009337805211544037,
0.006651121191680431,
0.08504107594490051,
-0.025419041514396667,
-0.08527427166700363,
-0.04617403820157051,
-0.016907161101698875,
-0.015410779044032097,
-0.030607789754867554,
0.01571199856698513,
-0.01283583790063858,
0.001370062935166061,
-0.006369335576891899,
-0.029733281582593918,
0.04057718440890312,
-0.0057523213326931,
0.026332415640354156,
-0.028431236743927002,
-0.007909441366791725,
-0.02631298266351223,
-0.04516349360346794,
0.023242486640810966,
-0.050993550568819046,
-0.017830252647399902,
0.021240834146738052,
0.06300346553325653,
0.05192635953426361,
0.025341307744383812,
-0.002137686824426055,
-0.052276160567998886,
0.00408832635730505,
-0.04800078645348549,
0.010503816418349743,
0.01081475242972374,
-0.05332557111978531,
0.014312786050140858,
0.03791479393839836,
0.011310307309031487,
-0.05589079484343529,
-0.019579268991947174,
0.017237529158592224,
0.03148229792714119,
-0.0031263672281056643,
-0.09320314973592758,
-0.00985765177756548,
0.006962057668715715,
-0.006165283266454935,
0.031229661777615547,
-0.014866640791296959,
-0.0063013178296387196,
-0.08713988959789276,
-0.0150998430326581,
-0.050993550568819046,
0.01997765526175499,
0.013545162044465542,
0.025963179767131805,
-0.024777734652161598,
-0.02961667999625206,
-0.007622797042131424,
-0.00980420969426632,
0.016120102256536484,
-0.029966484755277634,
-0.035932574421167374,
0.015235877595841885,
-0.03972211107611656,
0.019997090101242065,
-0.012602635659277439,
0.0028324350714683533,
0.03849779814481735,
-0.0024121853057295084,
0.01933635026216507,
-0.0603993721306324,
0.032998111099004745,
-0.02178497239947319,
-0.04901133105158806,
0.0446193553507328,
0.053830843418836594,
-0.022504013031721115,
-0.015945201739668846,
0.06929992139339447,
-0.010503816418349743,
-0.015216444618999958,
-0.011951613239943981,
-0.034960899502038956,
0.04403635114431381,
-0.02129913493990898,
-0.03332848101854324,
-0.035932574421167374,
-0.004357966128736734,
-0.003889132756739855,
-0.02248458005487919,
0.009556432254612446,
0.0007645874284207821,
-0.005694020539522171,
-0.01528446190059185,
-0.030491188168525696,
0.0067968727089464664,
0.020327460020780563,
0.07283682376146317,
-0.01879221200942993,
-0.0341058224439621,
0.012155665084719658,
0.012583202682435513,
0.03253170847892761,
0.05402517691254616,
0.06926105916500092,
-0.04384201392531395,
-0.03742895647883415,
-0.013039890676736832,
0.01762619987130165,
-0.062070656567811966,
-0.01794685423374176,
0.007700531277805567,
-0.06420834362506866,
-0.0115046426653862,
0.008531314320862293,
0.016285287216305733,
-0.03280377760529518,
-0.06055483967065811,
0.026818254962563515,
-0.004161201883107424,
-0.07582958787679672,
-0.06770637631416321,
0.042948074638843536,
0.046096302568912506,
0.02493320219218731,
-0.013049607165157795,
-0.011601810343563557,
0.05375310778617859,
-0.05188749358057976,
-0.08403053134679794,
0.03494146466255188,
0.014196184463799,
0.019938789308071136,
-0.03453335911035538,
0.04038285091519356,
0.008798524737358093,
-0.038128562271595,
-0.05138222128152847,
-0.0025069238618016243,
-0.020016523078083992,
0.030821558088064194,
-0.03597144037485123,
0.020424626767635345,
0.053403306752443314,
0.00801146775484085,
-0.030102519318461418,
-0.011135405860841274,
-0.03140456601977348,
-0.0804547592997551,
0.03871156647801399,
0.0230092853307724,
0.009809068404138088,
-0.036243509501218796,
-0.030277419835329056,
-0.013914398849010468,
0.026779387146234512,
0.011524075642228127,
-0.014895791187882423,
0.020793864503502846,
-0.013088474050164223,
-0.012466601096093655,
-0.002659962745383382,
0.01448768749833107,
-0.023631157353520393,
-0.0032478265929967165,
0.028625572100281715,
-0.08846136927604675,
-0.000771267747040838,
0.023417389020323753,
-0.08356412500143051,
0.0020453776232898235,
-0.017927419394254684,
-0.0262546818703413,
0.08822816610336304,
0.009862510487437248,
0.0320458710193634,
0.004790361970663071,
-0.014633438549935818,
0.02524413913488388,
-0.014944374561309814,
-0.009813926182687283,
0.05985523387789726,
-0.02652675099670887,
0.018345240503549576,
-0.039916444569826126,
-0.017703933641314507,
-0.001303260214626789,
-0.010970220901072025,
0.010192879475653172,
0.012583202682435513,
-0.02753729373216629,
-0.010960503481328487,
0.031015893444418907,
-0.0007336153066717088,
0.024136429652571678,
-0.018345240503549576,
0.011660110205411911,
-0.011854445561766624,
-0.04014964774250984,
-0.05192635953426361,
-0.026079781353473663,
-0.0481562577188015,
-0.06121557950973511,
-0.008691640570759773,
-0.018782494589686394,
0.022776082158088684,
0.022037608548998833,
0.04660157486796379,
0.025691110640764236,
0.08504107594490051
]
|
30,367 | networkx.algorithms.shortest_paths.weighted | all_pairs_dijkstra | Find shortest weighted paths and lengths between all nodes.
Parameters
----------
G : NetworkX graph
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
weight : string or function
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edge[u][v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number or None to indicate a hidden edge.
Yields
------
(node, (distance, path)) : (node obj, (dict, dict))
Each source node has two associated dicts. The first holds distance
keyed by target and the second holds paths keyed by target.
(See single_source_dijkstra for the source/target node terminology.)
If desired you can apply `dict()` to this function to create a dict
keyed by source node to the two dicts.
Examples
--------
>>> G = nx.path_graph(5)
>>> len_path = dict(nx.all_pairs_dijkstra(G))
>>> len_path[3][0][1]
2
>>> for node in [0, 1, 2, 3, 4]:
... print(f"3 - {node}: {len_path[3][0][node]}")
3 - 0: 3
3 - 1: 2
3 - 2: 1
3 - 3: 0
3 - 4: 1
>>> len_path[3][1][1]
[3, 2, 1]
>>> for n, (dist, path) in nx.all_pairs_dijkstra(G):
... print(path[1])
[0, 1]
[1]
[2, 1]
[3, 2, 1]
[4, 3, 2, 1]
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
The yielded dicts only have keys for reachable nodes.
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, cutoff=None, weight='weight', *, backend=None, **backend_kwargs) | [
0.008706215769052505,
-0.004100472200661898,
-0.03420298919081688,
-0.044230684638023376,
-0.03898363560438156,
-0.021765539422631264,
-0.010688434354960918,
0.04053831845521927,
0.07361416518688202,
-0.010581550188362598,
-0.052859168499708176,
0.029694415628910065,
0.02866443805396557,
0.02551620826125145,
-0.027284659445285797,
0.035874273627996445,
0.00006410783680621535,
0.03597144037485123,
-0.001286255894228816,
0.013700629584491253,
-0.015041542239487171,
-0.05647380277514458,
0.05550212785601616,
0.04959433525800705,
-0.02098819799721241,
-0.009264929220080376,
0.014915225096046925,
-0.040033046156167984,
-0.025807710364460945,
-0.01634358800947666,
0.01778166927397251,
-0.01869504339993,
-0.0063596186228096485,
-0.005499685648828745,
0.01651849038898945,
0.058611489832401276,
0.007802557200193405,
-0.0030559205915778875,
-0.023359088227152824,
-0.04399748519062996,
-0.030180253088474274,
-0.030394021421670914,
0.005747462622821331,
-0.03781762346625328,
0.08014382421970367,
0.08379732817411423,
-0.01751931570470333,
0.008618764579296112,
-0.019404366612434387,
-0.018840795382857323,
0.015138709917664528,
0.0014720889739692211,
-0.009313513524830341,
0.009561290964484215,
-0.007899724878370762,
0.03941117227077484,
-0.033270180225372314,
0.05421951413154602,
0.027362393215298653,
-0.03820629417896271,
0.03950834274291992,
0.01052324939519167,
0.07085460424423218,
0.04014964774250984,
-0.06378080695867538,
-0.02365059033036232,
-0.04656270891427994,
-0.03754555433988571,
-0.040033046156167984,
0.021435169503092766,
0.001010542968288064,
-0.009488414973020554,
-0.013438276946544647,
-0.03556333854794502,
-0.001875334419310093,
0.03801196068525314,
-0.00007496327452827245,
-0.03478599712252617,
0.011125688441097736,
-0.03983871266245842,
0.0438808836042881,
-0.056434933096170425,
-0.025807710364460945,
-0.07101007550954819,
0.07299229502677917,
0.025108104571700096,
-0.004027596674859524,
0.0026478166691958904,
-0.009060877375304699,
-0.03408639132976532,
-0.03669048100709915,
0.030802125111222267,
-0.003330419072881341,
0.0004044600937049836,
0.05682360380887985,
0.026779387146234512,
0.009070593863725662,
-0.05705680698156357,
0.05002187564969063,
0.031074194237589836,
0.06852257996797562,
0.0048097954131662846,
-0.014477971009910107,
0.03612690791487694,
0.02646845020353794,
-0.06720110028982162,
-0.010989653877913952,
0.015886900946497917,
-0.013885248452425003,
-0.05561872571706772,
-0.022659480571746826,
0.012427734211087227,
0.025866011157631874,
-0.026779387146234512,
0.02349512279033661,
0.0032453974708914757,
0.006767722312361002,
0.04399748519062996,
-0.0005830055451951921,
-0.021124234423041344,
-0.025224706158041954,
0.052548229694366455,
-0.08309771865606308,
-0.0039012786000967026,
0.04038285091519356,
-0.05639606714248657,
0.024738868698477745,
-0.01991935633122921,
0.06630716472864151,
0.01788855344057083,
0.026196381077170372,
0.0048097954131662846,
-0.02790653146803379,
0.06560755521059036,
0.03202643617987633,
-0.02460283227264881,
-0.056590404361486435,
0.04687364399433136,
0.06502454727888107,
0.010387214832007885,
0.04255940392613411,
-0.07547978311777115,
0.007734539918601513,
0.0287616066634655,
0.005868922453373671,
-0.028528403490781784,
0.011125688441097736,
0.014021283015608788,
0.0313073955476284,
0.05977749824523926,
0.0154496468603611,
0.0028494393918663263,
0.00686974823474884,
0.011698977090418339,
0.0016506343381479383,
-0.0682116448879242,
-0.04201526567339897,
0.020424626767635345,
0.0058349138125777245,
-0.0004894817247986794,
0.01661565713584423,
-0.0446193553507328,
0.005762037821114063,
0.014895791187882423,
-0.04986640438437462,
0.03494146466255188,
0.022134777158498764,
0.05215956270694733,
-0.027129190042614937,
0.012388867326080799,
-0.005898072384297848,
-0.0640917420387268,
-0.047806452959775925,
-0.029150275513529778,
-0.0244473647326231,
0.0033085562754422426,
0.0251469723880291,
-0.0022882965859025717,
0.011883595958352089,
-0.019462667405605316,
0.009862510487437248,
-0.026604484766721725,
0.023145319893956184,
-0.01358402892947197,
0.030083084478974342,
0.029169710353016853,
0.022251376882195473,
-0.021610071882605553,
0.0029514655470848083,
0.03478599712252617,
-0.048233989626169205,
-0.09328088164329529,
-0.06059370934963226,
0.08325318992137909,
-0.009094886481761932,
0.0067239971831440926,
-0.03727348521351814,
-0.022115342319011688,
-0.027284659445285797,
0.06378080695867538,
-0.009162903763353825,
-0.029305744916200638,
0.03987757861614227,
-0.008881117217242718,
0.009245496243238449,
-0.028839340433478355,
-0.03245397284626961,
0.008623623289167881,
0.0010111501906067133,
0.018559008836746216,
-0.035135798156261444,
-0.04543556272983551,
0.02998591773211956,
-0.02977214939892292,
0.0011933394707739353,
0.013778364285826683,
-0.03175436705350876,
0.04007191210985184,
0.014011566527187824,
-0.059039026498794556,
-0.004404121078550816,
-0.01528446190059185,
-0.009546715766191483,
0.02114366739988327,
0.0618763193488121,
-0.0502939447760582,
0.04702911153435707,
0.030646657571196556,
0.025846578180789948,
-0.0733032301068306,
0.07718992978334427,
-0.03280377760529518,
0.096312515437603,
-0.014818057417869568,
0.07380849868059158,
-0.04784531891345978,
0.00343487411737442,
0.04073265194892883,
0.04562989994883537,
0.027925964444875717,
-0.021687805652618408,
-0.02343682199716568,
-0.014633438549935818,
-0.058145083487033844,
0.005820338614284992,
-0.00011994124361081049,
0.031501732766628265,
-0.012281983159482479,
0.026138080283999443,
-0.006500511430203915,
0.00507214805111289,
0.027731629088521004,
-0.042326200753450394,
-0.05748434364795685,
-0.012942722998559475,
-0.0431424081325531,
-0.021027065813541412,
-0.03756498917937279,
-0.036515578627586365,
-0.06591849029064178,
-0.03225963935256004,
-0.02784823067486286,
-0.06094351038336754,
0.10152069479227066,
-0.003925570752471685,
0.03260944411158562,
0.031171362847089767,
-0.01430306863039732,
-0.08022156357765198,
0.0066559799015522,
0.042637135833501816,
0.04310354217886925,
-0.006860031746327877,
-0.0035879132337868214,
-0.025049803778529167,
0.005208182614296675,
-0.03222077339887619,
0.03482486307621002,
0.012845555320382118,
-0.0230092853307724,
-0.04368654638528824,
-0.00833697896450758,
-0.04123792424798012,
-0.006515086628496647,
0.018024588003754616,
0.029636114835739136,
0.01211679819971323,
-0.034747131168842316,
0.01641160622239113,
0.006651121191680431,
0.07011613249778748,
-0.012165381573140621,
0.010562117211520672,
-0.03777875751256943,
0.06226499006152153,
0.04761211946606636,
-0.0034907455556094646,
-0.07287569344043732,
0.016363020986318588,
0.05363650992512703,
0.015381629578769207,
-0.025749411433935165,
0.025632809847593307,
-0.005737746134400368,
-0.042637135833501816,
0.008307828567922115,
0.031132495030760765,
-0.01677112653851509,
-0.0025506492238491774,
-0.03093815967440605,
-0.021396303549408913,
-0.025166405364871025,
0.001787883578799665,
0.007307002786546946,
0.0036122051533311605,
-0.03727348521351814,
-0.03511636704206467,
0.0073798783123493195,
-0.006792014464735985,
0.032201338559389114,
-0.038964200764894485,
0.07641258835792542,
-0.06832824647426605,
0.029208576306700706,
-0.03047175519168377,
0.029228011146187782,
0.031773801892995834,
0.02567167580127716,
0.035135798156261444,
0.022445712238550186,
0.03791479393839836,
0.02248458005487919,
0.026196381077170372,
0.030821558088064194,
-0.01982218772172928,
0.08970511704683304,
0.07439150661230087,
-0.005402517970651388,
0.00004873561920248903,
-0.003102075308561325,
0.0474177822470665,
0.021687805652618408,
-0.022037608548998833,
0.023728324100375175,
0.006106982938945293,
-0.043803147971630096,
0.03398922085762024,
-0.03898363560438156,
0.007418745197355747,
-0.0474177822470665,
0.021804407238960266,
0.06797844171524048,
0.01831609010696411,
0.02646845020353794,
0.050566013902425766,
0.0031166502740234137,
-0.01092163659632206,
-0.04069378599524498,
0.0223096776753664,
-0.00496526388451457,
0.008385563269257545,
0.018092604354023933,
0.009085169062018394,
-0.002927173627540469,
-0.04629063978791237,
0.013642329722642899,
0.019355783239006996,
-0.013360543176531792,
-0.018257789313793182,
-0.05060487985610962,
-0.008458438329398632,
-0.06055483967065811,
-0.02508867159485817,
0.055424392223358154,
0.012039064429700375,
0.0004293592646718025,
0.016431039199233055,
-0.0074333203956484795,
-0.003546616993844509,
0.044075217097997665,
-0.021959874778985977,
0.05748434364795685,
0.005203324370086193,
0.0460185706615448,
0.024855468422174454,
-0.041199058294296265,
0.06638489663600922,
0.007418745197355747,
0.03375602141022682,
0.006369335576891899,
-0.024641700088977814,
-0.0177913848310709,
0.04442502185702324,
0.028586704283952713,
-0.002633241703733802,
-0.04170432686805725,
0.07186514884233475,
0.030277419835329056,
-0.05060487985610962,
-0.025069236755371094,
0.015828600153326988,
-0.021240834146738052,
-0.05519118905067444,
0.0691055878996849,
0.009716758504509926,
-0.047650985419750214,
0.045940835028886795,
0.027867663651704788,
0.025963179767131805,
0.04858379438519478,
-0.041782062500715256,
-0.0024389063473790884,
-0.014623722061514854,
0.01720838062465191,
-0.04395861551165581,
-0.05880582332611084,
-0.06852257996797562,
0.04224846884608269,
0.05666813626885414,
0.002980615710839629,
0.03659331426024437,
-0.029364045709371567,
0.06397514045238495,
-0.08286451548337936,
0.012233398854732513,
-0.043220143765211105,
-0.013030173256993294,
-0.02802313305437565,
-0.0009400963899679482,
0.05079921334981918,
-0.02487490326166153,
-0.023631157353520393,
0.03941117227077484,
-0.05511345714330673,
-0.0070980922318995,
-0.005188749171793461,
0.016158970072865486,
0.0024571253452450037,
0.0719817504286766,
-0.03412525728344917,
-0.009381530806422234,
-0.027770496904850006,
-0.0262546818703413,
-0.027032023295760155,
-0.05200409144163132,
-0.0790555477142334,
0.020521795377135277,
-0.022814949974417686,
0.030860425904393196,
-0.03589370846748352,
0.007000924553722143,
-0.038750432431697845,
0.021163100376725197,
0.023145319893956184,
-0.026079781353473663,
0.024913769215345383,
0.0159840676933527,
0.010280330665409565,
-0.11986593902111053,
0.027070889249444008,
0.05079921334981918,
-0.03185153380036354,
0.028567271307110786,
-0.011961329728364944,
-0.04784531891345978,
0.05923335999250412,
0.034377891570329666,
0.0010311909718438983,
-0.0007220766274258494,
-0.025982612743973732,
0.045357830822467804,
-0.01083418633788824,
-0.08550747483968735,
-0.005873780697584152,
0.022348545491695404,
-0.004219502676278353,
-0.06350873410701752,
0.014769473113119602,
0.0021595496218651533,
-0.016712825745344162,
0.04073265194892883,
-0.04007191210985184,
0.06700676679611206,
-0.00783170759677887,
0.005480251740664244,
-0.05511345714330673,
0.03908080235123634,
-0.019637569785118103,
0.014448820613324642,
0.00295632379129529,
0.04065492004156113,
-0.06284799426794052,
0.06945539265871048,
-0.031190795823931694,
-0.003937716595828533,
0.04267600551247597,
0.03323131427168846,
-0.01656707376241684,
0.08076570183038712,
-0.01341884396970272,
0.002659962745383382,
-0.010445515625178814,
-0.054724786430597305,
0.05954429879784584,
0.033950354903936386,
0.01531361136585474,
0.014545988291501999,
0.04901133105158806,
-0.025710543617606163,
0.02646845020353794,
0.017286114394664764,
0.002963611390441656,
0.047106847167015076,
0.05507458746433258,
0.04582423344254494,
-0.007768548559397459,
-0.0066559799015522,
0.0689501166343689,
0.002219064859673381,
-0.022387411445379257,
0.043375611305236816,
0.062187254428863525,
-0.015546813607215881,
0.027712196111679077,
-0.07435263693332672,
0.03531070053577423,
0.004353107884526253,
-0.047534383833408356,
0.023028718307614326,
0.0040664635598659515,
0.010882769711315632,
0.03365885093808174,
-0.0004454526642803103,
0.02689598873257637,
0.018403541296720505,
0.014448820613324642,
0.056123998016119,
-0.01863674260675907,
-0.014672305434942245,
-0.017062628641724586,
0.059466563165187836,
0.00024884010781534016,
-0.004644610919058323,
-0.005674587097018957,
0.06999953091144562,
-0.005169315729290247,
-0.0021425453014671803,
-0.007996892556548119,
-0.0002564313472248614,
-0.05095468461513519,
-0.02194044180214405,
-0.0024291896261274815,
0.007224410306662321,
0.052120693027973175,
0.06964972615242004,
-0.00964388344436884,
0.01413788367062807,
0.009337805211544037,
0.006651121191680431,
0.08504107594490051,
-0.025419041514396667,
-0.08527427166700363,
-0.04617403820157051,
-0.016907161101698875,
-0.015410779044032097,
-0.030607789754867554,
0.01571199856698513,
-0.01283583790063858,
0.001370062935166061,
-0.006369335576891899,
-0.029733281582593918,
0.04057718440890312,
-0.0057523213326931,
0.026332415640354156,
-0.028431236743927002,
-0.007909441366791725,
-0.02631298266351223,
-0.04516349360346794,
0.023242486640810966,
-0.050993550568819046,
-0.017830252647399902,
0.021240834146738052,
0.06300346553325653,
0.05192635953426361,
0.025341307744383812,
-0.002137686824426055,
-0.052276160567998886,
0.00408832635730505,
-0.04800078645348549,
0.010503816418349743,
0.01081475242972374,
-0.05332557111978531,
0.014312786050140858,
0.03791479393839836,
0.011310307309031487,
-0.05589079484343529,
-0.019579268991947174,
0.017237529158592224,
0.03148229792714119,
-0.0031263672281056643,
-0.09320314973592758,
-0.00985765177756548,
0.006962057668715715,
-0.006165283266454935,
0.031229661777615547,
-0.014866640791296959,
-0.0063013178296387196,
-0.08713988959789276,
-0.0150998430326581,
-0.050993550568819046,
0.01997765526175499,
0.013545162044465542,
0.025963179767131805,
-0.024777734652161598,
-0.02961667999625206,
-0.007622797042131424,
-0.00980420969426632,
0.016120102256536484,
-0.029966484755277634,
-0.035932574421167374,
0.015235877595841885,
-0.03972211107611656,
0.019997090101242065,
-0.012602635659277439,
0.0028324350714683533,
0.03849779814481735,
-0.0024121853057295084,
0.01933635026216507,
-0.0603993721306324,
0.032998111099004745,
-0.02178497239947319,
-0.04901133105158806,
0.0446193553507328,
0.053830843418836594,
-0.022504013031721115,
-0.015945201739668846,
0.06929992139339447,
-0.010503816418349743,
-0.015216444618999958,
-0.011951613239943981,
-0.034960899502038956,
0.04403635114431381,
-0.02129913493990898,
-0.03332848101854324,
-0.035932574421167374,
-0.004357966128736734,
-0.003889132756739855,
-0.02248458005487919,
0.009556432254612446,
0.0007645874284207821,
-0.005694020539522171,
-0.01528446190059185,
-0.030491188168525696,
0.0067968727089464664,
0.020327460020780563,
0.07283682376146317,
-0.01879221200942993,
-0.0341058224439621,
0.012155665084719658,
0.012583202682435513,
0.03253170847892761,
0.05402517691254616,
0.06926105916500092,
-0.04384201392531395,
-0.03742895647883415,
-0.013039890676736832,
0.01762619987130165,
-0.062070656567811966,
-0.01794685423374176,
0.007700531277805567,
-0.06420834362506866,
-0.0115046426653862,
0.008531314320862293,
0.016285287216305733,
-0.03280377760529518,
-0.06055483967065811,
0.026818254962563515,
-0.004161201883107424,
-0.07582958787679672,
-0.06770637631416321,
0.042948074638843536,
0.046096302568912506,
0.02493320219218731,
-0.013049607165157795,
-0.011601810343563557,
0.05375310778617859,
-0.05188749358057976,
-0.08403053134679794,
0.03494146466255188,
0.014196184463799,
0.019938789308071136,
-0.03453335911035538,
0.04038285091519356,
0.008798524737358093,
-0.038128562271595,
-0.05138222128152847,
-0.0025069238618016243,
-0.020016523078083992,
0.030821558088064194,
-0.03597144037485123,
0.020424626767635345,
0.053403306752443314,
0.00801146775484085,
-0.030102519318461418,
-0.011135405860841274,
-0.03140456601977348,
-0.0804547592997551,
0.03871156647801399,
0.0230092853307724,
0.009809068404138088,
-0.036243509501218796,
-0.030277419835329056,
-0.013914398849010468,
0.026779387146234512,
0.011524075642228127,
-0.014895791187882423,
0.020793864503502846,
-0.013088474050164223,
-0.012466601096093655,
-0.002659962745383382,
0.01448768749833107,
-0.023631157353520393,
-0.0032478265929967165,
0.028625572100281715,
-0.08846136927604675,
-0.000771267747040838,
0.023417389020323753,
-0.08356412500143051,
0.0020453776232898235,
-0.017927419394254684,
-0.0262546818703413,
0.08822816610336304,
0.009862510487437248,
0.0320458710193634,
0.004790361970663071,
-0.014633438549935818,
0.02524413913488388,
-0.014944374561309814,
-0.009813926182687283,
0.05985523387789726,
-0.02652675099670887,
0.018345240503549576,
-0.039916444569826126,
-0.017703933641314507,
-0.001303260214626789,
-0.010970220901072025,
0.010192879475653172,
0.012583202682435513,
-0.02753729373216629,
-0.010960503481328487,
0.031015893444418907,
-0.0007336153066717088,
0.024136429652571678,
-0.018345240503549576,
0.011660110205411911,
-0.011854445561766624,
-0.04014964774250984,
-0.05192635953426361,
-0.026079781353473663,
-0.0481562577188015,
-0.06121557950973511,
-0.008691640570759773,
-0.018782494589686394,
0.022776082158088684,
0.022037608548998833,
0.04660157486796379,
0.025691110640764236,
0.08504107594490051
]
|
30,368 | networkx.algorithms.shortest_paths.weighted | all_pairs_dijkstra_path | Compute shortest paths between all nodes in a weighted graph.
Parameters
----------
G : NetworkX graph
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
weight : string or function
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number or None to indicate a hidden edge.
Returns
-------
paths : iterator
(source, dictionary) iterator with dictionary keyed by target and
shortest path as the key value.
Examples
--------
>>> G = nx.path_graph(5)
>>> path = dict(nx.all_pairs_dijkstra_path(G))
>>> path[0][4]
[0, 1, 2, 3, 4]
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
See Also
--------
floyd_warshall, all_pairs_bellman_ford_path
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, cutoff=None, weight='weight', *, backend=None, **backend_kwargs) | [
0.008706215769052505,
-0.004100472200661898,
-0.03420298919081688,
-0.044230684638023376,
-0.03898363560438156,
-0.021765539422631264,
-0.010688434354960918,
0.04053831845521927,
0.07361416518688202,
-0.010581550188362598,
-0.052859168499708176,
0.029694415628910065,
0.02866443805396557,
0.02551620826125145,
-0.027284659445285797,
0.035874273627996445,
0.00006410783680621535,
0.03597144037485123,
-0.001286255894228816,
0.013700629584491253,
-0.015041542239487171,
-0.05647380277514458,
0.05550212785601616,
0.04959433525800705,
-0.02098819799721241,
-0.009264929220080376,
0.014915225096046925,
-0.040033046156167984,
-0.025807710364460945,
-0.01634358800947666,
0.01778166927397251,
-0.01869504339993,
-0.0063596186228096485,
-0.005499685648828745,
0.01651849038898945,
0.058611489832401276,
0.007802557200193405,
-0.0030559205915778875,
-0.023359088227152824,
-0.04399748519062996,
-0.030180253088474274,
-0.030394021421670914,
0.005747462622821331,
-0.03781762346625328,
0.08014382421970367,
0.08379732817411423,
-0.01751931570470333,
0.008618764579296112,
-0.019404366612434387,
-0.018840795382857323,
0.015138709917664528,
0.0014720889739692211,
-0.009313513524830341,
0.009561290964484215,
-0.007899724878370762,
0.03941117227077484,
-0.033270180225372314,
0.05421951413154602,
0.027362393215298653,
-0.03820629417896271,
0.03950834274291992,
0.01052324939519167,
0.07085460424423218,
0.04014964774250984,
-0.06378080695867538,
-0.02365059033036232,
-0.04656270891427994,
-0.03754555433988571,
-0.040033046156167984,
0.021435169503092766,
0.001010542968288064,
-0.009488414973020554,
-0.013438276946544647,
-0.03556333854794502,
-0.001875334419310093,
0.03801196068525314,
-0.00007496327452827245,
-0.03478599712252617,
0.011125688441097736,
-0.03983871266245842,
0.0438808836042881,
-0.056434933096170425,
-0.025807710364460945,
-0.07101007550954819,
0.07299229502677917,
0.025108104571700096,
-0.004027596674859524,
0.0026478166691958904,
-0.009060877375304699,
-0.03408639132976532,
-0.03669048100709915,
0.030802125111222267,
-0.003330419072881341,
0.0004044600937049836,
0.05682360380887985,
0.026779387146234512,
0.009070593863725662,
-0.05705680698156357,
0.05002187564969063,
0.031074194237589836,
0.06852257996797562,
0.0048097954131662846,
-0.014477971009910107,
0.03612690791487694,
0.02646845020353794,
-0.06720110028982162,
-0.010989653877913952,
0.015886900946497917,
-0.013885248452425003,
-0.05561872571706772,
-0.022659480571746826,
0.012427734211087227,
0.025866011157631874,
-0.026779387146234512,
0.02349512279033661,
0.0032453974708914757,
0.006767722312361002,
0.04399748519062996,
-0.0005830055451951921,
-0.021124234423041344,
-0.025224706158041954,
0.052548229694366455,
-0.08309771865606308,
-0.0039012786000967026,
0.04038285091519356,
-0.05639606714248657,
0.024738868698477745,
-0.01991935633122921,
0.06630716472864151,
0.01788855344057083,
0.026196381077170372,
0.0048097954131662846,
-0.02790653146803379,
0.06560755521059036,
0.03202643617987633,
-0.02460283227264881,
-0.056590404361486435,
0.04687364399433136,
0.06502454727888107,
0.010387214832007885,
0.04255940392613411,
-0.07547978311777115,
0.007734539918601513,
0.0287616066634655,
0.005868922453373671,
-0.028528403490781784,
0.011125688441097736,
0.014021283015608788,
0.0313073955476284,
0.05977749824523926,
0.0154496468603611,
0.0028494393918663263,
0.00686974823474884,
0.011698977090418339,
0.0016506343381479383,
-0.0682116448879242,
-0.04201526567339897,
0.020424626767635345,
0.0058349138125777245,
-0.0004894817247986794,
0.01661565713584423,
-0.0446193553507328,
0.005762037821114063,
0.014895791187882423,
-0.04986640438437462,
0.03494146466255188,
0.022134777158498764,
0.05215956270694733,
-0.027129190042614937,
0.012388867326080799,
-0.005898072384297848,
-0.0640917420387268,
-0.047806452959775925,
-0.029150275513529778,
-0.0244473647326231,
0.0033085562754422426,
0.0251469723880291,
-0.0022882965859025717,
0.011883595958352089,
-0.019462667405605316,
0.009862510487437248,
-0.026604484766721725,
0.023145319893956184,
-0.01358402892947197,
0.030083084478974342,
0.029169710353016853,
0.022251376882195473,
-0.021610071882605553,
0.0029514655470848083,
0.03478599712252617,
-0.048233989626169205,
-0.09328088164329529,
-0.06059370934963226,
0.08325318992137909,
-0.009094886481761932,
0.0067239971831440926,
-0.03727348521351814,
-0.022115342319011688,
-0.027284659445285797,
0.06378080695867538,
-0.009162903763353825,
-0.029305744916200638,
0.03987757861614227,
-0.008881117217242718,
0.009245496243238449,
-0.028839340433478355,
-0.03245397284626961,
0.008623623289167881,
0.0010111501906067133,
0.018559008836746216,
-0.035135798156261444,
-0.04543556272983551,
0.02998591773211956,
-0.02977214939892292,
0.0011933394707739353,
0.013778364285826683,
-0.03175436705350876,
0.04007191210985184,
0.014011566527187824,
-0.059039026498794556,
-0.004404121078550816,
-0.01528446190059185,
-0.009546715766191483,
0.02114366739988327,
0.0618763193488121,
-0.0502939447760582,
0.04702911153435707,
0.030646657571196556,
0.025846578180789948,
-0.0733032301068306,
0.07718992978334427,
-0.03280377760529518,
0.096312515437603,
-0.014818057417869568,
0.07380849868059158,
-0.04784531891345978,
0.00343487411737442,
0.04073265194892883,
0.04562989994883537,
0.027925964444875717,
-0.021687805652618408,
-0.02343682199716568,
-0.014633438549935818,
-0.058145083487033844,
0.005820338614284992,
-0.00011994124361081049,
0.031501732766628265,
-0.012281983159482479,
0.026138080283999443,
-0.006500511430203915,
0.00507214805111289,
0.027731629088521004,
-0.042326200753450394,
-0.05748434364795685,
-0.012942722998559475,
-0.0431424081325531,
-0.021027065813541412,
-0.03756498917937279,
-0.036515578627586365,
-0.06591849029064178,
-0.03225963935256004,
-0.02784823067486286,
-0.06094351038336754,
0.10152069479227066,
-0.003925570752471685,
0.03260944411158562,
0.031171362847089767,
-0.01430306863039732,
-0.08022156357765198,
0.0066559799015522,
0.042637135833501816,
0.04310354217886925,
-0.006860031746327877,
-0.0035879132337868214,
-0.025049803778529167,
0.005208182614296675,
-0.03222077339887619,
0.03482486307621002,
0.012845555320382118,
-0.0230092853307724,
-0.04368654638528824,
-0.00833697896450758,
-0.04123792424798012,
-0.006515086628496647,
0.018024588003754616,
0.029636114835739136,
0.01211679819971323,
-0.034747131168842316,
0.01641160622239113,
0.006651121191680431,
0.07011613249778748,
-0.012165381573140621,
0.010562117211520672,
-0.03777875751256943,
0.06226499006152153,
0.04761211946606636,
-0.0034907455556094646,
-0.07287569344043732,
0.016363020986318588,
0.05363650992512703,
0.015381629578769207,
-0.025749411433935165,
0.025632809847593307,
-0.005737746134400368,
-0.042637135833501816,
0.008307828567922115,
0.031132495030760765,
-0.01677112653851509,
-0.0025506492238491774,
-0.03093815967440605,
-0.021396303549408913,
-0.025166405364871025,
0.001787883578799665,
0.007307002786546946,
0.0036122051533311605,
-0.03727348521351814,
-0.03511636704206467,
0.0073798783123493195,
-0.006792014464735985,
0.032201338559389114,
-0.038964200764894485,
0.07641258835792542,
-0.06832824647426605,
0.029208576306700706,
-0.03047175519168377,
0.029228011146187782,
0.031773801892995834,
0.02567167580127716,
0.035135798156261444,
0.022445712238550186,
0.03791479393839836,
0.02248458005487919,
0.026196381077170372,
0.030821558088064194,
-0.01982218772172928,
0.08970511704683304,
0.07439150661230087,
-0.005402517970651388,
0.00004873561920248903,
-0.003102075308561325,
0.0474177822470665,
0.021687805652618408,
-0.022037608548998833,
0.023728324100375175,
0.006106982938945293,
-0.043803147971630096,
0.03398922085762024,
-0.03898363560438156,
0.007418745197355747,
-0.0474177822470665,
0.021804407238960266,
0.06797844171524048,
0.01831609010696411,
0.02646845020353794,
0.050566013902425766,
0.0031166502740234137,
-0.01092163659632206,
-0.04069378599524498,
0.0223096776753664,
-0.00496526388451457,
0.008385563269257545,
0.018092604354023933,
0.009085169062018394,
-0.002927173627540469,
-0.04629063978791237,
0.013642329722642899,
0.019355783239006996,
-0.013360543176531792,
-0.018257789313793182,
-0.05060487985610962,
-0.008458438329398632,
-0.06055483967065811,
-0.02508867159485817,
0.055424392223358154,
0.012039064429700375,
0.0004293592646718025,
0.016431039199233055,
-0.0074333203956484795,
-0.003546616993844509,
0.044075217097997665,
-0.021959874778985977,
0.05748434364795685,
0.005203324370086193,
0.0460185706615448,
0.024855468422174454,
-0.041199058294296265,
0.06638489663600922,
0.007418745197355747,
0.03375602141022682,
0.006369335576891899,
-0.024641700088977814,
-0.0177913848310709,
0.04442502185702324,
0.028586704283952713,
-0.002633241703733802,
-0.04170432686805725,
0.07186514884233475,
0.030277419835329056,
-0.05060487985610962,
-0.025069236755371094,
0.015828600153326988,
-0.021240834146738052,
-0.05519118905067444,
0.0691055878996849,
0.009716758504509926,
-0.047650985419750214,
0.045940835028886795,
0.027867663651704788,
0.025963179767131805,
0.04858379438519478,
-0.041782062500715256,
-0.0024389063473790884,
-0.014623722061514854,
0.01720838062465191,
-0.04395861551165581,
-0.05880582332611084,
-0.06852257996797562,
0.04224846884608269,
0.05666813626885414,
0.002980615710839629,
0.03659331426024437,
-0.029364045709371567,
0.06397514045238495,
-0.08286451548337936,
0.012233398854732513,
-0.043220143765211105,
-0.013030173256993294,
-0.02802313305437565,
-0.0009400963899679482,
0.05079921334981918,
-0.02487490326166153,
-0.023631157353520393,
0.03941117227077484,
-0.05511345714330673,
-0.0070980922318995,
-0.005188749171793461,
0.016158970072865486,
0.0024571253452450037,
0.0719817504286766,
-0.03412525728344917,
-0.009381530806422234,
-0.027770496904850006,
-0.0262546818703413,
-0.027032023295760155,
-0.05200409144163132,
-0.0790555477142334,
0.020521795377135277,
-0.022814949974417686,
0.030860425904393196,
-0.03589370846748352,
0.007000924553722143,
-0.038750432431697845,
0.021163100376725197,
0.023145319893956184,
-0.026079781353473663,
0.024913769215345383,
0.0159840676933527,
0.010280330665409565,
-0.11986593902111053,
0.027070889249444008,
0.05079921334981918,
-0.03185153380036354,
0.028567271307110786,
-0.011961329728364944,
-0.04784531891345978,
0.05923335999250412,
0.034377891570329666,
0.0010311909718438983,
-0.0007220766274258494,
-0.025982612743973732,
0.045357830822467804,
-0.01083418633788824,
-0.08550747483968735,
-0.005873780697584152,
0.022348545491695404,
-0.004219502676278353,
-0.06350873410701752,
0.014769473113119602,
0.0021595496218651533,
-0.016712825745344162,
0.04073265194892883,
-0.04007191210985184,
0.06700676679611206,
-0.00783170759677887,
0.005480251740664244,
-0.05511345714330673,
0.03908080235123634,
-0.019637569785118103,
0.014448820613324642,
0.00295632379129529,
0.04065492004156113,
-0.06284799426794052,
0.06945539265871048,
-0.031190795823931694,
-0.003937716595828533,
0.04267600551247597,
0.03323131427168846,
-0.01656707376241684,
0.08076570183038712,
-0.01341884396970272,
0.002659962745383382,
-0.010445515625178814,
-0.054724786430597305,
0.05954429879784584,
0.033950354903936386,
0.01531361136585474,
0.014545988291501999,
0.04901133105158806,
-0.025710543617606163,
0.02646845020353794,
0.017286114394664764,
0.002963611390441656,
0.047106847167015076,
0.05507458746433258,
0.04582423344254494,
-0.007768548559397459,
-0.0066559799015522,
0.0689501166343689,
0.002219064859673381,
-0.022387411445379257,
0.043375611305236816,
0.062187254428863525,
-0.015546813607215881,
0.027712196111679077,
-0.07435263693332672,
0.03531070053577423,
0.004353107884526253,
-0.047534383833408356,
0.023028718307614326,
0.0040664635598659515,
0.010882769711315632,
0.03365885093808174,
-0.0004454526642803103,
0.02689598873257637,
0.018403541296720505,
0.014448820613324642,
0.056123998016119,
-0.01863674260675907,
-0.014672305434942245,
-0.017062628641724586,
0.059466563165187836,
0.00024884010781534016,
-0.004644610919058323,
-0.005674587097018957,
0.06999953091144562,
-0.005169315729290247,
-0.0021425453014671803,
-0.007996892556548119,
-0.0002564313472248614,
-0.05095468461513519,
-0.02194044180214405,
-0.0024291896261274815,
0.007224410306662321,
0.052120693027973175,
0.06964972615242004,
-0.00964388344436884,
0.01413788367062807,
0.009337805211544037,
0.006651121191680431,
0.08504107594490051,
-0.025419041514396667,
-0.08527427166700363,
-0.04617403820157051,
-0.016907161101698875,
-0.015410779044032097,
-0.030607789754867554,
0.01571199856698513,
-0.01283583790063858,
0.001370062935166061,
-0.006369335576891899,
-0.029733281582593918,
0.04057718440890312,
-0.0057523213326931,
0.026332415640354156,
-0.028431236743927002,
-0.007909441366791725,
-0.02631298266351223,
-0.04516349360346794,
0.023242486640810966,
-0.050993550568819046,
-0.017830252647399902,
0.021240834146738052,
0.06300346553325653,
0.05192635953426361,
0.025341307744383812,
-0.002137686824426055,
-0.052276160567998886,
0.00408832635730505,
-0.04800078645348549,
0.010503816418349743,
0.01081475242972374,
-0.05332557111978531,
0.014312786050140858,
0.03791479393839836,
0.011310307309031487,
-0.05589079484343529,
-0.019579268991947174,
0.017237529158592224,
0.03148229792714119,
-0.0031263672281056643,
-0.09320314973592758,
-0.00985765177756548,
0.006962057668715715,
-0.006165283266454935,
0.031229661777615547,
-0.014866640791296959,
-0.0063013178296387196,
-0.08713988959789276,
-0.0150998430326581,
-0.050993550568819046,
0.01997765526175499,
0.013545162044465542,
0.025963179767131805,
-0.024777734652161598,
-0.02961667999625206,
-0.007622797042131424,
-0.00980420969426632,
0.016120102256536484,
-0.029966484755277634,
-0.035932574421167374,
0.015235877595841885,
-0.03972211107611656,
0.019997090101242065,
-0.012602635659277439,
0.0028324350714683533,
0.03849779814481735,
-0.0024121853057295084,
0.01933635026216507,
-0.0603993721306324,
0.032998111099004745,
-0.02178497239947319,
-0.04901133105158806,
0.0446193553507328,
0.053830843418836594,
-0.022504013031721115,
-0.015945201739668846,
0.06929992139339447,
-0.010503816418349743,
-0.015216444618999958,
-0.011951613239943981,
-0.034960899502038956,
0.04403635114431381,
-0.02129913493990898,
-0.03332848101854324,
-0.035932574421167374,
-0.004357966128736734,
-0.003889132756739855,
-0.02248458005487919,
0.009556432254612446,
0.0007645874284207821,
-0.005694020539522171,
-0.01528446190059185,
-0.030491188168525696,
0.0067968727089464664,
0.020327460020780563,
0.07283682376146317,
-0.01879221200942993,
-0.0341058224439621,
0.012155665084719658,
0.012583202682435513,
0.03253170847892761,
0.05402517691254616,
0.06926105916500092,
-0.04384201392531395,
-0.03742895647883415,
-0.013039890676736832,
0.01762619987130165,
-0.062070656567811966,
-0.01794685423374176,
0.007700531277805567,
-0.06420834362506866,
-0.0115046426653862,
0.008531314320862293,
0.016285287216305733,
-0.03280377760529518,
-0.06055483967065811,
0.026818254962563515,
-0.004161201883107424,
-0.07582958787679672,
-0.06770637631416321,
0.042948074638843536,
0.046096302568912506,
0.02493320219218731,
-0.013049607165157795,
-0.011601810343563557,
0.05375310778617859,
-0.05188749358057976,
-0.08403053134679794,
0.03494146466255188,
0.014196184463799,
0.019938789308071136,
-0.03453335911035538,
0.04038285091519356,
0.008798524737358093,
-0.038128562271595,
-0.05138222128152847,
-0.0025069238618016243,
-0.020016523078083992,
0.030821558088064194,
-0.03597144037485123,
0.020424626767635345,
0.053403306752443314,
0.00801146775484085,
-0.030102519318461418,
-0.011135405860841274,
-0.03140456601977348,
-0.0804547592997551,
0.03871156647801399,
0.0230092853307724,
0.009809068404138088,
-0.036243509501218796,
-0.030277419835329056,
-0.013914398849010468,
0.026779387146234512,
0.011524075642228127,
-0.014895791187882423,
0.020793864503502846,
-0.013088474050164223,
-0.012466601096093655,
-0.002659962745383382,
0.01448768749833107,
-0.023631157353520393,
-0.0032478265929967165,
0.028625572100281715,
-0.08846136927604675,
-0.000771267747040838,
0.023417389020323753,
-0.08356412500143051,
0.0020453776232898235,
-0.017927419394254684,
-0.0262546818703413,
0.08822816610336304,
0.009862510487437248,
0.0320458710193634,
0.004790361970663071,
-0.014633438549935818,
0.02524413913488388,
-0.014944374561309814,
-0.009813926182687283,
0.05985523387789726,
-0.02652675099670887,
0.018345240503549576,
-0.039916444569826126,
-0.017703933641314507,
-0.001303260214626789,
-0.010970220901072025,
0.010192879475653172,
0.012583202682435513,
-0.02753729373216629,
-0.010960503481328487,
0.031015893444418907,
-0.0007336153066717088,
0.024136429652571678,
-0.018345240503549576,
0.011660110205411911,
-0.011854445561766624,
-0.04014964774250984,
-0.05192635953426361,
-0.026079781353473663,
-0.0481562577188015,
-0.06121557950973511,
-0.008691640570759773,
-0.018782494589686394,
0.022776082158088684,
0.022037608548998833,
0.04660157486796379,
0.025691110640764236,
0.08504107594490051
]
|
30,369 | networkx.algorithms.shortest_paths.weighted | all_pairs_dijkstra_path_length | Compute shortest path lengths between all nodes in a weighted graph.
Parameters
----------
G : NetworkX graph
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
weight : string or function
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number or None to indicate a hidden edge.
Returns
-------
distance : iterator
(source, dictionary) iterator with dictionary keyed by target and
shortest path length as the key value.
Examples
--------
>>> G = nx.path_graph(5)
>>> length = dict(nx.all_pairs_dijkstra_path_length(G))
>>> for node in [0, 1, 2, 3, 4]:
... print(f"1 - {node}: {length[1][node]}")
1 - 0: 1
1 - 1: 0
1 - 2: 1
1 - 3: 2
1 - 4: 3
>>> length[3][2]
1
>>> length[2][2]
0
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
The dictionary returned only has keys for reachable node pairs.
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, cutoff=None, weight='weight', *, backend=None, **backend_kwargs) | [
0.008706215769052505,
-0.004100472200661898,
-0.03420298919081688,
-0.044230684638023376,
-0.03898363560438156,
-0.021765539422631264,
-0.010688434354960918,
0.04053831845521927,
0.07361416518688202,
-0.010581550188362598,
-0.052859168499708176,
0.029694415628910065,
0.02866443805396557,
0.02551620826125145,
-0.027284659445285797,
0.035874273627996445,
0.00006410783680621535,
0.03597144037485123,
-0.001286255894228816,
0.013700629584491253,
-0.015041542239487171,
-0.05647380277514458,
0.05550212785601616,
0.04959433525800705,
-0.02098819799721241,
-0.009264929220080376,
0.014915225096046925,
-0.040033046156167984,
-0.025807710364460945,
-0.01634358800947666,
0.01778166927397251,
-0.01869504339993,
-0.0063596186228096485,
-0.005499685648828745,
0.01651849038898945,
0.058611489832401276,
0.007802557200193405,
-0.0030559205915778875,
-0.023359088227152824,
-0.04399748519062996,
-0.030180253088474274,
-0.030394021421670914,
0.005747462622821331,
-0.03781762346625328,
0.08014382421970367,
0.08379732817411423,
-0.01751931570470333,
0.008618764579296112,
-0.019404366612434387,
-0.018840795382857323,
0.015138709917664528,
0.0014720889739692211,
-0.009313513524830341,
0.009561290964484215,
-0.007899724878370762,
0.03941117227077484,
-0.033270180225372314,
0.05421951413154602,
0.027362393215298653,
-0.03820629417896271,
0.03950834274291992,
0.01052324939519167,
0.07085460424423218,
0.04014964774250984,
-0.06378080695867538,
-0.02365059033036232,
-0.04656270891427994,
-0.03754555433988571,
-0.040033046156167984,
0.021435169503092766,
0.001010542968288064,
-0.009488414973020554,
-0.013438276946544647,
-0.03556333854794502,
-0.001875334419310093,
0.03801196068525314,
-0.00007496327452827245,
-0.03478599712252617,
0.011125688441097736,
-0.03983871266245842,
0.0438808836042881,
-0.056434933096170425,
-0.025807710364460945,
-0.07101007550954819,
0.07299229502677917,
0.025108104571700096,
-0.004027596674859524,
0.0026478166691958904,
-0.009060877375304699,
-0.03408639132976532,
-0.03669048100709915,
0.030802125111222267,
-0.003330419072881341,
0.0004044600937049836,
0.05682360380887985,
0.026779387146234512,
0.009070593863725662,
-0.05705680698156357,
0.05002187564969063,
0.031074194237589836,
0.06852257996797562,
0.0048097954131662846,
-0.014477971009910107,
0.03612690791487694,
0.02646845020353794,
-0.06720110028982162,
-0.010989653877913952,
0.015886900946497917,
-0.013885248452425003,
-0.05561872571706772,
-0.022659480571746826,
0.012427734211087227,
0.025866011157631874,
-0.026779387146234512,
0.02349512279033661,
0.0032453974708914757,
0.006767722312361002,
0.04399748519062996,
-0.0005830055451951921,
-0.021124234423041344,
-0.025224706158041954,
0.052548229694366455,
-0.08309771865606308,
-0.0039012786000967026,
0.04038285091519356,
-0.05639606714248657,
0.024738868698477745,
-0.01991935633122921,
0.06630716472864151,
0.01788855344057083,
0.026196381077170372,
0.0048097954131662846,
-0.02790653146803379,
0.06560755521059036,
0.03202643617987633,
-0.02460283227264881,
-0.056590404361486435,
0.04687364399433136,
0.06502454727888107,
0.010387214832007885,
0.04255940392613411,
-0.07547978311777115,
0.007734539918601513,
0.0287616066634655,
0.005868922453373671,
-0.028528403490781784,
0.011125688441097736,
0.014021283015608788,
0.0313073955476284,
0.05977749824523926,
0.0154496468603611,
0.0028494393918663263,
0.00686974823474884,
0.011698977090418339,
0.0016506343381479383,
-0.0682116448879242,
-0.04201526567339897,
0.020424626767635345,
0.0058349138125777245,
-0.0004894817247986794,
0.01661565713584423,
-0.0446193553507328,
0.005762037821114063,
0.014895791187882423,
-0.04986640438437462,
0.03494146466255188,
0.022134777158498764,
0.05215956270694733,
-0.027129190042614937,
0.012388867326080799,
-0.005898072384297848,
-0.0640917420387268,
-0.047806452959775925,
-0.029150275513529778,
-0.0244473647326231,
0.0033085562754422426,
0.0251469723880291,
-0.0022882965859025717,
0.011883595958352089,
-0.019462667405605316,
0.009862510487437248,
-0.026604484766721725,
0.023145319893956184,
-0.01358402892947197,
0.030083084478974342,
0.029169710353016853,
0.022251376882195473,
-0.021610071882605553,
0.0029514655470848083,
0.03478599712252617,
-0.048233989626169205,
-0.09328088164329529,
-0.06059370934963226,
0.08325318992137909,
-0.009094886481761932,
0.0067239971831440926,
-0.03727348521351814,
-0.022115342319011688,
-0.027284659445285797,
0.06378080695867538,
-0.009162903763353825,
-0.029305744916200638,
0.03987757861614227,
-0.008881117217242718,
0.009245496243238449,
-0.028839340433478355,
-0.03245397284626961,
0.008623623289167881,
0.0010111501906067133,
0.018559008836746216,
-0.035135798156261444,
-0.04543556272983551,
0.02998591773211956,
-0.02977214939892292,
0.0011933394707739353,
0.013778364285826683,
-0.03175436705350876,
0.04007191210985184,
0.014011566527187824,
-0.059039026498794556,
-0.004404121078550816,
-0.01528446190059185,
-0.009546715766191483,
0.02114366739988327,
0.0618763193488121,
-0.0502939447760582,
0.04702911153435707,
0.030646657571196556,
0.025846578180789948,
-0.0733032301068306,
0.07718992978334427,
-0.03280377760529518,
0.096312515437603,
-0.014818057417869568,
0.07380849868059158,
-0.04784531891345978,
0.00343487411737442,
0.04073265194892883,
0.04562989994883537,
0.027925964444875717,
-0.021687805652618408,
-0.02343682199716568,
-0.014633438549935818,
-0.058145083487033844,
0.005820338614284992,
-0.00011994124361081049,
0.031501732766628265,
-0.012281983159482479,
0.026138080283999443,
-0.006500511430203915,
0.00507214805111289,
0.027731629088521004,
-0.042326200753450394,
-0.05748434364795685,
-0.012942722998559475,
-0.0431424081325531,
-0.021027065813541412,
-0.03756498917937279,
-0.036515578627586365,
-0.06591849029064178,
-0.03225963935256004,
-0.02784823067486286,
-0.06094351038336754,
0.10152069479227066,
-0.003925570752471685,
0.03260944411158562,
0.031171362847089767,
-0.01430306863039732,
-0.08022156357765198,
0.0066559799015522,
0.042637135833501816,
0.04310354217886925,
-0.006860031746327877,
-0.0035879132337868214,
-0.025049803778529167,
0.005208182614296675,
-0.03222077339887619,
0.03482486307621002,
0.012845555320382118,
-0.0230092853307724,
-0.04368654638528824,
-0.00833697896450758,
-0.04123792424798012,
-0.006515086628496647,
0.018024588003754616,
0.029636114835739136,
0.01211679819971323,
-0.034747131168842316,
0.01641160622239113,
0.006651121191680431,
0.07011613249778748,
-0.012165381573140621,
0.010562117211520672,
-0.03777875751256943,
0.06226499006152153,
0.04761211946606636,
-0.0034907455556094646,
-0.07287569344043732,
0.016363020986318588,
0.05363650992512703,
0.015381629578769207,
-0.025749411433935165,
0.025632809847593307,
-0.005737746134400368,
-0.042637135833501816,
0.008307828567922115,
0.031132495030760765,
-0.01677112653851509,
-0.0025506492238491774,
-0.03093815967440605,
-0.021396303549408913,
-0.025166405364871025,
0.001787883578799665,
0.007307002786546946,
0.0036122051533311605,
-0.03727348521351814,
-0.03511636704206467,
0.0073798783123493195,
-0.006792014464735985,
0.032201338559389114,
-0.038964200764894485,
0.07641258835792542,
-0.06832824647426605,
0.029208576306700706,
-0.03047175519168377,
0.029228011146187782,
0.031773801892995834,
0.02567167580127716,
0.035135798156261444,
0.022445712238550186,
0.03791479393839836,
0.02248458005487919,
0.026196381077170372,
0.030821558088064194,
-0.01982218772172928,
0.08970511704683304,
0.07439150661230087,
-0.005402517970651388,
0.00004873561920248903,
-0.003102075308561325,
0.0474177822470665,
0.021687805652618408,
-0.022037608548998833,
0.023728324100375175,
0.006106982938945293,
-0.043803147971630096,
0.03398922085762024,
-0.03898363560438156,
0.007418745197355747,
-0.0474177822470665,
0.021804407238960266,
0.06797844171524048,
0.01831609010696411,
0.02646845020353794,
0.050566013902425766,
0.0031166502740234137,
-0.01092163659632206,
-0.04069378599524498,
0.0223096776753664,
-0.00496526388451457,
0.008385563269257545,
0.018092604354023933,
0.009085169062018394,
-0.002927173627540469,
-0.04629063978791237,
0.013642329722642899,
0.019355783239006996,
-0.013360543176531792,
-0.018257789313793182,
-0.05060487985610962,
-0.008458438329398632,
-0.06055483967065811,
-0.02508867159485817,
0.055424392223358154,
0.012039064429700375,
0.0004293592646718025,
0.016431039199233055,
-0.0074333203956484795,
-0.003546616993844509,
0.044075217097997665,
-0.021959874778985977,
0.05748434364795685,
0.005203324370086193,
0.0460185706615448,
0.024855468422174454,
-0.041199058294296265,
0.06638489663600922,
0.007418745197355747,
0.03375602141022682,
0.006369335576891899,
-0.024641700088977814,
-0.0177913848310709,
0.04442502185702324,
0.028586704283952713,
-0.002633241703733802,
-0.04170432686805725,
0.07186514884233475,
0.030277419835329056,
-0.05060487985610962,
-0.025069236755371094,
0.015828600153326988,
-0.021240834146738052,
-0.05519118905067444,
0.0691055878996849,
0.009716758504509926,
-0.047650985419750214,
0.045940835028886795,
0.027867663651704788,
0.025963179767131805,
0.04858379438519478,
-0.041782062500715256,
-0.0024389063473790884,
-0.014623722061514854,
0.01720838062465191,
-0.04395861551165581,
-0.05880582332611084,
-0.06852257996797562,
0.04224846884608269,
0.05666813626885414,
0.002980615710839629,
0.03659331426024437,
-0.029364045709371567,
0.06397514045238495,
-0.08286451548337936,
0.012233398854732513,
-0.043220143765211105,
-0.013030173256993294,
-0.02802313305437565,
-0.0009400963899679482,
0.05079921334981918,
-0.02487490326166153,
-0.023631157353520393,
0.03941117227077484,
-0.05511345714330673,
-0.0070980922318995,
-0.005188749171793461,
0.016158970072865486,
0.0024571253452450037,
0.0719817504286766,
-0.03412525728344917,
-0.009381530806422234,
-0.027770496904850006,
-0.0262546818703413,
-0.027032023295760155,
-0.05200409144163132,
-0.0790555477142334,
0.020521795377135277,
-0.022814949974417686,
0.030860425904393196,
-0.03589370846748352,
0.007000924553722143,
-0.038750432431697845,
0.021163100376725197,
0.023145319893956184,
-0.026079781353473663,
0.024913769215345383,
0.0159840676933527,
0.010280330665409565,
-0.11986593902111053,
0.027070889249444008,
0.05079921334981918,
-0.03185153380036354,
0.028567271307110786,
-0.011961329728364944,
-0.04784531891345978,
0.05923335999250412,
0.034377891570329666,
0.0010311909718438983,
-0.0007220766274258494,
-0.025982612743973732,
0.045357830822467804,
-0.01083418633788824,
-0.08550747483968735,
-0.005873780697584152,
0.022348545491695404,
-0.004219502676278353,
-0.06350873410701752,
0.014769473113119602,
0.0021595496218651533,
-0.016712825745344162,
0.04073265194892883,
-0.04007191210985184,
0.06700676679611206,
-0.00783170759677887,
0.005480251740664244,
-0.05511345714330673,
0.03908080235123634,
-0.019637569785118103,
0.014448820613324642,
0.00295632379129529,
0.04065492004156113,
-0.06284799426794052,
0.06945539265871048,
-0.031190795823931694,
-0.003937716595828533,
0.04267600551247597,
0.03323131427168846,
-0.01656707376241684,
0.08076570183038712,
-0.01341884396970272,
0.002659962745383382,
-0.010445515625178814,
-0.054724786430597305,
0.05954429879784584,
0.033950354903936386,
0.01531361136585474,
0.014545988291501999,
0.04901133105158806,
-0.025710543617606163,
0.02646845020353794,
0.017286114394664764,
0.002963611390441656,
0.047106847167015076,
0.05507458746433258,
0.04582423344254494,
-0.007768548559397459,
-0.0066559799015522,
0.0689501166343689,
0.002219064859673381,
-0.022387411445379257,
0.043375611305236816,
0.062187254428863525,
-0.015546813607215881,
0.027712196111679077,
-0.07435263693332672,
0.03531070053577423,
0.004353107884526253,
-0.047534383833408356,
0.023028718307614326,
0.0040664635598659515,
0.010882769711315632,
0.03365885093808174,
-0.0004454526642803103,
0.02689598873257637,
0.018403541296720505,
0.014448820613324642,
0.056123998016119,
-0.01863674260675907,
-0.014672305434942245,
-0.017062628641724586,
0.059466563165187836,
0.00024884010781534016,
-0.004644610919058323,
-0.005674587097018957,
0.06999953091144562,
-0.005169315729290247,
-0.0021425453014671803,
-0.007996892556548119,
-0.0002564313472248614,
-0.05095468461513519,
-0.02194044180214405,
-0.0024291896261274815,
0.007224410306662321,
0.052120693027973175,
0.06964972615242004,
-0.00964388344436884,
0.01413788367062807,
0.009337805211544037,
0.006651121191680431,
0.08504107594490051,
-0.025419041514396667,
-0.08527427166700363,
-0.04617403820157051,
-0.016907161101698875,
-0.015410779044032097,
-0.030607789754867554,
0.01571199856698513,
-0.01283583790063858,
0.001370062935166061,
-0.006369335576891899,
-0.029733281582593918,
0.04057718440890312,
-0.0057523213326931,
0.026332415640354156,
-0.028431236743927002,
-0.007909441366791725,
-0.02631298266351223,
-0.04516349360346794,
0.023242486640810966,
-0.050993550568819046,
-0.017830252647399902,
0.021240834146738052,
0.06300346553325653,
0.05192635953426361,
0.025341307744383812,
-0.002137686824426055,
-0.052276160567998886,
0.00408832635730505,
-0.04800078645348549,
0.010503816418349743,
0.01081475242972374,
-0.05332557111978531,
0.014312786050140858,
0.03791479393839836,
0.011310307309031487,
-0.05589079484343529,
-0.019579268991947174,
0.017237529158592224,
0.03148229792714119,
-0.0031263672281056643,
-0.09320314973592758,
-0.00985765177756548,
0.006962057668715715,
-0.006165283266454935,
0.031229661777615547,
-0.014866640791296959,
-0.0063013178296387196,
-0.08713988959789276,
-0.0150998430326581,
-0.050993550568819046,
0.01997765526175499,
0.013545162044465542,
0.025963179767131805,
-0.024777734652161598,
-0.02961667999625206,
-0.007622797042131424,
-0.00980420969426632,
0.016120102256536484,
-0.029966484755277634,
-0.035932574421167374,
0.015235877595841885,
-0.03972211107611656,
0.019997090101242065,
-0.012602635659277439,
0.0028324350714683533,
0.03849779814481735,
-0.0024121853057295084,
0.01933635026216507,
-0.0603993721306324,
0.032998111099004745,
-0.02178497239947319,
-0.04901133105158806,
0.0446193553507328,
0.053830843418836594,
-0.022504013031721115,
-0.015945201739668846,
0.06929992139339447,
-0.010503816418349743,
-0.015216444618999958,
-0.011951613239943981,
-0.034960899502038956,
0.04403635114431381,
-0.02129913493990898,
-0.03332848101854324,
-0.035932574421167374,
-0.004357966128736734,
-0.003889132756739855,
-0.02248458005487919,
0.009556432254612446,
0.0007645874284207821,
-0.005694020539522171,
-0.01528446190059185,
-0.030491188168525696,
0.0067968727089464664,
0.020327460020780563,
0.07283682376146317,
-0.01879221200942993,
-0.0341058224439621,
0.012155665084719658,
0.012583202682435513,
0.03253170847892761,
0.05402517691254616,
0.06926105916500092,
-0.04384201392531395,
-0.03742895647883415,
-0.013039890676736832,
0.01762619987130165,
-0.062070656567811966,
-0.01794685423374176,
0.007700531277805567,
-0.06420834362506866,
-0.0115046426653862,
0.008531314320862293,
0.016285287216305733,
-0.03280377760529518,
-0.06055483967065811,
0.026818254962563515,
-0.004161201883107424,
-0.07582958787679672,
-0.06770637631416321,
0.042948074638843536,
0.046096302568912506,
0.02493320219218731,
-0.013049607165157795,
-0.011601810343563557,
0.05375310778617859,
-0.05188749358057976,
-0.08403053134679794,
0.03494146466255188,
0.014196184463799,
0.019938789308071136,
-0.03453335911035538,
0.04038285091519356,
0.008798524737358093,
-0.038128562271595,
-0.05138222128152847,
-0.0025069238618016243,
-0.020016523078083992,
0.030821558088064194,
-0.03597144037485123,
0.020424626767635345,
0.053403306752443314,
0.00801146775484085,
-0.030102519318461418,
-0.011135405860841274,
-0.03140456601977348,
-0.0804547592997551,
0.03871156647801399,
0.0230092853307724,
0.009809068404138088,
-0.036243509501218796,
-0.030277419835329056,
-0.013914398849010468,
0.026779387146234512,
0.011524075642228127,
-0.014895791187882423,
0.020793864503502846,
-0.013088474050164223,
-0.012466601096093655,
-0.002659962745383382,
0.01448768749833107,
-0.023631157353520393,
-0.0032478265929967165,
0.028625572100281715,
-0.08846136927604675,
-0.000771267747040838,
0.023417389020323753,
-0.08356412500143051,
0.0020453776232898235,
-0.017927419394254684,
-0.0262546818703413,
0.08822816610336304,
0.009862510487437248,
0.0320458710193634,
0.004790361970663071,
-0.014633438549935818,
0.02524413913488388,
-0.014944374561309814,
-0.009813926182687283,
0.05985523387789726,
-0.02652675099670887,
0.018345240503549576,
-0.039916444569826126,
-0.017703933641314507,
-0.001303260214626789,
-0.010970220901072025,
0.010192879475653172,
0.012583202682435513,
-0.02753729373216629,
-0.010960503481328487,
0.031015893444418907,
-0.0007336153066717088,
0.024136429652571678,
-0.018345240503549576,
0.011660110205411911,
-0.011854445561766624,
-0.04014964774250984,
-0.05192635953426361,
-0.026079781353473663,
-0.0481562577188015,
-0.06121557950973511,
-0.008691640570759773,
-0.018782494589686394,
0.022776082158088684,
0.022037608548998833,
0.04660157486796379,
0.025691110640764236,
0.08504107594490051
]
|
30,371 | networkx.algorithms.connectivity.connectivity | all_pairs_node_connectivity | Compute node connectivity between all pairs of nodes of G.
Parameters
----------
G : NetworkX graph
Undirected graph
nbunch: container
Container of nodes. If provided node connectivity will be computed
only over pairs of nodes in nbunch.
flow_func : function
A function for computing the maximum flow among a pair of nodes.
The function has to accept at least three parameters: a Digraph,
a source node, and a target node. And return a residual network
that follows NetworkX conventions (see :meth:`maximum_flow` for
details). If flow_func is None, the default maximum flow function
(:meth:`edmonds_karp`) is used. See below for details. The
choice of the default function may change from version
to version and should not be relied on. Default value: None.
Returns
-------
all_pairs : dict
A dictionary with node connectivity between all pairs of nodes
in G, or in nbunch if provided.
See also
--------
:meth:`local_node_connectivity`
:meth:`edge_connectivity`
:meth:`local_edge_connectivity`
:meth:`maximum_flow`
:meth:`edmonds_karp`
:meth:`preflow_push`
:meth:`shortest_augmenting_path`
| @nx._dispatchable
def edge_connectivity(G, s=None, t=None, flow_func=None, cutoff=None):
r"""Returns the edge connectivity of the graph or digraph G.
The edge connectivity is equal to the minimum number of edges that
must be removed to disconnect G or render it trivial. If source
and target nodes are provided, this function returns the local edge
connectivity: the minimum number of edges that must be removed to
break all paths from source to target in G.
Parameters
----------
G : NetworkX graph
Undirected or directed graph
s : node
Source node. Optional. Default value: None.
t : node
Target node. Optional. Default value: None.
flow_func : function
A function for computing the maximum flow among a pair of nodes.
The function has to accept at least three parameters: a Digraph,
a source node, and a target node. And return a residual network
that follows NetworkX conventions (see :meth:`maximum_flow` for
details). If flow_func is None, the default maximum flow function
(:meth:`edmonds_karp`) is used. See below for details. The
choice of the default function may change from version
to version and should not be relied on. Default value: None.
cutoff : integer, float, or None (default: None)
If specified, the maximum flow algorithm will terminate when the
flow value reaches or exceeds the cutoff. This only works for flows
that support the cutoff parameter (most do) and is ignored otherwise.
Returns
-------
K : integer
Edge connectivity for G, or local edge connectivity if source
and target were provided
Examples
--------
>>> # Platonic icosahedral graph is 5-edge-connected
>>> G = nx.icosahedral_graph()
>>> nx.edge_connectivity(G)
5
You can use alternative flow algorithms for the underlying
maximum flow computation. In dense networks the algorithm
:meth:`shortest_augmenting_path` will usually perform better
than the default :meth:`edmonds_karp`, which is faster for
sparse networks with highly skewed degree distributions.
Alternative flow functions have to be explicitly imported
from the flow package.
>>> from networkx.algorithms.flow import shortest_augmenting_path
>>> nx.edge_connectivity(G, flow_func=shortest_augmenting_path)
5
If you specify a pair of nodes (source and target) as parameters,
this function returns the value of local edge connectivity.
>>> nx.edge_connectivity(G, 3, 7)
5
If you need to perform several local computations among different
pairs of nodes on the same graph, it is recommended that you reuse
the data structures used in the maximum flow computations. See
:meth:`local_edge_connectivity` for details.
Notes
-----
This is a flow based implementation of global edge connectivity.
For undirected graphs the algorithm works by finding a 'small'
dominating set of nodes of G (see algorithm 7 in [1]_ ) and
computing local maximum flow (see :meth:`local_edge_connectivity`)
between an arbitrary node in the dominating set and the rest of
nodes in it. This is an implementation of algorithm 6 in [1]_ .
For directed graphs, the algorithm does n calls to the maximum
flow function. This is an implementation of algorithm 8 in [1]_ .
See also
--------
:meth:`local_edge_connectivity`
:meth:`local_node_connectivity`
:meth:`node_connectivity`
:meth:`maximum_flow`
:meth:`edmonds_karp`
:meth:`preflow_push`
:meth:`shortest_augmenting_path`
:meth:`k_edge_components`
:meth:`k_edge_subgraphs`
References
----------
.. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf
"""
if (s is not None and t is None) or (s is None and t is not None):
raise nx.NetworkXError("Both source and target must be specified.")
# Local edge connectivity
if s is not None and t is not None:
if s not in G:
raise nx.NetworkXError(f"node {s} not in graph")
if t not in G:
raise nx.NetworkXError(f"node {t} not in graph")
return local_edge_connectivity(G, s, t, flow_func=flow_func, cutoff=cutoff)
# Global edge connectivity
# reuse auxiliary digraph and residual network
H = build_auxiliary_edge_connectivity(G)
R = build_residual_network(H, "capacity")
kwargs = {"flow_func": flow_func, "auxiliary": H, "residual": R}
if G.is_directed():
# Algorithm 8 in [1]
if not nx.is_weakly_connected(G):
return 0
# initial value for \lambda is minimum degree
L = min(d for n, d in G.degree())
nodes = list(G)
n = len(nodes)
if cutoff is not None:
L = min(cutoff, L)
for i in range(n):
kwargs["cutoff"] = L
try:
L = min(L, local_edge_connectivity(G, nodes[i], nodes[i + 1], **kwargs))
except IndexError: # last node!
L = min(L, local_edge_connectivity(G, nodes[i], nodes[0], **kwargs))
return L
else: # undirected
# Algorithm 6 in [1]
if not nx.is_connected(G):
return 0
# initial value for \lambda is minimum degree
L = min(d for n, d in G.degree())
if cutoff is not None:
L = min(cutoff, L)
# A dominating set is \lambda-covering
# We need a dominating set with at least two nodes
for node in G:
D = nx.dominating_set(G, start_with=node)
v = D.pop()
if D:
break
else:
# in complete graphs the dominating sets will always be of one node
# thus we return min degree
return L
for w in D:
kwargs["cutoff"] = L
L = min(L, local_edge_connectivity(G, v, w, **kwargs))
return L
| (G, nbunch=None, flow_func=None, *, backend=None, **backend_kwargs) | [
-0.006537512876093388,
-0.039141926914453506,
0.022574687376618385,
0.039661604911088943,
0.012129216454923153,
0.011671902611851692,
-0.01825098879635334,
-0.020703855901956558,
0.03273953124880791,
-0.09512133151292801,
-0.03155467286705971,
0.019654111936688423,
0.034277770668268204,
0.004063859116286039,
-0.012264332734048367,
0.029787776991724968,
-0.04147007316350937,
0.006901285145431757,
0.041657157242298126,
0.04088803753256798,
0.0022813735995441675,
-0.06959488987922668,
0.02951754629611969,
-0.027210189029574394,
-0.008590229786932468,
0.029974859207868576,
0.03161703422665596,
0.0025399120058864355,
-0.039994195103645325,
-0.008605820126831532,
-0.05013825371861458,
-0.012950303964316845,
-0.07520738244056702,
0.006631054449826479,
0.0341530479490757,
0.038809336721897125,
0.025110701099038124,
0.030889488756656647,
-0.04768538847565651,
-0.048891033977270126,
-0.0738770142197609,
0.0006866207113489509,
-0.0020644094329327345,
0.00418598297983408,
0.0301203690469265,
0.031159719452261925,
0.011547180823981762,
0.023011213168501854,
0.001365446369163692,
-0.029330462217330933,
-0.002138463081791997,
-0.026170838624238968,
-0.008273228071630001,
-0.0007710679201409221,
0.031928837299346924,
0.028727639466524124,
0.010575388558208942,
0.012669678777456284,
-0.005695639178156853,
-0.02681523561477661,
-0.000037595244066324085,
0.006849317811429501,
0.05778787285089493,
0.03766605257987976,
-0.08223339170217514,
0.013012664392590523,
-0.061945270746946335,
0.0016304806340485811,
-0.013740209862589836,
0.021223532035946846,
-0.00410023657605052,
-0.014436574652791023,
0.01316856686025858,
-0.04092961177229881,
0.005815164186060429,
-0.030889488756656647,
0.04519094526767731,
-0.029164167121052742,
-0.044193170964717865,
-0.052341677248477936,
0.04943149536848068,
-0.025505654513835907,
0.035192396491765976,
-0.00828881748020649,
0.07346127182245255,
-0.026711300015449524,
-0.019373487681150436,
0.051177602261304855,
-0.026856809854507446,
-0.05022140219807625,
0.025380931794643402,
0.0012192877475172281,
-0.021254710853099823,
0.031741756945848465,
0.019955523312091827,
0.012752827256917953,
-0.03286425396800041,
-0.04101276025176048,
0.07192303240299225,
-0.03710480406880379,
0.022242093458771706,
0.02723097614943981,
-0.09794836491346359,
0.025256209075450897,
-0.008122521452605724,
-0.09545392543077469,
-0.039162714034318924,
0.03885091096162796,
-0.020589526742696762,
-0.04963936656713486,
-0.01733636111021042,
0.010066106915473938,
0.024008989334106445,
0.01579812355339527,
-0.006158149801194668,
0.03138837590813637,
0.027043892070651054,
-0.02968384139239788,
-0.012337086722254753,
-0.01336604356765747,
-0.004783609416335821,
0.044692058116197586,
-0.013438798487186432,
-0.04726964607834816,
0.047643814235925674,
-0.01647370122373104,
0.007815913297235966,
0.002842622809112072,
0.010383108630776405,
-0.043777432292699814,
0.06398239731788635,
0.0012023982126265764,
0.0008282322087325156,
0.09354151785373688,
-0.009322971105575562,
-0.03895484656095505,
-0.04365270957350731,
0.07104998081922531,
0.005118799861520529,
0.00837196595966816,
0.018874600529670715,
-0.04265493154525757,
-0.03273953124880791,
0.03481823205947876,
0.022512326017022133,
-0.004887544550001621,
0.013875325210392475,
-0.017856037244200706,
0.05712268874049187,
0.03421540930867195,
-0.00862140953540802,
-0.05309000983834267,
-0.01270085945725441,
0.006631054449826479,
0.004949905443936586,
0.008683770895004272,
-0.020464805886149406,
0.01673353835940361,
-0.020870152860879898,
-0.0033025352749973536,
-0.043777432292699814,
-0.028228752315044403,
-0.023447740823030472,
0.00450038630515337,
-0.018697910010814667,
-0.02153533697128296,
0.04022285342216492,
0.012763220816850662,
-0.037811558693647385,
0.0037130785640329123,
-0.020558347925543785,
-0.01758580468595028,
-0.06431499123573303,
-0.018625155091285706,
0.02523542381823063,
0.02901865728199482,
0.021992649883031845,
0.006002247333526611,
-0.009177462197840214,
-0.003409068565815687,
0.0016070952406153083,
-0.02488204464316368,
0.00020251088426448405,
-0.0249028317630291,
0.04277965426445007,
0.04294595122337341,
0.0666431337594986,
-0.03303055092692375,
-0.0048485687002539635,
-0.02868606522679329,
-0.03176254406571388,
-0.0499303825199604,
0.0016980384243652225,
0.05878564715385437,
0.004266532603651285,
-0.024341581389307976,
0.013428404927253723,
0.035961516201496124,
-0.016691964119672775,
0.07466691732406616,
0.02658657915890217,
0.03756211698055267,
0.05296528711915016,
0.017263606190681458,
0.01580851711332798,
0.004554952494800091,
0.04273808002471924,
-0.004765420686453581,
-0.02976698987185955,
0.024487091228365898,
-0.04431789368391037,
-0.04884945973753929,
0.030411386862397194,
0.011422459036111832,
-0.030411386862397194,
0.010944358073174953,
-0.013054238632321358,
0.029974859207868576,
0.005659261718392372,
-0.01917601190507412,
-0.03020351752638817,
0.007374189794063568,
0.027043892070651054,
0.008974788710474968,
0.04598085209727287,
-0.06734989583492279,
-0.007368993014097214,
0.00011765769158955663,
0.07046794146299362,
-0.06452286243438721,
0.06277675181627274,
-0.004367869347333908,
0.054960839450359344,
0.022824130952358246,
0.016962194815278053,
0.0038949649315327406,
0.018219809979200363,
-0.0021696435287594795,
-0.03159624710679054,
-0.009645169600844383,
-0.04381900280714035,
-0.03743739426136017,
-0.019986703991889954,
0.00823685061186552,
0.01949821040034294,
-0.031180506572127342,
0.01641133986413479,
0.011651115491986275,
0.025193849578499794,
0.001617488800548017,
-0.06294304877519608,
-0.06897127628326416,
-0.03330077975988388,
-0.08260755240917206,
-0.00354418414644897,
-0.0660611018538475,
-0.023073574528098106,
0.021722419187426567,
-0.019799621775746346,
-0.0030323041137307882,
-0.01136009767651558,
-0.0072494675405323505,
-0.04026442766189575,
0.04793483018875122,
-0.03070240467786789,
-0.00437566451728344,
-0.015995599329471588,
-0.001270605600439012,
-0.048974182456731796,
-0.04851686581969261,
0.051925934851169586,
0.000921773724257946,
0.022740982472896576,
0.010346731171011925,
-0.043361689895391464,
-0.0442347452044487,
-0.00018480945436749607,
0.025671949610114098,
0.041761092841625214,
-0.037375032901763916,
-0.05284056439995766,
-0.00010994376498274505,
-0.04876631125807762,
-0.004856363870203495,
-0.04153243452310562,
0.02405056357383728,
-0.04593927785754204,
-0.12147925049066544,
-0.011952527798712254,
-0.04951464384794235,
0.048724737018346786,
-0.03785313293337822,
0.027542781084775925,
0.04265493154525757,
0.08639078587293625,
0.038476742804050446,
0.011526393704116344,
-0.048891033977270126,
0.029372036457061768,
0.024008989334106445,
0.0706758126616478,
-0.05005510523915291,
0.014280672185122967,
-0.03702165558934212,
0.01951899752020836,
-0.039308223873376846,
0.04036836326122284,
-0.010627355426549911,
0.02656579203903675,
0.004812191240489483,
-0.04261335730552673,
-0.02236681617796421,
0.008714951574802399,
-0.04356956109404564,
-0.027127040550112724,
-0.00958800595253706,
-0.03228221833705902,
-0.018282169476151466,
-0.0006382259889505804,
0.028374260291457176,
0.0390172079205513,
0.08069515228271484,
-0.061612680554389954,
0.03242772817611694,
-0.056457504630088806,
0.019207192584872246,
0.05903509259223938,
0.03093106299638748,
0.026773661375045776,
-0.00712474575266242,
-0.005726819857954979,
0.019695686176419258,
0.013386830687522888,
0.005835951305925846,
-0.05803731456398964,
0.06726674735546112,
0.059326108545064926,
-0.01122498232871294,
-0.02783379890024662,
-0.04976408928632736,
0.06086434796452522,
0.08738856762647629,
0.009645169600844383,
0.01984119601547718,
0.010726094245910645,
0.04381900280714035,
0.025547228753566742,
-0.011796624399721622,
0.01924876496195793,
-0.02203422412276268,
0.048891033977270126,
0.0926268920302391,
-0.020495986565947533,
-0.03633568435907364,
-0.017876824364066124,
0.06323406845331192,
-0.002073503565043211,
-0.0030764765106141567,
0.03373730927705765,
0.022678621113300323,
0.010237599723041058,
0.00413921196013689,
-0.002636051969602704,
-0.029829351231455803,
0.006636251229792833,
0.05005510523915291,
-0.005602097604423761,
0.06265202909708023,
0.00903715007007122,
-0.062444161623716354,
-0.03236536681652069,
-0.08248282968997955,
-0.0035701680462807417,
-0.009567218832671642,
-0.019477423280477524,
0.05163491889834404,
0.0038559893146157265,
-0.0029231724329292774,
0.03953688219189644,
0.04144928604364395,
0.02849898301064968,
0.02783379890024662,
-0.025942180305719376,
0.01155757438391447,
0.030556896701455116,
-0.025526441633701324,
0.02876921370625496,
-0.004749830346554518,
0.06514646857976913,
0.017845643684267998,
0.028706852346658707,
-0.036044664680957794,
0.0570395402610302,
-0.00422236043959856,
0.011297736316919327,
0.011890166439116001,
0.05853620171546936,
0.043278541415929794,
0.004393852781504393,
-0.01315817330032587,
0.00448219757527113,
0.05275741592049599,
0.04440104216337204,
-0.010965144261717796,
0.007571666035801172,
0.007576862815767527,
0.07749395072460175,
-0.008008193224668503,
0.021826354786753654,
0.0029075820930302143,
0.00030092435190454125,
0.06884656101465225,
-0.044608909636735916,
0.006870104931294918,
0.005017463117837906,
-0.05408778414130211,
-0.026295559480786324,
0.041740305721759796,
0.05600018799304962,
-0.025422506034374237,
0.037707626819610596,
-0.041927386075258255,
0.033176057040691376,
-0.012170790694653988,
-0.012867155484855175,
-0.04169873148202896,
-0.017949577420949936,
0.01425988506525755,
-0.036792997270822525,
0.07283766567707062,
-0.02658657915890217,
-0.008907231502234936,
0.04768538847565651,
-0.04190659895539284,
-0.028997870162129402,
0.014311851933598518,
0.020163394510746002,
-0.008902034722268581,
0.04415159672498703,
-0.002377513563260436,
0.02824953943490982,
-0.011630328372120857,
-0.029559120535850525,
-0.01038830541074276,
0.004235351923853159,
-0.051925934851169586,
-0.02338537946343422,
0.01950860396027565,
-0.03733345866203308,
0.00008184882608475164,
0.020880546420812607,
-0.03303055092692375,
0.0010575387859717011,
0.023697184398770332,
-0.1416010707616806,
0.03743739426136017,
0.021067628636956215,
0.029704628512263298,
-0.11274871230125427,
-0.0024840470869094133,
0.025380931794643402,
-0.0016304806340485811,
-0.024570239707827568,
-0.00799260288476944,
-0.04735279455780983,
-0.005209743045270443,
0.02161848358809948,
-0.013979259878396988,
-0.02556801587343216,
-0.023738758638501167,
0.04051386937499046,
-0.04943149536848068,
-0.09628540277481079,
0.008345982059836388,
0.056374356150627136,
0.02615005150437355,
-0.03095184825360775,
0.015320021659135818,
0.0031908052042126656,
-0.014914675615727901,
0.02263704687356949,
-0.03145073726773262,
0.03429855778813362,
-0.030494535341858864,
0.008886444382369518,
0.0010900185443460941,
0.0010731291258707643,
0.03799864277243614,
-0.019290339201688766,
-0.028187178075313568,
-0.02303200028836727,
-0.004570542369037867,
-0.002508731558918953,
0.009738711640238762,
0.0029231724329292774,
0.05363047122955322,
-0.01800154522061348,
-0.04130377620458603,
0.021847141906619072,
-0.0028971887659281492,
0.00020494687487371266,
0.039162714034318924,
-0.06319249421358109,
0.03774920105934143,
0.01883302628993988,
0.03188726305961609,
-0.008335588499903679,
0.02244996465742588,
0.04668761044740677,
0.04155322164297104,
0.06406554579734802,
0.010419486090540886,
0.08323116600513458,
0.08356375992298126,
0.010564994998276234,
0.007223484106361866,
0.03103499673306942,
0.004266532603651285,
0.024528665468096733,
-0.05121917650103569,
-0.0076028467155992985,
0.021639270707964897,
-0.007197500206530094,
0.04059701785445213,
-0.04248863458633423,
0.03776998817920685,
0.027521993964910507,
-0.010585782118141651,
-0.01783525012433529,
0.011464032344520092,
0.003484421642497182,
0.04531566798686981,
-0.039911046624183655,
0.0474359430372715,
-0.003707881784066558,
0.035691287368535995,
-0.05350574851036072,
-0.0033934784587472677,
-0.06431499123573303,
0.0059450832195580006,
-0.01565261371433735,
0.010159648023545742,
0.010071303695440292,
0.020288115367293358,
0.01691022701561451,
-0.033758096396923065,
0.05587546527385712,
0.015112152323126793,
0.0013745406176894903,
-0.05400463566184044,
0.000014717361409566365,
0.04988880828022957,
0.005638475064188242,
-0.02827032469213009,
0.08339746296405792,
-0.02515227533876896,
-0.001781186438165605,
0.032926615327596664,
-0.014498935081064701,
0.014239097945392132,
-0.06855554133653641,
-0.0285197701305151,
-0.019363094121217728,
-0.04240548983216286,
-0.006215314380824566,
-0.03843517228960991,
0.04415159672498703,
-0.06157110631465912,
-0.017003769055008888,
0.025006765499711037,
-0.03363337367773056,
0.01290872972458601,
-0.04080488905310631,
0.010383108630776405,
0.014530115760862827,
0.01640094630420208,
-0.025339357554912567,
-0.0054409983567893505,
0.027272548526525497,
-0.012274726293981075,
-0.011505606584250927,
-0.02935124933719635,
0.06290147453546524,
0.04036836326122284,
0.014914675615727901,
0.05238325148820877,
-0.03804021701216698,
-0.00015435974637512118,
-0.09088078141212463,
-0.022325241938233376,
-0.020589526742696762,
-0.05616648495197296,
0.007623633835464716,
-0.012929516844451427,
-0.02405056357383728,
0.02479889616370201,
0.008008193224668503,
0.05712268874049187,
0.07695348560810089,
-0.013948080129921436,
-0.05205065757036209,
-0.00479400297626853,
-0.030411386862397194,
-0.014187130145728588,
-0.03506767749786377,
-0.01325171533972025,
0.0052643087692558765,
-0.0313052274286747,
0.03321763128042221,
-0.06040703505277634,
0.007665207609534264,
0.01942545548081398,
-0.04155322164297104,
-0.07786811888217926,
-0.04115826636552811,
-0.013220534659922123,
-0.010798848234117031,
0.06631053984165192,
-0.01842767931520939,
-0.03392438963055611,
0.02278255671262741,
0.02808324247598648,
-0.01030515693128109,
-0.005266907159239054,
0.020890939980745316,
0.09337522089481354,
-0.019144831225275993,
-0.010175238363444805,
-0.023364592343568802,
0.027459632605314255,
-0.03303055092692375,
-0.04618872329592705,
0.0013251715572550893,
0.09038189053535461,
0.01169268973171711,
-0.09079763293266296,
0.06955331563949585,
0.01799115166068077,
-0.029974859207868576,
0.047311220318078995,
-0.0868065282702446,
0.0684308186173439,
-0.026170838624238968,
-0.005654064938426018,
-0.029974859207868576,
0.021743206307291985,
0.034423280507326126,
-0.006558299995958805,
0.02488204464316368,
-0.01632819138467312,
-0.02017378807067871,
0.026461856439709663,
0.036356471478939056,
-0.03926664963364601,
-0.011256163008511066,
0.028228752315044403,
0.03804021701216698,
0.00807575136423111,
0.030058007687330246,
-0.04244706407189369,
0.0023138534743338823,
0.02523542381823063,
0.06215314194560051,
0.008979985490441322,
0.009832252748310566,
-0.006750579457730055,
0.0595339797437191,
-0.07271294295787811,
-0.014893888495862484,
0.015029003843665123,
-0.05828676000237465,
-0.05999129265546799,
0.034776657819747925,
0.017034949734807014,
-0.03523397073149681,
-0.05446195229887962,
0.03716716170310974,
0.0013602495891973376,
-0.020204968750476837,
-0.036959294229745865,
0.04876631125807762,
0.050512418150901794,
-0.02766750194132328,
-0.03219906985759735,
0.01840689219534397,
-0.009385332465171814,
-0.044608909636735916,
-0.0578710176050663,
0.021743206307291985,
0.015746155753731728,
-0.010461059398949146,
-0.026711300015449524,
0.03413226082921028,
0.015029003843665123,
0.004931716714054346,
-0.012409841641783714,
-0.05180121585726738,
0.03517160937190056,
0.01370902918279171,
-0.04080488905310631,
0.04735279455780983,
0.014395000413060188,
-0.018614761531352997,
0.004365270957350731,
-0.00971272774040699,
-0.02515227533876896,
-0.03465193510055542,
0.021493762731552124,
-0.01257613766938448,
0.004541960544884205,
-0.032074347138404846,
-0.03795706853270531,
-0.0069220722652971745,
-0.019446242600679398,
0.0007087069097906351,
0.009276201017200947,
-0.004934315104037523,
-0.03203277289867401,
-0.0787411704659462,
0.04440104216337204,
-0.008366769179701805,
-0.018219809979200363,
-0.014207917265594006,
0.039329010993242264,
-0.0031908052042126656,
0.04514937475323677,
0.044442616403102875,
0.0032869449350982904,
-0.006225707940757275,
-0.017024556174874306,
-0.00254510878585279,
0.09678429365158081,
0.01859397441148758,
0.0781591385602951,
-0.004027482122182846,
-0.004905732814222574,
0.02590060792863369,
0.022262880578637123,
-0.03323841840028763,
0.021930288523435593,
0.023281443864107132,
-0.018022332340478897,
-0.06768248230218887,
-0.055127136409282684,
0.011858985759317875,
0.021971862763166428,
-0.022304454818367958,
0.029559120535850525,
-0.008387556299567223,
-0.025526441633701324,
0.01866672933101654,
0.004417238291352987,
0.04922362416982651,
-0.06955331563949585,
-0.03768683969974518,
0.0030141156166791916,
-0.058993518352508545,
-0.041844237595796585,
-0.029829351231455803,
-0.030141156166791916,
-0.04298752546310425,
-0.029995646327733994,
0.009915401227772236,
0.018781058490276337,
-0.01316856686025858,
0.04593927785754204,
0.016432126984000206,
0.059824999421834946
]
|
30,375 | networkx.algorithms.simple_paths | all_simple_edge_paths | Generate lists of edges for all simple paths in G from source to target.
A simple path is a path with no repeated nodes.
Parameters
----------
G : NetworkX graph
source : node
Starting node for path
target : nodes
Single node or iterable of nodes at which to end path
cutoff : integer, optional
Depth to stop the search. Only paths of length <= cutoff are returned.
Returns
-------
path_generator: generator
A generator that produces lists of simple paths. If there are no paths
between the source and target within the given cutoff the generator
produces no output.
For multigraphs, the list of edges have elements of the form `(u,v,k)`.
Where `k` corresponds to the edge key.
Examples
--------
Print the simple path edges of a Graph::
>>> g = nx.Graph([(1, 2), (2, 4), (1, 3), (3, 4)])
>>> for path in sorted(nx.all_simple_edge_paths(g, 1, 4)):
... print(path)
[(1, 2), (2, 4)]
[(1, 3), (3, 4)]
Print the simple path edges of a MultiGraph. Returned edges come with
their associated keys::
>>> mg = nx.MultiGraph()
>>> mg.add_edge(1, 2, key="k0")
'k0'
>>> mg.add_edge(1, 2, key="k1")
'k1'
>>> mg.add_edge(2, 3, key="k0")
'k0'
>>> for path in sorted(nx.all_simple_edge_paths(mg, 1, 3)):
... print(path)
[(1, 2, 'k0'), (2, 3, 'k0')]
[(1, 2, 'k1'), (2, 3, 'k0')]
When ``source`` is one of the targets, the empty path starting and ending at
``source`` without traversing any edge is considered a valid simple edge path
and is included in the results:
>>> G = nx.Graph()
>>> G.add_node(0)
>>> paths = list(nx.all_simple_edge_paths(G, 0, 0))
>>> for path in paths:
... print(path)
[]
>>> len(paths)
1
Notes
-----
This algorithm uses a modified depth-first search to generate the
paths [1]_. A single path can be found in $O(V+E)$ time but the
number of simple paths in a graph can be very large, e.g. $O(n!)$ in
the complete graph of order $n$.
References
----------
.. [1] R. Sedgewick, "Algorithms in C, Part 5: Graph Algorithms",
Addison Wesley Professional, 3rd ed., 2001.
See Also
--------
all_shortest_paths, shortest_path, all_simple_paths
| def _bidirectional_dijkstra(
G, source, target, weight="weight", ignore_nodes=None, ignore_edges=None
):
"""Dijkstra's algorithm for shortest paths using bidirectional search.
This function returns the shortest path between source and target
ignoring nodes and edges in the containers ignore_nodes and
ignore_edges.
This is a custom modification of the standard Dijkstra bidirectional
shortest path implementation at networkx.algorithms.weighted
Parameters
----------
G : NetworkX graph
source : node
Starting node.
target : node
Ending node.
weight: string, function, optional (default='weight')
Edge data key or weight function corresponding to the edge weight
ignore_nodes : container of nodes
nodes to ignore, optional
ignore_edges : container of edges
edges to ignore, optional
Returns
-------
length : number
Shortest path length.
Returns a tuple of two dictionaries keyed by node.
The first dictionary stores distance from the source.
The second stores the path from the source to that node.
Raises
------
NetworkXNoPath
If no path exists between source and target.
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
In practice bidirectional Dijkstra is much more than twice as fast as
ordinary Dijkstra.
Ordinary Dijkstra expands nodes in a sphere-like manner from the
source. The radius of this sphere will eventually be the length
of the shortest path. Bidirectional Dijkstra will expand nodes
from both the source and the target, making two spheres of half
this radius. Volume of the first sphere is pi*r*r while the
others are 2*pi*r/2*r/2, making up half the volume.
This algorithm is not guaranteed to work if edge weights
are negative or are floating point numbers
(overflows and roundoff errors can cause problems).
See Also
--------
shortest_path
shortest_path_length
"""
if ignore_nodes and (source in ignore_nodes or target in ignore_nodes):
raise nx.NetworkXNoPath(f"No path between {source} and {target}.")
if source == target:
if source not in G:
raise nx.NodeNotFound(f"Node {source} not in graph")
return (0, [source])
# handle either directed or undirected
if G.is_directed():
Gpred = G.predecessors
Gsucc = G.successors
else:
Gpred = G.neighbors
Gsucc = G.neighbors
# support optional nodes filter
if ignore_nodes:
def filter_iter(nodes):
def iterate(v):
for w in nodes(v):
if w not in ignore_nodes:
yield w
return iterate
Gpred = filter_iter(Gpred)
Gsucc = filter_iter(Gsucc)
# support optional edges filter
if ignore_edges:
if G.is_directed():
def filter_pred_iter(pred_iter):
def iterate(v):
for w in pred_iter(v):
if (w, v) not in ignore_edges:
yield w
return iterate
def filter_succ_iter(succ_iter):
def iterate(v):
for w in succ_iter(v):
if (v, w) not in ignore_edges:
yield w
return iterate
Gpred = filter_pred_iter(Gpred)
Gsucc = filter_succ_iter(Gsucc)
else:
def filter_iter(nodes):
def iterate(v):
for w in nodes(v):
if (v, w) not in ignore_edges and (w, v) not in ignore_edges:
yield w
return iterate
Gpred = filter_iter(Gpred)
Gsucc = filter_iter(Gsucc)
push = heappush
pop = heappop
# Init: Forward Backward
dists = [{}, {}] # dictionary of final distances
paths = [{source: [source]}, {target: [target]}] # dictionary of paths
fringe = [[], []] # heap of (distance, node) tuples for
# extracting next node to expand
seen = [{source: 0}, {target: 0}] # dictionary of distances to
# nodes seen
c = count()
# initialize fringe heap
push(fringe[0], (0, next(c), source))
push(fringe[1], (0, next(c), target))
# neighs for extracting correct neighbor information
neighs = [Gsucc, Gpred]
# variables to hold shortest discovered path
# finaldist = 1e30000
finalpath = []
dir = 1
while fringe[0] and fringe[1]:
# choose direction
# dir == 0 is forward direction and dir == 1 is back
dir = 1 - dir
# extract closest to expand
(dist, _, v) = pop(fringe[dir])
if v in dists[dir]:
# Shortest path to v has already been found
continue
# update distance
dists[dir][v] = dist # equal to seen[dir][v]
if v in dists[1 - dir]:
# if we have scanned v in both directions we are done
# we have now discovered the shortest path
return (finaldist, finalpath)
wt = _weight_function(G, weight)
for w in neighs[dir](v):
if dir == 0: # forward
minweight = wt(v, w, G.get_edge_data(v, w))
vwLength = dists[dir][v] + minweight
else: # back, must remember to change v,w->w,v
minweight = wt(w, v, G.get_edge_data(w, v))
vwLength = dists[dir][v] + minweight
if w in dists[dir]:
if vwLength < dists[dir][w]:
raise ValueError("Contradictory paths found: negative weights?")
elif w not in seen[dir] or vwLength < seen[dir][w]:
# relaxing
seen[dir][w] = vwLength
push(fringe[dir], (vwLength, next(c), w))
paths[dir][w] = paths[dir][v] + [w]
if w in seen[0] and w in seen[1]:
# see if this path is better than the already
# discovered shortest path
totaldist = seen[0][w] + seen[1][w]
if finalpath == [] or finaldist > totaldist:
finaldist = totaldist
revpath = paths[1][w][:]
revpath.reverse()
finalpath = paths[0][w] + revpath[1:]
raise nx.NetworkXNoPath(f"No path between {source} and {target}.")
| (G, source, target, cutoff=None, *, backend=None, **backend_kwargs) | [
-0.006689601112157106,
-0.017859874293208122,
-0.034568171948194504,
-0.03584537282586098,
-0.02661184035241604,
-0.0307993832975626,
-0.01804831437766552,
0.045811727643013,
0.07177449762821198,
-0.053056180477142334,
-0.029836248606443405,
0.029689684510231018,
0.021105220541357994,
0.016875801607966423,
-0.028328733518719673,
0.04151949658989906,
0.006621553562581539,
0.02562776766717434,
0.00709788640961051,
0.03368879109621048,
-0.014562183059751987,
-0.04970614239573479,
0.034295983612537384,
0.06741945445537567,
-0.03408660739660263,
-0.025502141565084457,
0.007490468677133322,
-0.009442911483347416,
-0.021733351051807404,
-0.019409265369176865,
0.03988635540008545,
-0.02816123142838478,
0.0020034778863191605,
-0.02472744509577751,
0.023408370092511177,
0.04710986837744713,
0.005134975537657738,
0.015137970447540283,
-0.04853363335132599,
-0.0679219588637352,
-0.05745309963822365,
-0.05083677917718887,
0.006700070109218359,
-0.0250833872705698,
0.03735288977622986,
0.04928738996386528,
0.00006228153506526724,
0.030359692871570587,
0.005137592554092407,
0.004582743160426617,
0.01863456889986992,
-0.0018830860499292612,
-0.01386076956987381,
0.03863009065389633,
0.012279972434043884,
0.029920000582933426,
-0.019147543236613274,
0.04208481311798096,
0.057118095457553864,
-0.04040979593992233,
0.035049740225076675,
0.009353925473988056,
0.07064386457204819,
0.034379735589027405,
-0.05284680053591728,
-0.003923205193132162,
-0.04277575761079788,
-0.035761624574661255,
-0.05431244149804115,
0.026130272075533867,
0.006077172700315714,
-0.020979594439268112,
-0.010013463906943798,
0.0018556052818894386,
-0.015452036634087563,
0.01417483575642109,
0.013180294074118137,
-0.01769237220287323,
0.009484786540269852,
-0.05887686461210251,
0.04447171464562416,
-0.03609662875533104,
-0.002868467476218939,
-0.07968895882368088,
0.03971885144710541,
0.018372848629951477,
0.018341440707445145,
0.017011895775794983,
-0.011473869904875755,
-0.03285127878189087,
-0.07248637825250626,
0.036075688898563385,
0.017388775944709778,
0.042712945491075516,
0.05364243686199188,
0.023240868002176285,
0.0033500350546091795,
-0.06670757383108139,
0.047570496797561646,
0.004234653431922197,
0.011934499256312847,
0.05406118929386139,
-0.06737758219242096,
0.03448442369699478,
0.002308383584022522,
-0.051632415503263474,
-0.02033052407205105,
0.0011319454060867429,
-0.006527333986014128,
-0.05435431748628616,
-0.057285599410533905,
0.004572274163365364,
0.021544912829995155,
-0.015326409600675106,
0.009484786540269852,
0.026172148063778877,
-0.006181861273944378,
0.019011449068784714,
0.012981385923922062,
-0.004391686525195837,
0.01587079092860222,
0.022612735629081726,
-0.0904509425163269,
-0.01969192363321781,
0.04158230870962143,
-0.02393181249499321,
0.03479848802089691,
0.008458837866783142,
0.04639798402786255,
0.019859425723552704,
0.019199887290596962,
0.03159501776099205,
-0.020466620102524757,
0.10644736140966415,
0.00029901679954491556,
0.009657522663474083,
-0.0687175914645195,
0.02950124628841877,
0.05473119765520096,
0.016792049631476402,
0.03601287677884102,
-0.10234356671571732,
0.06197564676403999,
0.012677788734436035,
0.01711658574640751,
-0.004331490490585566,
0.0017024982953444123,
0.006291784346103668,
0.04911988973617554,
0.03877665475010872,
0.028496235609054565,
-0.019493015483021736,
0.010060573928058147,
-0.0037426170893013477,
-0.0002553420199546963,
-0.039279159158468246,
-0.04669111222028732,
0.03530099242925644,
-0.0030856963712722063,
-0.0056060743518173695,
0.009558068588376045,
-0.0762132927775383,
0.028852175921201706,
-0.0019576766062527895,
-0.044011086225509644,
0.015242659486830235,
0.049622394144535065,
0.025920895859599113,
-0.022738361731171608,
0.033751603215932846,
0.0021474247332662344,
-0.04447171464562416,
-0.07407765090465546,
-0.021733351051807404,
-0.04576985165476799,
0.0363478809595108,
0.024183064699172974,
-0.007359608076512814,
0.007746955845504999,
-0.014499370008707047,
0.008898530155420303,
-0.05736934766173363,
0.013661861419677734,
-0.04706799238920212,
0.0533074326813221,
0.04861738160252571,
0.03056906908750534,
-0.03205564618110657,
0.0035096851643174887,
0.03768789395689964,
-0.04212668910622597,
-0.06453005224466324,
0.017284085974097252,
0.0631900355219841,
0.012646381743252277,
0.008218054659664631,
-0.005307711660861969,
0.01111792866140604,
-0.052302420139312744,
0.05288867652416229,
-0.005210874602198601,
-0.01760862208902836,
0.05117178335785866,
-0.012604506686329842,
0.005600839853286743,
-0.0027035828679800034,
-0.01970239356160164,
0.004745010286569595,
0.020927250385284424,
0.012824352830648422,
-0.03423317149281502,
-0.03247440233826637,
0.012918571941554546,
-0.05066927894949913,
-0.031218137592077255,
0.010704408399760723,
-0.026088397949934006,
0.060635633766651154,
0.04447171464562416,
-0.04208481311798096,
-0.005053841974586248,
0.0030124143231660128,
-0.019911769777536392,
-0.010353702120482922,
0.05611308664083481,
-0.06164064258337021,
0.03454723581671715,
0.010002994909882545,
0.04350857809185982,
-0.06930384784936905,
0.06369253993034363,
-0.029270930215716362,
0.07198387384414673,
-0.010908551514148712,
0.07441265136003494,
-0.04216856509447098,
-0.020382869988679886,
0.005962015595287085,
0.02847529761493206,
-0.0025360812433063984,
-0.03383535146713257,
-0.04652361199259758,
-0.03163689374923706,
-0.027595913037657738,
0.01769237220287323,
0.004307935480028391,
0.044764842838048935,
-0.01675017550587654,
0.040849488228559494,
0.006930384784936905,
-0.03971885144710541,
-0.0030176485888659954,
-0.029522182419896126,
-0.06607943773269653,
0.004946535918861628,
-0.03412847965955734,
-0.03274659067392349,
-0.036075688898563385,
-0.05703434720635414,
-0.019042855128645897,
-0.021733351051807404,
-0.021670538932085037,
-0.04355045408010483,
0.061389390379190445,
0.007438124623149633,
0.03659913316369057,
0.020340994000434875,
-0.027868103235960007,
-0.046188607811927795,
-0.0051297410391271114,
0.021063344553112984,
0.010908551514148712,
-0.03609662875533104,
0.03528005629777908,
-0.03239065036177635,
0.011379649862647057,
-0.025439327582716942,
0.05326555669307709,
-0.009720335714519024,
-0.0037190623115748167,
-0.09145595133304596,
0.0076317982748150826,
-0.004954387899488211,
0.003538474440574646,
-0.02816123142838478,
0.043382953852415085,
0.007014135830104351,
-0.05875123664736748,
0.013232638128101826,
-0.020215367898344994,
0.07730205357074738,
-0.001612204359844327,
0.029270930215716362,
-0.012709194794297218,
0.07906082272529602,
0.046062979847192764,
0.005043372977524996,
-0.07889332622289658,
0.01966051757335663,
0.02717715874314308,
0.019681455567479134,
-0.04292232170701027,
0.015242659486830235,
-0.048156753182411194,
-0.0007249685004353523,
0.006035297177731991,
0.02713528275489807,
-0.014289992861449718,
0.00300194532610476,
-0.01778659224510193,
-0.05644809082150459,
-0.035677872598171234,
0.008254695683717728,
-0.009762211702764034,
0.023952750489115715,
-0.07554329186677933,
-0.0248740091919899,
0.009699397720396519,
-0.007574219722300768,
0.04040979593992233,
-0.03827415034174919,
0.08919467777013779,
-0.06880134344100952,
0.03308159485459328,
-0.07219325751066208,
0.034610047936439514,
0.03613850101828575,
0.058499984443187714,
0.02535557746887207,
-0.020518964156508446,
0.035719748586416245,
0.020403806120157242,
-0.013839831575751305,
0.0089351711794734,
-0.048910509794950485,
0.06180814653635025,
0.07508265972137451,
0.023680560290813446,
-0.002975773299112916,
-0.011578558012843132,
0.07298889011144638,
0.03385629132390022,
-0.005836389027535915,
0.05020865052938461,
0.029878124594688416,
-0.022717425599694252,
0.019325513392686844,
-0.04489046707749367,
-0.004410007037222385,
-0.019482547417283058,
0.03368879109621048,
0.0592537447810173,
-0.017985500395298004,
-0.0015834149671718478,
0.047444868832826614,
0.003240111982449889,
-0.01743065007030964,
-0.010908551514148712,
0.010311826132237911,
0.023638684302568436,
-0.022089293226599693,
0.022968677803874016,
-0.033625975251197815,
0.016603611409664154,
-0.01751440204679966,
0.0001866401289589703,
-0.0020950804464519024,
0.0014368509873747826,
-0.02985718660056591,
-0.03243252635002136,
-0.020644590258598328,
-0.07554329186677933,
-0.01996411383152008,
0.03551037237048149,
0.00021575664868578315,
0.05280492454767227,
0.017859874293208122,
0.0006657540216110647,
0.016027823090553284,
0.058709364384412766,
-0.014216710813343525,
0.05276305228471756,
0.004090706817805767,
0.04040979593992233,
0.01764002814888954,
-0.028956864029169083,
0.09061844646930695,
0.0005633555119857192,
0.043341077864170074,
-0.01145293191075325,
-0.05267930030822754,
-0.044722966849803925,
0.038399774581193924,
0.023680560290813446,
0.006511630490422249,
-0.014143428765237331,
0.09212595969438553,
0.05062740296125412,
-0.026276836171746254,
-0.019231295213103294,
0.02183804102241993,
-0.01675017550587654,
-0.05050177872180939,
0.05418681725859642,
0.009322519414126873,
-0.021241314709186554,
0.07453827559947968,
0.03632694110274315,
0.04313170164823532,
0.03452629968523979,
-0.0391116589307785,
0.003038586350157857,
-0.017346899956464767,
0.012520755641162395,
-0.026528090238571167,
-0.046104855835437775,
-0.04277575761079788,
0.05695059522986412,
0.052260544151067734,
-0.005579901859164238,
0.024392442777752876,
-0.014677341096103191,
0.06427879631519318,
-0.0568668432533741,
0.035447556525468826,
-0.013839831575751305,
-0.003776641096919775,
-0.023157116025686264,
-0.0017208188073709607,
0.08048459142446518,
-0.00008628630166640505,
-0.03310253471136093,
0.021356472745537758,
-0.05004114657640457,
-0.00998205691576004,
0.016645485535264015,
0.022612735629081726,
-0.028140293434262276,
0.06892696768045425,
-0.011526213958859444,
-0.038127586245536804,
-0.004229418933391571,
-0.022570861503481865,
-0.010919020511209965,
0.011903093196451664,
-0.07248637825250626,
-0.01613251306116581,
0.004297466948628426,
0.034735675901174545,
-0.03685038536787033,
0.01966051757335663,
-0.0576624758541584,
0.01832050457596779,
0.0036065219901502132,
-0.08186648041009903,
0.022926801815629005,
-0.02196366712450981,
0.024120252579450607,
-0.10753612220287323,
0.025167137384414673,
0.05762059986591339,
-0.00782023835927248,
0.02464369498193264,
-0.01368279941380024,
-0.03605475276708603,
0.044639214873313904,
0.012112470343708992,
-0.024078376591205597,
-0.034693799912929535,
-0.03123907558619976,
0.044639214873313904,
-0.04694236442446709,
-0.07114636898040771,
-0.02950124628841877,
0.07152324914932251,
-0.012740601785480976,
-0.06113813817501068,
0.0076317982748150826,
0.01747252605855465,
-0.053139928728342056,
-0.006888509262353182,
-0.030464380979537964,
0.039593227207660675,
0.022570861503481865,
0.0038708606734871864,
-0.03906978294253349,
0.007500937674194574,
-0.010683471336960793,
0.019325513392686844,
-0.020435214042663574,
0.015075157396495342,
-0.016635017469525337,
0.03163689374923706,
-0.03329097107052803,
-0.003473044140264392,
0.06469754874706268,
-0.017263149842619896,
-0.03144845366477966,
0.07730205357074738,
-0.019451141357421875,
0.005820685997605324,
-0.03283034265041351,
-0.044639214873313904,
0.03984447941184044,
0.022759299725294113,
0.041875436902046204,
-0.020026927813887596,
0.02820310741662979,
-0.030820321291685104,
0.03333284705877304,
0.02468557097017765,
0.02134600467979908,
0.049664270132780075,
0.06587006151676178,
0.019063793122768402,
0.005417634733021259,
-0.021858979016542435,
0.03641069307923317,
0.022214919328689575,
-0.051088035106658936,
0.012332316488027573,
0.05263742431998253,
0.006663429085165262,
0.0074800001457333565,
-0.04505797103047371,
0.022340545430779457,
0.02063412219285965,
-0.04715174064040184,
0.030548131093382835,
-0.0006425262545235455,
0.007438124623149633,
0.04149855673313141,
0.016687361523509026,
0.044094834476709366,
0.04853363335132599,
0.03056906908750534,
0.05891874060034752,
-0.019796613603830338,
-0.02187991514801979,
-0.026549026370048523,
0.031071575358510017,
-0.011463400907814503,
-0.05200929194688797,
-0.014279523864388466,
0.03421223163604736,
0.02059224620461464,
0.02839154563844204,
0.010887613520026207,
-0.032411590218544006,
-0.05045990273356438,
-0.047570496797561646,
-0.013421077281236649,
0.027930917218327522,
0.041414808481931686,
0.07474765181541443,
-0.05205116793513298,
0.022089293226599693,
0.026088397949934006,
0.011013239622116089,
0.07864207029342651,
-0.04920363798737526,
-0.059379369020462036,
-0.0406610481441021,
-0.039237283170223236,
-0.010505500249564648,
-0.0012876696418970823,
0.02175428904592991,
0.01299185398966074,
0.029710622504353523,
0.008249460719525814,
-0.005265836138278246,
0.0319928340613842,
-0.011882155202329159,
-0.0042896149680018425,
-0.03488223999738693,
-0.015944072976708412,
-0.01782846823334694,
-0.037771645933389664,
0.020152553915977478,
-0.06716819852590561,
0.005017200950533152,
0.0022285585291683674,
0.03668288141489029,
0.049664270132780075,
0.008631574921309948,
-0.005647949408739805,
-0.03140657767653465,
0.04064011201262474,
-0.03421223163604736,
-0.0068780407309532166,
0.013284982182085514,
-0.06381816416978836,
0.044639214873313904,
-0.003473044140264392,
0.0036719522904604673,
-0.041372932493686676,
-0.010207138024270535,
0.01670829951763153,
0.05008302256464958,
-0.02633965015411377,
-0.04451359063386917,
0.0037138278130441904,
0.034735675901174545,
0.024099314585328102,
0.003957228735089302,
0.009887837804853916,
0.0015965010970830917,
-0.08274586498737335,
-0.015452036634087563,
-0.046188607811927795,
0.02321993000805378,
0.03172064200043678,
0.03029687888920307,
-0.03096688538789749,
-0.07520828396081924,
0.004773799795657396,
-0.011201679706573486,
0.011431993916630745,
-0.057201847434043884,
-0.018508942797780037,
0.005600839853286743,
-0.04648173600435257,
0.03404473140835762,
-0.009819789789617062,
-0.016467515379190445,
0.03209752216935158,
0.0349450521171093,
0.01544156763702631,
-0.04143574461340904,
0.02834967151284218,
-0.029920000582933426,
-0.08144772797822952,
0.016676893457770348,
0.058541860431432724,
-0.035363808274269104,
-0.022382421419024467,
0.06708445399999619,
-0.002714051865041256,
-0.029124366119503975,
0.020885374397039413,
-0.05221867188811302,
0.02717715874314308,
-0.02958499640226364,
-0.022612735629081726,
-0.03454723581671715,
-0.024183064699172974,
0.018686912953853607,
-0.012855758890509605,
-0.01863456889986992,
0.009887837804853916,
-0.0056113083846867085,
0.01559860073029995,
-0.010573548264801502,
-0.02455994486808777,
0.011013239622116089,
0.07277950644493103,
0.0032662840094417334,
-0.017493464052677155,
0.02282211370766163,
0.002013946883380413,
0.043299201875925064,
0.05025052651762962,
0.06059375777840614,
-0.042315129190683365,
-0.021984605118632317,
0.015902196988463402,
0.013494359329342842,
-0.03871384263038635,
0.015410160645842552,
-0.02512526325881481,
-0.04183356091380119,
-0.018153002485632896,
0.004755479283630848,
0.015305472537875175,
-0.0529305525124073,
-0.04447171464562416,
0.003938908223062754,
0.008908999152481556,
-0.018153002485632896,
-0.07072761654853821,
0.027909979224205017,
0.022047417238354683,
0.021461160853505135,
-0.0442204624414444,
0.007129293400794268,
0.03760414198040962,
-0.06272940337657928,
-0.06348316371440887,
0.042001064866781235,
-0.009364394471049309,
0.00219453452154994,
-0.04798925295472145,
0.03965603932738304,
0.02945937030017376,
-0.0034285513684153557,
-0.05762059986591339,
-0.015242659486830235,
-0.013243107125163078,
0.03274659067392349,
-0.06574443727731705,
0.05422868952155113,
0.029689684510231018,
-0.0025687962770462036,
-0.04170793667435646,
0.010212372057139874,
-0.010542141273617744,
-0.06511630862951279,
0.02393181249499321,
-0.025250889360904694,
0.02954312041401863,
-0.004789503291249275,
-0.03664100915193558,
-0.023743372410535812,
0.0046193841844797134,
0.02330368012189865,
-0.004551336634904146,
-0.01893816702067852,
-0.046230483800172806,
-0.021366942673921585,
0.012300909496843815,
-0.017315493896603584,
-0.03802289813756943,
-0.02527182549238205,
0.046104855835437775,
-0.07918645441532135,
0.018069250509142876,
0.0043602799996733665,
-0.0714813694357872,
-0.0270515326410532,
-0.025167137384414673,
-0.03530099242925644,
0.07516641169786453,
0.016729237511754036,
0.060635633766651154,
0.01836237870156765,
-0.0004589940363075584,
0.00627084681764245,
0.015650944784283638,
0.004321021493524313,
0.06348316371440887,
-0.0026433870662003756,
0.021366942673921585,
-0.06059375777840614,
0.00649592699483037,
-0.005244898609817028,
0.00555896433070302,
0.010877144522964954,
0.019178951159119606,
-0.015054219402372837,
-0.030045626685023308,
0.0442204624414444,
-0.007595157250761986,
0.04350857809185982,
-0.02638152614235878,
0.0270515326410532,
0.008898530155420303,
-0.03515442833304405,
-0.01974426954984665,
-0.03528005629777908,
-0.057159971445798874,
-0.04417858645319939,
-0.02071787230670452,
-0.03213939815759659,
0.036431629210710526,
-0.009076501242816448,
0.05058552697300911,
0.02950124628841877,
0.08961343765258789
]
|
30,376 | networkx.algorithms.simple_paths | all_simple_paths | Generate all simple paths in the graph G from source to target.
A simple path is a path with no repeated nodes.
Parameters
----------
G : NetworkX graph
source : node
Starting node for path
target : nodes
Single node or iterable of nodes at which to end path
cutoff : integer, optional
Depth to stop the search. Only paths of length <= cutoff are returned.
Returns
-------
path_generator: generator
A generator that produces lists of simple paths. If there are no paths
between the source and target within the given cutoff the generator
produces no output. If it is possible to traverse the same sequence of
nodes in multiple ways, namely through parallel edges, then it will be
returned multiple times (once for each viable edge combination).
Examples
--------
This iterator generates lists of nodes::
>>> G = nx.complete_graph(4)
>>> for path in nx.all_simple_paths(G, source=0, target=3):
... print(path)
...
[0, 1, 2, 3]
[0, 1, 3]
[0, 2, 1, 3]
[0, 2, 3]
[0, 3]
You can generate only those paths that are shorter than a certain
length by using the `cutoff` keyword argument::
>>> paths = nx.all_simple_paths(G, source=0, target=3, cutoff=2)
>>> print(list(paths))
[[0, 1, 3], [0, 2, 3], [0, 3]]
To get each path as the corresponding list of edges, you can use the
:func:`networkx.utils.pairwise` helper function::
>>> paths = nx.all_simple_paths(G, source=0, target=3)
>>> for path in map(nx.utils.pairwise, paths):
... print(list(path))
[(0, 1), (1, 2), (2, 3)]
[(0, 1), (1, 3)]
[(0, 2), (2, 1), (1, 3)]
[(0, 2), (2, 3)]
[(0, 3)]
Pass an iterable of nodes as target to generate all paths ending in any of several nodes::
>>> G = nx.complete_graph(4)
>>> for path in nx.all_simple_paths(G, source=0, target=[3, 2]):
... print(path)
...
[0, 1, 2]
[0, 1, 2, 3]
[0, 1, 3]
[0, 1, 3, 2]
[0, 2]
[0, 2, 1, 3]
[0, 2, 3]
[0, 3]
[0, 3, 1, 2]
[0, 3, 2]
The singleton path from ``source`` to itself is considered a simple path and is
included in the results:
>>> G = nx.empty_graph(5)
>>> list(nx.all_simple_paths(G, source=0, target=0))
[[0]]
>>> G = nx.path_graph(3)
>>> list(nx.all_simple_paths(G, source=0, target={0, 1, 2}))
[[0], [0, 1], [0, 1, 2]]
Iterate over each path from the root nodes to the leaf nodes in a
directed acyclic graph using a functional programming approach::
>>> from itertools import chain
>>> from itertools import product
>>> from itertools import starmap
>>> from functools import partial
>>>
>>> chaini = chain.from_iterable
>>>
>>> G = nx.DiGraph([(0, 1), (1, 2), (0, 3), (3, 2)])
>>> roots = (v for v, d in G.in_degree() if d == 0)
>>> leaves = (v for v, d in G.out_degree() if d == 0)
>>> all_paths = partial(nx.all_simple_paths, G)
>>> list(chaini(starmap(all_paths, product(roots, leaves))))
[[0, 1, 2], [0, 3, 2]]
The same list computed using an iterative approach::
>>> G = nx.DiGraph([(0, 1), (1, 2), (0, 3), (3, 2)])
>>> roots = (v for v, d in G.in_degree() if d == 0)
>>> leaves = (v for v, d in G.out_degree() if d == 0)
>>> all_paths = []
>>> for root in roots:
... for leaf in leaves:
... paths = nx.all_simple_paths(G, root, leaf)
... all_paths.extend(paths)
>>> all_paths
[[0, 1, 2], [0, 3, 2]]
Iterate over each path from the root nodes to the leaf nodes in a
directed acyclic graph passing all leaves together to avoid unnecessary
compute::
>>> G = nx.DiGraph([(0, 1), (2, 1), (1, 3), (1, 4)])
>>> roots = (v for v, d in G.in_degree() if d == 0)
>>> leaves = [v for v, d in G.out_degree() if d == 0]
>>> all_paths = []
>>> for root in roots:
... paths = nx.all_simple_paths(G, root, leaves)
... all_paths.extend(paths)
>>> all_paths
[[0, 1, 3], [0, 1, 4], [2, 1, 3], [2, 1, 4]]
If parallel edges offer multiple ways to traverse a given sequence of
nodes, this sequence of nodes will be returned multiple times:
>>> G = nx.MultiDiGraph([(0, 1), (0, 1), (1, 2)])
>>> list(nx.all_simple_paths(G, 0, 2))
[[0, 1, 2], [0, 1, 2]]
Notes
-----
This algorithm uses a modified depth-first search to generate the
paths [1]_. A single path can be found in $O(V+E)$ time but the
number of simple paths in a graph can be very large, e.g. $O(n!)$ in
the complete graph of order $n$.
This function does not check that a path exists between `source` and
`target`. For large graphs, this may result in very long runtimes.
Consider using `has_path` to check that a path exists between `source` and
`target` before calling this function on large graphs.
References
----------
.. [1] R. Sedgewick, "Algorithms in C, Part 5: Graph Algorithms",
Addison Wesley Professional, 3rd ed., 2001.
See Also
--------
all_shortest_paths, shortest_path, has_path
| def _bidirectional_dijkstra(
G, source, target, weight="weight", ignore_nodes=None, ignore_edges=None
):
"""Dijkstra's algorithm for shortest paths using bidirectional search.
This function returns the shortest path between source and target
ignoring nodes and edges in the containers ignore_nodes and
ignore_edges.
This is a custom modification of the standard Dijkstra bidirectional
shortest path implementation at networkx.algorithms.weighted
Parameters
----------
G : NetworkX graph
source : node
Starting node.
target : node
Ending node.
weight: string, function, optional (default='weight')
Edge data key or weight function corresponding to the edge weight
ignore_nodes : container of nodes
nodes to ignore, optional
ignore_edges : container of edges
edges to ignore, optional
Returns
-------
length : number
Shortest path length.
Returns a tuple of two dictionaries keyed by node.
The first dictionary stores distance from the source.
The second stores the path from the source to that node.
Raises
------
NetworkXNoPath
If no path exists between source and target.
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
In practice bidirectional Dijkstra is much more than twice as fast as
ordinary Dijkstra.
Ordinary Dijkstra expands nodes in a sphere-like manner from the
source. The radius of this sphere will eventually be the length
of the shortest path. Bidirectional Dijkstra will expand nodes
from both the source and the target, making two spheres of half
this radius. Volume of the first sphere is pi*r*r while the
others are 2*pi*r/2*r/2, making up half the volume.
This algorithm is not guaranteed to work if edge weights
are negative or are floating point numbers
(overflows and roundoff errors can cause problems).
See Also
--------
shortest_path
shortest_path_length
"""
if ignore_nodes and (source in ignore_nodes or target in ignore_nodes):
raise nx.NetworkXNoPath(f"No path between {source} and {target}.")
if source == target:
if source not in G:
raise nx.NodeNotFound(f"Node {source} not in graph")
return (0, [source])
# handle either directed or undirected
if G.is_directed():
Gpred = G.predecessors
Gsucc = G.successors
else:
Gpred = G.neighbors
Gsucc = G.neighbors
# support optional nodes filter
if ignore_nodes:
def filter_iter(nodes):
def iterate(v):
for w in nodes(v):
if w not in ignore_nodes:
yield w
return iterate
Gpred = filter_iter(Gpred)
Gsucc = filter_iter(Gsucc)
# support optional edges filter
if ignore_edges:
if G.is_directed():
def filter_pred_iter(pred_iter):
def iterate(v):
for w in pred_iter(v):
if (w, v) not in ignore_edges:
yield w
return iterate
def filter_succ_iter(succ_iter):
def iterate(v):
for w in succ_iter(v):
if (v, w) not in ignore_edges:
yield w
return iterate
Gpred = filter_pred_iter(Gpred)
Gsucc = filter_succ_iter(Gsucc)
else:
def filter_iter(nodes):
def iterate(v):
for w in nodes(v):
if (v, w) not in ignore_edges and (w, v) not in ignore_edges:
yield w
return iterate
Gpred = filter_iter(Gpred)
Gsucc = filter_iter(Gsucc)
push = heappush
pop = heappop
# Init: Forward Backward
dists = [{}, {}] # dictionary of final distances
paths = [{source: [source]}, {target: [target]}] # dictionary of paths
fringe = [[], []] # heap of (distance, node) tuples for
# extracting next node to expand
seen = [{source: 0}, {target: 0}] # dictionary of distances to
# nodes seen
c = count()
# initialize fringe heap
push(fringe[0], (0, next(c), source))
push(fringe[1], (0, next(c), target))
# neighs for extracting correct neighbor information
neighs = [Gsucc, Gpred]
# variables to hold shortest discovered path
# finaldist = 1e30000
finalpath = []
dir = 1
while fringe[0] and fringe[1]:
# choose direction
# dir == 0 is forward direction and dir == 1 is back
dir = 1 - dir
# extract closest to expand
(dist, _, v) = pop(fringe[dir])
if v in dists[dir]:
# Shortest path to v has already been found
continue
# update distance
dists[dir][v] = dist # equal to seen[dir][v]
if v in dists[1 - dir]:
# if we have scanned v in both directions we are done
# we have now discovered the shortest path
return (finaldist, finalpath)
wt = _weight_function(G, weight)
for w in neighs[dir](v):
if dir == 0: # forward
minweight = wt(v, w, G.get_edge_data(v, w))
vwLength = dists[dir][v] + minweight
else: # back, must remember to change v,w->w,v
minweight = wt(w, v, G.get_edge_data(w, v))
vwLength = dists[dir][v] + minweight
if w in dists[dir]:
if vwLength < dists[dir][w]:
raise ValueError("Contradictory paths found: negative weights?")
elif w not in seen[dir] or vwLength < seen[dir][w]:
# relaxing
seen[dir][w] = vwLength
push(fringe[dir], (vwLength, next(c), w))
paths[dir][w] = paths[dir][v] + [w]
if w in seen[0] and w in seen[1]:
# see if this path is better than the already
# discovered shortest path
totaldist = seen[0][w] + seen[1][w]
if finalpath == [] or finaldist > totaldist:
finaldist = totaldist
revpath = paths[1][w][:]
revpath.reverse()
finalpath = paths[0][w] + revpath[1:]
raise nx.NetworkXNoPath(f"No path between {source} and {target}.")
| (G, source, target, cutoff=None, *, backend=None, **backend_kwargs) | [
-0.006689601112157106,
-0.017859874293208122,
-0.034568171948194504,
-0.03584537282586098,
-0.02661184035241604,
-0.0307993832975626,
-0.01804831437766552,
0.045811727643013,
0.07177449762821198,
-0.053056180477142334,
-0.029836248606443405,
0.029689684510231018,
0.021105220541357994,
0.016875801607966423,
-0.028328733518719673,
0.04151949658989906,
0.006621553562581539,
0.02562776766717434,
0.00709788640961051,
0.03368879109621048,
-0.014562183059751987,
-0.04970614239573479,
0.034295983612537384,
0.06741945445537567,
-0.03408660739660263,
-0.025502141565084457,
0.007490468677133322,
-0.009442911483347416,
-0.021733351051807404,
-0.019409265369176865,
0.03988635540008545,
-0.02816123142838478,
0.0020034778863191605,
-0.02472744509577751,
0.023408370092511177,
0.04710986837744713,
0.005134975537657738,
0.015137970447540283,
-0.04853363335132599,
-0.0679219588637352,
-0.05745309963822365,
-0.05083677917718887,
0.006700070109218359,
-0.0250833872705698,
0.03735288977622986,
0.04928738996386528,
0.00006228153506526724,
0.030359692871570587,
0.005137592554092407,
0.004582743160426617,
0.01863456889986992,
-0.0018830860499292612,
-0.01386076956987381,
0.03863009065389633,
0.012279972434043884,
0.029920000582933426,
-0.019147543236613274,
0.04208481311798096,
0.057118095457553864,
-0.04040979593992233,
0.035049740225076675,
0.009353925473988056,
0.07064386457204819,
0.034379735589027405,
-0.05284680053591728,
-0.003923205193132162,
-0.04277575761079788,
-0.035761624574661255,
-0.05431244149804115,
0.026130272075533867,
0.006077172700315714,
-0.020979594439268112,
-0.010013463906943798,
0.0018556052818894386,
-0.015452036634087563,
0.01417483575642109,
0.013180294074118137,
-0.01769237220287323,
0.009484786540269852,
-0.05887686461210251,
0.04447171464562416,
-0.03609662875533104,
-0.002868467476218939,
-0.07968895882368088,
0.03971885144710541,
0.018372848629951477,
0.018341440707445145,
0.017011895775794983,
-0.011473869904875755,
-0.03285127878189087,
-0.07248637825250626,
0.036075688898563385,
0.017388775944709778,
0.042712945491075516,
0.05364243686199188,
0.023240868002176285,
0.0033500350546091795,
-0.06670757383108139,
0.047570496797561646,
0.004234653431922197,
0.011934499256312847,
0.05406118929386139,
-0.06737758219242096,
0.03448442369699478,
0.002308383584022522,
-0.051632415503263474,
-0.02033052407205105,
0.0011319454060867429,
-0.006527333986014128,
-0.05435431748628616,
-0.057285599410533905,
0.004572274163365364,
0.021544912829995155,
-0.015326409600675106,
0.009484786540269852,
0.026172148063778877,
-0.006181861273944378,
0.019011449068784714,
0.012981385923922062,
-0.004391686525195837,
0.01587079092860222,
0.022612735629081726,
-0.0904509425163269,
-0.01969192363321781,
0.04158230870962143,
-0.02393181249499321,
0.03479848802089691,
0.008458837866783142,
0.04639798402786255,
0.019859425723552704,
0.019199887290596962,
0.03159501776099205,
-0.020466620102524757,
0.10644736140966415,
0.00029901679954491556,
0.009657522663474083,
-0.0687175914645195,
0.02950124628841877,
0.05473119765520096,
0.016792049631476402,
0.03601287677884102,
-0.10234356671571732,
0.06197564676403999,
0.012677788734436035,
0.01711658574640751,
-0.004331490490585566,
0.0017024982953444123,
0.006291784346103668,
0.04911988973617554,
0.03877665475010872,
0.028496235609054565,
-0.019493015483021736,
0.010060573928058147,
-0.0037426170893013477,
-0.0002553420199546963,
-0.039279159158468246,
-0.04669111222028732,
0.03530099242925644,
-0.0030856963712722063,
-0.0056060743518173695,
0.009558068588376045,
-0.0762132927775383,
0.028852175921201706,
-0.0019576766062527895,
-0.044011086225509644,
0.015242659486830235,
0.049622394144535065,
0.025920895859599113,
-0.022738361731171608,
0.033751603215932846,
0.0021474247332662344,
-0.04447171464562416,
-0.07407765090465546,
-0.021733351051807404,
-0.04576985165476799,
0.0363478809595108,
0.024183064699172974,
-0.007359608076512814,
0.007746955845504999,
-0.014499370008707047,
0.008898530155420303,
-0.05736934766173363,
0.013661861419677734,
-0.04706799238920212,
0.0533074326813221,
0.04861738160252571,
0.03056906908750534,
-0.03205564618110657,
0.0035096851643174887,
0.03768789395689964,
-0.04212668910622597,
-0.06453005224466324,
0.017284085974097252,
0.0631900355219841,
0.012646381743252277,
0.008218054659664631,
-0.005307711660861969,
0.01111792866140604,
-0.052302420139312744,
0.05288867652416229,
-0.005210874602198601,
-0.01760862208902836,
0.05117178335785866,
-0.012604506686329842,
0.005600839853286743,
-0.0027035828679800034,
-0.01970239356160164,
0.004745010286569595,
0.020927250385284424,
0.012824352830648422,
-0.03423317149281502,
-0.03247440233826637,
0.012918571941554546,
-0.05066927894949913,
-0.031218137592077255,
0.010704408399760723,
-0.026088397949934006,
0.060635633766651154,
0.04447171464562416,
-0.04208481311798096,
-0.005053841974586248,
0.0030124143231660128,
-0.019911769777536392,
-0.010353702120482922,
0.05611308664083481,
-0.06164064258337021,
0.03454723581671715,
0.010002994909882545,
0.04350857809185982,
-0.06930384784936905,
0.06369253993034363,
-0.029270930215716362,
0.07198387384414673,
-0.010908551514148712,
0.07441265136003494,
-0.04216856509447098,
-0.020382869988679886,
0.005962015595287085,
0.02847529761493206,
-0.0025360812433063984,
-0.03383535146713257,
-0.04652361199259758,
-0.03163689374923706,
-0.027595913037657738,
0.01769237220287323,
0.004307935480028391,
0.044764842838048935,
-0.01675017550587654,
0.040849488228559494,
0.006930384784936905,
-0.03971885144710541,
-0.0030176485888659954,
-0.029522182419896126,
-0.06607943773269653,
0.004946535918861628,
-0.03412847965955734,
-0.03274659067392349,
-0.036075688898563385,
-0.05703434720635414,
-0.019042855128645897,
-0.021733351051807404,
-0.021670538932085037,
-0.04355045408010483,
0.061389390379190445,
0.007438124623149633,
0.03659913316369057,
0.020340994000434875,
-0.027868103235960007,
-0.046188607811927795,
-0.0051297410391271114,
0.021063344553112984,
0.010908551514148712,
-0.03609662875533104,
0.03528005629777908,
-0.03239065036177635,
0.011379649862647057,
-0.025439327582716942,
0.05326555669307709,
-0.009720335714519024,
-0.0037190623115748167,
-0.09145595133304596,
0.0076317982748150826,
-0.004954387899488211,
0.003538474440574646,
-0.02816123142838478,
0.043382953852415085,
0.007014135830104351,
-0.05875123664736748,
0.013232638128101826,
-0.020215367898344994,
0.07730205357074738,
-0.001612204359844327,
0.029270930215716362,
-0.012709194794297218,
0.07906082272529602,
0.046062979847192764,
0.005043372977524996,
-0.07889332622289658,
0.01966051757335663,
0.02717715874314308,
0.019681455567479134,
-0.04292232170701027,
0.015242659486830235,
-0.048156753182411194,
-0.0007249685004353523,
0.006035297177731991,
0.02713528275489807,
-0.014289992861449718,
0.00300194532610476,
-0.01778659224510193,
-0.05644809082150459,
-0.035677872598171234,
0.008254695683717728,
-0.009762211702764034,
0.023952750489115715,
-0.07554329186677933,
-0.0248740091919899,
0.009699397720396519,
-0.007574219722300768,
0.04040979593992233,
-0.03827415034174919,
0.08919467777013779,
-0.06880134344100952,
0.03308159485459328,
-0.07219325751066208,
0.034610047936439514,
0.03613850101828575,
0.058499984443187714,
0.02535557746887207,
-0.020518964156508446,
0.035719748586416245,
0.020403806120157242,
-0.013839831575751305,
0.0089351711794734,
-0.048910509794950485,
0.06180814653635025,
0.07508265972137451,
0.023680560290813446,
-0.002975773299112916,
-0.011578558012843132,
0.07298889011144638,
0.03385629132390022,
-0.005836389027535915,
0.05020865052938461,
0.029878124594688416,
-0.022717425599694252,
0.019325513392686844,
-0.04489046707749367,
-0.004410007037222385,
-0.019482547417283058,
0.03368879109621048,
0.0592537447810173,
-0.017985500395298004,
-0.0015834149671718478,
0.047444868832826614,
0.003240111982449889,
-0.01743065007030964,
-0.010908551514148712,
0.010311826132237911,
0.023638684302568436,
-0.022089293226599693,
0.022968677803874016,
-0.033625975251197815,
0.016603611409664154,
-0.01751440204679966,
0.0001866401289589703,
-0.0020950804464519024,
0.0014368509873747826,
-0.02985718660056591,
-0.03243252635002136,
-0.020644590258598328,
-0.07554329186677933,
-0.01996411383152008,
0.03551037237048149,
0.00021575664868578315,
0.05280492454767227,
0.017859874293208122,
0.0006657540216110647,
0.016027823090553284,
0.058709364384412766,
-0.014216710813343525,
0.05276305228471756,
0.004090706817805767,
0.04040979593992233,
0.01764002814888954,
-0.028956864029169083,
0.09061844646930695,
0.0005633555119857192,
0.043341077864170074,
-0.01145293191075325,
-0.05267930030822754,
-0.044722966849803925,
0.038399774581193924,
0.023680560290813446,
0.006511630490422249,
-0.014143428765237331,
0.09212595969438553,
0.05062740296125412,
-0.026276836171746254,
-0.019231295213103294,
0.02183804102241993,
-0.01675017550587654,
-0.05050177872180939,
0.05418681725859642,
0.009322519414126873,
-0.021241314709186554,
0.07453827559947968,
0.03632694110274315,
0.04313170164823532,
0.03452629968523979,
-0.0391116589307785,
0.003038586350157857,
-0.017346899956464767,
0.012520755641162395,
-0.026528090238571167,
-0.046104855835437775,
-0.04277575761079788,
0.05695059522986412,
0.052260544151067734,
-0.005579901859164238,
0.024392442777752876,
-0.014677341096103191,
0.06427879631519318,
-0.0568668432533741,
0.035447556525468826,
-0.013839831575751305,
-0.003776641096919775,
-0.023157116025686264,
-0.0017208188073709607,
0.08048459142446518,
-0.00008628630166640505,
-0.03310253471136093,
0.021356472745537758,
-0.05004114657640457,
-0.00998205691576004,
0.016645485535264015,
0.022612735629081726,
-0.028140293434262276,
0.06892696768045425,
-0.011526213958859444,
-0.038127586245536804,
-0.004229418933391571,
-0.022570861503481865,
-0.010919020511209965,
0.011903093196451664,
-0.07248637825250626,
-0.01613251306116581,
0.004297466948628426,
0.034735675901174545,
-0.03685038536787033,
0.01966051757335663,
-0.0576624758541584,
0.01832050457596779,
0.0036065219901502132,
-0.08186648041009903,
0.022926801815629005,
-0.02196366712450981,
0.024120252579450607,
-0.10753612220287323,
0.025167137384414673,
0.05762059986591339,
-0.00782023835927248,
0.02464369498193264,
-0.01368279941380024,
-0.03605475276708603,
0.044639214873313904,
0.012112470343708992,
-0.024078376591205597,
-0.034693799912929535,
-0.03123907558619976,
0.044639214873313904,
-0.04694236442446709,
-0.07114636898040771,
-0.02950124628841877,
0.07152324914932251,
-0.012740601785480976,
-0.06113813817501068,
0.0076317982748150826,
0.01747252605855465,
-0.053139928728342056,
-0.006888509262353182,
-0.030464380979537964,
0.039593227207660675,
0.022570861503481865,
0.0038708606734871864,
-0.03906978294253349,
0.007500937674194574,
-0.010683471336960793,
0.019325513392686844,
-0.020435214042663574,
0.015075157396495342,
-0.016635017469525337,
0.03163689374923706,
-0.03329097107052803,
-0.003473044140264392,
0.06469754874706268,
-0.017263149842619896,
-0.03144845366477966,
0.07730205357074738,
-0.019451141357421875,
0.005820685997605324,
-0.03283034265041351,
-0.044639214873313904,
0.03984447941184044,
0.022759299725294113,
0.041875436902046204,
-0.020026927813887596,
0.02820310741662979,
-0.030820321291685104,
0.03333284705877304,
0.02468557097017765,
0.02134600467979908,
0.049664270132780075,
0.06587006151676178,
0.019063793122768402,
0.005417634733021259,
-0.021858979016542435,
0.03641069307923317,
0.022214919328689575,
-0.051088035106658936,
0.012332316488027573,
0.05263742431998253,
0.006663429085165262,
0.0074800001457333565,
-0.04505797103047371,
0.022340545430779457,
0.02063412219285965,
-0.04715174064040184,
0.030548131093382835,
-0.0006425262545235455,
0.007438124623149633,
0.04149855673313141,
0.016687361523509026,
0.044094834476709366,
0.04853363335132599,
0.03056906908750534,
0.05891874060034752,
-0.019796613603830338,
-0.02187991514801979,
-0.026549026370048523,
0.031071575358510017,
-0.011463400907814503,
-0.05200929194688797,
-0.014279523864388466,
0.03421223163604736,
0.02059224620461464,
0.02839154563844204,
0.010887613520026207,
-0.032411590218544006,
-0.05045990273356438,
-0.047570496797561646,
-0.013421077281236649,
0.027930917218327522,
0.041414808481931686,
0.07474765181541443,
-0.05205116793513298,
0.022089293226599693,
0.026088397949934006,
0.011013239622116089,
0.07864207029342651,
-0.04920363798737526,
-0.059379369020462036,
-0.0406610481441021,
-0.039237283170223236,
-0.010505500249564648,
-0.0012876696418970823,
0.02175428904592991,
0.01299185398966074,
0.029710622504353523,
0.008249460719525814,
-0.005265836138278246,
0.0319928340613842,
-0.011882155202329159,
-0.0042896149680018425,
-0.03488223999738693,
-0.015944072976708412,
-0.01782846823334694,
-0.037771645933389664,
0.020152553915977478,
-0.06716819852590561,
0.005017200950533152,
0.0022285585291683674,
0.03668288141489029,
0.049664270132780075,
0.008631574921309948,
-0.005647949408739805,
-0.03140657767653465,
0.04064011201262474,
-0.03421223163604736,
-0.0068780407309532166,
0.013284982182085514,
-0.06381816416978836,
0.044639214873313904,
-0.003473044140264392,
0.0036719522904604673,
-0.041372932493686676,
-0.010207138024270535,
0.01670829951763153,
0.05008302256464958,
-0.02633965015411377,
-0.04451359063386917,
0.0037138278130441904,
0.034735675901174545,
0.024099314585328102,
0.003957228735089302,
0.009887837804853916,
0.0015965010970830917,
-0.08274586498737335,
-0.015452036634087563,
-0.046188607811927795,
0.02321993000805378,
0.03172064200043678,
0.03029687888920307,
-0.03096688538789749,
-0.07520828396081924,
0.004773799795657396,
-0.011201679706573486,
0.011431993916630745,
-0.057201847434043884,
-0.018508942797780037,
0.005600839853286743,
-0.04648173600435257,
0.03404473140835762,
-0.009819789789617062,
-0.016467515379190445,
0.03209752216935158,
0.0349450521171093,
0.01544156763702631,
-0.04143574461340904,
0.02834967151284218,
-0.029920000582933426,
-0.08144772797822952,
0.016676893457770348,
0.058541860431432724,
-0.035363808274269104,
-0.022382421419024467,
0.06708445399999619,
-0.002714051865041256,
-0.029124366119503975,
0.020885374397039413,
-0.05221867188811302,
0.02717715874314308,
-0.02958499640226364,
-0.022612735629081726,
-0.03454723581671715,
-0.024183064699172974,
0.018686912953853607,
-0.012855758890509605,
-0.01863456889986992,
0.009887837804853916,
-0.0056113083846867085,
0.01559860073029995,
-0.010573548264801502,
-0.02455994486808777,
0.011013239622116089,
0.07277950644493103,
0.0032662840094417334,
-0.017493464052677155,
0.02282211370766163,
0.002013946883380413,
0.043299201875925064,
0.05025052651762962,
0.06059375777840614,
-0.042315129190683365,
-0.021984605118632317,
0.015902196988463402,
0.013494359329342842,
-0.03871384263038635,
0.015410160645842552,
-0.02512526325881481,
-0.04183356091380119,
-0.018153002485632896,
0.004755479283630848,
0.015305472537875175,
-0.0529305525124073,
-0.04447171464562416,
0.003938908223062754,
0.008908999152481556,
-0.018153002485632896,
-0.07072761654853821,
0.027909979224205017,
0.022047417238354683,
0.021461160853505135,
-0.0442204624414444,
0.007129293400794268,
0.03760414198040962,
-0.06272940337657928,
-0.06348316371440887,
0.042001064866781235,
-0.009364394471049309,
0.00219453452154994,
-0.04798925295472145,
0.03965603932738304,
0.02945937030017376,
-0.0034285513684153557,
-0.05762059986591339,
-0.015242659486830235,
-0.013243107125163078,
0.03274659067392349,
-0.06574443727731705,
0.05422868952155113,
0.029689684510231018,
-0.0025687962770462036,
-0.04170793667435646,
0.010212372057139874,
-0.010542141273617744,
-0.06511630862951279,
0.02393181249499321,
-0.025250889360904694,
0.02954312041401863,
-0.004789503291249275,
-0.03664100915193558,
-0.023743372410535812,
0.0046193841844797134,
0.02330368012189865,
-0.004551336634904146,
-0.01893816702067852,
-0.046230483800172806,
-0.021366942673921585,
0.012300909496843815,
-0.017315493896603584,
-0.03802289813756943,
-0.02527182549238205,
0.046104855835437775,
-0.07918645441532135,
0.018069250509142876,
0.0043602799996733665,
-0.0714813694357872,
-0.0270515326410532,
-0.025167137384414673,
-0.03530099242925644,
0.07516641169786453,
0.016729237511754036,
0.060635633766651154,
0.01836237870156765,
-0.0004589940363075584,
0.00627084681764245,
0.015650944784283638,
0.004321021493524313,
0.06348316371440887,
-0.0026433870662003756,
0.021366942673921585,
-0.06059375777840614,
0.00649592699483037,
-0.005244898609817028,
0.00555896433070302,
0.010877144522964954,
0.019178951159119606,
-0.015054219402372837,
-0.030045626685023308,
0.0442204624414444,
-0.007595157250761986,
0.04350857809185982,
-0.02638152614235878,
0.0270515326410532,
0.008898530155420303,
-0.03515442833304405,
-0.01974426954984665,
-0.03528005629777908,
-0.057159971445798874,
-0.04417858645319939,
-0.02071787230670452,
-0.03213939815759659,
0.036431629210710526,
-0.009076501242816448,
0.05058552697300911,
0.02950124628841877,
0.08961343765258789
]
|
30,377 | networkx.algorithms.dag | all_topological_sorts | Returns a generator of _all_ topological sorts of the directed graph G.
A topological sort is a nonunique permutation of the nodes such that an
edge from u to v implies that u appears before v in the topological sort
order.
Parameters
----------
G : NetworkX DiGraph
A directed graph
Yields
------
topological_sort_order : list
a list of nodes in `G`, representing one of the topological sort orders
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` is not acyclic
Examples
--------
To enumerate all topological sorts of directed graph:
>>> DG = nx.DiGraph([(1, 2), (2, 3), (2, 4)])
>>> list(nx.all_topological_sorts(DG))
[[1, 2, 4, 3], [1, 2, 3, 4]]
Notes
-----
Implements an iterative version of the algorithm given in [1].
References
----------
.. [1] Knuth, Donald E., Szwarcfiter, Jayme L. (1974).
"A Structured Program to Generate All Topological Sorting Arrangements"
Information Processing Letters, Volume 2, Issue 6, 1974, Pages 153-157,
ISSN 0020-0190,
https://doi.org/10.1016/0020-0190(74)90001-5.
Elsevier (North-Holland), Amsterdam
| def transitive_closure_dag(G, topo_order=None):
"""Returns the transitive closure of a directed acyclic graph.
This function is faster than the function `transitive_closure`, but fails
if the graph has a cycle.
The transitive closure of G = (V,E) is a graph G+ = (V,E+) such that
for all v, w in V there is an edge (v, w) in E+ if and only if there
is a non-null path from v to w in G.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
topo_order: list or tuple, optional
A topological order for G (if None, the function will compute one)
Returns
-------
NetworkX DiGraph
The transitive closure of `G`
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` has a cycle
Examples
--------
>>> DG = nx.DiGraph([(1, 2), (2, 3)])
>>> TC = nx.transitive_closure_dag(DG)
>>> TC.edges()
OutEdgeView([(1, 2), (1, 3), (2, 3)])
Notes
-----
This algorithm is probably simple enough to be well-known but I didn't find
a mention in the literature.
"""
if topo_order is None:
topo_order = list(topological_sort(G))
TC = G.copy()
# idea: traverse vertices following a reverse topological order, connecting
# each vertex to its descendants at distance 2 as we go
for v in reversed(topo_order):
TC.add_edges_from((v, u) for u in nx.descendants_at_distance(TC, v, 2))
return TC
| (G, *, backend=None, **backend_kwargs) | [
-0.03272243216633797,
0.021181616932153702,
-0.02473534271121025,
0.007965097203850746,
-0.036276157945394516,
-0.03101593814790249,
-0.018947342410683632,
-0.01261396985501051,
0.09303022176027298,
-0.07768938690423965,
0.01213017012923956,
0.02828907035291195,
0.0004367938672658056,
-0.01176072284579277,
-0.03156131133437157,
0.022413106635212898,
-0.014038978144526482,
-0.017284832894802094,
0.0031820805743336678,
0.029432594776153564,
0.0009423092706128955,
-0.06410782039165497,
0.013467215932905674,
-0.02385570853948593,
-0.015683896839618683,
0.01657232828438282,
-0.047078076750040054,
0.03212428092956543,
-0.06055409088730812,
-0.03135019913315773,
0.031174272298812866,
-0.04538917914032936,
-0.09049687534570694,
0.013467215932905674,
0.05263737216591835,
0.0809968113899231,
-0.0004389929526951164,
0.018155671656131744,
-0.017126498743891716,
-0.06041334941983223,
0.01224452257156372,
-0.018401969224214554,
-0.011479239910840988,
-0.03242335468530655,
0.04591695964336395,
0.013405641540884972,
-0.009121817536652088,
0.038070615381002426,
-0.0373317189514637,
-0.04954105615615845,
0.08634499460458755,
-0.03722616285085678,
-0.0057572126388549805,
-0.01064358651638031,
0.015279264189302921,
0.03902062028646469,
0.019475124776363373,
0.059463344514369965,
0.06815414130687714,
-0.0177950207144022,
-0.00993987824767828,
-0.05517072230577469,
-0.0090426504611969,
0.035554856061935425,
-0.05098365992307663,
0.021181616932153702,
-0.036768753081560135,
-0.06013186648488045,
-0.021181616932153702,
0.007340556010603905,
-0.01367832813411951,
0.0202140174806118,
0.00559008214622736,
-0.07607085257768631,
-0.027374248951673508,
-0.07635234296321869,
0.02795480750501156,
-0.0452132523059845,
-0.028588145971298218,
-0.035115040838718414,
-0.03439373895525932,
-0.06843562424182892,
0.02343348227441311,
-0.008264172822237015,
0.06129298359155655,
-0.02798999287188053,
0.033707622438669205,
-0.0014645926421508193,
-0.06762635707855225,
-0.04074470326304436,
0.007833152078092098,
-0.03437614440917969,
-0.031191864982247353,
0.03272243216633797,
0.03747246041893959,
-0.008879917673766613,
-0.0009483567555435002,
-0.04852068051695824,
0.010089416056871414,
0.009948674589395523,
0.038950249552726746,
0.007560465019196272,
-0.08543017506599426,
-0.0063201794400811195,
0.02323996275663376,
-0.04535399377346039,
-0.017487147822976112,
0.016792237758636475,
-0.01734640635550022,
-0.08747092634439468,
-0.0024475851096212864,
-0.0012985615758225322,
0.09774506837129593,
-0.0388798788189888,
0.03154372051358223,
0.013115361332893372,
0.007731993682682514,
0.0006971109542064369,
-0.0003727454459294677,
-0.005678045563399792,
0.014144535176455975,
0.022184401750564575,
0.00108744902536273,
0.012710729613900185,
-0.0073097688145935535,
0.008057459257543087,
0.00937691144645214,
0.027620546519756317,
0.03441132977604866,
-0.010907476767897606,
0.06090594455599785,
-0.01373110618442297,
0.03333817422389984,
0.08170051872730255,
0.05165218189358711,
0.0038154178764671087,
-0.03237057849764824,
0.015420005656778812,
-0.020301980897784233,
0.02269458957016468,
-0.010150990448892117,
-0.061363354325294495,
-0.02153347060084343,
0.04936512932181358,
0.04978735372424126,
0.003960557747632265,
-0.005787999834865332,
-0.013273695483803749,
0.011927854269742966,
0.019264012575149536,
0.008510471321642399,
0.0038506032433360815,
-0.014848243445158005,
0.03261687606573105,
0.00016726813919376582,
-0.007815559394657612,
-0.043629907071590424,
0.07241157442331314,
-0.053728122264146805,
0.01210378110408783,
-0.03126223757863045,
0.047218821942806244,
-0.040076181292533875,
0.02473534271121025,
0.01667788438498974,
-0.0018593290587887168,
0.11414147168397903,
0.0062410118989646435,
-0.03149094060063362,
0.03140297904610634,
-0.05685962364077568,
-0.03071686252951622,
-0.00730097247287631,
-0.00483359582722187,
-0.006210224702954292,
0.029907599091529846,
0.0038374087307602167,
0.030558528378605843,
-0.01604454778134823,
0.021797360852360725,
-0.016545938327908516,
0.0006036497070454061,
-0.04574103280901909,
0.021199209615588188,
0.032440949231386185,
0.030998345464468002,
0.0412021167576313,
-0.04011136665940285,
0.0769856795668602,
-0.02095291204750538,
-0.05495961010456085,
0.012701933272182941,
0.037894684821367264,
0.023310333490371704,
0.07529677450656891,
-0.05590961501002312,
-0.029960377141833305,
0.037155792117118835,
-0.04767623171210289,
0.0715671256184578,
0.06396707892417908,
0.015059355646371841,
0.07191897928714752,
0.03335576876997948,
0.023697374388575554,
0.08155977725982666,
0.03430577367544174,
-0.03305669128894806,
-0.0237677451223135,
0.008668805472552776,
-0.012965823523700237,
-0.025527015328407288,
0.010661179199814796,
-0.03993543982505798,
-0.05172255262732506,
0.032247427850961685,
-0.038316912949085236,
0.013555179350078106,
0.04809845611453056,
0.0018725235713645816,
-0.026371464133262634,
0.03708542138338089,
0.02566775679588318,
-0.01690658926963806,
0.07044119387865067,
-0.07754864543676376,
-0.00041205412708222866,
0.011241738684475422,
0.02026679553091526,
-0.05949852988123894,
0.011039422824978828,
-0.007155832834541798,
0.03281039372086525,
-0.01973901502788067,
0.06196150556206703,
-0.04433361813426018,
-0.03513263165950775,
0.0031490942928940058,
0.018947342410683632,
0.01788298413157463,
-0.05073736235499382,
-0.006034297868609428,
-0.02464737929403782,
0.010573215782642365,
-0.016994552686810493,
-0.005132671445608139,
0.026652948930859566,
0.005985917989164591,
0.032493725419044495,
0.02638905681669712,
-0.05122995749115944,
-0.03560763597488403,
-0.04866142198443413,
-0.02960852161049843,
-0.03101593814790249,
-0.012552394531667233,
-0.004099100362509489,
-0.056789252907037735,
-0.005356978625059128,
0.017293628305196762,
0.0003515792195685208,
0.01725844293832779,
-0.057668887078762054,
0.06931525468826294,
0.00887112133204937,
-0.029520558193325996,
0.03421781212091446,
-0.0817708894610405,
-0.06688746064901352,
-0.005524109583348036,
-0.01657232828438282,
0.003855001414194703,
0.044016946107149124,
0.005409756675362587,
0.0037274544592946768,
-0.04092063009738922,
0.015481580048799515,
0.016106121242046356,
-0.00303254253230989,
-0.029960377141833305,
-0.041870638728141785,
0.029291853308677673,
-0.031191864982247353,
-0.02313440665602684,
-0.06273558735847473,
-0.006456522736698389,
-0.011303313076496124,
-0.026899246498942375,
0.022078845649957657,
0.01852511800825596,
0.07649308443069458,
0.0026257112622261047,
0.07290416955947876,
0.02478812076151371,
0.06305225193500519,
0.03532615303993225,
0.02638905681669712,
-0.02542145922780037,
-0.002388209803029895,
0.032986320555210114,
0.07353750616312027,
0.009508856572210789,
-0.016405196860432625,
-0.05175773799419403,
0.0018362385453656316,
0.004587297793477774,
0.009834322147071362,
-0.008013477548956871,
-0.029432594776153564,
0.04011136665940285,
-0.051687367260456085,
-0.04992809519171715,
-0.0704060047864914,
0.045072510838508606,
-0.06920970231294632,
-0.034200217574834824,
-0.03270483762025833,
-0.04936512932181358,
0.05439664423465729,
0.0117871118709445,
0.0023904088884592056,
0.015631118789315224,
-0.008541258051991463,
-0.006579671520739794,
-0.07649308443069458,
0.04686696454882622,
0.00969358067959547,
0.05784481391310692,
0.058548521250486374,
0.010230157524347305,
-0.005678045563399792,
0.03866876661777496,
0.005247024353593588,
0.05710592120885849,
-0.003074325155466795,
0.0707930475473404,
0.0966191366314888,
-0.029925191774964333,
0.015279264189302921,
-0.028218699619174004,
0.04563547670841217,
0.041870638728141785,
-0.02881685085594654,
0.009702377021312714,
-0.01232368964701891,
0.010027841664850712,
0.003028144361451268,
-0.0013832264812663198,
0.03705023601651192,
-0.0228001456707716,
0.04310212656855583,
0.038070615381002426,
-0.018208449706435204,
0.027303878217935562,
-0.03923173248767853,
0.06576152890920639,
0.049118831753730774,
-0.008655610494315624,
0.014962595887482166,
0.027814066037535667,
0.003382197581231594,
-0.022131623700261116,
0.019457532092928886,
-0.036276157945394516,
0.05517072230577469,
0.0032282613683491945,
-0.0090426504611969,
0.03743727505207062,
-0.020935319364070892,
-0.04450954496860504,
0.017082516103982925,
-0.011294516734778881,
0.040709517896175385,
0.009306540712714195,
-0.051300328224897385,
0.030435379594564438,
0.04778178781270981,
-0.05404479056596756,
0.053094781935214996,
0.03602986037731171,
-0.01996771991252899,
0.017575113102793694,
-0.008053060621023178,
0.031279828399419785,
0.020442722365260124,
0.015279264189302921,
0.04359472170472145,
0.00862482376396656,
0.023574223741889,
-0.027831658720970154,
-0.0056912400759756565,
-0.02702239528298378,
0.045424364507198334,
-0.004004539456218481,
0.000392262329114601,
-0.034288182854652405,
0.06614857167005539,
0.04461510106921196,
0.025738127529621124,
0.0029291852843016386,
-0.014593148604035378,
0.007683613803237677,
0.021938102319836617,
0.008959084749221802,
0.023679781705141068,
-0.03340854495763779,
0.012200540862977505,
0.03687430918216705,
0.06178557872772217,
0.048872534185647964,
-0.0037274544592946768,
0.006306984927505255,
0.03208909556269646,
-0.017232054844498634,
-0.02017883211374283,
-0.019756607711315155,
-0.07110971212387085,
0.0030017553362995386,
0.058689262717962265,
0.0023178388364613056,
0.048872534185647964,
0.02901037037372589,
0.02842981182038784,
-0.03898543491959572,
0.00460489047691226,
-0.03405947610735893,
0.03140297904610634,
0.039196547120809555,
-0.010379696264863014,
0.09211540222167969,
0.010757938958704472,
-0.03208909556269646,
0.013212121091783047,
-0.033320583403110504,
0.00010163910337723792,
0.020970504730939865,
0.014170924201607704,
0.008180608041584492,
0.039970625191926956,
0.06614857167005539,
-0.007696808315813541,
0.04025210812687874,
-0.02531590312719345,
-0.0608355738222599,
-0.011936650611460209,
-0.029467780143022537,
0.009033854119479656,
0.032933544367551804,
0.04915401712059975,
-0.022289957851171494,
0.04626881331205368,
0.04651511088013649,
-0.006751200649887323,
-0.011584796011447906,
-0.08514869213104248,
0.050033651292324066,
0.02464737929403782,
-0.005339385941624641,
-0.11864519864320755,
0.010212564840912819,
0.008616027422249317,
-0.03214187175035477,
0.059604085981845856,
-0.04528362303972244,
-0.016317233443260193,
-0.022219587117433548,
0.00261251674965024,
0.000926915614400059,
-0.040850259363651276,
-0.03259928151965141,
0.0514058843255043,
-0.03277520835399628,
-0.05925222858786583,
-0.04398176074028015,
0.04489658400416374,
0.01513852272182703,
-0.05312996730208397,
0.033267803490161896,
0.05731703341007233,
-0.03340854495763779,
0.02070661447942257,
-0.029573336243629456,
0.003544930135831237,
0.01115377526730299,
0.0026696929708123207,
0.0008988772751763463,
0.015279264189302921,
-0.020425129681825638,
0.011206553317606449,
-0.00045328703708946705,
0.001599836628884077,
-0.022976072505116463,
-0.0059463344514369965,
-0.011470443569123745,
0.006188233848661184,
0.038950249552726746,
-0.015903804451227188,
-0.035994675010442734,
0.009438485838472843,
0.006188233848661184,
-0.0015481580048799515,
0.042011380195617676,
-0.01817326433956623,
0.021111246198415756,
-0.000950555840972811,
-0.0361706018447876,
0.00955283921211958,
0.026371464133262634,
0.0127547113224864,
0.013994996435940266,
0.041096560657024384,
0.022852923721075058,
0.008761167526245117,
0.03398910537362099,
0.010168583132326603,
0.014760279096662998,
-0.023345518857240677,
0.004939151927828789,
0.024330710992217064,
-0.029538150876760483,
0.004191461950540543,
0.013132954016327858,
0.02070661447942257,
0.08057458698749542,
-0.011276924051344395,
-0.012983416207134724,
0.02139272913336754,
-0.03416503220796585,
-0.0069359238259494305,
-0.003039139788597822,
0.0004574103222694248,
0.03237057849764824,
-0.013933422043919563,
0.057281848043203354,
-0.0035801155027002096,
-0.05284848436713219,
-0.00796949490904808,
-0.024436267092823982,
-0.11604148149490356,
0.0005932039930485189,
0.014047774486243725,
0.04827438294887543,
0.015912601724267006,
0.013212121091783047,
0.03912617638707161,
-0.010819513350725174,
0.04616325721144676,
-0.04092063009738922,
-0.028201106935739517,
-0.010881087742745876,
-0.07902643084526062,
0.031139086931943893,
-0.012710729613900185,
0.02531590312719345,
0.03631134331226349,
-0.034288182854652405,
-0.027004802599549294,
0.04978735372424126,
-0.02142791450023651,
0.010467659682035446,
-0.05731703341007233,
-0.009702377021312714,
-0.06586708873510361,
-0.05302441120147705,
0.01462833397090435,
0.006887543946504593,
0.05122995749115944,
-0.009051446802914143,
0.03212428092956543,
-0.02294088713824749,
0.013907033018767834,
-0.08141903579235077,
0.012059799395501614,
-0.0021177218295633793,
-0.02095291204750538,
0.05073736235499382,
-0.01249082013964653,
0.011804705485701561,
0.03722616285085678,
-0.06168002262711525,
-0.019844571128487587,
-0.03576596826314926,
0.018261227756738663,
0.03891506418585777,
0.007626437582075596,
-0.0114000728353858,
-0.0007344954065047204,
0.03432336822152138,
0.0020814368035644293,
-0.03937247395515442,
0.01822604238986969,
-0.04039284959435463,
0.019563088193535805,
0.006830367725342512,
-0.0017669673543423414,
-0.015639914199709892,
-0.01081071700900793,
0.06741524487733841,
-0.01724964752793312,
-0.023451074957847595,
-0.038703951984643936,
0.005400960333645344,
0.028218699619174004,
0.016836218535900116,
-0.0694911852478981,
0.0019296997925266623,
0.008035467937588692,
-0.037402089685201645,
0.0694911852478981,
-0.039829883724451065,
-0.0021507081110030413,
0.017425574362277985,
-0.03659282624721527,
-0.04433361813426018,
-0.049118831753730774,
-0.010555623099207878,
-0.07508566230535507,
0.028939999639987946,
-0.07916717231273651,
0.004299217369407415,
0.01841956190764904,
-0.02570294216275215,
0.014848243445158005,
-0.033953920006752014,
-0.03912617638707161,
0.0808560699224472,
0.033707622438669205,
-0.046972520649433136,
0.002122120000422001,
0.05327071249485016,
-0.032335393130779266,
-0.020864948630332947,
-0.0062630027532577515,
0.035941895097494125,
0.015763062983751297,
-0.07951902598142624,
0.0013304483145475388,
0.024313118308782578,
-0.01836678385734558,
-0.027814066037535667,
-0.10689327865839005,
0.04503732547163963,
-0.03947803005576134,
0.0007988187717273831,
-0.050913289189338684,
-0.020724207162857056,
0.009834322147071362,
-0.04647992551326752,
-0.0052294316701591015,
-0.04285582900047302,
-0.013071379624307156,
0.0188593789935112,
0.03708542138338089,
0.004248638171702623,
0.013414437882602215,
0.06695783138275146,
0.04183545336127281,
-0.04472065716981888,
0.03460485115647316,
0.011496832594275475,
0.07825235277414322,
0.013660735450685024,
0.018542710691690445,
-0.01993253454566002,
-0.00199237372726202,
0.025826090946793556,
0.050139207392930984,
-0.06635968387126923,
-0.004820401314646006,
-0.04257434606552124,
-0.024471452459692955,
0.02313440665602684,
0.012666747905313969,
-0.027814066037535667,
-0.02244829200208187,
-0.00505350437015295,
0.03705023601651192,
0.02911592647433281,
0.012367671355605125,
-0.029907599091529846,
0.02735665626823902,
0.06449485570192337,
0.00710745295509696,
-0.045705847442150116,
-0.014988984912633896,
-0.014549166895449162,
-0.013994996435940266,
-0.03909099102020264,
0.06382633000612259,
-0.05330589786171913,
0.0384928397834301,
-0.0022980470675975084,
0.0073097688145935535,
-0.016440382227301598,
0.05787999927997589,
0.0056032766588032246,
-0.0016625105636194348,
0.014619537629187107,
0.016000565141439438,
-0.01910567842423916,
-0.0051414682529866695,
0.00224746810272336,
0.03402429074048996,
0.036944679915905,
-0.02570294216275215,
-0.005607674829661846,
-0.03430577367544174,
-0.03145575523376465,
0.002112224232405424,
0.017100108787417412,
-0.03460485115647316,
-0.03242335468530655,
-0.00606508506461978,
0.01599176973104477,
0.017751039937138557,
-0.049118831753730774,
-0.04127248749136925,
0.006491708103567362,
-0.044298432767391205,
-0.0021386132575571537,
0.019017713144421577,
0.03245854005217552,
-0.05745777487754822,
0.021515877917408943,
0.024225154891610146,
0.05200403556227684,
0.022852923721075058,
-0.035941895097494125,
-0.03143816441297531,
-0.029274260625243187,
-0.011945446953177452,
0.048626236617565155,
0.021814953535795212,
0.008013477548956871,
-0.019985312595963478,
-0.0038264133036136627,
-0.04778178781270981,
0.03361966088414192,
-0.041378043591976166,
0.03277520835399628,
-0.035062260925769806,
0.015463987365365028,
-0.05495961010456085,
0.02177976816892624,
-0.010230157524347305,
-0.01803252287209034,
-0.025597386062145233,
-0.0008268571109510958,
0.015270467847585678,
-0.01880660094320774,
0.0046004923060536385,
0.006390550173819065,
0.004758826922625303,
-0.08402276039123535,
-0.018595488741993904,
-0.010238953866064548,
-0.05714110657572746,
-0.020477907732129097,
-0.06227817386388779,
-0.06101150065660477,
-0.044192876666784286,
-0.013018601574003696,
0.015420005656778812,
-0.026265908032655716,
0.056155912578105927,
0.014320462010800838,
0.034200217574834824,
0.04957624152302742
]
|
30,380 | networkx.algorithms.dag | ancestors | Returns all nodes having a path to `source` in `G`.
Parameters
----------
G : NetworkX Graph
source : node in `G`
Returns
-------
set()
The ancestors of `source` in `G`
Raises
------
NetworkXError
If node `source` is not in `G`.
Examples
--------
>>> DG = nx.path_graph(5, create_using=nx.DiGraph)
>>> sorted(nx.ancestors(DG, 2))
[0, 1]
The `source` node is not an ancestor of itself, but can be included manually:
>>> sorted(nx.ancestors(DG, 2) | {2})
[0, 1, 2]
See also
--------
descendants
| def transitive_closure_dag(G, topo_order=None):
"""Returns the transitive closure of a directed acyclic graph.
This function is faster than the function `transitive_closure`, but fails
if the graph has a cycle.
The transitive closure of G = (V,E) is a graph G+ = (V,E+) such that
for all v, w in V there is an edge (v, w) in E+ if and only if there
is a non-null path from v to w in G.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
topo_order: list or tuple, optional
A topological order for G (if None, the function will compute one)
Returns
-------
NetworkX DiGraph
The transitive closure of `G`
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` has a cycle
Examples
--------
>>> DG = nx.DiGraph([(1, 2), (2, 3)])
>>> TC = nx.transitive_closure_dag(DG)
>>> TC.edges()
OutEdgeView([(1, 2), (1, 3), (2, 3)])
Notes
-----
This algorithm is probably simple enough to be well-known but I didn't find
a mention in the literature.
"""
if topo_order is None:
topo_order = list(topological_sort(G))
TC = G.copy()
# idea: traverse vertices following a reverse topological order, connecting
# each vertex to its descendants at distance 2 as we go
for v in reversed(topo_order):
TC.add_edges_from((v, u) for u in nx.descendants_at_distance(TC, v, 2))
return TC
| (G, source, *, backend=None, **backend_kwargs) | [
-0.03272243216633797,
0.021181616932153702,
-0.02473534271121025,
0.007965097203850746,
-0.036276157945394516,
-0.03101593814790249,
-0.018947342410683632,
-0.01261396985501051,
0.09303022176027298,
-0.07768938690423965,
0.01213017012923956,
0.02828907035291195,
0.0004367938672658056,
-0.01176072284579277,
-0.03156131133437157,
0.022413106635212898,
-0.014038978144526482,
-0.017284832894802094,
0.0031820805743336678,
0.029432594776153564,
0.0009423092706128955,
-0.06410782039165497,
0.013467215932905674,
-0.02385570853948593,
-0.015683896839618683,
0.01657232828438282,
-0.047078076750040054,
0.03212428092956543,
-0.06055409088730812,
-0.03135019913315773,
0.031174272298812866,
-0.04538917914032936,
-0.09049687534570694,
0.013467215932905674,
0.05263737216591835,
0.0809968113899231,
-0.0004389929526951164,
0.018155671656131744,
-0.017126498743891716,
-0.06041334941983223,
0.01224452257156372,
-0.018401969224214554,
-0.011479239910840988,
-0.03242335468530655,
0.04591695964336395,
0.013405641540884972,
-0.009121817536652088,
0.038070615381002426,
-0.0373317189514637,
-0.04954105615615845,
0.08634499460458755,
-0.03722616285085678,
-0.0057572126388549805,
-0.01064358651638031,
0.015279264189302921,
0.03902062028646469,
0.019475124776363373,
0.059463344514369965,
0.06815414130687714,
-0.0177950207144022,
-0.00993987824767828,
-0.05517072230577469,
-0.0090426504611969,
0.035554856061935425,
-0.05098365992307663,
0.021181616932153702,
-0.036768753081560135,
-0.06013186648488045,
-0.021181616932153702,
0.007340556010603905,
-0.01367832813411951,
0.0202140174806118,
0.00559008214622736,
-0.07607085257768631,
-0.027374248951673508,
-0.07635234296321869,
0.02795480750501156,
-0.0452132523059845,
-0.028588145971298218,
-0.035115040838718414,
-0.03439373895525932,
-0.06843562424182892,
0.02343348227441311,
-0.008264172822237015,
0.06129298359155655,
-0.02798999287188053,
0.033707622438669205,
-0.0014645926421508193,
-0.06762635707855225,
-0.04074470326304436,
0.007833152078092098,
-0.03437614440917969,
-0.031191864982247353,
0.03272243216633797,
0.03747246041893959,
-0.008879917673766613,
-0.0009483567555435002,
-0.04852068051695824,
0.010089416056871414,
0.009948674589395523,
0.038950249552726746,
0.007560465019196272,
-0.08543017506599426,
-0.0063201794400811195,
0.02323996275663376,
-0.04535399377346039,
-0.017487147822976112,
0.016792237758636475,
-0.01734640635550022,
-0.08747092634439468,
-0.0024475851096212864,
-0.0012985615758225322,
0.09774506837129593,
-0.0388798788189888,
0.03154372051358223,
0.013115361332893372,
0.007731993682682514,
0.0006971109542064369,
-0.0003727454459294677,
-0.005678045563399792,
0.014144535176455975,
0.022184401750564575,
0.00108744902536273,
0.012710729613900185,
-0.0073097688145935535,
0.008057459257543087,
0.00937691144645214,
0.027620546519756317,
0.03441132977604866,
-0.010907476767897606,
0.06090594455599785,
-0.01373110618442297,
0.03333817422389984,
0.08170051872730255,
0.05165218189358711,
0.0038154178764671087,
-0.03237057849764824,
0.015420005656778812,
-0.020301980897784233,
0.02269458957016468,
-0.010150990448892117,
-0.061363354325294495,
-0.02153347060084343,
0.04936512932181358,
0.04978735372424126,
0.003960557747632265,
-0.005787999834865332,
-0.013273695483803749,
0.011927854269742966,
0.019264012575149536,
0.008510471321642399,
0.0038506032433360815,
-0.014848243445158005,
0.03261687606573105,
0.00016726813919376582,
-0.007815559394657612,
-0.043629907071590424,
0.07241157442331314,
-0.053728122264146805,
0.01210378110408783,
-0.03126223757863045,
0.047218821942806244,
-0.040076181292533875,
0.02473534271121025,
0.01667788438498974,
-0.0018593290587887168,
0.11414147168397903,
0.0062410118989646435,
-0.03149094060063362,
0.03140297904610634,
-0.05685962364077568,
-0.03071686252951622,
-0.00730097247287631,
-0.00483359582722187,
-0.006210224702954292,
0.029907599091529846,
0.0038374087307602167,
0.030558528378605843,
-0.01604454778134823,
0.021797360852360725,
-0.016545938327908516,
0.0006036497070454061,
-0.04574103280901909,
0.021199209615588188,
0.032440949231386185,
0.030998345464468002,
0.0412021167576313,
-0.04011136665940285,
0.0769856795668602,
-0.02095291204750538,
-0.05495961010456085,
0.012701933272182941,
0.037894684821367264,
0.023310333490371704,
0.07529677450656891,
-0.05590961501002312,
-0.029960377141833305,
0.037155792117118835,
-0.04767623171210289,
0.0715671256184578,
0.06396707892417908,
0.015059355646371841,
0.07191897928714752,
0.03335576876997948,
0.023697374388575554,
0.08155977725982666,
0.03430577367544174,
-0.03305669128894806,
-0.0237677451223135,
0.008668805472552776,
-0.012965823523700237,
-0.025527015328407288,
0.010661179199814796,
-0.03993543982505798,
-0.05172255262732506,
0.032247427850961685,
-0.038316912949085236,
0.013555179350078106,
0.04809845611453056,
0.0018725235713645816,
-0.026371464133262634,
0.03708542138338089,
0.02566775679588318,
-0.01690658926963806,
0.07044119387865067,
-0.07754864543676376,
-0.00041205412708222866,
0.011241738684475422,
0.02026679553091526,
-0.05949852988123894,
0.011039422824978828,
-0.007155832834541798,
0.03281039372086525,
-0.01973901502788067,
0.06196150556206703,
-0.04433361813426018,
-0.03513263165950775,
0.0031490942928940058,
0.018947342410683632,
0.01788298413157463,
-0.05073736235499382,
-0.006034297868609428,
-0.02464737929403782,
0.010573215782642365,
-0.016994552686810493,
-0.005132671445608139,
0.026652948930859566,
0.005985917989164591,
0.032493725419044495,
0.02638905681669712,
-0.05122995749115944,
-0.03560763597488403,
-0.04866142198443413,
-0.02960852161049843,
-0.03101593814790249,
-0.012552394531667233,
-0.004099100362509489,
-0.056789252907037735,
-0.005356978625059128,
0.017293628305196762,
0.0003515792195685208,
0.01725844293832779,
-0.057668887078762054,
0.06931525468826294,
0.00887112133204937,
-0.029520558193325996,
0.03421781212091446,
-0.0817708894610405,
-0.06688746064901352,
-0.005524109583348036,
-0.01657232828438282,
0.003855001414194703,
0.044016946107149124,
0.005409756675362587,
0.0037274544592946768,
-0.04092063009738922,
0.015481580048799515,
0.016106121242046356,
-0.00303254253230989,
-0.029960377141833305,
-0.041870638728141785,
0.029291853308677673,
-0.031191864982247353,
-0.02313440665602684,
-0.06273558735847473,
-0.006456522736698389,
-0.011303313076496124,
-0.026899246498942375,
0.022078845649957657,
0.01852511800825596,
0.07649308443069458,
0.0026257112622261047,
0.07290416955947876,
0.02478812076151371,
0.06305225193500519,
0.03532615303993225,
0.02638905681669712,
-0.02542145922780037,
-0.002388209803029895,
0.032986320555210114,
0.07353750616312027,
0.009508856572210789,
-0.016405196860432625,
-0.05175773799419403,
0.0018362385453656316,
0.004587297793477774,
0.009834322147071362,
-0.008013477548956871,
-0.029432594776153564,
0.04011136665940285,
-0.051687367260456085,
-0.04992809519171715,
-0.0704060047864914,
0.045072510838508606,
-0.06920970231294632,
-0.034200217574834824,
-0.03270483762025833,
-0.04936512932181358,
0.05439664423465729,
0.0117871118709445,
0.0023904088884592056,
0.015631118789315224,
-0.008541258051991463,
-0.006579671520739794,
-0.07649308443069458,
0.04686696454882622,
0.00969358067959547,
0.05784481391310692,
0.058548521250486374,
0.010230157524347305,
-0.005678045563399792,
0.03866876661777496,
0.005247024353593588,
0.05710592120885849,
-0.003074325155466795,
0.0707930475473404,
0.0966191366314888,
-0.029925191774964333,
0.015279264189302921,
-0.028218699619174004,
0.04563547670841217,
0.041870638728141785,
-0.02881685085594654,
0.009702377021312714,
-0.01232368964701891,
0.010027841664850712,
0.003028144361451268,
-0.0013832264812663198,
0.03705023601651192,
-0.0228001456707716,
0.04310212656855583,
0.038070615381002426,
-0.018208449706435204,
0.027303878217935562,
-0.03923173248767853,
0.06576152890920639,
0.049118831753730774,
-0.008655610494315624,
0.014962595887482166,
0.027814066037535667,
0.003382197581231594,
-0.022131623700261116,
0.019457532092928886,
-0.036276157945394516,
0.05517072230577469,
0.0032282613683491945,
-0.0090426504611969,
0.03743727505207062,
-0.020935319364070892,
-0.04450954496860504,
0.017082516103982925,
-0.011294516734778881,
0.040709517896175385,
0.009306540712714195,
-0.051300328224897385,
0.030435379594564438,
0.04778178781270981,
-0.05404479056596756,
0.053094781935214996,
0.03602986037731171,
-0.01996771991252899,
0.017575113102793694,
-0.008053060621023178,
0.031279828399419785,
0.020442722365260124,
0.015279264189302921,
0.04359472170472145,
0.00862482376396656,
0.023574223741889,
-0.027831658720970154,
-0.0056912400759756565,
-0.02702239528298378,
0.045424364507198334,
-0.004004539456218481,
0.000392262329114601,
-0.034288182854652405,
0.06614857167005539,
0.04461510106921196,
0.025738127529621124,
0.0029291852843016386,
-0.014593148604035378,
0.007683613803237677,
0.021938102319836617,
0.008959084749221802,
0.023679781705141068,
-0.03340854495763779,
0.012200540862977505,
0.03687430918216705,
0.06178557872772217,
0.048872534185647964,
-0.0037274544592946768,
0.006306984927505255,
0.03208909556269646,
-0.017232054844498634,
-0.02017883211374283,
-0.019756607711315155,
-0.07110971212387085,
0.0030017553362995386,
0.058689262717962265,
0.0023178388364613056,
0.048872534185647964,
0.02901037037372589,
0.02842981182038784,
-0.03898543491959572,
0.00460489047691226,
-0.03405947610735893,
0.03140297904610634,
0.039196547120809555,
-0.010379696264863014,
0.09211540222167969,
0.010757938958704472,
-0.03208909556269646,
0.013212121091783047,
-0.033320583403110504,
0.00010163910337723792,
0.020970504730939865,
0.014170924201607704,
0.008180608041584492,
0.039970625191926956,
0.06614857167005539,
-0.007696808315813541,
0.04025210812687874,
-0.02531590312719345,
-0.0608355738222599,
-0.011936650611460209,
-0.029467780143022537,
0.009033854119479656,
0.032933544367551804,
0.04915401712059975,
-0.022289957851171494,
0.04626881331205368,
0.04651511088013649,
-0.006751200649887323,
-0.011584796011447906,
-0.08514869213104248,
0.050033651292324066,
0.02464737929403782,
-0.005339385941624641,
-0.11864519864320755,
0.010212564840912819,
0.008616027422249317,
-0.03214187175035477,
0.059604085981845856,
-0.04528362303972244,
-0.016317233443260193,
-0.022219587117433548,
0.00261251674965024,
0.000926915614400059,
-0.040850259363651276,
-0.03259928151965141,
0.0514058843255043,
-0.03277520835399628,
-0.05925222858786583,
-0.04398176074028015,
0.04489658400416374,
0.01513852272182703,
-0.05312996730208397,
0.033267803490161896,
0.05731703341007233,
-0.03340854495763779,
0.02070661447942257,
-0.029573336243629456,
0.003544930135831237,
0.01115377526730299,
0.0026696929708123207,
0.0008988772751763463,
0.015279264189302921,
-0.020425129681825638,
0.011206553317606449,
-0.00045328703708946705,
0.001599836628884077,
-0.022976072505116463,
-0.0059463344514369965,
-0.011470443569123745,
0.006188233848661184,
0.038950249552726746,
-0.015903804451227188,
-0.035994675010442734,
0.009438485838472843,
0.006188233848661184,
-0.0015481580048799515,
0.042011380195617676,
-0.01817326433956623,
0.021111246198415756,
-0.000950555840972811,
-0.0361706018447876,
0.00955283921211958,
0.026371464133262634,
0.0127547113224864,
0.013994996435940266,
0.041096560657024384,
0.022852923721075058,
0.008761167526245117,
0.03398910537362099,
0.010168583132326603,
0.014760279096662998,
-0.023345518857240677,
0.004939151927828789,
0.024330710992217064,
-0.029538150876760483,
0.004191461950540543,
0.013132954016327858,
0.02070661447942257,
0.08057458698749542,
-0.011276924051344395,
-0.012983416207134724,
0.02139272913336754,
-0.03416503220796585,
-0.0069359238259494305,
-0.003039139788597822,
0.0004574103222694248,
0.03237057849764824,
-0.013933422043919563,
0.057281848043203354,
-0.0035801155027002096,
-0.05284848436713219,
-0.00796949490904808,
-0.024436267092823982,
-0.11604148149490356,
0.0005932039930485189,
0.014047774486243725,
0.04827438294887543,
0.015912601724267006,
0.013212121091783047,
0.03912617638707161,
-0.010819513350725174,
0.04616325721144676,
-0.04092063009738922,
-0.028201106935739517,
-0.010881087742745876,
-0.07902643084526062,
0.031139086931943893,
-0.012710729613900185,
0.02531590312719345,
0.03631134331226349,
-0.034288182854652405,
-0.027004802599549294,
0.04978735372424126,
-0.02142791450023651,
0.010467659682035446,
-0.05731703341007233,
-0.009702377021312714,
-0.06586708873510361,
-0.05302441120147705,
0.01462833397090435,
0.006887543946504593,
0.05122995749115944,
-0.009051446802914143,
0.03212428092956543,
-0.02294088713824749,
0.013907033018767834,
-0.08141903579235077,
0.012059799395501614,
-0.0021177218295633793,
-0.02095291204750538,
0.05073736235499382,
-0.01249082013964653,
0.011804705485701561,
0.03722616285085678,
-0.06168002262711525,
-0.019844571128487587,
-0.03576596826314926,
0.018261227756738663,
0.03891506418585777,
0.007626437582075596,
-0.0114000728353858,
-0.0007344954065047204,
0.03432336822152138,
0.0020814368035644293,
-0.03937247395515442,
0.01822604238986969,
-0.04039284959435463,
0.019563088193535805,
0.006830367725342512,
-0.0017669673543423414,
-0.015639914199709892,
-0.01081071700900793,
0.06741524487733841,
-0.01724964752793312,
-0.023451074957847595,
-0.038703951984643936,
0.005400960333645344,
0.028218699619174004,
0.016836218535900116,
-0.0694911852478981,
0.0019296997925266623,
0.008035467937588692,
-0.037402089685201645,
0.0694911852478981,
-0.039829883724451065,
-0.0021507081110030413,
0.017425574362277985,
-0.03659282624721527,
-0.04433361813426018,
-0.049118831753730774,
-0.010555623099207878,
-0.07508566230535507,
0.028939999639987946,
-0.07916717231273651,
0.004299217369407415,
0.01841956190764904,
-0.02570294216275215,
0.014848243445158005,
-0.033953920006752014,
-0.03912617638707161,
0.0808560699224472,
0.033707622438669205,
-0.046972520649433136,
0.002122120000422001,
0.05327071249485016,
-0.032335393130779266,
-0.020864948630332947,
-0.0062630027532577515,
0.035941895097494125,
0.015763062983751297,
-0.07951902598142624,
0.0013304483145475388,
0.024313118308782578,
-0.01836678385734558,
-0.027814066037535667,
-0.10689327865839005,
0.04503732547163963,
-0.03947803005576134,
0.0007988187717273831,
-0.050913289189338684,
-0.020724207162857056,
0.009834322147071362,
-0.04647992551326752,
-0.0052294316701591015,
-0.04285582900047302,
-0.013071379624307156,
0.0188593789935112,
0.03708542138338089,
0.004248638171702623,
0.013414437882602215,
0.06695783138275146,
0.04183545336127281,
-0.04472065716981888,
0.03460485115647316,
0.011496832594275475,
0.07825235277414322,
0.013660735450685024,
0.018542710691690445,
-0.01993253454566002,
-0.00199237372726202,
0.025826090946793556,
0.050139207392930984,
-0.06635968387126923,
-0.004820401314646006,
-0.04257434606552124,
-0.024471452459692955,
0.02313440665602684,
0.012666747905313969,
-0.027814066037535667,
-0.02244829200208187,
-0.00505350437015295,
0.03705023601651192,
0.02911592647433281,
0.012367671355605125,
-0.029907599091529846,
0.02735665626823902,
0.06449485570192337,
0.00710745295509696,
-0.045705847442150116,
-0.014988984912633896,
-0.014549166895449162,
-0.013994996435940266,
-0.03909099102020264,
0.06382633000612259,
-0.05330589786171913,
0.0384928397834301,
-0.0022980470675975084,
0.0073097688145935535,
-0.016440382227301598,
0.05787999927997589,
0.0056032766588032246,
-0.0016625105636194348,
0.014619537629187107,
0.016000565141439438,
-0.01910567842423916,
-0.0051414682529866695,
0.00224746810272336,
0.03402429074048996,
0.036944679915905,
-0.02570294216275215,
-0.005607674829661846,
-0.03430577367544174,
-0.03145575523376465,
0.002112224232405424,
0.017100108787417412,
-0.03460485115647316,
-0.03242335468530655,
-0.00606508506461978,
0.01599176973104477,
0.017751039937138557,
-0.049118831753730774,
-0.04127248749136925,
0.006491708103567362,
-0.044298432767391205,
-0.0021386132575571537,
0.019017713144421577,
0.03245854005217552,
-0.05745777487754822,
0.021515877917408943,
0.024225154891610146,
0.05200403556227684,
0.022852923721075058,
-0.035941895097494125,
-0.03143816441297531,
-0.029274260625243187,
-0.011945446953177452,
0.048626236617565155,
0.021814953535795212,
0.008013477548956871,
-0.019985312595963478,
-0.0038264133036136627,
-0.04778178781270981,
0.03361966088414192,
-0.041378043591976166,
0.03277520835399628,
-0.035062260925769806,
0.015463987365365028,
-0.05495961010456085,
0.02177976816892624,
-0.010230157524347305,
-0.01803252287209034,
-0.025597386062145233,
-0.0008268571109510958,
0.015270467847585678,
-0.01880660094320774,
0.0046004923060536385,
0.006390550173819065,
0.004758826922625303,
-0.08402276039123535,
-0.018595488741993904,
-0.010238953866064548,
-0.05714110657572746,
-0.020477907732129097,
-0.06227817386388779,
-0.06101150065660477,
-0.044192876666784286,
-0.013018601574003696,
0.015420005656778812,
-0.026265908032655716,
0.056155912578105927,
0.014320462010800838,
0.034200217574834824,
0.04957624152302742
]
|
30,381 | networkx.algorithms.dag | antichains | Generates antichains from a directed acyclic graph (DAG).
An antichain is a subset of a partially ordered set such that any
two elements in the subset are incomparable.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
topo_order: list or tuple, optional
A topological order for G (if None, the function will compute one)
Yields
------
antichain : list
a list of nodes in `G` representing an antichain
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` contains a cycle
Examples
--------
>>> DG = nx.DiGraph([(1, 2), (1, 3)])
>>> list(nx.antichains(DG))
[[], [3], [2], [2, 3], [1]]
Notes
-----
This function was originally developed by Peter Jipsen and Franco Saliola
for the SAGE project. It's included in NetworkX with permission from the
authors. Original SAGE code at:
https://github.com/sagemath/sage/blob/master/src/sage/combinat/posets/hasse_diagram.py
References
----------
.. [1] Free Lattices, by R. Freese, J. Jezek and J. B. Nation,
AMS, Vol 42, 1995, p. 226.
| def transitive_closure_dag(G, topo_order=None):
"""Returns the transitive closure of a directed acyclic graph.
This function is faster than the function `transitive_closure`, but fails
if the graph has a cycle.
The transitive closure of G = (V,E) is a graph G+ = (V,E+) such that
for all v, w in V there is an edge (v, w) in E+ if and only if there
is a non-null path from v to w in G.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
topo_order: list or tuple, optional
A topological order for G (if None, the function will compute one)
Returns
-------
NetworkX DiGraph
The transitive closure of `G`
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` has a cycle
Examples
--------
>>> DG = nx.DiGraph([(1, 2), (2, 3)])
>>> TC = nx.transitive_closure_dag(DG)
>>> TC.edges()
OutEdgeView([(1, 2), (1, 3), (2, 3)])
Notes
-----
This algorithm is probably simple enough to be well-known but I didn't find
a mention in the literature.
"""
if topo_order is None:
topo_order = list(topological_sort(G))
TC = G.copy()
# idea: traverse vertices following a reverse topological order, connecting
# each vertex to its descendants at distance 2 as we go
for v in reversed(topo_order):
TC.add_edges_from((v, u) for u in nx.descendants_at_distance(TC, v, 2))
return TC
| (G, topo_order=None, *, backend=None, **backend_kwargs) | [
-0.03272243216633797,
0.021181616932153702,
-0.02473534271121025,
0.007965097203850746,
-0.036276157945394516,
-0.03101593814790249,
-0.018947342410683632,
-0.01261396985501051,
0.09303022176027298,
-0.07768938690423965,
0.01213017012923956,
0.02828907035291195,
0.0004367938672658056,
-0.01176072284579277,
-0.03156131133437157,
0.022413106635212898,
-0.014038978144526482,
-0.017284832894802094,
0.0031820805743336678,
0.029432594776153564,
0.0009423092706128955,
-0.06410782039165497,
0.013467215932905674,
-0.02385570853948593,
-0.015683896839618683,
0.01657232828438282,
-0.047078076750040054,
0.03212428092956543,
-0.06055409088730812,
-0.03135019913315773,
0.031174272298812866,
-0.04538917914032936,
-0.09049687534570694,
0.013467215932905674,
0.05263737216591835,
0.0809968113899231,
-0.0004389929526951164,
0.018155671656131744,
-0.017126498743891716,
-0.06041334941983223,
0.01224452257156372,
-0.018401969224214554,
-0.011479239910840988,
-0.03242335468530655,
0.04591695964336395,
0.013405641540884972,
-0.009121817536652088,
0.038070615381002426,
-0.0373317189514637,
-0.04954105615615845,
0.08634499460458755,
-0.03722616285085678,
-0.0057572126388549805,
-0.01064358651638031,
0.015279264189302921,
0.03902062028646469,
0.019475124776363373,
0.059463344514369965,
0.06815414130687714,
-0.0177950207144022,
-0.00993987824767828,
-0.05517072230577469,
-0.0090426504611969,
0.035554856061935425,
-0.05098365992307663,
0.021181616932153702,
-0.036768753081560135,
-0.06013186648488045,
-0.021181616932153702,
0.007340556010603905,
-0.01367832813411951,
0.0202140174806118,
0.00559008214622736,
-0.07607085257768631,
-0.027374248951673508,
-0.07635234296321869,
0.02795480750501156,
-0.0452132523059845,
-0.028588145971298218,
-0.035115040838718414,
-0.03439373895525932,
-0.06843562424182892,
0.02343348227441311,
-0.008264172822237015,
0.06129298359155655,
-0.02798999287188053,
0.033707622438669205,
-0.0014645926421508193,
-0.06762635707855225,
-0.04074470326304436,
0.007833152078092098,
-0.03437614440917969,
-0.031191864982247353,
0.03272243216633797,
0.03747246041893959,
-0.008879917673766613,
-0.0009483567555435002,
-0.04852068051695824,
0.010089416056871414,
0.009948674589395523,
0.038950249552726746,
0.007560465019196272,
-0.08543017506599426,
-0.0063201794400811195,
0.02323996275663376,
-0.04535399377346039,
-0.017487147822976112,
0.016792237758636475,
-0.01734640635550022,
-0.08747092634439468,
-0.0024475851096212864,
-0.0012985615758225322,
0.09774506837129593,
-0.0388798788189888,
0.03154372051358223,
0.013115361332893372,
0.007731993682682514,
0.0006971109542064369,
-0.0003727454459294677,
-0.005678045563399792,
0.014144535176455975,
0.022184401750564575,
0.00108744902536273,
0.012710729613900185,
-0.0073097688145935535,
0.008057459257543087,
0.00937691144645214,
0.027620546519756317,
0.03441132977604866,
-0.010907476767897606,
0.06090594455599785,
-0.01373110618442297,
0.03333817422389984,
0.08170051872730255,
0.05165218189358711,
0.0038154178764671087,
-0.03237057849764824,
0.015420005656778812,
-0.020301980897784233,
0.02269458957016468,
-0.010150990448892117,
-0.061363354325294495,
-0.02153347060084343,
0.04936512932181358,
0.04978735372424126,
0.003960557747632265,
-0.005787999834865332,
-0.013273695483803749,
0.011927854269742966,
0.019264012575149536,
0.008510471321642399,
0.0038506032433360815,
-0.014848243445158005,
0.03261687606573105,
0.00016726813919376582,
-0.007815559394657612,
-0.043629907071590424,
0.07241157442331314,
-0.053728122264146805,
0.01210378110408783,
-0.03126223757863045,
0.047218821942806244,
-0.040076181292533875,
0.02473534271121025,
0.01667788438498974,
-0.0018593290587887168,
0.11414147168397903,
0.0062410118989646435,
-0.03149094060063362,
0.03140297904610634,
-0.05685962364077568,
-0.03071686252951622,
-0.00730097247287631,
-0.00483359582722187,
-0.006210224702954292,
0.029907599091529846,
0.0038374087307602167,
0.030558528378605843,
-0.01604454778134823,
0.021797360852360725,
-0.016545938327908516,
0.0006036497070454061,
-0.04574103280901909,
0.021199209615588188,
0.032440949231386185,
0.030998345464468002,
0.0412021167576313,
-0.04011136665940285,
0.0769856795668602,
-0.02095291204750538,
-0.05495961010456085,
0.012701933272182941,
0.037894684821367264,
0.023310333490371704,
0.07529677450656891,
-0.05590961501002312,
-0.029960377141833305,
0.037155792117118835,
-0.04767623171210289,
0.0715671256184578,
0.06396707892417908,
0.015059355646371841,
0.07191897928714752,
0.03335576876997948,
0.023697374388575554,
0.08155977725982666,
0.03430577367544174,
-0.03305669128894806,
-0.0237677451223135,
0.008668805472552776,
-0.012965823523700237,
-0.025527015328407288,
0.010661179199814796,
-0.03993543982505798,
-0.05172255262732506,
0.032247427850961685,
-0.038316912949085236,
0.013555179350078106,
0.04809845611453056,
0.0018725235713645816,
-0.026371464133262634,
0.03708542138338089,
0.02566775679588318,
-0.01690658926963806,
0.07044119387865067,
-0.07754864543676376,
-0.00041205412708222866,
0.011241738684475422,
0.02026679553091526,
-0.05949852988123894,
0.011039422824978828,
-0.007155832834541798,
0.03281039372086525,
-0.01973901502788067,
0.06196150556206703,
-0.04433361813426018,
-0.03513263165950775,
0.0031490942928940058,
0.018947342410683632,
0.01788298413157463,
-0.05073736235499382,
-0.006034297868609428,
-0.02464737929403782,
0.010573215782642365,
-0.016994552686810493,
-0.005132671445608139,
0.026652948930859566,
0.005985917989164591,
0.032493725419044495,
0.02638905681669712,
-0.05122995749115944,
-0.03560763597488403,
-0.04866142198443413,
-0.02960852161049843,
-0.03101593814790249,
-0.012552394531667233,
-0.004099100362509489,
-0.056789252907037735,
-0.005356978625059128,
0.017293628305196762,
0.0003515792195685208,
0.01725844293832779,
-0.057668887078762054,
0.06931525468826294,
0.00887112133204937,
-0.029520558193325996,
0.03421781212091446,
-0.0817708894610405,
-0.06688746064901352,
-0.005524109583348036,
-0.01657232828438282,
0.003855001414194703,
0.044016946107149124,
0.005409756675362587,
0.0037274544592946768,
-0.04092063009738922,
0.015481580048799515,
0.016106121242046356,
-0.00303254253230989,
-0.029960377141833305,
-0.041870638728141785,
0.029291853308677673,
-0.031191864982247353,
-0.02313440665602684,
-0.06273558735847473,
-0.006456522736698389,
-0.011303313076496124,
-0.026899246498942375,
0.022078845649957657,
0.01852511800825596,
0.07649308443069458,
0.0026257112622261047,
0.07290416955947876,
0.02478812076151371,
0.06305225193500519,
0.03532615303993225,
0.02638905681669712,
-0.02542145922780037,
-0.002388209803029895,
0.032986320555210114,
0.07353750616312027,
0.009508856572210789,
-0.016405196860432625,
-0.05175773799419403,
0.0018362385453656316,
0.004587297793477774,
0.009834322147071362,
-0.008013477548956871,
-0.029432594776153564,
0.04011136665940285,
-0.051687367260456085,
-0.04992809519171715,
-0.0704060047864914,
0.045072510838508606,
-0.06920970231294632,
-0.034200217574834824,
-0.03270483762025833,
-0.04936512932181358,
0.05439664423465729,
0.0117871118709445,
0.0023904088884592056,
0.015631118789315224,
-0.008541258051991463,
-0.006579671520739794,
-0.07649308443069458,
0.04686696454882622,
0.00969358067959547,
0.05784481391310692,
0.058548521250486374,
0.010230157524347305,
-0.005678045563399792,
0.03866876661777496,
0.005247024353593588,
0.05710592120885849,
-0.003074325155466795,
0.0707930475473404,
0.0966191366314888,
-0.029925191774964333,
0.015279264189302921,
-0.028218699619174004,
0.04563547670841217,
0.041870638728141785,
-0.02881685085594654,
0.009702377021312714,
-0.01232368964701891,
0.010027841664850712,
0.003028144361451268,
-0.0013832264812663198,
0.03705023601651192,
-0.0228001456707716,
0.04310212656855583,
0.038070615381002426,
-0.018208449706435204,
0.027303878217935562,
-0.03923173248767853,
0.06576152890920639,
0.049118831753730774,
-0.008655610494315624,
0.014962595887482166,
0.027814066037535667,
0.003382197581231594,
-0.022131623700261116,
0.019457532092928886,
-0.036276157945394516,
0.05517072230577469,
0.0032282613683491945,
-0.0090426504611969,
0.03743727505207062,
-0.020935319364070892,
-0.04450954496860504,
0.017082516103982925,
-0.011294516734778881,
0.040709517896175385,
0.009306540712714195,
-0.051300328224897385,
0.030435379594564438,
0.04778178781270981,
-0.05404479056596756,
0.053094781935214996,
0.03602986037731171,
-0.01996771991252899,
0.017575113102793694,
-0.008053060621023178,
0.031279828399419785,
0.020442722365260124,
0.015279264189302921,
0.04359472170472145,
0.00862482376396656,
0.023574223741889,
-0.027831658720970154,
-0.0056912400759756565,
-0.02702239528298378,
0.045424364507198334,
-0.004004539456218481,
0.000392262329114601,
-0.034288182854652405,
0.06614857167005539,
0.04461510106921196,
0.025738127529621124,
0.0029291852843016386,
-0.014593148604035378,
0.007683613803237677,
0.021938102319836617,
0.008959084749221802,
0.023679781705141068,
-0.03340854495763779,
0.012200540862977505,
0.03687430918216705,
0.06178557872772217,
0.048872534185647964,
-0.0037274544592946768,
0.006306984927505255,
0.03208909556269646,
-0.017232054844498634,
-0.02017883211374283,
-0.019756607711315155,
-0.07110971212387085,
0.0030017553362995386,
0.058689262717962265,
0.0023178388364613056,
0.048872534185647964,
0.02901037037372589,
0.02842981182038784,
-0.03898543491959572,
0.00460489047691226,
-0.03405947610735893,
0.03140297904610634,
0.039196547120809555,
-0.010379696264863014,
0.09211540222167969,
0.010757938958704472,
-0.03208909556269646,
0.013212121091783047,
-0.033320583403110504,
0.00010163910337723792,
0.020970504730939865,
0.014170924201607704,
0.008180608041584492,
0.039970625191926956,
0.06614857167005539,
-0.007696808315813541,
0.04025210812687874,
-0.02531590312719345,
-0.0608355738222599,
-0.011936650611460209,
-0.029467780143022537,
0.009033854119479656,
0.032933544367551804,
0.04915401712059975,
-0.022289957851171494,
0.04626881331205368,
0.04651511088013649,
-0.006751200649887323,
-0.011584796011447906,
-0.08514869213104248,
0.050033651292324066,
0.02464737929403782,
-0.005339385941624641,
-0.11864519864320755,
0.010212564840912819,
0.008616027422249317,
-0.03214187175035477,
0.059604085981845856,
-0.04528362303972244,
-0.016317233443260193,
-0.022219587117433548,
0.00261251674965024,
0.000926915614400059,
-0.040850259363651276,
-0.03259928151965141,
0.0514058843255043,
-0.03277520835399628,
-0.05925222858786583,
-0.04398176074028015,
0.04489658400416374,
0.01513852272182703,
-0.05312996730208397,
0.033267803490161896,
0.05731703341007233,
-0.03340854495763779,
0.02070661447942257,
-0.029573336243629456,
0.003544930135831237,
0.01115377526730299,
0.0026696929708123207,
0.0008988772751763463,
0.015279264189302921,
-0.020425129681825638,
0.011206553317606449,
-0.00045328703708946705,
0.001599836628884077,
-0.022976072505116463,
-0.0059463344514369965,
-0.011470443569123745,
0.006188233848661184,
0.038950249552726746,
-0.015903804451227188,
-0.035994675010442734,
0.009438485838472843,
0.006188233848661184,
-0.0015481580048799515,
0.042011380195617676,
-0.01817326433956623,
0.021111246198415756,
-0.000950555840972811,
-0.0361706018447876,
0.00955283921211958,
0.026371464133262634,
0.0127547113224864,
0.013994996435940266,
0.041096560657024384,
0.022852923721075058,
0.008761167526245117,
0.03398910537362099,
0.010168583132326603,
0.014760279096662998,
-0.023345518857240677,
0.004939151927828789,
0.024330710992217064,
-0.029538150876760483,
0.004191461950540543,
0.013132954016327858,
0.02070661447942257,
0.08057458698749542,
-0.011276924051344395,
-0.012983416207134724,
0.02139272913336754,
-0.03416503220796585,
-0.0069359238259494305,
-0.003039139788597822,
0.0004574103222694248,
0.03237057849764824,
-0.013933422043919563,
0.057281848043203354,
-0.0035801155027002096,
-0.05284848436713219,
-0.00796949490904808,
-0.024436267092823982,
-0.11604148149490356,
0.0005932039930485189,
0.014047774486243725,
0.04827438294887543,
0.015912601724267006,
0.013212121091783047,
0.03912617638707161,
-0.010819513350725174,
0.04616325721144676,
-0.04092063009738922,
-0.028201106935739517,
-0.010881087742745876,
-0.07902643084526062,
0.031139086931943893,
-0.012710729613900185,
0.02531590312719345,
0.03631134331226349,
-0.034288182854652405,
-0.027004802599549294,
0.04978735372424126,
-0.02142791450023651,
0.010467659682035446,
-0.05731703341007233,
-0.009702377021312714,
-0.06586708873510361,
-0.05302441120147705,
0.01462833397090435,
0.006887543946504593,
0.05122995749115944,
-0.009051446802914143,
0.03212428092956543,
-0.02294088713824749,
0.013907033018767834,
-0.08141903579235077,
0.012059799395501614,
-0.0021177218295633793,
-0.02095291204750538,
0.05073736235499382,
-0.01249082013964653,
0.011804705485701561,
0.03722616285085678,
-0.06168002262711525,
-0.019844571128487587,
-0.03576596826314926,
0.018261227756738663,
0.03891506418585777,
0.007626437582075596,
-0.0114000728353858,
-0.0007344954065047204,
0.03432336822152138,
0.0020814368035644293,
-0.03937247395515442,
0.01822604238986969,
-0.04039284959435463,
0.019563088193535805,
0.006830367725342512,
-0.0017669673543423414,
-0.015639914199709892,
-0.01081071700900793,
0.06741524487733841,
-0.01724964752793312,
-0.023451074957847595,
-0.038703951984643936,
0.005400960333645344,
0.028218699619174004,
0.016836218535900116,
-0.0694911852478981,
0.0019296997925266623,
0.008035467937588692,
-0.037402089685201645,
0.0694911852478981,
-0.039829883724451065,
-0.0021507081110030413,
0.017425574362277985,
-0.03659282624721527,
-0.04433361813426018,
-0.049118831753730774,
-0.010555623099207878,
-0.07508566230535507,
0.028939999639987946,
-0.07916717231273651,
0.004299217369407415,
0.01841956190764904,
-0.02570294216275215,
0.014848243445158005,
-0.033953920006752014,
-0.03912617638707161,
0.0808560699224472,
0.033707622438669205,
-0.046972520649433136,
0.002122120000422001,
0.05327071249485016,
-0.032335393130779266,
-0.020864948630332947,
-0.0062630027532577515,
0.035941895097494125,
0.015763062983751297,
-0.07951902598142624,
0.0013304483145475388,
0.024313118308782578,
-0.01836678385734558,
-0.027814066037535667,
-0.10689327865839005,
0.04503732547163963,
-0.03947803005576134,
0.0007988187717273831,
-0.050913289189338684,
-0.020724207162857056,
0.009834322147071362,
-0.04647992551326752,
-0.0052294316701591015,
-0.04285582900047302,
-0.013071379624307156,
0.0188593789935112,
0.03708542138338089,
0.004248638171702623,
0.013414437882602215,
0.06695783138275146,
0.04183545336127281,
-0.04472065716981888,
0.03460485115647316,
0.011496832594275475,
0.07825235277414322,
0.013660735450685024,
0.018542710691690445,
-0.01993253454566002,
-0.00199237372726202,
0.025826090946793556,
0.050139207392930984,
-0.06635968387126923,
-0.004820401314646006,
-0.04257434606552124,
-0.024471452459692955,
0.02313440665602684,
0.012666747905313969,
-0.027814066037535667,
-0.02244829200208187,
-0.00505350437015295,
0.03705023601651192,
0.02911592647433281,
0.012367671355605125,
-0.029907599091529846,
0.02735665626823902,
0.06449485570192337,
0.00710745295509696,
-0.045705847442150116,
-0.014988984912633896,
-0.014549166895449162,
-0.013994996435940266,
-0.03909099102020264,
0.06382633000612259,
-0.05330589786171913,
0.0384928397834301,
-0.0022980470675975084,
0.0073097688145935535,
-0.016440382227301598,
0.05787999927997589,
0.0056032766588032246,
-0.0016625105636194348,
0.014619537629187107,
0.016000565141439438,
-0.01910567842423916,
-0.0051414682529866695,
0.00224746810272336,
0.03402429074048996,
0.036944679915905,
-0.02570294216275215,
-0.005607674829661846,
-0.03430577367544174,
-0.03145575523376465,
0.002112224232405424,
0.017100108787417412,
-0.03460485115647316,
-0.03242335468530655,
-0.00606508506461978,
0.01599176973104477,
0.017751039937138557,
-0.049118831753730774,
-0.04127248749136925,
0.006491708103567362,
-0.044298432767391205,
-0.0021386132575571537,
0.019017713144421577,
0.03245854005217552,
-0.05745777487754822,
0.021515877917408943,
0.024225154891610146,
0.05200403556227684,
0.022852923721075058,
-0.035941895097494125,
-0.03143816441297531,
-0.029274260625243187,
-0.011945446953177452,
0.048626236617565155,
0.021814953535795212,
0.008013477548956871,
-0.019985312595963478,
-0.0038264133036136627,
-0.04778178781270981,
0.03361966088414192,
-0.041378043591976166,
0.03277520835399628,
-0.035062260925769806,
0.015463987365365028,
-0.05495961010456085,
0.02177976816892624,
-0.010230157524347305,
-0.01803252287209034,
-0.025597386062145233,
-0.0008268571109510958,
0.015270467847585678,
-0.01880660094320774,
0.0046004923060536385,
0.006390550173819065,
0.004758826922625303,
-0.08402276039123535,
-0.018595488741993904,
-0.010238953866064548,
-0.05714110657572746,
-0.020477907732129097,
-0.06227817386388779,
-0.06101150065660477,
-0.044192876666784286,
-0.013018601574003696,
0.015420005656778812,
-0.026265908032655716,
0.056155912578105927,
0.014320462010800838,
0.034200217574834824,
0.04957624152302742
]
|
30,384 | networkx.drawing.layout | arf_layout | Arf layout for networkx
The attractive and repulsive forces (arf) layout [1]
improves the spring layout in three ways. First, it
prevents congestion of highly connected nodes due to
strong forcing between nodes. Second, it utilizes the
layout space more effectively by preventing large gaps
that spring layout tends to create. Lastly, the arf
layout represents symmetries in the layout better than
the default spring layout.
Parameters
----------
G : nx.Graph or nx.DiGraph
Networkx graph.
pos : dict
Initial position of the nodes. If set to None a
random layout will be used.
scaling : float
Scales the radius of the circular layout space.
a : float
Strength of springs between connected nodes. Should be larger than 1. The greater a, the clearer the separation ofunconnected sub clusters.
etol : float
Gradient sum of spring forces must be larger than `etol` before successful termination.
dt : float
Time step for force differential equation simulations.
max_iter : int
Max iterations before termination of the algorithm.
References
.. [1] "Self-Organization Applied to Dynamic Network Layout", M. Geipel,
International Journal of Modern Physics C, 2007, Vol 18, No 10, pp. 1537-1549.
https://doi.org/10.1142/S0129183107011558 https://arxiv.org/abs/0704.1748
Returns
-------
pos : dict
A dictionary of positions keyed by node.
Examples
--------
>>> G = nx.grid_graph((5, 5))
>>> pos = nx.arf_layout(G)
| def arf_layout(
G,
pos=None,
scaling=1,
a=1.1,
etol=1e-6,
dt=1e-3,
max_iter=1000,
):
"""Arf layout for networkx
The attractive and repulsive forces (arf) layout [1]
improves the spring layout in three ways. First, it
prevents congestion of highly connected nodes due to
strong forcing between nodes. Second, it utilizes the
layout space more effectively by preventing large gaps
that spring layout tends to create. Lastly, the arf
layout represents symmetries in the layout better than
the default spring layout.
Parameters
----------
G : nx.Graph or nx.DiGraph
Networkx graph.
pos : dict
Initial position of the nodes. If set to None a
random layout will be used.
scaling : float
Scales the radius of the circular layout space.
a : float
Strength of springs between connected nodes. Should be larger than 1. The greater a, the clearer the separation ofunconnected sub clusters.
etol : float
Gradient sum of spring forces must be larger than `etol` before successful termination.
dt : float
Time step for force differential equation simulations.
max_iter : int
Max iterations before termination of the algorithm.
References
.. [1] "Self-Organization Applied to Dynamic Network Layout", M. Geipel,
International Journal of Modern Physics C, 2007, Vol 18, No 10, pp. 1537-1549.
https://doi.org/10.1142/S0129183107011558 https://arxiv.org/abs/0704.1748
Returns
-------
pos : dict
A dictionary of positions keyed by node.
Examples
--------
>>> G = nx.grid_graph((5, 5))
>>> pos = nx.arf_layout(G)
"""
import warnings
import numpy as np
if a <= 1:
msg = "The parameter a should be larger than 1"
raise ValueError(msg)
pos_tmp = nx.random_layout(G)
if pos is None:
pos = pos_tmp
else:
for node in G.nodes():
if node not in pos:
pos[node] = pos_tmp[node].copy()
# Initialize spring constant matrix
N = len(G)
# No nodes no computation
if N == 0:
return pos
# init force of springs
K = np.ones((N, N)) - np.eye(N)
node_order = {node: i for i, node in enumerate(G)}
for x, y in G.edges():
if x != y:
idx, jdx = (node_order[i] for i in (x, y))
K[idx, jdx] = a
# vectorize values
p = np.asarray(list(pos.values()))
# equation 10 in [1]
rho = scaling * np.sqrt(N)
# looping variables
error = etol + 1
n_iter = 0
while error > etol:
diff = p[:, np.newaxis] - p[np.newaxis]
A = np.linalg.norm(diff, axis=-1)[..., np.newaxis]
# attraction_force - repulsions force
# suppress nans due to division; caused by diagonal set to zero.
# Does not affect the computation due to nansum
with warnings.catch_warnings():
warnings.simplefilter("ignore")
change = K[..., np.newaxis] * diff - rho / A * diff
change = np.nansum(change, axis=0)
p += change * dt
error = np.linalg.norm(change, axis=-1).sum()
if n_iter > max_iter:
break
n_iter += 1
return dict(zip(G.nodes(), p))
| (G, pos=None, scaling=1, a=1.1, etol=1e-06, dt=0.001, max_iter=1000) | [
0.050178270787000656,
0.01847580447793007,
-0.040095165371894836,
-0.04642181843519211,
0.03685275465250015,
0.040035851299762726,
-0.06472957134246826,
-0.05852154269814491,
-0.005229374393820763,
-0.024436699226498604,
-0.015223509632050991,
-0.0023107111919671297,
0.02016620710492134,
0.06259432435035706,
-0.016251590102910995,
0.025939278304576874,
0.017596004530787468,
0.01929629221558571,
-0.027718650177121162,
-0.029557334259152412,
0.025464778766036034,
-0.06737885624170303,
-0.016815058887004852,
0.01675574667751789,
0.018376950174570084,
-0.008254305459558964,
0.011565913446247578,
0.025978820398449898,
0.0027431973721832037,
0.012574223801493645,
0.045551903545856476,
-0.009242844767868519,
0.012277661822736263,
-0.01725001633167267,
0.01648884080350399,
-0.008842486888170242,
0.02077910117805004,
-0.019197437912225723,
-0.008788117207586765,
-0.035804904997348785,
0.07212384790182114,
0.015579383820295334,
-0.022874806076288223,
-0.041795454919338226,
0.024278532713651657,
0.046579986810684204,
-0.0012610057601705194,
0.049308355897665024,
-0.030545873567461967,
0.05247168242931366,
0.017675086855888367,
-0.06607398390769958,
0.014580958522856236,
0.006835751235485077,
0.0055852485820651054,
0.042151328176259995,
0.0017843139357864857,
0.014353594742715359,
0.06378057599067688,
-0.10731586068868637,
0.03491521626710892,
-0.00010171145549975336,
-0.014155887067317963,
-0.01874271035194397,
-0.04246766120195389,
-0.028568793088197708,
-0.010438977740705013,
-0.05266938731074333,
0.02194557897746563,
-0.015174082480370998,
-0.007092771586030722,
0.01920732483267784,
0.03368942812085152,
-0.04669861122965813,
0.034855905920267105,
0.01704242266714573,
0.07346826046705246,
-0.012593993917107582,
-0.0030570586677640676,
-0.05527913197875023,
0.003865189850330353,
-0.0034178756177425385,
0.021451309323310852,
-0.00841247197240591,
0.004631307907402515,
0.03200891241431236,
0.04887339845299721,
0.05923329293727875,
0.051008641719818115,
-0.07346826046705246,
0.040095165371894836,
-0.024021511897444725,
0.031653039157390594,
-0.010310468263924122,
-0.010478519834578037,
0.04511694610118866,
0.0330963060259819,
-0.12083908170461655,
0.02514844760298729,
-0.008970996364951134,
0.003136141924187541,
0.05235305801033974,
-0.09719321131706238,
-0.00035896344343200326,
-0.027857044711709023,
-0.018890991806983948,
-0.054132428020238876,
0.01956319808959961,
0.006618272513151169,
0.006178372539579868,
0.033353324979543686,
0.08469807356595993,
0.00487350020557642,
0.042902618646621704,
-0.024219220504164696,
0.009524579159915447,
0.0024157436564564705,
0.01468969788402319,
0.03712954744696617,
-0.011644996702671051,
-0.0015828990144655108,
0.013108034618198872,
-0.011674652807414532,
-0.024555323645472527,
0.019731249660253525,
0.009356527589261532,
-0.00848166923969984,
-0.00920330360531807,
0.010844279080629349,
-0.030348164960741997,
0.016409756615757942,
-0.015361905097961426,
0.02255847305059433,
0.031119225546717644,
0.014590844511985779,
-0.027501171454787254,
-0.026631256565451622,
-0.006301939953118563,
-0.05239259824156761,
0.00017191321239806712,
0.023487700149416924,
-0.017418067902326584,
-0.030763352289795876,
-0.0272046085447073,
-0.02943870797753334,
0.00019770792277995497,
0.03038770705461502,
-0.007878660224378109,
0.0034722452983260155,
-0.029418937861919403,
0.06223845109343529,
0.003707023337483406,
0.07030493766069412,
0.017329098656773567,
0.01134843472391367,
-0.01908869855105877,
-0.007636468391865492,
-0.03701092302799225,
-0.011496715247631073,
0.016607465222477913,
-0.07520809024572372,
-0.04472152888774872,
0.023270221427083015,
-0.013384825550019741,
-0.017062192782759666,
-0.0035167294554412365,
0.020798873156309128,
-0.008288904093205929,
-0.0014407964190468192,
-0.014096574857831001,
-0.024278532713651657,
-0.04756852611899376,
-0.03384759649634361,
-0.0591542087495327,
0.025583405047655106,
0.0014716882724314928,
-0.01648884080350399,
-0.031653039157390594,
0.021431537345051765,
-0.009445495903491974,
-0.009242844767868519,
-0.018110044300556183,
0.06749748438596725,
-0.02821291983127594,
-0.041004620492458344,
0.049980562180280685,
0.0017188232159242034,
-0.019523655995726585,
0.034381408244371414,
-0.0038948459550738335,
-0.029873665422201157,
-0.013780241832137108,
-0.04147912189364433,
0.04155820235610008,
-0.034045301377773285,
0.04313986748456955,
0.017062192782759666,
0.011743850074708462,
0.012752160429954529,
0.01847580447793007,
0.042151328176259995,
0.03074358031153679,
0.004475613124668598,
0.030269082635641098,
-0.013266201131045818,
0.01485775038599968,
0.01588583178818226,
-0.04804302379488945,
-0.009717344306409359,
0.03366965800523758,
-0.06409690529108047,
0.006440335419028997,
0.0376238152384758,
-0.04005562514066696,
-0.0036378256045281887,
0.036081694066524506,
-0.015579383820295334,
0.04772669076919556,
0.025642717257142067,
-0.03740633651614189,
-0.015856174752116203,
0.025108905509114265,
-0.017536692321300507,
-0.02999229170382023,
0.025524092838168144,
-0.02815360762178898,
0.028726959601044655,
-0.02506936341524124,
-0.026156757026910782,
-0.0022551058791577816,
0.04143957793712616,
-0.04116278886795044,
0.07188659906387329,
-0.009015480987727642,
0.05555592477321625,
-0.05168084800243378,
-0.01812981627881527,
0.023823803290724754,
-0.04238857701420784,
0.02309228479862213,
-0.03509315475821495,
-0.024555323645472527,
-0.08580523729324341,
0.003034816589206457,
-0.021095434203743935,
0.03637825697660446,
0.03568628057837486,
0.020897727459669113,
-0.011585683561861515,
-0.03507338464260101,
-0.08683332055807114,
-0.04895247891545296,
-0.0076463534496724606,
0.004352045711129904,
-0.016656892374157906,
-0.02506936341524124,
-0.05535821616649628,
0.07046309858560562,
0.021016351878643036,
0.012890555895864964,
-0.0169732253998518,
-0.02807452343404293,
-0.06425507366657257,
-0.007023573853075504,
0.07129347324371338,
0.018772367388010025,
-0.019236980006098747,
0.0265126321464777,
-0.0288851261138916,
0.014561188407242298,
-0.00794291589409113,
0.05187855660915375,
0.03141578659415245,
0.012070068158209324,
0.06797198206186295,
0.017131390050053596,
-0.015025801956653595,
0.0196917075663805,
0.057612087577581406,
-0.02166878804564476,
-0.017536692321300507,
-0.04389115795493126,
-0.010972789488732815,
0.06876281648874283,
-0.05417196825146675,
-0.010953018441796303,
-0.03311607614159584,
0.0025207758881151676,
0.05096910148859024,
-0.027955899015069008,
0.024159908294677734,
-0.012732389383018017,
0.002604801906272769,
-0.0022909403778612614,
0.06631123274564743,
0.014244855381548405,
-0.009588833898305893,
0.000011642370736808516,
-0.004591766279190779,
-0.014580958522856236,
0.10873935371637344,
-0.05096910148859024,
0.05069230869412422,
0.015450873412191868,
0.050810933113098145,
0.054686009883880615,
0.014847864396870136,
0.0314948707818985,
0.016469068825244904,
-0.000462451163912192,
-0.044800613075494766,
-0.023250451311469078,
-0.004186464939266443,
0.020344143733382225,
-0.030783122405409813,
-0.0057137589901685715,
-0.010310468263924122,
-0.03888914734125137,
0.07358688861131668,
0.03426278010010719,
-0.0017237658612430096,
0.06690435856580734,
-0.03612123802304268,
0.038335565477609634,
-0.054092887789011,
0.006005377974361181,
0.024001741781830788,
0.034855905920267105,
0.01691391132771969,
0.016113195568323135,
-0.014007605612277985,
0.030980831012129784,
-0.05069230869412422,
-0.01437336578965187,
-0.08493532240390778,
-0.004495383705943823,
0.01683482900261879,
-0.00794291589409113,
0.0016780459554865956,
-0.0712539330124855,
0.029695728793740273,
0.03568628057837486,
-0.01111118495464325,
0.0330963060259819,
0.01223811972886324,
0.005545706953853369,
0.04015447944402695,
-0.043377116322517395,
-0.038948461413383484,
0.003076829481869936,
0.003180626081302762,
0.03355103358626366,
-0.01921720989048481,
0.011486830189824104,
-0.0154409883543849,
0.04539373889565468,
0.021569933742284775,
-0.051483143121004105,
0.0066479286178946495,
0.04899202287197113,
-0.017892565578222275,
-0.009707458317279816,
-0.026354465633630753,
0.0065293037332594395,
-0.03293813765048981,
-0.018248440697789192,
-0.03898800164461136,
0.013819782994687557,
0.10043562203645706,
-0.02589973621070385,
0.03578513115644455,
-0.06338515877723694,
-0.05037597566843033,
-0.0029779754113405943,
-0.042902618646621704,
0.05828429386019707,
-0.010478519834578037,
-0.02985389530658722,
0.024614635854959488,
-0.03060518577694893,
0.05452784523367882,
-0.026828965172171593,
0.029260771349072456,
0.033294014632701874,
0.048359356820583344,
-0.04982239380478859,
0.046856775879859924,
-0.008397643454372883,
0.0028939496260136366,
-0.004806773737072945,
-0.0330963060259819,
-0.000769207370467484,
0.07959720492362976,
0.019671937450766563,
-0.037030693143606186,
0.015717780217528343,
0.006672642193734646,
0.04420749098062515,
-0.08264190703630447,
0.009134105406701565,
0.01297952514141798,
-0.037722669541835785,
0.0025702028069645166,
-0.011022216640412807,
0.04001608118414879,
-0.0763152539730072,
0.042823534458875656,
-0.016706319525837898,
0.0033610346727073193,
0.13206888735294342,
0.013661617413163185,
0.016538267955183983,
0.017675086855888367,
-0.022439848631620407,
0.004492912441492081,
-0.018762480467557907,
-0.011032101698219776,
0.023823803290724754,
0.023487700149416924,
-0.010142415761947632,
-0.011239695362746716,
0.007928087376058102,
0.0617639534175396,
0.05555592477321625,
0.02829200215637684,
-0.010646571405231953,
-0.022380536422133446,
0.011733965016901493,
-0.07113530486822128,
0.041123244911432266,
-0.012406171299517155,
-0.01110129989683628,
0.003971457947045565,
-0.003862718353047967,
-0.009148933924734592,
-0.039699748158454895,
0.04598686099052429,
-0.02473326027393341,
-0.043100327253341675,
-0.007933029904961586,
0.08177199214696884,
0.006835751235485077,
0.018564773723483086,
0.0030002177227288485,
-0.03414415568113327,
0.035192009061574936,
0.005110749509185553,
0.002220507012680173,
-0.011694422923028469,
0.010646571405231953,
0.03657596558332443,
-0.005886753089725971,
0.045828696340322495,
0.037920378148555756,
-0.06828831136226654,
-0.01193167269229889,
0.01867351308465004,
-0.05338113754987717,
-0.14290328323841095,
0.012178807519376278,
0.03845418989658356,
-0.012603879906237125,
-0.07825279235839844,
0.004117267206311226,
0.027777962386608124,
0.029755041003227234,
0.008872142992913723,
0.04495878145098686,
-0.061091747134923935,
-0.04911064729094505,
0.02085818536579609,
-0.04606594517827034,
-0.020057467743754387,
-0.05895650014281273,
-0.031316932290792465,
0.005486394744366407,
-0.01942480355501175,
0.017200589179992676,
-0.04464244842529297,
0.019029386341571808,
0.018278097733855247,
-0.042902618646621704,
-0.047805774956941605,
0.06223845109343529,
0.026828965172171593,
0.023626096546649933,
0.06097312271595001,
0.004567052703350782,
-0.012396286241710186,
-0.013691273517906666,
-0.054013803601264954,
-0.05539775639772415,
0.03552811220288277,
0.06884189695119858,
0.03279974311590195,
0.009806312620639801,
0.006751725450158119,
-0.03902754187583923,
-0.0058126128278672695,
-0.02671033889055252,
-0.005570420529693365,
-0.014867635443806648,
-0.016182392835617065,
0.04519603028893471,
0.018011191859841347,
-0.03175188973546028,
-0.05211580544710159,
0.01710173487663269,
0.04246766120195389,
0.06350377947092056,
0.009677802212536335,
0.010953018441796303,
0.055990882217884064,
0.0072212815284729,
-0.0012387636816129088,
0.02166878804564476,
-0.03388713672757149,
0.002550432225689292,
0.011229809373617172,
-0.048359356820583344,
-0.010221499018371105,
-0.010962904430925846,
-0.003113899612799287,
-0.007102657109498978,
-0.05895650014281273,
0.10304536670446396,
0.09355538338422775,
-0.03361034765839577,
0.0038528330624103546,
-0.03958112373948097,
-0.02882581390440464,
0.036556195467710495,
0.028094295412302017,
0.039146166294813156,
0.015104885213077068,
0.010883821174502373,
0.030842434614896774,
-0.035745590925216675,
-0.03835533559322357,
-0.0179321076720953,
0.003771278541535139,
0.06579719483852386,
-0.0005943594151176512,
-0.02085818536579609,
0.024891426786780357,
0.03250318020582199,
0.03839487582445145,
-0.07374504953622818,
-0.037109777331352234,
-0.0910247266292572,
-0.024357615038752556,
0.026334693655371666,
-0.002387323183938861,
-0.005446853116154671,
0.05168084800243378,
-0.002004263922572136,
-0.012722504325211048,
-0.02951779216527939,
0.021510621532797813,
-0.01921720989048481,
-0.021826954558491707,
0.01038955058902502,
0.012969639152288437,
-0.04191407933831215,
0.024772802367806435,
-0.0199586134403944,
0.00666275667026639,
-0.06314790993928909,
0.010587259195744991,
0.04015447944402695,
0.025168217718601227,
-0.030644727870821953,
0.02882581390440464,
-0.03380805253982544,
0.018376950174570084,
-0.041202329099178314,
0.0016755745746195316,
-0.019434688612818718,
-0.013236545026302338,
-0.03434186428785324,
0.02064070664346218,
-0.055437300354242325,
0.001696581020951271,
0.0008384051616303623,
0.03507338464260101,
0.062317535281181335,
-0.035330403596162796,
0.06496682018041611,
0.011387975886464119,
-0.014363479800522327,
-0.035745590925216675,
0.0028272231575101614,
0.05954962596297264,
-0.04614502936601639,
-0.06571811437606812,
-0.02242007851600647,
0.06409690529108047,
0.021787412464618683,
-0.008837543427944183,
-0.006993917748332024,
-0.06049862131476402,
0.03141578659415245,
0.016340559348464012,
-0.00559019111096859,
-0.020957039669156075,
0.00039418015512637794,
0.007982457056641579,
0.041953619569540024,
0.016874371096491814,
-0.031455330550670624,
-0.0024787629954516888,
-0.006741839926689863,
0.0030966002959758043,
-0.060894038528203964,
-0.0019770790822803974,
-0.0381576269865036,
-0.025504320859909058,
0.032681118696928024,
0.043179407715797424,
-0.0227561816573143,
-0.003964043688029051,
-0.028114065527915955,
-0.022677097469568253,
-0.02874673157930374,
0.007824290543794632,
0.08968031406402588,
0.023685408756136894,
-0.08145566284656525,
-0.020324373617768288,
0.05274847149848938,
0.04634273424744606,
-0.02617652900516987,
-0.01989930123090744,
-0.010132530704140663,
-0.012495140545070171,
-0.041597746312618256,
-0.012623650021851063,
0.030545873567461967,
-0.01615273766219616,
0.0038281194865703583,
0.01087393518537283,
-0.033768512308597565,
-0.031573954969644547,
0.004060426261276007,
0.024851884692907333,
-0.01805073209106922,
0.08161383122205734,
-0.044128406792879105,
0.0418349951505661,
0.02665102668106556,
-0.03859258443117142,
0.001909117097966373,
-0.032740432769060135,
-0.001323407399468124,
0.00531340017914772,
0.04839889705181122,
-0.008298790082335472,
0.00022458384046331048,
0.0067467824555933475,
-0.06243615970015526,
-0.0135627631098032,
0.00031849509105086327,
-0.05211580544710159,
0.015925372019410133,
-0.013691273517906666,
-0.03285905718803406,
0.013137690722942352,
-0.008980882354080677,
0.008343273773789406,
0.004917984362691641,
-0.024911196902394295,
-0.001699052401818335,
0.03584444522857666,
-0.00013978566857986152,
-0.029873665422201157,
-0.005392483435571194,
0.004680735059082508,
0.020976809784770012,
0.02311205491423607,
-0.013681387528777122,
0.025524092838168144,
0.027580253779888153,
0.0022600486408919096,
-0.010686112567782402,
-0.006227799225598574,
-0.020047582685947418,
0.032127536833286285,
-0.03129716217517853,
0.032542724162340164,
0.020462770015001297,
0.05262984707951546,
0.024080824106931686,
0.03803900256752968,
-0.000053558764193439856,
0.05773071199655533,
-0.029834125190973282,
0.0036254688166081905,
0.041874535381793976,
0.05096910148859024,
-0.030269082635641098,
0.038256481289863586,
-0.00872880406677723,
-0.018713055178523064,
0.04270491003990173,
-0.06002412363886833,
0.001330821425653994,
-0.08343274146318436,
0.04776623100042343,
-0.08430265635251999,
0.049506060779094696,
-0.01900961622595787,
0.019108470529317856,
0.0045448108576238155,
-0.05187855660915375,
-0.011368204839527607,
0.022815493866801262,
0.032740432769060135,
-0.002599859144538641,
-0.051759932190179825,
0.03661550581455231,
-0.05282755568623543,
0.033768512308597565,
0.014393135905265808,
0.007671067025512457,
0.0037811638321727514,
-0.03189028799533844,
-0.02261778526008129,
-0.03060518577694893,
-0.05262984707951546,
-0.014640271663665771,
0.03981837257742882,
0.09561154991388321,
-0.008165337145328522,
0.02801521122455597,
-0.018574658781290054,
0.030684268102049828,
-0.03434186428785324,
-0.003027402563020587,
-0.06813015043735504,
0.08062528818845749,
0.042151328176259995,
-0.0013036365853622556,
-0.0836699903011322,
-0.03303699195384979,
0.01055760309100151,
0.024140136316418648,
-0.0419931598007679,
0.0314948707818985,
-0.030447019264101982,
0.0432189516723156,
0.027718650177121162,
0.0004846933006774634,
0.0005205278866924345,
0.022598015144467354,
-0.022934118285775185,
-0.0227561816573143,
0.032068222761154175,
-0.04626365378499031,
-0.00559019111096859,
-0.06971181184053421,
-0.07334963977336884,
-0.05444876104593277,
-0.027837274596095085,
0.0983794629573822,
-0.003277008654549718,
-0.015658466145396233,
-0.004658492747694254,
0.03973929211497307
]
|
30,403 | networkx.algorithms.connectivity.connectivity | average_node_connectivity | Returns the average connectivity of a graph G.
The average connectivity `\bar{\kappa}` of a graph G is the average
of local node connectivity over all pairs of nodes of G [1]_ .
.. math::
\bar{\kappa}(G) = \frac{\sum_{u,v} \kappa_{G}(u,v)}{{n \choose 2}}
Parameters
----------
G : NetworkX graph
Undirected graph
flow_func : function
A function for computing the maximum flow among a pair of nodes.
The function has to accept at least three parameters: a Digraph,
a source node, and a target node. And return a residual network
that follows NetworkX conventions (see :meth:`maximum_flow` for
details). If flow_func is None, the default maximum flow function
(:meth:`edmonds_karp`) is used. See :meth:`local_node_connectivity`
for details. The choice of the default function may change from
version to version and should not be relied on. Default value: None.
Returns
-------
K : float
Average node connectivity
See also
--------
:meth:`local_node_connectivity`
:meth:`node_connectivity`
:meth:`edge_connectivity`
:meth:`maximum_flow`
:meth:`edmonds_karp`
:meth:`preflow_push`
:meth:`shortest_augmenting_path`
References
----------
.. [1] Beineke, L., O. Oellermann, and R. Pippert (2002). The average
connectivity of a graph. Discrete mathematics 252(1-3), 31-45.
http://www.sciencedirect.com/science/article/pii/S0012365X01001807
| @nx._dispatchable
def edge_connectivity(G, s=None, t=None, flow_func=None, cutoff=None):
r"""Returns the edge connectivity of the graph or digraph G.
The edge connectivity is equal to the minimum number of edges that
must be removed to disconnect G or render it trivial. If source
and target nodes are provided, this function returns the local edge
connectivity: the minimum number of edges that must be removed to
break all paths from source to target in G.
Parameters
----------
G : NetworkX graph
Undirected or directed graph
s : node
Source node. Optional. Default value: None.
t : node
Target node. Optional. Default value: None.
flow_func : function
A function for computing the maximum flow among a pair of nodes.
The function has to accept at least three parameters: a Digraph,
a source node, and a target node. And return a residual network
that follows NetworkX conventions (see :meth:`maximum_flow` for
details). If flow_func is None, the default maximum flow function
(:meth:`edmonds_karp`) is used. See below for details. The
choice of the default function may change from version
to version and should not be relied on. Default value: None.
cutoff : integer, float, or None (default: None)
If specified, the maximum flow algorithm will terminate when the
flow value reaches or exceeds the cutoff. This only works for flows
that support the cutoff parameter (most do) and is ignored otherwise.
Returns
-------
K : integer
Edge connectivity for G, or local edge connectivity if source
and target were provided
Examples
--------
>>> # Platonic icosahedral graph is 5-edge-connected
>>> G = nx.icosahedral_graph()
>>> nx.edge_connectivity(G)
5
You can use alternative flow algorithms for the underlying
maximum flow computation. In dense networks the algorithm
:meth:`shortest_augmenting_path` will usually perform better
than the default :meth:`edmonds_karp`, which is faster for
sparse networks with highly skewed degree distributions.
Alternative flow functions have to be explicitly imported
from the flow package.
>>> from networkx.algorithms.flow import shortest_augmenting_path
>>> nx.edge_connectivity(G, flow_func=shortest_augmenting_path)
5
If you specify a pair of nodes (source and target) as parameters,
this function returns the value of local edge connectivity.
>>> nx.edge_connectivity(G, 3, 7)
5
If you need to perform several local computations among different
pairs of nodes on the same graph, it is recommended that you reuse
the data structures used in the maximum flow computations. See
:meth:`local_edge_connectivity` for details.
Notes
-----
This is a flow based implementation of global edge connectivity.
For undirected graphs the algorithm works by finding a 'small'
dominating set of nodes of G (see algorithm 7 in [1]_ ) and
computing local maximum flow (see :meth:`local_edge_connectivity`)
between an arbitrary node in the dominating set and the rest of
nodes in it. This is an implementation of algorithm 6 in [1]_ .
For directed graphs, the algorithm does n calls to the maximum
flow function. This is an implementation of algorithm 8 in [1]_ .
See also
--------
:meth:`local_edge_connectivity`
:meth:`local_node_connectivity`
:meth:`node_connectivity`
:meth:`maximum_flow`
:meth:`edmonds_karp`
:meth:`preflow_push`
:meth:`shortest_augmenting_path`
:meth:`k_edge_components`
:meth:`k_edge_subgraphs`
References
----------
.. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf
"""
if (s is not None and t is None) or (s is None and t is not None):
raise nx.NetworkXError("Both source and target must be specified.")
# Local edge connectivity
if s is not None and t is not None:
if s not in G:
raise nx.NetworkXError(f"node {s} not in graph")
if t not in G:
raise nx.NetworkXError(f"node {t} not in graph")
return local_edge_connectivity(G, s, t, flow_func=flow_func, cutoff=cutoff)
# Global edge connectivity
# reuse auxiliary digraph and residual network
H = build_auxiliary_edge_connectivity(G)
R = build_residual_network(H, "capacity")
kwargs = {"flow_func": flow_func, "auxiliary": H, "residual": R}
if G.is_directed():
# Algorithm 8 in [1]
if not nx.is_weakly_connected(G):
return 0
# initial value for \lambda is minimum degree
L = min(d for n, d in G.degree())
nodes = list(G)
n = len(nodes)
if cutoff is not None:
L = min(cutoff, L)
for i in range(n):
kwargs["cutoff"] = L
try:
L = min(L, local_edge_connectivity(G, nodes[i], nodes[i + 1], **kwargs))
except IndexError: # last node!
L = min(L, local_edge_connectivity(G, nodes[i], nodes[0], **kwargs))
return L
else: # undirected
# Algorithm 6 in [1]
if not nx.is_connected(G):
return 0
# initial value for \lambda is minimum degree
L = min(d for n, d in G.degree())
if cutoff is not None:
L = min(cutoff, L)
# A dominating set is \lambda-covering
# We need a dominating set with at least two nodes
for node in G:
D = nx.dominating_set(G, start_with=node)
v = D.pop()
if D:
break
else:
# in complete graphs the dominating sets will always be of one node
# thus we return min degree
return L
for w in D:
kwargs["cutoff"] = L
L = min(L, local_edge_connectivity(G, v, w, **kwargs))
return L
| (G, flow_func=None, *, backend=None, **backend_kwargs) | [
-0.006537512876093388,
-0.039141926914453506,
0.022574687376618385,
0.039661604911088943,
0.012129216454923153,
0.011671902611851692,
-0.01825098879635334,
-0.020703855901956558,
0.03273953124880791,
-0.09512133151292801,
-0.03155467286705971,
0.019654111936688423,
0.034277770668268204,
0.004063859116286039,
-0.012264332734048367,
0.029787776991724968,
-0.04147007316350937,
0.006901285145431757,
0.041657157242298126,
0.04088803753256798,
0.0022813735995441675,
-0.06959488987922668,
0.02951754629611969,
-0.027210189029574394,
-0.008590229786932468,
0.029974859207868576,
0.03161703422665596,
0.0025399120058864355,
-0.039994195103645325,
-0.008605820126831532,
-0.05013825371861458,
-0.012950303964316845,
-0.07520738244056702,
0.006631054449826479,
0.0341530479490757,
0.038809336721897125,
0.025110701099038124,
0.030889488756656647,
-0.04768538847565651,
-0.048891033977270126,
-0.0738770142197609,
0.0006866207113489509,
-0.0020644094329327345,
0.00418598297983408,
0.0301203690469265,
0.031159719452261925,
0.011547180823981762,
0.023011213168501854,
0.001365446369163692,
-0.029330462217330933,
-0.002138463081791997,
-0.026170838624238968,
-0.008273228071630001,
-0.0007710679201409221,
0.031928837299346924,
0.028727639466524124,
0.010575388558208942,
0.012669678777456284,
-0.005695639178156853,
-0.02681523561477661,
-0.000037595244066324085,
0.006849317811429501,
0.05778787285089493,
0.03766605257987976,
-0.08223339170217514,
0.013012664392590523,
-0.061945270746946335,
0.0016304806340485811,
-0.013740209862589836,
0.021223532035946846,
-0.00410023657605052,
-0.014436574652791023,
0.01316856686025858,
-0.04092961177229881,
0.005815164186060429,
-0.030889488756656647,
0.04519094526767731,
-0.029164167121052742,
-0.044193170964717865,
-0.052341677248477936,
0.04943149536848068,
-0.025505654513835907,
0.035192396491765976,
-0.00828881748020649,
0.07346127182245255,
-0.026711300015449524,
-0.019373487681150436,
0.051177602261304855,
-0.026856809854507446,
-0.05022140219807625,
0.025380931794643402,
0.0012192877475172281,
-0.021254710853099823,
0.031741756945848465,
0.019955523312091827,
0.012752827256917953,
-0.03286425396800041,
-0.04101276025176048,
0.07192303240299225,
-0.03710480406880379,
0.022242093458771706,
0.02723097614943981,
-0.09794836491346359,
0.025256209075450897,
-0.008122521452605724,
-0.09545392543077469,
-0.039162714034318924,
0.03885091096162796,
-0.020589526742696762,
-0.04963936656713486,
-0.01733636111021042,
0.010066106915473938,
0.024008989334106445,
0.01579812355339527,
-0.006158149801194668,
0.03138837590813637,
0.027043892070651054,
-0.02968384139239788,
-0.012337086722254753,
-0.01336604356765747,
-0.004783609416335821,
0.044692058116197586,
-0.013438798487186432,
-0.04726964607834816,
0.047643814235925674,
-0.01647370122373104,
0.007815913297235966,
0.002842622809112072,
0.010383108630776405,
-0.043777432292699814,
0.06398239731788635,
0.0012023982126265764,
0.0008282322087325156,
0.09354151785373688,
-0.009322971105575562,
-0.03895484656095505,
-0.04365270957350731,
0.07104998081922531,
0.005118799861520529,
0.00837196595966816,
0.018874600529670715,
-0.04265493154525757,
-0.03273953124880791,
0.03481823205947876,
0.022512326017022133,
-0.004887544550001621,
0.013875325210392475,
-0.017856037244200706,
0.05712268874049187,
0.03421540930867195,
-0.00862140953540802,
-0.05309000983834267,
-0.01270085945725441,
0.006631054449826479,
0.004949905443936586,
0.008683770895004272,
-0.020464805886149406,
0.01673353835940361,
-0.020870152860879898,
-0.0033025352749973536,
-0.043777432292699814,
-0.028228752315044403,
-0.023447740823030472,
0.00450038630515337,
-0.018697910010814667,
-0.02153533697128296,
0.04022285342216492,
0.012763220816850662,
-0.037811558693647385,
0.0037130785640329123,
-0.020558347925543785,
-0.01758580468595028,
-0.06431499123573303,
-0.018625155091285706,
0.02523542381823063,
0.02901865728199482,
0.021992649883031845,
0.006002247333526611,
-0.009177462197840214,
-0.003409068565815687,
0.0016070952406153083,
-0.02488204464316368,
0.00020251088426448405,
-0.0249028317630291,
0.04277965426445007,
0.04294595122337341,
0.0666431337594986,
-0.03303055092692375,
-0.0048485687002539635,
-0.02868606522679329,
-0.03176254406571388,
-0.0499303825199604,
0.0016980384243652225,
0.05878564715385437,
0.004266532603651285,
-0.024341581389307976,
0.013428404927253723,
0.035961516201496124,
-0.016691964119672775,
0.07466691732406616,
0.02658657915890217,
0.03756211698055267,
0.05296528711915016,
0.017263606190681458,
0.01580851711332798,
0.004554952494800091,
0.04273808002471924,
-0.004765420686453581,
-0.02976698987185955,
0.024487091228365898,
-0.04431789368391037,
-0.04884945973753929,
0.030411386862397194,
0.011422459036111832,
-0.030411386862397194,
0.010944358073174953,
-0.013054238632321358,
0.029974859207868576,
0.005659261718392372,
-0.01917601190507412,
-0.03020351752638817,
0.007374189794063568,
0.027043892070651054,
0.008974788710474968,
0.04598085209727287,
-0.06734989583492279,
-0.007368993014097214,
0.00011765769158955663,
0.07046794146299362,
-0.06452286243438721,
0.06277675181627274,
-0.004367869347333908,
0.054960839450359344,
0.022824130952358246,
0.016962194815278053,
0.0038949649315327406,
0.018219809979200363,
-0.0021696435287594795,
-0.03159624710679054,
-0.009645169600844383,
-0.04381900280714035,
-0.03743739426136017,
-0.019986703991889954,
0.00823685061186552,
0.01949821040034294,
-0.031180506572127342,
0.01641133986413479,
0.011651115491986275,
0.025193849578499794,
0.001617488800548017,
-0.06294304877519608,
-0.06897127628326416,
-0.03330077975988388,
-0.08260755240917206,
-0.00354418414644897,
-0.0660611018538475,
-0.023073574528098106,
0.021722419187426567,
-0.019799621775746346,
-0.0030323041137307882,
-0.01136009767651558,
-0.0072494675405323505,
-0.04026442766189575,
0.04793483018875122,
-0.03070240467786789,
-0.00437566451728344,
-0.015995599329471588,
-0.001270605600439012,
-0.048974182456731796,
-0.04851686581969261,
0.051925934851169586,
0.000921773724257946,
0.022740982472896576,
0.010346731171011925,
-0.043361689895391464,
-0.0442347452044487,
-0.00018480945436749607,
0.025671949610114098,
0.041761092841625214,
-0.037375032901763916,
-0.05284056439995766,
-0.00010994376498274505,
-0.04876631125807762,
-0.004856363870203495,
-0.04153243452310562,
0.02405056357383728,
-0.04593927785754204,
-0.12147925049066544,
-0.011952527798712254,
-0.04951464384794235,
0.048724737018346786,
-0.03785313293337822,
0.027542781084775925,
0.04265493154525757,
0.08639078587293625,
0.038476742804050446,
0.011526393704116344,
-0.048891033977270126,
0.029372036457061768,
0.024008989334106445,
0.0706758126616478,
-0.05005510523915291,
0.014280672185122967,
-0.03702165558934212,
0.01951899752020836,
-0.039308223873376846,
0.04036836326122284,
-0.010627355426549911,
0.02656579203903675,
0.004812191240489483,
-0.04261335730552673,
-0.02236681617796421,
0.008714951574802399,
-0.04356956109404564,
-0.027127040550112724,
-0.00958800595253706,
-0.03228221833705902,
-0.018282169476151466,
-0.0006382259889505804,
0.028374260291457176,
0.0390172079205513,
0.08069515228271484,
-0.061612680554389954,
0.03242772817611694,
-0.056457504630088806,
0.019207192584872246,
0.05903509259223938,
0.03093106299638748,
0.026773661375045776,
-0.00712474575266242,
-0.005726819857954979,
0.019695686176419258,
0.013386830687522888,
0.005835951305925846,
-0.05803731456398964,
0.06726674735546112,
0.059326108545064926,
-0.01122498232871294,
-0.02783379890024662,
-0.04976408928632736,
0.06086434796452522,
0.08738856762647629,
0.009645169600844383,
0.01984119601547718,
0.010726094245910645,
0.04381900280714035,
0.025547228753566742,
-0.011796624399721622,
0.01924876496195793,
-0.02203422412276268,
0.048891033977270126,
0.0926268920302391,
-0.020495986565947533,
-0.03633568435907364,
-0.017876824364066124,
0.06323406845331192,
-0.002073503565043211,
-0.0030764765106141567,
0.03373730927705765,
0.022678621113300323,
0.010237599723041058,
0.00413921196013689,
-0.002636051969602704,
-0.029829351231455803,
0.006636251229792833,
0.05005510523915291,
-0.005602097604423761,
0.06265202909708023,
0.00903715007007122,
-0.062444161623716354,
-0.03236536681652069,
-0.08248282968997955,
-0.0035701680462807417,
-0.009567218832671642,
-0.019477423280477524,
0.05163491889834404,
0.0038559893146157265,
-0.0029231724329292774,
0.03953688219189644,
0.04144928604364395,
0.02849898301064968,
0.02783379890024662,
-0.025942180305719376,
0.01155757438391447,
0.030556896701455116,
-0.025526441633701324,
0.02876921370625496,
-0.004749830346554518,
0.06514646857976913,
0.017845643684267998,
0.028706852346658707,
-0.036044664680957794,
0.0570395402610302,
-0.00422236043959856,
0.011297736316919327,
0.011890166439116001,
0.05853620171546936,
0.043278541415929794,
0.004393852781504393,
-0.01315817330032587,
0.00448219757527113,
0.05275741592049599,
0.04440104216337204,
-0.010965144261717796,
0.007571666035801172,
0.007576862815767527,
0.07749395072460175,
-0.008008193224668503,
0.021826354786753654,
0.0029075820930302143,
0.00030092435190454125,
0.06884656101465225,
-0.044608909636735916,
0.006870104931294918,
0.005017463117837906,
-0.05408778414130211,
-0.026295559480786324,
0.041740305721759796,
0.05600018799304962,
-0.025422506034374237,
0.037707626819610596,
-0.041927386075258255,
0.033176057040691376,
-0.012170790694653988,
-0.012867155484855175,
-0.04169873148202896,
-0.017949577420949936,
0.01425988506525755,
-0.036792997270822525,
0.07283766567707062,
-0.02658657915890217,
-0.008907231502234936,
0.04768538847565651,
-0.04190659895539284,
-0.028997870162129402,
0.014311851933598518,
0.020163394510746002,
-0.008902034722268581,
0.04415159672498703,
-0.002377513563260436,
0.02824953943490982,
-0.011630328372120857,
-0.029559120535850525,
-0.01038830541074276,
0.004235351923853159,
-0.051925934851169586,
-0.02338537946343422,
0.01950860396027565,
-0.03733345866203308,
0.00008184882608475164,
0.020880546420812607,
-0.03303055092692375,
0.0010575387859717011,
0.023697184398770332,
-0.1416010707616806,
0.03743739426136017,
0.021067628636956215,
0.029704628512263298,
-0.11274871230125427,
-0.0024840470869094133,
0.025380931794643402,
-0.0016304806340485811,
-0.024570239707827568,
-0.00799260288476944,
-0.04735279455780983,
-0.005209743045270443,
0.02161848358809948,
-0.013979259878396988,
-0.02556801587343216,
-0.023738758638501167,
0.04051386937499046,
-0.04943149536848068,
-0.09628540277481079,
0.008345982059836388,
0.056374356150627136,
0.02615005150437355,
-0.03095184825360775,
0.015320021659135818,
0.0031908052042126656,
-0.014914675615727901,
0.02263704687356949,
-0.03145073726773262,
0.03429855778813362,
-0.030494535341858864,
0.008886444382369518,
0.0010900185443460941,
0.0010731291258707643,
0.03799864277243614,
-0.019290339201688766,
-0.028187178075313568,
-0.02303200028836727,
-0.004570542369037867,
-0.002508731558918953,
0.009738711640238762,
0.0029231724329292774,
0.05363047122955322,
-0.01800154522061348,
-0.04130377620458603,
0.021847141906619072,
-0.0028971887659281492,
0.00020494687487371266,
0.039162714034318924,
-0.06319249421358109,
0.03774920105934143,
0.01883302628993988,
0.03188726305961609,
-0.008335588499903679,
0.02244996465742588,
0.04668761044740677,
0.04155322164297104,
0.06406554579734802,
0.010419486090540886,
0.08323116600513458,
0.08356375992298126,
0.010564994998276234,
0.007223484106361866,
0.03103499673306942,
0.004266532603651285,
0.024528665468096733,
-0.05121917650103569,
-0.0076028467155992985,
0.021639270707964897,
-0.007197500206530094,
0.04059701785445213,
-0.04248863458633423,
0.03776998817920685,
0.027521993964910507,
-0.010585782118141651,
-0.01783525012433529,
0.011464032344520092,
0.003484421642497182,
0.04531566798686981,
-0.039911046624183655,
0.0474359430372715,
-0.003707881784066558,
0.035691287368535995,
-0.05350574851036072,
-0.0033934784587472677,
-0.06431499123573303,
0.0059450832195580006,
-0.01565261371433735,
0.010159648023545742,
0.010071303695440292,
0.020288115367293358,
0.01691022701561451,
-0.033758096396923065,
0.05587546527385712,
0.015112152323126793,
0.0013745406176894903,
-0.05400463566184044,
0.000014717361409566365,
0.04988880828022957,
0.005638475064188242,
-0.02827032469213009,
0.08339746296405792,
-0.02515227533876896,
-0.001781186438165605,
0.032926615327596664,
-0.014498935081064701,
0.014239097945392132,
-0.06855554133653641,
-0.0285197701305151,
-0.019363094121217728,
-0.04240548983216286,
-0.006215314380824566,
-0.03843517228960991,
0.04415159672498703,
-0.06157110631465912,
-0.017003769055008888,
0.025006765499711037,
-0.03363337367773056,
0.01290872972458601,
-0.04080488905310631,
0.010383108630776405,
0.014530115760862827,
0.01640094630420208,
-0.025339357554912567,
-0.0054409983567893505,
0.027272548526525497,
-0.012274726293981075,
-0.011505606584250927,
-0.02935124933719635,
0.06290147453546524,
0.04036836326122284,
0.014914675615727901,
0.05238325148820877,
-0.03804021701216698,
-0.00015435974637512118,
-0.09088078141212463,
-0.022325241938233376,
-0.020589526742696762,
-0.05616648495197296,
0.007623633835464716,
-0.012929516844451427,
-0.02405056357383728,
0.02479889616370201,
0.008008193224668503,
0.05712268874049187,
0.07695348560810089,
-0.013948080129921436,
-0.05205065757036209,
-0.00479400297626853,
-0.030411386862397194,
-0.014187130145728588,
-0.03506767749786377,
-0.01325171533972025,
0.0052643087692558765,
-0.0313052274286747,
0.03321763128042221,
-0.06040703505277634,
0.007665207609534264,
0.01942545548081398,
-0.04155322164297104,
-0.07786811888217926,
-0.04115826636552811,
-0.013220534659922123,
-0.010798848234117031,
0.06631053984165192,
-0.01842767931520939,
-0.03392438963055611,
0.02278255671262741,
0.02808324247598648,
-0.01030515693128109,
-0.005266907159239054,
0.020890939980745316,
0.09337522089481354,
-0.019144831225275993,
-0.010175238363444805,
-0.023364592343568802,
0.027459632605314255,
-0.03303055092692375,
-0.04618872329592705,
0.0013251715572550893,
0.09038189053535461,
0.01169268973171711,
-0.09079763293266296,
0.06955331563949585,
0.01799115166068077,
-0.029974859207868576,
0.047311220318078995,
-0.0868065282702446,
0.0684308186173439,
-0.026170838624238968,
-0.005654064938426018,
-0.029974859207868576,
0.021743206307291985,
0.034423280507326126,
-0.006558299995958805,
0.02488204464316368,
-0.01632819138467312,
-0.02017378807067871,
0.026461856439709663,
0.036356471478939056,
-0.03926664963364601,
-0.011256163008511066,
0.028228752315044403,
0.03804021701216698,
0.00807575136423111,
0.030058007687330246,
-0.04244706407189369,
0.0023138534743338823,
0.02523542381823063,
0.06215314194560051,
0.008979985490441322,
0.009832252748310566,
-0.006750579457730055,
0.0595339797437191,
-0.07271294295787811,
-0.014893888495862484,
0.015029003843665123,
-0.05828676000237465,
-0.05999129265546799,
0.034776657819747925,
0.017034949734807014,
-0.03523397073149681,
-0.05446195229887962,
0.03716716170310974,
0.0013602495891973376,
-0.020204968750476837,
-0.036959294229745865,
0.04876631125807762,
0.050512418150901794,
-0.02766750194132328,
-0.03219906985759735,
0.01840689219534397,
-0.009385332465171814,
-0.044608909636735916,
-0.0578710176050663,
0.021743206307291985,
0.015746155753731728,
-0.010461059398949146,
-0.026711300015449524,
0.03413226082921028,
0.015029003843665123,
0.004931716714054346,
-0.012409841641783714,
-0.05180121585726738,
0.03517160937190056,
0.01370902918279171,
-0.04080488905310631,
0.04735279455780983,
0.014395000413060188,
-0.018614761531352997,
0.004365270957350731,
-0.00971272774040699,
-0.02515227533876896,
-0.03465193510055542,
0.021493762731552124,
-0.01257613766938448,
0.004541960544884205,
-0.032074347138404846,
-0.03795706853270531,
-0.0069220722652971745,
-0.019446242600679398,
0.0007087069097906351,
0.009276201017200947,
-0.004934315104037523,
-0.03203277289867401,
-0.0787411704659462,
0.04440104216337204,
-0.008366769179701805,
-0.018219809979200363,
-0.014207917265594006,
0.039329010993242264,
-0.0031908052042126656,
0.04514937475323677,
0.044442616403102875,
0.0032869449350982904,
-0.006225707940757275,
-0.017024556174874306,
-0.00254510878585279,
0.09678429365158081,
0.01859397441148758,
0.0781591385602951,
-0.004027482122182846,
-0.004905732814222574,
0.02590060792863369,
0.022262880578637123,
-0.03323841840028763,
0.021930288523435593,
0.023281443864107132,
-0.018022332340478897,
-0.06768248230218887,
-0.055127136409282684,
0.011858985759317875,
0.021971862763166428,
-0.022304454818367958,
0.029559120535850525,
-0.008387556299567223,
-0.025526441633701324,
0.01866672933101654,
0.004417238291352987,
0.04922362416982651,
-0.06955331563949585,
-0.03768683969974518,
0.0030141156166791916,
-0.058993518352508545,
-0.041844237595796585,
-0.029829351231455803,
-0.030141156166791916,
-0.04298752546310425,
-0.029995646327733994,
0.009915401227772236,
0.018781058490276337,
-0.01316856686025858,
0.04593927785754204,
0.016432126984000206,
0.059824999421834946
]
|
30,405 | networkx.generators.classic | balanced_tree | Returns the perfectly balanced `r`-ary tree of height `h`.
.. plot::
>>> nx.draw(nx.balanced_tree(2, 3))
Parameters
----------
r : int
Branching factor of the tree; each node will have `r`
children.
h : int
Height of the tree.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : NetworkX graph
A balanced `r`-ary tree of height `h`.
Notes
-----
This is the rooted tree where all leaves are at distance `h` from
the root. The root has degree `r` and all other internal nodes
have degree `r + 1`.
Node labels are integers, starting from zero.
A balanced tree is also known as a *complete r-ary tree*.
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (r, h, create_using=None, *, backend=None, **backend_kwargs) | [
0.0222346018999815,
-0.006948312744498253,
0.021684063598513603,
-0.050223205238580704,
-0.012688995338976383,
0.06666828691959381,
-0.04755931347608566,
0.007427813019603491,
-0.0007164754206314683,
0.005061390809714794,
0.00412458973005414,
0.062477096915245056,
0.016995618119835854,
0.07608069479465485,
0.027011843398213387,
-0.007609845604747534,
0.014828987419605255,
0.011898708529770374,
-0.0228916946798563,
0.03793379291892052,
-0.019819341599941254,
0.01516641303896904,
0.03425762429833412,
0.013914384879171848,
-0.02088489755988121,
0.012058542110025883,
0.022287879139184952,
0.032446179538965225,
-0.037365496158599854,
0.02727823331952095,
0.033121030777692795,
-0.012182856909930706,
0.0012098499573767185,
0.018309803679585457,
0.02060074917972088,
0.042338091880083084,
-0.02148871123790741,
0.05310020595788956,
-0.10442448407411575,
-0.015690311789512634,
0.0463872030377388,
-0.005896076560020447,
0.014855626039206982,
-0.032978955656290054,
0.012200616300106049,
0.028450343757867813,
0.0833975151181221,
0.004568571224808693,
-0.06876388192176819,
-0.0175461545586586,
0.04279983043670654,
0.0042933025397360325,
-0.04319053515791893,
-0.058392468839883804,
-0.0019291002536192536,
0.010122781619429588,
-0.00752992881461978,
-0.012271652929484844,
0.0594935417175293,
-0.039958350360393524,
0.03358277305960655,
0.03210875391960144,
0.006197983864694834,
-0.023477749899029732,
-0.05622583627700806,
-0.021897174417972565,
-0.03885727375745773,
-0.061447061598300934,
-0.01426957082003355,
-0.018984654918313026,
0.05405920743942261,
0.041592203080654144,
0.03017299249768257,
-0.009669920429587364,
0.012831069529056549,
0.026336992159485817,
0.03644201532006264,
0.01088642980903387,
-0.010477966628968716,
-0.009061665274202824,
-0.02282065711915493,
-0.03628218173980713,
0.021985972300171852,
-0.04809209331870079,
0.046280648559331894,
0.0983152985572815,
-0.0197127852588892,
0.02095593325793743,
-0.044646795839071274,
-0.023903971537947655,
-0.02445450983941555,
-0.027828769758343697,
-0.02610612101852894,
0.0054831732995808125,
-0.012715634889900684,
0.015965580940246582,
0.050294242799282074,
-0.09249025583267212,
0.012316050939261913,
-0.0010111682349815965,
-0.03747205063700676,
-0.033405181020498276,
-0.08865425735712051,
-0.02186165750026703,
-0.05665205791592598,
-0.031416140496730804,
-0.025306954979896545,
0.05686517059803009,
-0.01311521790921688,
0.02855690009891987,
-0.019073452800512314,
0.017448479309678078,
0.06613551080226898,
-0.013647995889186859,
0.02974677085876465,
0.0426577590405941,
-0.0182032473385334,
0.03864416480064392,
0.06528306007385254,
-0.023069286718964577,
-0.05842798575758934,
0.04422057420015335,
-0.04031353443861008,
0.029764529317617416,
0.026887528598308563,
-0.00033298623748123646,
0.04461127519607544,
-0.05310020595788956,
0.03026179037988186,
0.021098008379340172,
-0.0015728049911558628,
0.018931377679109573,
-0.0010305923642590642,
0.0682666227221489,
-0.035358697175979614,
0.013257292099297047,
-0.0788511410355568,
-0.028450343757867813,
-0.0012653477024286985,
-0.01426957082003355,
0.0338846817612648,
-0.03409779071807861,
0.03875071927905083,
0.0495128333568573,
-0.060772210359573364,
0.015468320809304714,
0.018682748079299927,
0.019162248820066452,
0.013266172260046005,
-0.014500441029667854,
0.02370862103998661,
0.0020545250736176968,
0.09526070207357407,
0.030652493238449097,
-0.022128045558929443,
-0.018380841240286827,
0.027118399739265442,
-0.022394435480237007,
-0.012138458900153637,
0.02981780841946602,
-0.007498850114643574,
0.01196974515914917,
0.039816275238990784,
-0.016596034169197083,
-0.07622276991605759,
-0.0033276425674557686,
-0.0063045392744243145,
-0.004266663920134306,
0.006526530254632235,
-0.027118399739265442,
-0.04162771999835968,
-0.0008951780037023127,
0.0013219553511589766,
-0.056012727320194244,
-0.004577450919896364,
-0.0020034671761095524,
-0.030865604057908058,
-0.01115281879901886,
-0.017235368490219116,
-0.025893010199069977,
0.02965797483921051,
-0.07071739435195923,
0.029107436537742615,
-0.041734274476766586,
-0.012094059959053993,
0.017723748460412025,
0.009900790639221668,
0.014109737239778042,
0.029196234419941902,
0.03361828997731209,
0.04667135328054428,
0.02512936107814312,
-0.012928745709359646,
0.056012727320194244,
0.022856175899505615,
-0.058392468839883804,
0.06986495107412338,
0.036246661096811295,
-0.07224469631910324,
0.055195800960063934,
0.07735936343669891,
0.07132121175527573,
0.020405396819114685,
-0.01040692999958992,
0.04851831495761871,
-0.0006398885743692517,
-0.051324278116226196,
-0.04816313087940216,
-0.05175050348043442,
0.028716733679175377,
-0.008022748865187168,
0.019641747698187828,
0.03796930983662605,
0.044575758278369904,
-0.06478580087423325,
0.0696873590350151,
0.039070386439561844,
0.03171804919838905,
0.010069504380226135,
-0.06112739443778992,
-0.0351455882191658,
-0.015716951340436935,
0.0032166470773518085,
0.03425762429833412,
-0.00845785066485405,
-0.005762882065027952,
-0.00834241509437561,
-0.01677362620830536,
-0.004617409314960241,
-0.06269021332263947,
0.026514584198594093,
-0.026567861437797546,
0.04425609111785889,
-0.015272969380021095,
0.012573560699820518,
-0.015193052589893341,
0.03352949395775795,
-0.01166783832013607,
-0.04237360879778862,
0.03232186287641525,
-0.055124763399362564,
-0.01948191411793232,
0.007383415009826422,
-0.009314735420048237,
-0.013852227479219437,
0.07977462559938431,
-0.010389170609414577,
0.03146941959857941,
0.0024263598024845123,
-0.011632319539785385,
-0.004450916312634945,
-0.01902017369866371,
0.012839949689805508,
-0.030901122838258743,
0.018895858898758888,
0.030492659658193588,
-0.056971725076436996,
-0.007387854624539614,
0.01516641303896904,
0.04269327595829964,
-0.027562381699681282,
-0.008861874230206013,
-0.05796624347567558,
-0.02839706651866436,
0.061731208115816116,
0.018078932538628578,
-0.06869284063577652,
0.05285157635807991,
-0.05952905863523483,
-0.02862793765962124,
0.05722035467624664,
0.081479512155056,
0.1052769273519516,
0.004539712332189083,
0.012724514119327068,
-0.05604824423789978,
0.0024929570499807596,
0.039816275238990784,
-0.04294190555810928,
-0.03166477009654045,
-0.053775057196617126,
-0.03715238347649574,
-0.01174775417894125,
0.04290638864040375,
0.025306954979896545,
0.032304104417562485,
0.05001009255647659,
-0.004022473935037851,
0.025662139058113098,
-0.02877001091837883,
0.01969502680003643,
-0.014802348800003529,
-0.03679719939827919,
-0.0031189711298793554,
0.030492659658193588,
0.020245563238859177,
-0.02653234452009201,
0.015317367389798164,
0.0023264638148248196,
0.05256742984056473,
0.09419514983892441,
-0.05310020595788956,
0.03665512427687645,
0.022483231499791145,
0.045392684638500214,
0.02699408493936062,
0.00044203922152519226,
0.010398050770163536,
0.012768912129104137,
0.014731311239302158,
-0.05448542907834053,
0.01431396882981062,
0.0049947937950491905,
0.009341374039649963,
-0.010477966628968716,
-0.05860557779669762,
-0.020476434379816055,
-0.02139991521835327,
0.03796930983662605,
0.0382179394364357,
0.01918000727891922,
0.005194585304707289,
-0.05256742984056473,
0.02125784195959568,
-0.05242535471916199,
0.053348835557699203,
-0.01007838360965252,
0.05704276263713837,
-0.04919316619634628,
0.0210269708186388,
0.019002415239810944,
-0.01955295167863369,
-0.031096475198864937,
0.03544749692082405,
-0.07206710427999496,
0.03544749692082405,
0.013861107639968395,
-0.0325704924762249,
-0.015539358370006084,
-0.05107564851641655,
0.0298000480979681,
0.01055788341909647,
-0.015583756379783154,
0.007028229534626007,
-0.030048677697777748,
0.03871519863605499,
0.046955499798059464,
-0.0934847742319107,
-0.03793379291892052,
-0.026674417778849602,
0.031558215618133545,
0.07870906591415405,
-0.026265954598784447,
-0.029764529317617416,
0.04027801752090454,
0.06649069488048553,
0.005349978804588318,
0.012324931100010872,
-0.0640399158000946,
-0.010655559599399567,
-0.0036961473524570465,
0.003547413507476449,
0.062192950397729874,
-0.009865272790193558,
-0.005691844969987869,
0.021098008379340172,
-0.013576959259808064,
0.08694937080144882,
0.01166783832013607,
-0.006499891635030508,
-0.0241526011377573,
-0.07359439879655838,
-0.07679107040166855,
0.050365280359983444,
-0.005833919160068035,
0.05420127883553505,
-0.015352885238826275,
-0.031771328300237656,
0.02713615819811821,
-0.001838084077462554,
-0.0419473871588707,
-0.019730545580387115,
0.04251568391919136,
0.0068950350396335125,
0.026408029720187187,
-0.000005484734174387995,
0.04113046079874039,
0.01925104483962059,
-0.04269327595829964,
-0.02758014015853405,
-0.05359746515750885,
-0.0463872030377388,
0.06244157999753952,
-0.004950395319610834,
-0.02937382645905018,
0.0021999292075634003,
0.09561588615179062,
0.04905109480023384,
-0.052887093275785446,
0.017377441748976707,
0.051786020398139954,
-0.04571235179901123,
0.025484547019004822,
0.0026527903974056244,
-0.004741724114865065,
-0.0370103120803833,
0.010540124960243702,
-0.00992743019014597,
-0.026212677359580994,
-0.026656659319996834,
0.020050210878252983,
-0.07870906591415405,
-0.030439382418990135,
-0.00044897643965668976,
0.07153432071208954,
0.006202423945069313,
0.010398050770163536,
0.0009140472393482924,
0.029391584917902946,
0.0046973261050879955,
0.023903971537947655,
-0.09391099959611893,
-0.015193052589893341,
0.09689455479383469,
0.05313572287559509,
-0.05079150199890137,
0.028006363660097122,
-0.016329646110534668,
-0.012014143168926239,
0.07267091423273087,
0.03420434519648552,
-0.02379741705954075,
0.035944756120443344,
0.006695243529975414,
0.007405614014714956,
-0.06162465363740921,
0.0253602322191,
0.006149145774543285,
-0.0017503977287560701,
0.0013596938224509358,
0.031096475198864937,
-0.005336659494787455,
0.018682748079299927,
-0.021080249920487404,
-0.002617271849885583,
-0.015779107809066772,
0.0382179394364357,
0.034683845937252045,
-0.002319804159924388,
-0.03395571559667587,
-0.006752960849553347,
-0.031416140496730804,
0.05217672511935234,
0.00029219541465863585,
-0.03867968171834946,
-0.007791878189891577,
0.01902017369866371,
-0.0457833893597126,
-0.05967113375663757,
0.04713309183716774,
-0.010948587208986282,
0.02690528891980648,
-0.02090265601873398,
0.021914934739470482,
-0.016702590510249138,
-0.042409129440784454,
0.028077399358153343,
-0.005802840460091829,
-0.04116597771644592,
-0.07053980231285095,
0.02445450983941555,
0.013070819899439812,
-0.03903486579656601,
-0.031025437638163567,
0.03814690560102463,
-0.03480816259980202,
-0.026408029720187187,
-0.04652927815914154,
-0.0002465485595166683,
-0.030830085277557373,
-0.06073668971657753,
0.015379524789750576,
-0.010167179629206657,
0.03960316255688667,
-0.04713309183716774,
-0.023673102259635925,
0.0231936015188694,
-0.04755931347608566,
0.0018458537524566054,
-0.035429734736680984,
-0.0030790127348154783,
-0.022643065080046654,
-0.01516641303896904,
0.01598333939909935,
-0.030652493238449097,
0.0708949938416481,
-0.017510635778307915,
-0.03828897699713707,
-0.00198015826754272,
-0.009314735420048237,
0.019233284518122673,
-0.002103363163769245,
-0.022021489217877388,
0.014926663599908352,
0.006886155344545841,
0.05810831859707832,
-0.0065975673496723175,
-0.012875467538833618,
0.00824917946010828,
0.04269327595829964,
0.039070386439561844,
0.038537606596946716,
0.02461434341967106,
0.04201842471957207,
-0.02260754629969597,
0.00796947069466114,
-0.02171958237886429,
-0.007698642089962959,
0.043226055800914764,
-0.05732691287994385,
0.04127253592014313,
0.038182422518730164,
0.009838633239269257,
0.04180531203746796,
-0.025324713438749313,
-0.005953793879598379,
0.03843105211853981,
-0.026638898998498917,
0.016223089769482613,
-0.0005810610018670559,
0.022394435480237007,
0.061731208115816116,
-0.03946109116077423,
0.010717716999351978,
-0.0413435734808445,
-0.08084017783403397,
0.03464832901954651,
0.04674238711595535,
0.008195901289582253,
-0.020263323560357094,
0.0027038482949137688,
-0.0022865054197609425,
-0.011126180179417133,
0.001969058532267809,
0.0010810953099280596,
0.029693493619561195,
0.006144706159830093,
-0.06752073019742966,
0.02639026939868927,
-0.0596000961959362,
0.03429314121603966,
-0.0038826195523142815,
0.0074899704195559025,
0.006575368344783783,
0.08375269919633865,
-0.006109187379479408,
0.00801386870443821,
-0.026869770139455795,
0.004133469425141811,
0.03239290043711662,
-0.062192950397729874,
0.00656204903498292,
-0.0017148791812360287,
-0.029622456058859825,
0.01866498962044716,
0.000007140994057408534,
0.008657642640173435,
-0.022998249158263206,
0.024703139439225197,
0.007521049119532108,
-0.00557640939950943,
0.06428854167461395,
0.0896487757563591,
-0.009225938469171524,
-0.016089895740151405,
-0.0072591002099215984,
-0.04269327595829964,
-0.004808321129530668,
-0.03967420011758804,
-0.017892461270093918,
-0.020334359258413315,
-0.01962398923933506,
0.0025528944097459316,
0.0005899406387470663,
-0.002632811199873686,
0.0639333575963974,
-0.09426618367433548,
-0.004630728624761105,
-0.017927980050444603,
0.015583756379783154,
0.04500197991728783,
-0.056900687515735626,
0.06428854167461395,
0.03345845639705658,
-0.04368779435753822,
0.010699957609176636,
-0.020121248438954353,
-0.04571235179901123,
0.026479065418243408,
0.005975992884486914,
-0.04681342467665672,
0.08858322352170944,
-0.020831618458032608,
0.03285464271903038,
0.06222846731543541,
0.043012943118810654,
0.03159373626112938,
-0.016045497730374336,
-0.016347404569387436,
-0.08453410863876343,
-0.006100308150053024,
0.053775057196617126,
-0.020938174799084663,
-0.048660390079021454,
-0.050223205238580704,
0.012724514119327068,
-0.02877001091837883,
0.051999133080244064,
-0.06538961827754974,
-0.029924362897872925,
-0.015859024599194527,
0.035429734736680984,
-0.015228570438921452,
-0.007707521319389343,
-0.02900088205933571,
0.0011698916787281632,
0.018487395718693733,
-0.02900088205933571,
0.001343044452369213,
0.004040232859551907,
0.010682198219001293,
-0.05487613379955292,
-0.0228916946798563,
-0.03471936658024788,
-0.011561281979084015,
-0.007556567899882793,
0.009394652210175991,
-0.027526862919330597,
0.0038337816949933767,
0.09625522047281265,
-0.04304846003651619,
0.008329096250236034,
-0.02907191962003708,
-0.026336992159485817,
-0.0037782839499413967,
-0.031096475198864937,
0.018629470840096474,
-0.03658408671617508,
-0.00644661346450448,
-0.0281839556992054,
-0.03903486579656601,
-0.0028481422923505306,
0.017679348587989807,
0.01887810043990612,
0.04272879287600517,
0.03729445859789848,
-0.03484367951750755,
-0.062477096915245056,
0.00542545598000288,
-0.06176672875881195,
0.0538460947573185,
-0.015628153458237648,
0.0298000480979681,
0.06155361607670784,
0.0012708974536508322,
0.06105635687708855,
-0.0036850478500127792,
-0.06155361607670784,
0.006055909674614668,
-0.0004131804162170738,
0.004648488014936447,
0.008076026104390621,
0.038253460079431534,
-0.016853542998433113,
-0.05508924275636673,
-0.015050978399813175,
-0.014882264658808708,
0.028130678460001945,
-0.04468231275677681,
-0.009847513400018215,
0.009430170059204102,
-0.009172661229968071,
0.03285464271903038,
-0.024401232600212097,
-0.019908137619495392,
-0.01784806326031685,
-0.04095286875963211,
-0.051999133080244064,
0.018700506538152695,
0.01115281879901886,
-0.017492877319455147,
0.0281839556992054,
0.010682198219001293,
0.016320765018463135,
-0.019535193219780922,
0.014873385429382324,
-0.015965580940246582,
0.027189437299966812,
0.004248904529958963,
-0.05075598135590553,
0.036690644919872284,
-0.001486228546127677,
-0.009341374039649963,
0.037720680236816406,
0.017448479309678078,
0.022785138338804245,
-0.03420434519648552,
0.012067421339452267,
-0.041450127959251404,
0.0356961265206337,
-0.0713922530412674,
-0.023229120299220085,
0.004324381239712238,
0.02177285961806774,
-0.0872335135936737,
0.005172386299818754,
0.029764529317617416,
0.005270062480121851,
-0.05189257487654686,
-0.0015639254124835134,
0.03367156907916069,
-0.04734620451927185,
-0.025839732959866524,
0.051111169159412384,
-0.03590923547744751,
0.009017267264425755,
-0.03217979148030281,
-0.03708134964108467,
-0.04223153367638588,
-0.029480382800102234,
-0.02104473114013672,
0.030386105179786682,
0.011836551129817963,
-0.016089895740151405,
0.01894913613796234,
-0.0016305226599797606,
0.02095593325793743,
0.027562381699681282,
-0.016604913398623466,
-0.016667071729898453,
0.003027954837307334,
-0.021524230018258095,
-0.0665617287158966,
-0.020920416340231895,
-0.01665819250047207,
-0.014482681639492512,
0.00834241509437561,
-0.01843411847949028,
0.001144362729974091,
0.029249511659145355,
0.041379090398550034,
-0.0027038482949137688,
0.008968429639935493,
0.026585621759295464,
-0.04475335031747818,
-0.024063805118203163,
0.015326246619224548,
-0.005465414375066757,
-0.01784806326031685,
-0.04347468540072441,
-0.02282065711915493,
0.028414826840162277,
0.0640399158000946,
-0.010966346599161625,
-0.0450730174779892,
0.0033320824149996042,
0.04571235179901123,
-0.003163369372487068
]
|
30,406 | networkx.generators.random_graphs | barabasi_albert_graph | Returns a random graph using Barabási–Albert preferential attachment
A graph of $n$ nodes is grown by attaching new nodes each with $m$
edges that are preferentially attached to existing nodes with high degree.
Parameters
----------
n : int
Number of nodes
m : int
Number of edges to attach from a new node to existing nodes
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
initial_graph : Graph or None (default)
Initial network for Barabási–Albert algorithm.
It should be a connected graph for most use cases.
A copy of `initial_graph` is used.
If None, starts from a star graph on (m+1) nodes.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m` does not satisfy ``1 <= m < n``, or
the initial graph number of nodes m0 does not satisfy ``m <= m0 <= n``.
References
----------
.. [1] A. L. Barabási and R. Albert "Emergence of scaling in
random networks", Science 286, pp 509-512, 1999.
| def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None):
"""Returns a random graph using dual Barabási–Albert preferential attachment
A graph of $n$ nodes is grown by attaching new nodes each with either $m_1$
edges (with probability $p$) or $m_2$ edges (with probability $1-p$) that
are preferentially attached to existing nodes with high degree.
Parameters
----------
n : int
Number of nodes
m1 : int
Number of edges to link each new node to existing nodes with probability $p$
m2 : int
Number of edges to link each new node to existing nodes with probability $1-p$
p : float
The probability of attaching $m_1$ edges (as opposed to $m_2$ edges)
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
initial_graph : Graph or None (default)
Initial network for Barabási–Albert algorithm.
A copy of `initial_graph` is used.
It should be connected for most use cases.
If None, starts from an star graph on max(m1, m2) + 1 nodes.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m1` and `m2` do not satisfy ``1 <= m1,m2 < n``, or
`p` does not satisfy ``0 <= p <= 1``, or
the initial graph number of nodes m0 does not satisfy m1, m2 <= m0 <= n.
References
----------
.. [1] N. Moshiri "The dual-Barabasi-Albert model", arXiv:1810.10538.
"""
if m1 < 1 or m1 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m1 >= 1 and m1 < n, m1 = {m1}, n = {n}"
)
if m2 < 1 or m2 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m2 >= 1 and m2 < n, m2 = {m2}, n = {n}"
)
if p < 0 or p > 1:
raise nx.NetworkXError(
f"Dual Barabási–Albert network must have 0 <= p <= 1, p = {p}"
)
# For simplicity, if p == 0 or 1, just return BA
if p == 1:
return barabasi_albert_graph(n, m1, seed)
elif p == 0:
return barabasi_albert_graph(n, m2, seed)
if initial_graph is None:
# Default initial graph : empty graph on max(m1, m2) nodes
G = star_graph(max(m1, m2))
else:
if len(initial_graph) < max(m1, m2) or len(initial_graph) > n:
raise nx.NetworkXError(
f"Barabási–Albert initial graph must have between "
f"max(m1, m2) = {max(m1, m2)} and n = {n} nodes"
)
G = initial_graph.copy()
# Target nodes for new edges
targets = list(G)
# List of existing nodes, with nodes repeated once for each adjacent edge
repeated_nodes = [n for n, d in G.degree() for _ in range(d)]
# Start adding the remaining nodes.
source = len(G)
while source < n:
# Pick which m to use (m1 or m2)
if seed.random() < p:
m = m1
else:
m = m2
# Now choose m unique nodes from the existing nodes
# Pick uniformly from repeated_nodes (preferential attachment)
targets = _random_subset(repeated_nodes, m, seed)
# Add edges to m nodes from the source.
G.add_edges_from(zip([source] * m, targets))
# Add one node to the list for each new edge just created.
repeated_nodes.extend(targets)
# And the new node "source" has m edges to add to the list.
repeated_nodes.extend([source] * m)
source += 1
return G
| (n, m, seed=None, initial_graph=None, *, backend=None, **backend_kwargs) | [
0.003537906799465418,
0.0015090598026290536,
0.015320549719035625,
0.004910432733595371,
-0.02494978718459606,
-0.0408547967672348,
-0.0648464560508728,
-0.036294084042310715,
0.01211080327630043,
-0.030066218227148056,
0.006457817740738392,
0.041966233402490616,
-0.036830637603998184,
0.1071576178073883,
-0.043039340525865555,
0.013049773871898651,
0.03466525673866272,
0.04740842804312706,
-0.005897309631109238,
0.027345120906829834,
-0.0400499664247036,
0.0019869287498295307,
0.00009296886128140613,
0.0710168331861496,
-0.03455028310418129,
0.010721510276198387,
-0.039130158722400665,
0.010759835131466389,
-0.015598407946527004,
0.05928928032517433,
0.039245136082172394,
-0.12348420172929764,
0.020983116701245308,
0.0390726700425148,
-0.00014147434558253735,
0.010175374336540699,
0.02769004926085472,
0.06116722151637077,
-0.10953378677368164,
-0.036792315542697906,
0.07090185582637787,
-0.05541842430830002,
0.08339591324329376,
0.01310726162046194,
0.024700673297047615,
-0.02389584109187126,
0.030947702005505562,
0.012973123230040073,
-0.09650317579507828,
-0.009830445982515812,
0.01611579954624176,
-0.0705185979604721,
0.02621452324092388,
-0.0023833562154322863,
-0.020408237352967262,
0.018444063141942024,
-0.0031283048447221518,
0.044610679149627686,
0.017840439453721046,
0.025313878431916237,
0.06300684064626694,
-0.019545916467905045,
-0.01459236815571785,
-0.03525929898023605,
-0.02445155940949917,
0.021998737007379532,
-0.04855819046497345,
-0.026789404451847076,
-0.001455164747312665,
0.06204870343208313,
0.05035948008298874,
0.06407994776964188,
-0.008077062666416168,
0.05511182174086571,
0.054728567600250244,
0.0442657507956028,
0.048634838312864304,
0.027038518339395523,
-0.05212244391441345,
0.019718380644917488,
0.004194227978587151,
-0.02581210806965828,
0.01180420070886612,
-0.03432033210992813,
0.005490103270858526,
-0.015473851002752781,
0.006036239210516214,
0.003147467505186796,
0.0002807030687108636,
-0.10186871886253357,
-0.048596516251564026,
-0.04986124858260155,
0.05568670108914375,
0.016336170956492424,
0.03159923106431961,
-0.03328554704785347,
-0.006304516457021236,
-0.03234657645225525,
0.007516554556787014,
-0.024566534906625748,
-0.0450705848634243,
0.04369087144732475,
-0.038172025233507156,
0.0005952402134425938,
0.0065057240426540375,
0.007209951989352703,
-0.05216076970100403,
0.015138504095375538,
0.02084897831082344,
-0.03537427634000778,
-0.11712219566106796,
0.0436142235994339,
0.07979333400726318,
0.018242856487631798,
-0.022937707602977753,
-0.013279725797474384,
0.01500436570495367,
0.011622155085206032,
0.031963322311639786,
0.03221243619918823,
0.016307426616549492,
0.027096007019281387,
-0.03290229290723801,
-0.000196117878658697,
0.0007593205664306879,
-0.024068305268883705,
0.04825158789753914,
-0.008580083027482033,
-0.01290605403482914,
-0.03876606747508049,
0.010520302690565586,
0.014860645867884159,
-0.04706349968910217,
0.07017367333173752,
-0.012034152634441853,
-0.034396979957818985,
-0.04790665954351425,
0.005753589794039726,
0.06913889199495316,
0.004019368439912796,
-0.0008311805431731045,
-0.06683936715126038,
0.08899141103029251,
0.01290605403482914,
-0.03951341286301613,
-0.02150050923228264,
0.01721765287220478,
-0.05710473656654358,
0.0017976973904296756,
-0.012197035364806652,
0.0400499664247036,
-0.0012815031222999096,
0.020887304097414017,
-0.03455028310418129,
-0.039551738649606705,
0.017696719616651535,
-0.041506327688694,
-0.0003613958542700857,
-0.023205986246466637,
0.014688181690871716,
-0.030621936544775963,
-0.05465191602706909,
0.04874981567263603,
0.054306987673044205,
0.010098723694682121,
-0.03075607493519783,
0.04947799816727638,
0.0018683597445487976,
0.017438024282455444,
-0.03548925369977951,
-0.07431280612945557,
-0.001143771456554532,
-0.06607286632061005,
-0.06162712723016739,
0.05265899747610092,
-0.0021641834173351526,
-0.02602289617061615,
-0.031043514609336853,
0.02929971180856228,
0.03432033210992813,
0.03830616548657417,
-0.04729345440864563,
0.06779750436544418,
-0.05921262875199318,
-0.03064109943807125,
-0.035450927913188934,
-0.00637158565223217,
0.04300101846456528,
0.01806081086397171,
0.008541757240891457,
0.021366368979215622,
0.024815648794174194,
0.036159947514534,
0.06089894473552704,
0.025218065828084946,
0.005207453854382038,
0.02517974004149437,
0.01459236815571785,
-0.012915635481476784,
0.01111434493213892,
0.04560713842511177,
0.0021953226532787085,
0.020504049956798553,
0.02316766045987606,
0.027939163148403168,
0.0076794372871518135,
-0.03284480422735214,
-0.041966233402490616,
0.023148497566580772,
-0.02726846933364868,
0.004910432733595371,
-0.010472395457327366,
0.028571531176567078,
-0.027019355446100235,
-0.015397200360894203,
-0.06285353749990463,
0.0192105695605278,
0.017179327085614204,
-0.00008615713159088045,
-0.03493353724479675,
0.032078299671411514,
-0.058829378336668015,
0.010903555899858475,
0.02579294517636299,
0.005744008347392082,
0.043767523020505905,
-0.014582786709070206,
0.004048112779855728,
-0.01511934120208025,
0.028993109241127968,
0.03378377482295036,
-0.0008036341750994325,
0.03673482686281204,
-0.02834158018231392,
-0.03916848450899124,
-0.030200358480215073,
0.003092374885454774,
-0.03959006443619728,
-0.03579585626721382,
0.018971037119627,
-0.02937636338174343,
0.01981419324874878,
-0.020312422886490822,
-0.009011242538690567,
0.022267015650868416,
0.015560083091259003,
0.028284091502428055,
-0.05813952162861824,
-0.06852568686008453,
-0.01979503221809864,
-0.09336049854755402,
-0.01247489359229803,
0.024777323007583618,
0.03148425742983818,
0.02613787353038788,
-0.026463638991117477,
-0.02150050923228264,
0.009739424102008343,
-0.004000206012278795,
0.05859942361712456,
0.007166835945099592,
-0.02033158577978611,
-0.1112200990319252,
0.03169504553079605,
-0.0014743274077773094,
-0.005950007122009993,
-0.07074855268001556,
0.06952214241027832,
-0.013461771421134472,
-0.03131179139018059,
0.061780426651239395,
0.0006784780416637659,
0.00885315053164959,
0.00045062199933454394,
0.02698102965950966,
0.02339761145412922,
-0.012426987290382385,
0.019517172127962112,
-0.01960340514779091,
-0.04357589781284332,
-0.04127637669444084,
-0.043460920453071594,
0.024719836190342903,
0.04537718743085861,
-0.005863775033503771,
0.0041798558086156845,
-0.023320961743593216,
-0.06204870343208313,
0.02433658204972744,
-0.03351549804210663,
0.015435525216162205,
-0.028494881466031075,
0.005758380517363548,
0.05005287751555443,
-0.0017378140473738313,
-0.004840967711061239,
0.058637749403715134,
0.02349342592060566,
0.020159121602773666,
-0.008925010450184345,
0.037961237132549286,
-0.009677144698798656,
0.09113762527704239,
0.003961880691349506,
-0.01670026034116745,
-0.032059136778116226,
0.013643816113471985,
-0.025333041325211525,
-0.019871681928634644,
0.020044146105647087,
-0.09060107171535492,
0.02517974004149437,
0.05760296806693077,
0.030832724645733833,
-0.009451983496546745,
-0.06726095080375671,
0.011593411676585674,
0.0006659025675617158,
0.04047154635190964,
-0.003851695451885462,
-0.01733262836933136,
0.03748216852545738,
-0.001366537413559854,
0.0465269461274147,
-0.01757216267287731,
-0.002178555354475975,
0.04641197249293327,
0.07500266283750534,
0.0013365957420319319,
0.022286176681518555,
-0.04204288497567177,
0.01658528484404087,
-0.01064485963433981,
0.018798572942614555,
-0.08753504604101181,
0.08086644113063812,
-0.02749842219054699,
-0.02326347306370735,
0.06664774566888809,
-0.08600203692913055,
0.021653810515999794,
-0.04668024927377701,
-0.005221826024353504,
-0.010664022527635098,
0.04633532091975212,
0.044074125587940216,
0.012101221829652786,
-0.004096019547432661,
-0.05695143714547157,
0.06929218769073486,
-0.013653397560119629,
0.04192790761590004,
-0.002766609424725175,
0.02579294517636299,
-0.01916266418993473,
0.033534660935401917,
-0.0098496088758111,
0.0044936444610357285,
0.010165792889893055,
0.07028865069150925,
-0.023359287530183792,
-0.0056673577055335045,
-0.027766698971390724,
-0.013672560453414917,
0.027670886367559433,
0.006280562840402126,
0.002358205383643508,
0.043882500380277634,
0.03847862780094147,
-0.05254402384161949,
0.06975209712982178,
-0.06714597344398499,
-0.04510891065001488,
0.049248043447732925,
0.010405326262116432,
-0.028782321140170097,
-0.03771212324500084,
0.020044146105647087,
0.03211662545800209,
0.03305559605360031,
-0.012350336648523808,
-0.03959006443619728,
0.009964585304260254,
0.03959006443619728,
-0.006179959047585726,
-0.012043734081089497,
0.07258816808462143,
0.003760672640055418,
-0.00655363081023097,
-0.027019355446100235,
0.01284856628626585,
-0.029855430126190186,
0.07323969900608063,
0.007018325384706259,
-0.05499684438109398,
0.005068524274975061,
0.04116139933466911,
-0.026061221957206726,
-0.03709891811013222,
-0.003533116076141596,
0.002505518263205886,
0.016939794644713402,
-0.05055110529065132,
-0.023646727204322815,
-0.0056721484288573265,
-0.033956240862607956,
0.027843350544571877,
0.02803497575223446,
0.011296390555799007,
0.014966039918363094,
-0.015157666988670826,
0.02295687049627304,
-0.019028523936867714,
-0.011670062318444252,
0.023665890097618103,
-0.0010820917086675763,
-0.005916472524404526,
-0.020178284496068954,
0.010903555899858475,
0.014975621365010738,
0.03244239091873169,
-0.007775250822305679,
0.0065057240426540375,
-0.02487313747406006,
0.04411245137453079,
0.005815868265926838,
-0.05104933679103851,
0.019660891965031624,
-0.0815562978386879,
0.022094551473855972,
0.05396205931901932,
-0.03962838649749756,
0.033458009362220764,
-0.043039340525865555,
0.024624021723866463,
0.008556129410862923,
0.028935622423887253,
0.005365545861423016,
0.05679813399910927,
-0.02295687049627304,
0.01211080327630043,
0.02222868986427784,
0.011708387173712254,
-0.057449664920568466,
-0.029644640162587166,
-0.04568378999829292,
-0.02171129733324051,
-0.001282700803130865,
0.01606789417564869,
-0.020465724170207977,
-0.005729636177420616,
-0.00529368594288826,
0.0711701288819313,
-0.006726094987243414,
-0.04748507961630821,
0.035757530480623245,
0.05974918603897095,
-0.02801581472158432,
-0.034607771784067154,
0.10064230859279633,
0.014822320081293583,
0.00700395368039608,
0.01233117375522852,
0.0958133190870285,
0.034282006323337555,
-0.01918182522058487,
0.054192014038562775,
-0.020044146105647087,
-0.015263061039149761,
0.03803788870573044,
-0.019009362906217575,
0.0002275566221214831,
0.015560083091259003,
-0.03305559605360031,
-0.01679607480764389,
-0.038708578795194626,
-0.009442402049899101,
-0.03970503807067871,
-0.011373041197657585,
-0.011238901875913143,
0.017342209815979004,
0.004016973543912172,
0.010309512726962566,
0.032174110412597656,
0.022918544709682465,
-0.027766698971390724,
-0.035546742379665375,
0.0253713671118021,
0.012014989741146564,
0.0027091214433312416,
-0.07316304743289948,
-0.0800999328494072,
0.02232450246810913,
0.037022266536951065,
-0.05150923877954483,
-0.012647357769310474,
-0.01716974563896656,
-0.047983311116695404,
-0.007554879877716303,
-0.07634405046701431,
0.01927763968706131,
-0.011210158467292786,
-0.014659437350928783,
-0.04656527191400528,
0.0073632532730698586,
0.0004200815164949745,
-0.00216657854616642,
-0.0174284428358078,
0.0022108922712504864,
0.06342841684818268,
-0.00012800061085727066,
-0.02381919138133526,
0.03759714588522911,
0.03686896339058876,
-0.014611531049013138,
0.01627868227660656,
-0.008599244989454746,
0.0045607141219079494,
0.0513942651450634,
-0.028782321140170097,
0.034818559885025024,
0.034703582525253296,
0.03146509453654289,
-0.04595206677913666,
0.027536747977137566,
-0.008814824745059013,
0.01400790736079216,
-0.011085600592195988,
0.02150050923228264,
-0.007051859982311726,
-0.024700673297047615,
0.03640906140208244,
0.040088292211294174,
0.02012079581618309,
-0.010865230113267899,
-0.014027069322764874,
0.01006997935473919,
0.005451777949929237,
-0.05235239490866661,
-0.05170086771249771,
0.008239945396780968,
0.019268058240413666,
-0.007540508173406124,
-0.012676102109253407,
-0.006476980168372393,
-0.012973123230040073,
-0.040701497346162796,
0.0009263950050808489,
-0.012771915644407272,
-0.01922973245382309,
-0.002457611495628953,
0.015033109113574028,
-0.01850155182182789,
-0.02234366536140442,
0.00671651354059577,
-0.05652985721826553,
-0.0779920369386673,
0.048519864678382874,
0.06028573960065842,
0.024604860693216324,
-0.06714597344398499,
0.01500436570495367,
-0.02220952697098255,
0.0017905114218592644,
0.03778877109289169,
0.04307766631245613,
-0.024719836190342903,
-0.0013569560833275318,
-0.019574660807847977,
-0.010970625095069408,
0.02401081658899784,
0.0342053547501564,
0.030162032693624496,
0.01770630106329918,
-0.042924366891384125,
-0.007209951989352703,
-0.04970794916152954,
-0.05001455172896385,
-0.009830445982515812,
0.008925010450184345,
0.000021183725039009005,
0.06185707822442055,
-0.02274608239531517,
0.016336170956492424,
0.0442657507956028,
0.028475718572735786,
-0.02939552627503872,
0.0188081543892622,
0.0019474056316539645,
-0.02866734378039837,
-0.07688060402870178,
-0.022477803751826286,
0.032289087772369385,
-0.044610679149627686,
0.004730782471597195,
0.0423111617565155,
0.04767670854926109,
-0.015215154737234116,
-0.056721482425928116,
-0.07546257227659225,
0.03562339022755623,
0.032499875873327255,
0.0019701614510267973,
-0.0014994784723967314,
0.055150143802165985,
0.016786493360996246,
-0.0036193481646478176,
-0.06316013634204865,
0.02529471553862095,
0.0034684420097619295,
-0.03654319792985916,
-0.001748593058437109,
-0.027153493836522102,
-0.06381166726350784,
-0.03799956291913986,
-0.05396205931901932,
-0.045032259076833725,
0.0186452716588974,
0.023340124636888504,
0.047255128622055054,
-0.035431765019893646,
0.019833356142044067,
0.018252436071634293,
0.05108766257762909,
-0.025352204218506813,
-0.006170377600938082,
-0.025658806785941124,
-0.025735456496477127,
0.01576129160821438,
-0.0032408854458481073,
0.01668109931051731,
-0.05794789269566536,
0.0291847363114357,
-0.001885127043351531,
0.024585697799921036,
-0.02381919138133526,
0.05170086771249771,
0.00797645840793848,
0.0020252540707588196,
0.08776500076055527,
-0.06664774566888809,
0.010769416578114033,
-0.06335176527500153,
-0.003676836146041751,
-0.03782709687948227,
0.005734426900744438,
-0.020197447389364243,
0.019239313900470734,
0.010961043648421764,
-0.02600373513996601,
-0.022305339574813843,
0.0507427342236042,
0.0081058070063591,
-0.0031235141213983297,
-0.03278731554746628,
-0.0024252745788544416,
0.017811695113778114,
-0.005734426900744438,
-0.0030205147340893745,
-0.03414786607027054,
0.06591956317424774,
0.004608620423823595,
0.029012272134423256,
0.044189102947711945,
0.007818366400897503,
0.05813952162861824,
0.022631105035543442,
-0.03978168964385986,
-0.0366390123963356,
0.007842320017516613,
-0.028092464432120323,
-0.027440933510661125,
-0.006227865815162659,
-0.06511472910642624,
-0.04802163317799568,
0.0299129169434309,
-0.021328045055270195,
-0.0047738985158503056,
0.011497598141431808,
0.011986246332526207,
0.0773405134677887,
-0.002876794897019863,
-0.002946259453892708,
-0.0053415922448039055,
0.0016431984258815646,
0.050627756863832474,
-0.014774413779377937,
0.018194949254393578,
-0.05721971392631531,
-0.0022528106346726418,
0.021538833156228065,
-0.02517974004149437,
0.023455100134015083,
0.05032115429639816,
0.03865109384059906,
0.06392664462327957,
-0.02579294517636299,
-0.017294304445385933,
-0.053770434111356735,
-0.04752340540289879,
0.021193906664848328,
-0.03890020772814751,
-0.03604497015476227,
0.058177847415208817,
-0.07596080005168915,
0.03537427634000778,
-0.05112598463892937,
0.008987288922071457,
-0.03253820165991783,
0.010232862085103989,
-0.018079973757267,
-0.04530053585767746,
0.04920972138643265,
-0.00857529230415821,
0.004306808579713106,
-0.0402032695710659,
-0.005605079233646393,
0.031560905277729034,
-0.05453693866729736,
0.001576129114255309,
-0.0619337297976017,
-0.013806698843836784,
0.03612162172794342,
0.007377625443041325,
0.023838354274630547,
-0.008350130170583725,
0.03163755685091019,
-0.05373210832476616,
-0.01211080327630043,
-0.03610245883464813,
0.01422827783972025,
0.032825641334056854,
0.0013749210629612207,
0.015033109113574028,
-0.00384690472856164,
-0.03393707796931267,
0.011037694290280342,
0.0092411944642663,
0.023665890097618103,
0.00850343145430088,
0.01665235497057438,
0.0034253261983394623,
-0.052199095487594604,
0.04457235336303711,
-0.006117680110037327,
0.03600664436817169,
-0.030315333977341652,
0.00811538752168417,
0.008398037403821945,
0.0003272623580414802,
0.05453693866729736,
-0.017907509580254555,
-0.0186452716588974,
0.0549585185945034,
0.027670886367559433,
0.004982292652130127,
0.047983311116695404,
-0.029223062098026276,
-0.032078299671411514,
-0.07339300215244293,
-0.016317008063197136,
0.013653397560119629,
0.061895404011011124,
-0.04073982313275337,
-0.002276764018461108,
0.02065735124051571,
0.01592417247593403,
0.047140151262283325
]
|
30,407 | networkx.generators.classic | barbell_graph | Returns the Barbell Graph: two complete graphs connected by a path.
.. plot::
>>> nx.draw(nx.barbell_graph(4, 2))
Parameters
----------
m1 : int
Size of the left and right barbells, must be greater than 2.
m2 : int
Length of the path connecting the barbells.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Only undirected Graphs are supported.
Returns
-------
G : NetworkX graph
A barbell graph.
Notes
-----
Two identical complete graphs $K_{m1}$ form the left and right bells,
and are connected by a path $P_{m2}$.
The `2*m1+m2` nodes are numbered
`0, ..., m1-1` for the left barbell,
`m1, ..., m1+m2-1` for the path,
and `m1+m2, ..., 2*m1+m2-1` for the right barbell.
The 3 subgraphs are joined via the edges `(m1-1, m1)` and
`(m1+m2-1, m1+m2)`. If `m2=0`, this is merely two complete
graphs joined together.
This graph is an extremal example in David Aldous
and Jim Fill's e-text on Random Walks on Graphs.
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (m1, m2, create_using=None, *, backend=None, **backend_kwargs) | [
0.0222346018999815,
-0.006948312744498253,
0.021684063598513603,
-0.050223205238580704,
-0.012688995338976383,
0.06666828691959381,
-0.04755931347608566,
0.007427813019603491,
-0.0007164754206314683,
0.005061390809714794,
0.00412458973005414,
0.062477096915245056,
0.016995618119835854,
0.07608069479465485,
0.027011843398213387,
-0.007609845604747534,
0.014828987419605255,
0.011898708529770374,
-0.0228916946798563,
0.03793379291892052,
-0.019819341599941254,
0.01516641303896904,
0.03425762429833412,
0.013914384879171848,
-0.02088489755988121,
0.012058542110025883,
0.022287879139184952,
0.032446179538965225,
-0.037365496158599854,
0.02727823331952095,
0.033121030777692795,
-0.012182856909930706,
0.0012098499573767185,
0.018309803679585457,
0.02060074917972088,
0.042338091880083084,
-0.02148871123790741,
0.05310020595788956,
-0.10442448407411575,
-0.015690311789512634,
0.0463872030377388,
-0.005896076560020447,
0.014855626039206982,
-0.032978955656290054,
0.012200616300106049,
0.028450343757867813,
0.0833975151181221,
0.004568571224808693,
-0.06876388192176819,
-0.0175461545586586,
0.04279983043670654,
0.0042933025397360325,
-0.04319053515791893,
-0.058392468839883804,
-0.0019291002536192536,
0.010122781619429588,
-0.00752992881461978,
-0.012271652929484844,
0.0594935417175293,
-0.039958350360393524,
0.03358277305960655,
0.03210875391960144,
0.006197983864694834,
-0.023477749899029732,
-0.05622583627700806,
-0.021897174417972565,
-0.03885727375745773,
-0.061447061598300934,
-0.01426957082003355,
-0.018984654918313026,
0.05405920743942261,
0.041592203080654144,
0.03017299249768257,
-0.009669920429587364,
0.012831069529056549,
0.026336992159485817,
0.03644201532006264,
0.01088642980903387,
-0.010477966628968716,
-0.009061665274202824,
-0.02282065711915493,
-0.03628218173980713,
0.021985972300171852,
-0.04809209331870079,
0.046280648559331894,
0.0983152985572815,
-0.0197127852588892,
0.02095593325793743,
-0.044646795839071274,
-0.023903971537947655,
-0.02445450983941555,
-0.027828769758343697,
-0.02610612101852894,
0.0054831732995808125,
-0.012715634889900684,
0.015965580940246582,
0.050294242799282074,
-0.09249025583267212,
0.012316050939261913,
-0.0010111682349815965,
-0.03747205063700676,
-0.033405181020498276,
-0.08865425735712051,
-0.02186165750026703,
-0.05665205791592598,
-0.031416140496730804,
-0.025306954979896545,
0.05686517059803009,
-0.01311521790921688,
0.02855690009891987,
-0.019073452800512314,
0.017448479309678078,
0.06613551080226898,
-0.013647995889186859,
0.02974677085876465,
0.0426577590405941,
-0.0182032473385334,
0.03864416480064392,
0.06528306007385254,
-0.023069286718964577,
-0.05842798575758934,
0.04422057420015335,
-0.04031353443861008,
0.029764529317617416,
0.026887528598308563,
-0.00033298623748123646,
0.04461127519607544,
-0.05310020595788956,
0.03026179037988186,
0.021098008379340172,
-0.0015728049911558628,
0.018931377679109573,
-0.0010305923642590642,
0.0682666227221489,
-0.035358697175979614,
0.013257292099297047,
-0.0788511410355568,
-0.028450343757867813,
-0.0012653477024286985,
-0.01426957082003355,
0.0338846817612648,
-0.03409779071807861,
0.03875071927905083,
0.0495128333568573,
-0.060772210359573364,
0.015468320809304714,
0.018682748079299927,
0.019162248820066452,
0.013266172260046005,
-0.014500441029667854,
0.02370862103998661,
0.0020545250736176968,
0.09526070207357407,
0.030652493238449097,
-0.022128045558929443,
-0.018380841240286827,
0.027118399739265442,
-0.022394435480237007,
-0.012138458900153637,
0.02981780841946602,
-0.007498850114643574,
0.01196974515914917,
0.039816275238990784,
-0.016596034169197083,
-0.07622276991605759,
-0.0033276425674557686,
-0.0063045392744243145,
-0.004266663920134306,
0.006526530254632235,
-0.027118399739265442,
-0.04162771999835968,
-0.0008951780037023127,
0.0013219553511589766,
-0.056012727320194244,
-0.004577450919896364,
-0.0020034671761095524,
-0.030865604057908058,
-0.01115281879901886,
-0.017235368490219116,
-0.025893010199069977,
0.02965797483921051,
-0.07071739435195923,
0.029107436537742615,
-0.041734274476766586,
-0.012094059959053993,
0.017723748460412025,
0.009900790639221668,
0.014109737239778042,
0.029196234419941902,
0.03361828997731209,
0.04667135328054428,
0.02512936107814312,
-0.012928745709359646,
0.056012727320194244,
0.022856175899505615,
-0.058392468839883804,
0.06986495107412338,
0.036246661096811295,
-0.07224469631910324,
0.055195800960063934,
0.07735936343669891,
0.07132121175527573,
0.020405396819114685,
-0.01040692999958992,
0.04851831495761871,
-0.0006398885743692517,
-0.051324278116226196,
-0.04816313087940216,
-0.05175050348043442,
0.028716733679175377,
-0.008022748865187168,
0.019641747698187828,
0.03796930983662605,
0.044575758278369904,
-0.06478580087423325,
0.0696873590350151,
0.039070386439561844,
0.03171804919838905,
0.010069504380226135,
-0.06112739443778992,
-0.0351455882191658,
-0.015716951340436935,
0.0032166470773518085,
0.03425762429833412,
-0.00845785066485405,
-0.005762882065027952,
-0.00834241509437561,
-0.01677362620830536,
-0.004617409314960241,
-0.06269021332263947,
0.026514584198594093,
-0.026567861437797546,
0.04425609111785889,
-0.015272969380021095,
0.012573560699820518,
-0.015193052589893341,
0.03352949395775795,
-0.01166783832013607,
-0.04237360879778862,
0.03232186287641525,
-0.055124763399362564,
-0.01948191411793232,
0.007383415009826422,
-0.009314735420048237,
-0.013852227479219437,
0.07977462559938431,
-0.010389170609414577,
0.03146941959857941,
0.0024263598024845123,
-0.011632319539785385,
-0.004450916312634945,
-0.01902017369866371,
0.012839949689805508,
-0.030901122838258743,
0.018895858898758888,
0.030492659658193588,
-0.056971725076436996,
-0.007387854624539614,
0.01516641303896904,
0.04269327595829964,
-0.027562381699681282,
-0.008861874230206013,
-0.05796624347567558,
-0.02839706651866436,
0.061731208115816116,
0.018078932538628578,
-0.06869284063577652,
0.05285157635807991,
-0.05952905863523483,
-0.02862793765962124,
0.05722035467624664,
0.081479512155056,
0.1052769273519516,
0.004539712332189083,
0.012724514119327068,
-0.05604824423789978,
0.0024929570499807596,
0.039816275238990784,
-0.04294190555810928,
-0.03166477009654045,
-0.053775057196617126,
-0.03715238347649574,
-0.01174775417894125,
0.04290638864040375,
0.025306954979896545,
0.032304104417562485,
0.05001009255647659,
-0.004022473935037851,
0.025662139058113098,
-0.02877001091837883,
0.01969502680003643,
-0.014802348800003529,
-0.03679719939827919,
-0.0031189711298793554,
0.030492659658193588,
0.020245563238859177,
-0.02653234452009201,
0.015317367389798164,
0.0023264638148248196,
0.05256742984056473,
0.09419514983892441,
-0.05310020595788956,
0.03665512427687645,
0.022483231499791145,
0.045392684638500214,
0.02699408493936062,
0.00044203922152519226,
0.010398050770163536,
0.012768912129104137,
0.014731311239302158,
-0.05448542907834053,
0.01431396882981062,
0.0049947937950491905,
0.009341374039649963,
-0.010477966628968716,
-0.05860557779669762,
-0.020476434379816055,
-0.02139991521835327,
0.03796930983662605,
0.0382179394364357,
0.01918000727891922,
0.005194585304707289,
-0.05256742984056473,
0.02125784195959568,
-0.05242535471916199,
0.053348835557699203,
-0.01007838360965252,
0.05704276263713837,
-0.04919316619634628,
0.0210269708186388,
0.019002415239810944,
-0.01955295167863369,
-0.031096475198864937,
0.03544749692082405,
-0.07206710427999496,
0.03544749692082405,
0.013861107639968395,
-0.0325704924762249,
-0.015539358370006084,
-0.05107564851641655,
0.0298000480979681,
0.01055788341909647,
-0.015583756379783154,
0.007028229534626007,
-0.030048677697777748,
0.03871519863605499,
0.046955499798059464,
-0.0934847742319107,
-0.03793379291892052,
-0.026674417778849602,
0.031558215618133545,
0.07870906591415405,
-0.026265954598784447,
-0.029764529317617416,
0.04027801752090454,
0.06649069488048553,
0.005349978804588318,
0.012324931100010872,
-0.0640399158000946,
-0.010655559599399567,
-0.0036961473524570465,
0.003547413507476449,
0.062192950397729874,
-0.009865272790193558,
-0.005691844969987869,
0.021098008379340172,
-0.013576959259808064,
0.08694937080144882,
0.01166783832013607,
-0.006499891635030508,
-0.0241526011377573,
-0.07359439879655838,
-0.07679107040166855,
0.050365280359983444,
-0.005833919160068035,
0.05420127883553505,
-0.015352885238826275,
-0.031771328300237656,
0.02713615819811821,
-0.001838084077462554,
-0.0419473871588707,
-0.019730545580387115,
0.04251568391919136,
0.0068950350396335125,
0.026408029720187187,
-0.000005484734174387995,
0.04113046079874039,
0.01925104483962059,
-0.04269327595829964,
-0.02758014015853405,
-0.05359746515750885,
-0.0463872030377388,
0.06244157999753952,
-0.004950395319610834,
-0.02937382645905018,
0.0021999292075634003,
0.09561588615179062,
0.04905109480023384,
-0.052887093275785446,
0.017377441748976707,
0.051786020398139954,
-0.04571235179901123,
0.025484547019004822,
0.0026527903974056244,
-0.004741724114865065,
-0.0370103120803833,
0.010540124960243702,
-0.00992743019014597,
-0.026212677359580994,
-0.026656659319996834,
0.020050210878252983,
-0.07870906591415405,
-0.030439382418990135,
-0.00044897643965668976,
0.07153432071208954,
0.006202423945069313,
0.010398050770163536,
0.0009140472393482924,
0.029391584917902946,
0.0046973261050879955,
0.023903971537947655,
-0.09391099959611893,
-0.015193052589893341,
0.09689455479383469,
0.05313572287559509,
-0.05079150199890137,
0.028006363660097122,
-0.016329646110534668,
-0.012014143168926239,
0.07267091423273087,
0.03420434519648552,
-0.02379741705954075,
0.035944756120443344,
0.006695243529975414,
0.007405614014714956,
-0.06162465363740921,
0.0253602322191,
0.006149145774543285,
-0.0017503977287560701,
0.0013596938224509358,
0.031096475198864937,
-0.005336659494787455,
0.018682748079299927,
-0.021080249920487404,
-0.002617271849885583,
-0.015779107809066772,
0.0382179394364357,
0.034683845937252045,
-0.002319804159924388,
-0.03395571559667587,
-0.006752960849553347,
-0.031416140496730804,
0.05217672511935234,
0.00029219541465863585,
-0.03867968171834946,
-0.007791878189891577,
0.01902017369866371,
-0.0457833893597126,
-0.05967113375663757,
0.04713309183716774,
-0.010948587208986282,
0.02690528891980648,
-0.02090265601873398,
0.021914934739470482,
-0.016702590510249138,
-0.042409129440784454,
0.028077399358153343,
-0.005802840460091829,
-0.04116597771644592,
-0.07053980231285095,
0.02445450983941555,
0.013070819899439812,
-0.03903486579656601,
-0.031025437638163567,
0.03814690560102463,
-0.03480816259980202,
-0.026408029720187187,
-0.04652927815914154,
-0.0002465485595166683,
-0.030830085277557373,
-0.06073668971657753,
0.015379524789750576,
-0.010167179629206657,
0.03960316255688667,
-0.04713309183716774,
-0.023673102259635925,
0.0231936015188694,
-0.04755931347608566,
0.0018458537524566054,
-0.035429734736680984,
-0.0030790127348154783,
-0.022643065080046654,
-0.01516641303896904,
0.01598333939909935,
-0.030652493238449097,
0.0708949938416481,
-0.017510635778307915,
-0.03828897699713707,
-0.00198015826754272,
-0.009314735420048237,
0.019233284518122673,
-0.002103363163769245,
-0.022021489217877388,
0.014926663599908352,
0.006886155344545841,
0.05810831859707832,
-0.0065975673496723175,
-0.012875467538833618,
0.00824917946010828,
0.04269327595829964,
0.039070386439561844,
0.038537606596946716,
0.02461434341967106,
0.04201842471957207,
-0.02260754629969597,
0.00796947069466114,
-0.02171958237886429,
-0.007698642089962959,
0.043226055800914764,
-0.05732691287994385,
0.04127253592014313,
0.038182422518730164,
0.009838633239269257,
0.04180531203746796,
-0.025324713438749313,
-0.005953793879598379,
0.03843105211853981,
-0.026638898998498917,
0.016223089769482613,
-0.0005810610018670559,
0.022394435480237007,
0.061731208115816116,
-0.03946109116077423,
0.010717716999351978,
-0.0413435734808445,
-0.08084017783403397,
0.03464832901954651,
0.04674238711595535,
0.008195901289582253,
-0.020263323560357094,
0.0027038482949137688,
-0.0022865054197609425,
-0.011126180179417133,
0.001969058532267809,
0.0010810953099280596,
0.029693493619561195,
0.006144706159830093,
-0.06752073019742966,
0.02639026939868927,
-0.0596000961959362,
0.03429314121603966,
-0.0038826195523142815,
0.0074899704195559025,
0.006575368344783783,
0.08375269919633865,
-0.006109187379479408,
0.00801386870443821,
-0.026869770139455795,
0.004133469425141811,
0.03239290043711662,
-0.062192950397729874,
0.00656204903498292,
-0.0017148791812360287,
-0.029622456058859825,
0.01866498962044716,
0.000007140994057408534,
0.008657642640173435,
-0.022998249158263206,
0.024703139439225197,
0.007521049119532108,
-0.00557640939950943,
0.06428854167461395,
0.0896487757563591,
-0.009225938469171524,
-0.016089895740151405,
-0.0072591002099215984,
-0.04269327595829964,
-0.004808321129530668,
-0.03967420011758804,
-0.017892461270093918,
-0.020334359258413315,
-0.01962398923933506,
0.0025528944097459316,
0.0005899406387470663,
-0.002632811199873686,
0.0639333575963974,
-0.09426618367433548,
-0.004630728624761105,
-0.017927980050444603,
0.015583756379783154,
0.04500197991728783,
-0.056900687515735626,
0.06428854167461395,
0.03345845639705658,
-0.04368779435753822,
0.010699957609176636,
-0.020121248438954353,
-0.04571235179901123,
0.026479065418243408,
0.005975992884486914,
-0.04681342467665672,
0.08858322352170944,
-0.020831618458032608,
0.03285464271903038,
0.06222846731543541,
0.043012943118810654,
0.03159373626112938,
-0.016045497730374336,
-0.016347404569387436,
-0.08453410863876343,
-0.006100308150053024,
0.053775057196617126,
-0.020938174799084663,
-0.048660390079021454,
-0.050223205238580704,
0.012724514119327068,
-0.02877001091837883,
0.051999133080244064,
-0.06538961827754974,
-0.029924362897872925,
-0.015859024599194527,
0.035429734736680984,
-0.015228570438921452,
-0.007707521319389343,
-0.02900088205933571,
0.0011698916787281632,
0.018487395718693733,
-0.02900088205933571,
0.001343044452369213,
0.004040232859551907,
0.010682198219001293,
-0.05487613379955292,
-0.0228916946798563,
-0.03471936658024788,
-0.011561281979084015,
-0.007556567899882793,
0.009394652210175991,
-0.027526862919330597,
0.0038337816949933767,
0.09625522047281265,
-0.04304846003651619,
0.008329096250236034,
-0.02907191962003708,
-0.026336992159485817,
-0.0037782839499413967,
-0.031096475198864937,
0.018629470840096474,
-0.03658408671617508,
-0.00644661346450448,
-0.0281839556992054,
-0.03903486579656601,
-0.0028481422923505306,
0.017679348587989807,
0.01887810043990612,
0.04272879287600517,
0.03729445859789848,
-0.03484367951750755,
-0.062477096915245056,
0.00542545598000288,
-0.06176672875881195,
0.0538460947573185,
-0.015628153458237648,
0.0298000480979681,
0.06155361607670784,
0.0012708974536508322,
0.06105635687708855,
-0.0036850478500127792,
-0.06155361607670784,
0.006055909674614668,
-0.0004131804162170738,
0.004648488014936447,
0.008076026104390621,
0.038253460079431534,
-0.016853542998433113,
-0.05508924275636673,
-0.015050978399813175,
-0.014882264658808708,
0.028130678460001945,
-0.04468231275677681,
-0.009847513400018215,
0.009430170059204102,
-0.009172661229968071,
0.03285464271903038,
-0.024401232600212097,
-0.019908137619495392,
-0.01784806326031685,
-0.04095286875963211,
-0.051999133080244064,
0.018700506538152695,
0.01115281879901886,
-0.017492877319455147,
0.0281839556992054,
0.010682198219001293,
0.016320765018463135,
-0.019535193219780922,
0.014873385429382324,
-0.015965580940246582,
0.027189437299966812,
0.004248904529958963,
-0.05075598135590553,
0.036690644919872284,
-0.001486228546127677,
-0.009341374039649963,
0.037720680236816406,
0.017448479309678078,
0.022785138338804245,
-0.03420434519648552,
0.012067421339452267,
-0.041450127959251404,
0.0356961265206337,
-0.0713922530412674,
-0.023229120299220085,
0.004324381239712238,
0.02177285961806774,
-0.0872335135936737,
0.005172386299818754,
0.029764529317617416,
0.005270062480121851,
-0.05189257487654686,
-0.0015639254124835134,
0.03367156907916069,
-0.04734620451927185,
-0.025839732959866524,
0.051111169159412384,
-0.03590923547744751,
0.009017267264425755,
-0.03217979148030281,
-0.03708134964108467,
-0.04223153367638588,
-0.029480382800102234,
-0.02104473114013672,
0.030386105179786682,
0.011836551129817963,
-0.016089895740151405,
0.01894913613796234,
-0.0016305226599797606,
0.02095593325793743,
0.027562381699681282,
-0.016604913398623466,
-0.016667071729898453,
0.003027954837307334,
-0.021524230018258095,
-0.0665617287158966,
-0.020920416340231895,
-0.01665819250047207,
-0.014482681639492512,
0.00834241509437561,
-0.01843411847949028,
0.001144362729974091,
0.029249511659145355,
0.041379090398550034,
-0.0027038482949137688,
0.008968429639935493,
0.026585621759295464,
-0.04475335031747818,
-0.024063805118203163,
0.015326246619224548,
-0.005465414375066757,
-0.01784806326031685,
-0.04347468540072441,
-0.02282065711915493,
0.028414826840162277,
0.0640399158000946,
-0.010966346599161625,
-0.0450730174779892,
0.0033320824149996042,
0.04571235179901123,
-0.003163369372487068
]
|
30,408 | networkx.algorithms.distance_measures | barycenter | Calculate barycenter of a connected graph, optionally with edge weights.
The :dfn:`barycenter` a
:func:`connected <networkx.algorithms.components.is_connected>` graph
:math:`G` is the subgraph induced by the set of its nodes :math:`v`
minimizing the objective function
.. math::
\sum_{u \in V(G)} d_G(u, v),
where :math:`d_G` is the (possibly weighted) :func:`path length
<networkx.algorithms.shortest_paths.generic.shortest_path_length>`.
The barycenter is also called the :dfn:`median`. See [West01]_, p. 78.
Parameters
----------
G : :class:`networkx.Graph`
The connected graph :math:`G`.
weight : :class:`str`, optional
Passed through to
:func:`~networkx.algorithms.shortest_paths.generic.shortest_path_length`.
attr : :class:`str`, optional
If given, write the value of the objective function to each node's
`attr` attribute. Otherwise do not store the value.
sp : dict of dicts, optional
All pairs shortest path lengths as a dictionary of dictionaries
Returns
-------
list
Nodes of `G` that induce the barycenter of `G`.
Raises
------
NetworkXNoPath
If `G` is disconnected. `G` may appear disconnected to
:func:`barycenter` if `sp` is given but is missing shortest path
lengths for any pairs.
ValueError
If `sp` and `weight` are both given.
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> nx.barycenter(G)
[1, 3, 4]
See Also
--------
center
periphery
| def effective_graph_resistance(G, weight=None, invert_weight=True):
"""Returns the Effective graph resistance of G.
Also known as the Kirchhoff index.
The effective graph resistance is defined as the sum
of the resistance distance of every node pair in G [1]_.
If weight is not provided, then a weight of 1 is used for all edges.
The effective graph resistance of a disconnected graph is infinite.
Parameters
----------
G : NetworkX graph
A graph
weight : string or None, optional (default=None)
The edge data key used to compute the effective graph resistance.
If None, then each edge has weight 1.
invert_weight : boolean (default=True)
Proper calculation of resistance distance requires building the
Laplacian matrix with the reciprocal of the weight. Not required
if the weight is already inverted. Weight cannot be zero.
Returns
-------
RG : float
The effective graph resistance of `G`.
Raises
------
NetworkXNotImplemented
If `G` is a directed graph.
NetworkXError
If `G` does not contain any nodes.
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> round(nx.effective_graph_resistance(G), 10)
10.25
Notes
-----
The implementation is based on Theorem 2.2 in [2]_. Self-loops are ignored.
Multi-edges are contracted in one edge with weight equal to the harmonic sum of the weights.
References
----------
.. [1] Wolfram
"Kirchhoff Index."
https://mathworld.wolfram.com/KirchhoffIndex.html
.. [2] W. Ellens, F. M. Spieksma, P. Van Mieghem, A. Jamakovic, R. E. Kooij.
Effective graph resistance.
Lin. Alg. Appl. 435:2491-2506, 2011.
"""
import numpy as np
if len(G) == 0:
raise nx.NetworkXError("Graph G must contain at least one node.")
# Disconnected graphs have infinite Effective graph resistance
if not nx.is_connected(G):
return float("inf")
# Invert weights
G = G.copy()
if invert_weight and weight is not None:
if G.is_multigraph():
for u, v, k, d in G.edges(keys=True, data=True):
d[weight] = 1 / d[weight]
else:
for u, v, d in G.edges(data=True):
d[weight] = 1 / d[weight]
# Get Laplacian eigenvalues
mu = np.sort(nx.laplacian_spectrum(G, weight=weight))
# Compute Effective graph resistance based on spectrum of the Laplacian
# Self-loops are ignored
return float(np.sum(1 / mu[1:]) * G.number_of_nodes())
| (G, weight=None, attr=None, sp=None, *, backend=None, **backend_kwargs) | [
0.05050395056605339,
-0.014621064066886902,
0.0027076045516878366,
0.0592062845826149,
0.05628017336130142,
-0.009433864615857601,
-0.03190223127603531,
-0.04947790876030922,
0.10077989101409912,
-0.008683335036039352,
0.03188323229551315,
-0.00023231365776155144,
0.015229088254272938,
-0.004503173753619194,
-0.05973830819129944,
0.04510774090886116,
-0.05692619830369949,
0.0003728893934749067,
-0.005837975535541773,
0.04632378742098808,
0.005244202446192503,
-0.10412401705980301,
-0.0036552660167217255,
0.06061233952641487,
-0.02795007824897766,
0.007453037891536951,
0.020349785685539246,
0.01344301924109459,
-0.0035460118670016527,
0.0005044101271778345,
-0.006602754816412926,
-0.05031394213438034,
-0.023332901298999786,
-0.006512501277029514,
0.022914884611964226,
0.023883922025561333,
0.00700652040541172,
0.007785550784319639,
-0.09257157146930695,
-0.05350606516003609,
-0.011561946012079716,
0.03385930880904198,
0.03209223970770836,
-0.026677029207348824,
0.033251285552978516,
0.01780368760228157,
-0.003686142386868596,
0.01883922703564167,
-0.030306169763207436,
-0.03914150968194008,
0.02584099769592285,
-0.010906420648097992,
-0.04620978236198425,
0.009163103997707367,
0.0018786975415423512,
0.03342229127883911,
0.026126008480787277,
0.05411408841609955,
0.029185127466917038,
-0.07303881645202637,
0.011115428991615772,
-0.08056311309337616,
0.02764606662094593,
0.01684414967894554,
-0.06133436784148216,
0.01502958033233881,
-0.01964675821363926,
-0.005505462642759085,
0.007999308407306671,
0.013813532888889313,
-0.029128124937415123,
-0.0022634624037891626,
0.026050005108118057,
-0.0682506337761879,
0.01872522383928299,
0.026373017579317093,
0.023902922868728638,
-0.013253011740744114,
-0.02692404016852379,
-0.014098544605076313,
0.03178822621703148,
-0.013167507946491241,
0.04620978236198425,
-0.03644340857863426,
0.02534697949886322,
-0.03729844093322754,
0.011039426550269127,
-0.016625642776489258,
0.02599300444126129,
-0.03144621476531029,
-0.0067405104637146,
0.026069005951285362,
0.03378330543637276,
0.03748844563961029,
0.07322882860898972,
0.0010450403206050396,
-0.04989592730998993,
-0.07349483668804169,
0.07072073221206665,
-0.022116854786872864,
-0.013452519662678242,
0.08641533553600311,
-0.018041197210550308,
0.0051919505931437016,
0.028672106564044952,
-0.0460197776556015,
-0.01537159364670515,
-0.034410327672958374,
0.05365807190537453,
-0.031199203804135323,
-0.05631817504763603,
0.021679837256669998,
0.01654013805091381,
-0.013728030025959015,
-0.03610139340162277,
0.04510774090886116,
-0.016872651875019073,
0.015276589430868626,
0.05932028964161873,
0.027665067464113235,
0.013186508789658546,
0.0322442464530468,
-0.01772768422961235,
-0.0009731938480399549,
0.010735414922237396,
0.021812841296195984,
0.009585870429873466,
0.0014523685676977038,
-0.011922960169613361,
0.02198384888470173,
0.04913589730858803,
0.00012105545465601608,
0.025289976969361305,
0.04848987236618996,
0.02738005667924881,
0.00989938247948885,
-0.007685796823352575,
0.03756444901227951,
0.06722459197044373,
0.0207488015294075,
-0.01041240245103836,
-0.023294899612665176,
0.02319989539682865,
0.05118797719478607,
0.03188323229551315,
0.008360322564840317,
0.01742367260158062,
0.03955952823162079,
0.03982553631067276,
-0.0027836074586957693,
0.026373017579317093,
-0.014041542075574398,
0.04389169439673424,
-0.011029926128685474,
0.009623871184885502,
0.017243165522813797,
-0.014279051683843136,
0.013870535418391228,
-0.04043355956673622,
-0.03484734520316124,
-0.07425487041473389,
-0.030724186450242996,
0.04024355486035347,
-0.021755840629339218,
0.01384203415364027,
-0.02722805179655552,
0.04947790876030922,
0.015580601990222931,
-0.06490650773048401,
0.028159087523818016,
-0.04503173753619194,
-0.05160599201917648,
-0.03410631790757179,
-0.03874249756336212,
0.030458176508545876,
0.08527529239654541,
0.026620028540492058,
-0.014564062468707561,
0.012150969356298447,
0.023560909554362297,
-0.014906075783073902,
-0.05863626301288605,
-0.0018549466039985418,
-0.021470829844474792,
0.028938116505742073,
0.04499373584985733,
0.03465733677148819,
-0.004804810509085655,
0.004643304273486137,
0.0004655179800465703,
0.008189315907657146,
-0.04145960137248039,
0.02534697949886322,
0.028957117348909378,
0.029109124094247818,
-0.014972577802836895,
0.03591138496994972,
0.01834520883858204,
-0.03473334014415741,
0.07056872546672821,
0.029014119878411293,
-0.001060478389263153,
0.037393443286418915,
0.03201623633503914,
0.005548214074224234,
0.011200932785868645,
-0.00922485627233982,
-0.029071122407913208,
-0.008236818015575409,
0.009965884499251842,
-0.066768579185009,
0.005068445578217506,
0.00555296428501606,
-0.03492334857583046,
-0.024301938712596893,
0.0299831572920084,
-0.026430020108819008,
0.008897093124687672,
0.013690028339624405,
-0.06399446725845337,
-0.05479811504483223,
-0.010051388293504715,
-0.00982337910681963,
-0.013091505505144596,
0.04461372271180153,
-0.04928790405392647,
0.02240186557173729,
0.00002389935980318114,
0.014193547889590263,
0.007020771037787199,
0.05449410527944565,
0.00319212325848639,
0.07904305309057236,
-0.05122597888112068,
0.014184047468006611,
-0.021109815686941147,
-0.05981430783867836,
0.07250680029392242,
0.052404023706912994,
0.04123159125447273,
-0.03570237755775452,
-0.06281642615795135,
-0.042827654629945755,
0.05890227481722832,
-0.03627239912748337,
-0.03705143183469772,
0.013870535418391228,
0.0018656345782801509,
0.02855810336768627,
0.00901584792882204,
-0.08793539553880692,
-0.06794662028551102,
-0.014108045026659966,
-0.02319989539682865,
0.02757006511092186,
-0.010944422334432602,
-0.08519928902387619,
0.016559138894081116,
-0.018050696700811386,
-0.02726605348289013,
0.014497559517621994,
-0.008374573662877083,
-0.07227879017591476,
-0.0045815519988536835,
-0.04822386056184769,
0.010089389979839325,
0.0004385013016872108,
0.010250896215438843,
-0.025479983538389206,
0.05076995864510536,
0.04491773247718811,
0.010431402362883091,
0.013566523790359497,
-0.009495616890490055,
-0.00493069039657712,
0.02017877995967865,
0.021185817196965218,
0.04461372271180153,
-0.00506369536742568,
0.0363864041864872,
-0.08451526612043381,
0.0016803774051368237,
-0.007638294715434313,
0.02443494275212288,
-0.05692619830369949,
0.017452172935009003,
-0.009248606860637665,
-0.05639417842030525,
0.02312389202415943,
-0.009082350879907608,
0.09249556809663773,
0.007785550784319639,
0.0035887635312974453,
0.0033607548102736473,
0.07379885017871857,
0.010393401607871056,
-0.013965539634227753,
-0.04837586730718613,
0.016369132325053215,
0.06958068907260895,
0.043131664395332336,
-0.0243209395557642,
0.004655179567635059,
-0.04936390742659569,
0.05552014335989952,
0.04081357643008232,
0.034866347908973694,
-0.00006460991426138207,
0.01723366603255272,
0.057838231325149536,
-0.09621971845626831,
0.004897438921034336,
-0.043131664395332336,
0.022876882925629616,
-0.052480027079582214,
-0.02967914566397667,
0.05012393370270729,
-0.02726605348289013,
0.020083775743842125,
0.025593988597393036,
0.015979617834091187,
0.09697974473237991,
0.014459557831287384,
0.03874249756336212,
-0.07117674499750137,
-0.0023477780632674694,
0.01983676664531231,
0.07828301936388016,
0.07934706658124924,
-0.04943990707397461,
-0.042789652943611145,
0.018411710858345032,
-0.010250896215438843,
0.004743058234453201,
-0.04145960137248039,
0.042181629687547684,
0.10952022671699524,
-0.03382130712270737,
-0.02783607505261898,
-0.02948913909494877,
0.027703069150447845,
0.004256164189428091,
-0.005305954720824957,
-0.0026197261177003384,
-0.00513019785284996,
0.019276244565844536,
0.017053158953785896,
-0.027399057522416115,
-0.03484734520316124,
-0.053202055394649506,
-0.012853995896875858,
0.003964027855545282,
-0.031997233629226685,
0.02688603848218918,
-0.016787149012088776,
0.04552575945854187,
-0.011704452335834503,
-0.048109859228134155,
0.02198384888470173,
0.023788917809724808,
-0.10359200090169907,
0.006331994663923979,
-0.028691107407212257,
-0.019390247762203217,
-0.006887766066938639,
0.012141468934714794,
-0.016511637717485428,
0.017214665189385414,
0.018326207995414734,
-0.04096558317542076,
-0.0022670249454677105,
-0.08200716972351074,
-0.07744698971509933,
0.0048095607198774815,
0.010925421491265297,
0.03748844563961029,
-0.03404931351542473,
-0.021090814843773842,
-0.01573260687291622,
-0.006398497149348259,
0.009191605262458324,
0.019323745742440224,
-0.04457572102546692,
0.01114393025636673,
0.04472772777080536,
-0.012663989327847958,
0.04909789562225342,
0.004070907365530729,
0.02416893281042576,
-0.003253875533118844,
-0.041801612824201584,
-0.02757006511092186,
0.06764261424541473,
-0.010896921157836914,
-0.043435677886009216,
0.03480934351682663,
0.061790384352207184,
0.028273090720176697,
-0.04579176753759384,
-0.014193547889590263,
-0.04609578102827072,
-0.007799800951033831,
-0.021394826471805573,
0.00854082964360714,
-0.026601027697324753,
0.015001079067587852,
0.007742798887193203,
0.043473679572343826,
0.04472772777080536,
0.014440557919442654,
-0.04962991550564766,
0.015637604519724846,
0.013452519662678242,
0.004263289738446474,
-0.01968475989997387,
-0.02017877995967865,
-0.013129507191479206,
0.0023465906269848347,
0.03701343014836311,
0.02990715391933918,
0.021318823099136353,
-0.02967914566397667,
0.07509090006351471,
-0.0059377290308475494,
0.0226298738270998,
-0.04670380428433418,
0.00012461809092201293,
-0.02002677321434021,
-0.0663885623216629,
0.05403808504343033,
-0.023845920339226723,
0.0016863150522112846,
0.018905729055404663,
-0.03127520903944969,
0.00022177418577484787,
-0.0022313985973596573,
0.01795569248497486,
0.017490174621343613,
-0.02010277658700943,
-0.03726043924689293,
0.04016755148768425,
0.012188971042633057,
0.027741070836782455,
-0.04829986393451691,
-0.0032990023028105497,
-0.06281642615795135,
-0.006906766444444656,
-0.0008485015132464468,
-0.005158699117600918,
-0.03165522217750549,
0.005514963064342737,
-0.04434771090745926,
0.02673403173685074,
0.028805112466216087,
-0.11719652265310287,
0.029128124937415123,
-0.03718443587422371,
-0.01405104249715805,
-0.06806062906980515,
0.02553698606789112,
0.016169624403119087,
0.03157921880483627,
-0.009144103154540062,
-0.02994515560567379,
-0.01957075484097004,
-0.032833267003297806,
0.007799800951033831,
-0.015618602745234966,
-0.027171049267053604,
-0.021090814843773842,
0.04909789562225342,
-0.020159779116511345,
-0.0199887715280056,
-0.043283671140670776,
0.056546181440353394,
0.012568985112011433,
-0.09120351821184158,
-0.011837457306683064,
0.006175238639116287,
-0.04415770620107651,
-0.019969770684838295,
0.02017877995967865,
0.05563414841890335,
0.023921923711895943,
0.020919807255268097,
-0.0392175130546093,
-0.0039022755809128284,
-0.0057097203098237514,
0.01995076984167099,
-0.041877616196870804,
-0.015552100725471973,
0.03163622319698334,
0.02565099112689495,
0.01212246809154749,
0.0006721509271301329,
-0.004702681675553322,
0.01229347474873066,
0.004595802631229162,
0.032757263630628586,
0.014402556233108044,
-0.026354016736149788,
-0.03144621476531029,
-0.015485597774386406,
0.04848987236618996,
0.03695642575621605,
0.03163622319698334,
-0.03859049081802368,
0.0076525453478097916,
0.08960746228694916,
0.03526536002755165,
-0.01401304081082344,
0.019152740016579628,
0.07414086163043976,
0.047463834285736084,
0.011856458149850368,
-0.026183011010289192,
-0.036557409912347794,
0.05434209853410721,
0.0652485191822052,
-0.02852010168135166,
-0.01887722872197628,
0.024225935339927673,
0.000541520887054503,
-0.0018549466039985418,
-0.016787149012088776,
0.008944595232605934,
-0.004469922743737698,
-0.07748499512672424,
-0.0021815216168761253,
-0.015305090695619583,
-0.014459557831287384,
0.01995076984167099,
-0.01944725029170513,
0.047121819108724594,
-0.00038506175042130053,
-0.007809301372617483,
-0.018630219623446465,
-0.042029622942209244,
-0.1022239476442337,
-0.011789955198764801,
-0.015476097352802753,
0.0030068662017583847,
0.014678066596388817,
0.011257934384047985,
0.08246318250894547,
0.020349785685539246,
0.001218422083184123,
0.0024000301491469145,
-0.02247786708176136,
-0.07072073221206665,
-0.04480373114347458,
0.02825409173965454,
-0.020843803882598877,
-0.03387830778956413,
0.061942391097545624,
0.03686142340302467,
-0.0501619353890419,
0.004564926028251648,
0.025403980165719986,
-0.017642181366682053,
-0.016644641757011414,
-0.08732736855745316,
-0.018126700073480606,
-0.06304443627595901,
0.006469749845564365,
-0.04043355956673622,
0.03232024610042572,
-0.024985965341329575,
-0.04491773247718811,
0.03382130712270737,
-0.03182622790336609,
0.032453253865242004,
0.07835902273654938,
0.004472297616302967,
-0.006545752752572298,
-0.013281513005495071,
0.025270976126194,
-0.06319644302129745,
0.035094354301691055,
-0.06353845447301865,
-0.012739991769194603,
-0.06106835603713989,
0.01635013148188591,
0.04119358956813812,
0.017148161306977272,
0.04161160811781883,
-0.01673964597284794,
0.05346806347370148,
-0.03860948979854584,
-0.014602064155042171,
-0.02428293786942959,
-0.057268209755420685,
0.03824847564101219,
0.0035270112566649914,
-0.0019440125906839967,
-0.03349829465150833,
-0.022078853100538254,
0.00798505824059248,
0.0460197776556015,
0.0032134989742189646,
-0.052062008529901505,
-0.009277108125388622,
0.019551753997802734,
-0.006949518341571093,
-0.04381569102406502,
0.04947790876030922,
0.005343956407159567,
-0.07041671872138977,
0.036158397793769836,
-0.053240057080984116,
0.0015663729282096028,
-0.0243209395557642,
-0.016245627775788307,
-0.000583084998652339,
-0.0033940060529857874,
0.012739991769194603,
-0.002312151715159416,
0.016511637717485428,
-0.042333632707595825,
0.017670681700110435,
-0.004811935592442751,
-0.004712182097136974,
0.03767845407128334,
-0.03277626633644104,
-0.01853521540760994,
0.05700220167636871,
0.04005354642868042,
0.005951979663223028,
-0.03323228284716606,
0.041801612824201584,
-0.0021577707957476377,
-0.042143628001213074,
-0.009889882057905197,
0.042257633060216904,
0.03171222284436226,
-0.07132875174283981,
0.04031955823302269,
-0.017480675131082535,
-0.02014077827334404,
0.041687607765197754,
-0.03572138026356697,
0.07600293308496475,
-0.057344213128089905,
-0.0006210864521563053,
-0.06399446725845337,
0.01941874995827675,
0.04898389056324959,
-0.017205163836479187,
-0.005220451392233372,
-0.005652718245983124,
-0.02010277658700943,
0.03184523060917854,
0.0333842895925045,
-0.017908191308379173,
-0.008555080741643906,
0.036006391048431396,
0.026487022638320923,
-0.02466295287013054,
0.009538368321955204,
-0.05133998394012451,
0.001156075857579708,
0.03631040081381798,
0.03336528688669205,
0.011789955198764801,
0.024035928770899773,
0.017053158953785896,
0.0330042727291584,
-0.0362153984606266,
-0.0026221012230962515,
-0.06255041807889938,
-0.019741762429475784,
-0.01229347474873066,
0.022990887984633446,
0.03127520903944969,
-0.06874465197324753,
0.023104891180992126,
-0.0032158740796148777,
0.038001466542482376,
-0.0006234615575522184,
-0.020881805568933487,
0.004716932307928801,
0.06722459197044373,
-0.02553698606789112,
-0.004377293866127729,
0.017547177150845528,
-0.021432828158140182,
-0.03070518560707569,
-0.021071814000606537,
0.02929913066327572,
-0.004873688332736492,
-0.03967353329062462,
-0.042827654629945755,
0.02067279815673828,
-0.0009179729386232793,
0.057914234697818756,
-0.04009154811501503,
-0.04989592730998993,
0.04822386056184769,
0.07034071534872055,
-0.05924428626894951,
0.07904305309057236,
0.02538497932255268,
-0.016625642776489258,
0.02681003510951996,
-0.023921923711895943,
-0.02572699263691902,
-0.07611694186925888,
-0.011210433207452297,
-0.04552575945854187,
0.03387830778956413,
-0.011970462277531624,
-0.023940924555063248,
0.018316706642508507,
-0.004070907365530729,
0.03993954136967659,
0.023769916966557503,
-0.0036243898794054985,
-0.030914193019270897,
-0.04362568259239197,
-0.006303493399173021,
-0.018250204622745514,
-0.009324610233306885,
0.012796994298696518,
0.03040117397904396,
-0.032035235315561295,
0.01212246809154749,
0.07254479825496674,
-0.04468972608447075,
0.0068830158561468124,
0.047881849110126495,
-0.027133047580718994,
0.004215787630528212,
0.015580601990222931,
0.03710843250155449,
0.02278187870979309,
0.020767802372574806,
-0.005780973006039858,
0.028273090720176697,
0.037507448345422745,
0.052100010216236115,
0.02599300444126129,
0.04153560474514961,
-0.047539833933115005,
-0.032567258924245834,
0.001257611089386046,
-0.007039771880954504,
-0.04020555317401886,
0.023294899612665176,
0.01933324709534645,
-0.02304789051413536,
0.05076995864510536,
-0.00471930718049407,
0.03175022453069687,
-0.008897093124687672,
0.057610224932432175,
-0.007799800951033831,
-0.015675604343414307,
-0.0516819953918457,
-0.0025936001911759377,
-0.005258453078567982,
-0.0038856500759720802,
-0.06657856702804565,
-0.05175799876451492,
0.014108045026659966,
-0.029185127466917038,
0.008778339251875877,
0.006583753973245621,
0.05464610829949379
]
|
30,410 | networkx.algorithms.shortest_paths.weighted | bellman_ford_path | Returns the shortest path from source to target in a weighted graph G.
Parameters
----------
G : NetworkX graph
source : node
Starting node
target : node
Ending node
weight : string or function (default="weight")
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number.
Returns
-------
path : list
List of nodes in a shortest path.
Raises
------
NodeNotFound
If `source` is not in `G`.
NetworkXNoPath
If no path exists between source and target.
Examples
--------
>>> G = nx.path_graph(5)
>>> nx.bellman_ford_path(G, 0, 4)
[0, 1, 2, 3, 4]
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
See Also
--------
dijkstra_path, bellman_ford_path_length
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, source, target, weight='weight', *, backend=None, **backend_kwargs) | [
0.008667515590786934,
-0.004119985271245241,
-0.03422308340668678,
-0.044231537729501724,
-0.0389455184340477,
-0.021785393357276917,
-0.010727508924901485,
0.0405779667198658,
0.07369332015514374,
-0.010572037659585476,
-0.052860185503959656,
0.029714420437812805,
0.02866499125957489,
0.025536134839057922,
-0.027246316894888878,
0.03587496653199196,
0.00007329462096095085,
0.035991568118333817,
-0.0012595591833814979,
0.013720327988266945,
-0.015012681484222412,
-0.056436024606227875,
0.05550319701433182,
0.049595292657613754,
-0.02100803703069687,
-0.009240815415978432,
0.014857210218906403,
-0.04007268697023392,
-0.025788774713873863,
-0.01634390279650688,
0.01778201200067997,
-0.018782855942845345,
-0.006330590229481459,
-0.0055289422161877155,
0.016538241878151894,
0.058534882962703705,
0.007841575890779495,
-0.00303411646746099,
-0.023320671170949936,
-0.04403720051050186,
-0.030180834233760834,
-0.03045290894806385,
0.005698988679796457,
-0.037837788462638855,
0.08006763458251953,
0.08379894495010376,
-0.017509937286376953,
0.008643223904073238,
-0.019346440210938454,
-0.018821723759174347,
0.01514871884137392,
0.0014842635719105601,
-0.009337984956800938,
0.00955661665648222,
-0.007822141982614994,
0.03948966786265373,
-0.03327082470059395,
0.05418169125914574,
0.027304617688059807,
-0.03822646662592888,
0.03948966786265373,
0.010562320239841938,
0.07085596770048141,
0.04011155292391777,
-0.06378203630447388,
-0.023592745885252953,
-0.04664134234189987,
-0.037526845932006836,
-0.03999495133757591,
0.021396715193986893,
0.001006311271339655,
-0.009512890130281448,
-0.01346768718212843,
-0.03552515432238579,
-0.0019020922482013702,
0.03801269456744194,
-0.000060351343563525006,
-0.034825533628463745,
0.011145337484776974,
-0.0398394800722599,
0.043920595198869705,
-0.05647489055991173,
-0.02584707736968994,
-0.07101143896579742,
0.07303256541490555,
0.025069721043109894,
-0.004134560469537973,
0.0026940233074128628,
-0.009036759845912457,
-0.03406761214137077,
-0.036710623651742935,
0.030841587111353874,
-0.0033159079030156136,
0.00043513698619790375,
0.05678583309054375,
0.02677990309894085,
0.009046477265655994,
-0.05701903998851776,
0.05006170645356178,
0.031035926192998886,
0.06852390617132187,
0.004824463743716478,
-0.01453655119985342,
0.036147039383649826,
0.026449527591466904,
-0.06720239669084549,
-0.011019016616046429,
0.015867773443460464,
-0.013885515742003918,
-0.055619798600673676,
-0.022621050477027893,
0.012369672767817974,
0.025944245979189873,
-0.02677990309894085,
0.02345670759677887,
0.0032697522547096014,
0.006724126636981964,
0.04395946487784386,
-0.0005186420166864991,
-0.021124640479683876,
-0.025225192308425903,
0.05254924297332764,
-0.08309932053089142,
-0.0038770614191889763,
0.040500231087207794,
-0.05635828897356987,
0.024739345535635948,
-0.019900305196642876,
0.06626956909894943,
0.01792776584625244,
0.026196885854005814,
0.004856043960899115,
-0.02790706977248192,
0.06560882180929184,
0.03202705457806587,
-0.02458387427031994,
-0.05663036182522774,
0.046835679560899734,
0.06506466865539551,
0.010406848974525928,
0.04256022348999977,
-0.07548123598098755,
0.007724971976131201,
0.02876215986907482,
0.005893327761441469,
-0.02850951999425888,
0.011135620065033436,
0.014031270518898964,
0.031307999044656754,
0.05973978340625763,
0.01545966137200594,
0.002900508465245366,
0.006850447040051222,
0.011621467769145966,
0.001647022319957614,
-0.0681740939617157,
-0.04201607406139374,
0.02044445462524891,
0.005835026036947966,
-0.0005210712552070618,
0.016645127907395363,
-0.0446590855717659,
0.005713564343750477,
0.0148183424025774,
-0.04982849955558777,
0.03488383814692497,
0.02217407152056694,
0.05212169885635376,
-0.02712971344590187,
0.012359955348074436,
-0.005893327761441469,
-0.06413184106349945,
-0.047807373106479645,
-0.02917027287185192,
-0.024447835981845856,
0.003320766380056739,
0.025050286203622818,
-0.002266477793455124,
0.01182552333921194,
-0.01942417584359646,
0.00988699309527874,
-0.02662443183362484,
0.02314576506614685,
-0.013564856722950935,
0.030083665624260902,
0.02917027287185192,
0.02227124013006687,
-0.02161048725247383,
0.0029685271438211203,
0.03478666767477989,
-0.04827378690242767,
-0.09328268468379974,
-0.06059487536549568,
0.08325479179620743,
-0.009085345081984997,
0.006728985346853733,
-0.03729363903403282,
-0.02217407152056694,
-0.027265751734375954,
0.06374316662549973,
-0.009153363294899464,
-0.029306309297680855,
0.0398394800722599,
-0.008837562054395676,
0.00925053283572197,
-0.028859330341219902,
-0.03245459869503975,
0.0086140725761652,
0.0010421425104141235,
0.018510783091187477,
-0.03511704504489899,
-0.04543644189834595,
0.030005929991602898,
-0.029772723093628883,
0.0011903259437531233,
0.01374947838485241,
-0.031754981726408005,
0.040033817291259766,
0.013963251374661922,
-0.05907903239130974,
-0.004413922782987356,
-0.015284756198525429,
-0.00953232403844595,
0.02116350829601288,
0.061799775809049606,
-0.050256043672561646,
0.047030020505189896,
0.030627815052866936,
0.02584707736968994,
-0.07330463826656342,
0.07719141989946365,
-0.032726675271987915,
0.09639210253953934,
-0.014808625914156437,
0.0738099217414856,
-0.047846242785453796,
0.0034495159052312374,
0.04073343798518181,
0.04559190943837166,
0.027868201956152916,
-0.021707657724618912,
-0.02345670759677887,
-0.014653154648840427,
-0.05814620479941368,
0.0059370542876422405,
-0.00008912261546356604,
0.03148290514945984,
-0.012301653623580933,
0.026099717244505882,
-0.006495778448879719,
0.005057670641690493,
0.027673862874507904,
-0.04236588627099991,
-0.05748545378446579,
-0.01292353868484497,
-0.043143242597579956,
-0.02100803703069687,
-0.03748797997832298,
-0.03653571754693985,
-0.06584202498197556,
-0.03224082663655281,
-0.027829334139823914,
-0.06094468757510185,
0.10152265429496765,
-0.0038892077282071114,
0.032629504799842834,
0.031210830435156822,
-0.014342212118208408,
-0.08022310584783554,
0.006626957096159458,
0.042637959122657776,
0.043104372918605804,
-0.006865022238343954,
-0.003619562368839979,
-0.0251474566757679,
0.005193707533180714,
-0.03220196068286896,
0.03484496846795082,
0.012884670868515968,
-0.023029161617159843,
-0.04372625797986984,
-0.008361431770026684,
-0.04123871773481369,
-0.006461769342422485,
0.01797635108232498,
0.02969498746097088,
0.012117031961679459,
-0.03484496846795082,
0.0164507906883955,
0.00665610795840621,
0.07019522041082382,
-0.012165616266429424,
0.010591471567749977,
-0.037740617990493774,
0.062266189604997635,
0.04769077152013779,
-0.003413077211007476,
-0.07287709414958954,
0.016392488032579422,
0.0536375418305397,
0.015449943952262402,
-0.02571103908121586,
0.025633303448557854,
-0.005698988679796457,
-0.04267682880163193,
0.008269120939075947,
0.031191397458314896,
-0.016781166195869446,
-0.0025847076904028654,
-0.03091932274401188,
-0.02141615003347397,
-0.025205757468938828,
0.0017733427230268717,
0.007326577324420214,
0.0036705764941871166,
-0.037274204194545746,
-0.035136476159095764,
0.0073994542472064495,
-0.006758136209100485,
0.03224082663655281,
-0.038964953273534775,
0.0764140635728836,
-0.06832956522703171,
0.02922857366502285,
-0.030530644580721855,
0.029248008504509926,
0.03183271363377571,
0.025672171264886856,
0.03509761020541191,
0.022465579211711884,
0.037896089255809784,
0.022446146234869957,
0.026177452877163887,
0.030841587111353874,
-0.01987115480005741,
0.08970684558153152,
0.07435407489538193,
-0.00544148962944746,
0.000042245941585861146,
-0.003153149038553238,
0.04741869866847992,
0.021746525540947914,
-0.022057468071579933,
0.02380651794373989,
0.006082808133214712,
-0.0438428595662117,
0.03398987650871277,
-0.0389455184340477,
0.0074480390176177025,
-0.04737982898950577,
0.02186312898993492,
0.06797975301742554,
0.01834559440612793,
0.02646896056830883,
0.050605855882167816,
0.0031312857754528522,
-0.010941280983388424,
-0.04061683639883995,
0.02232954278588295,
-0.004931350238621235,
0.008390583097934723,
0.018160972744226456,
0.009114495478570461,
-0.002917513018473983,
-0.0462915301322937,
0.01364259235560894,
0.019356155768036842,
-0.013331649824976921,
-0.01824842393398285,
-0.050605855882167816,
-0.008463460020720959,
-0.06055600941181183,
-0.025108588859438896,
0.05542546138167381,
0.012010145001113415,
0.000449105107691139,
0.016363337635993958,
-0.0074528977274894714,
-0.003529680659994483,
0.044076066464185715,
-0.02197973243892193,
0.05748545378446579,
0.0052228583954274654,
0.046019457280635834,
0.024875381961464882,
-0.04123871773481369,
0.06638617813587189,
0.007389737293124199,
0.03381497412919998,
0.0063597410917282104,
-0.024661609902977943,
-0.01783059537410736,
0.044425878673791885,
0.028606688603758812,
-0.0026697309222072363,
-0.04170513153076172,
0.07186653465032578,
0.03025856986641884,
-0.050566986203193665,
-0.025069721043109894,
0.01584833860397339,
-0.021241243928670883,
-0.0551922544836998,
0.06910692155361176,
0.009721804410219193,
-0.047651905566453934,
0.04594172164797783,
0.027926502749323845,
0.025944245979189873,
0.04854586347937584,
-0.041782867163419724,
-0.002404944272711873,
-0.014624004252254963,
0.017198994755744934,
-0.04388172924518585,
-0.058884695172309875,
-0.06852390617132187,
0.0422104150056839,
0.05678583309054375,
0.002992819296196103,
0.03659401834011078,
-0.029364611953496933,
0.06405410915613174,
-0.0828661173582077,
0.01213646586984396,
-0.04318210855126381,
-0.013020708225667477,
-0.027965370565652847,
-0.0009692653547972441,
0.05083906278014183,
-0.024894816800951958,
-0.023592745885252953,
0.0393536314368248,
-0.05515338480472565,
-0.00710308738052845,
-0.005208283197134733,
0.016178715974092484,
0.002471748273819685,
0.07206087559461594,
-0.034164782613515854,
-0.009410861879587173,
-0.02775159850716591,
-0.026196885854005814,
-0.027013109996914864,
-0.0520050972700119,
-0.07901820540428162,
0.020502755418419838,
-0.022815389558672905,
0.030899887904524803,
-0.03593326732516289,
0.006942757871001959,
-0.03877061605453491,
0.021182943135499954,
0.023184632882475853,
-0.02615801803767681,
0.024972552433609962,
0.016013527289032936,
0.010241661220788956,
-0.11986824870109558,
0.02703254483640194,
0.05080019310116768,
-0.03187158331274986,
0.028528952971100807,
-0.011942126788198948,
-0.04788510873913765,
0.05923450365662575,
0.03439798951148987,
0.0010269597405567765,
-0.0007287709740921855,
-0.025944245979189873,
0.04531983658671379,
-0.010824677534401417,
-0.08550912886857986,
-0.0059370542876422405,
0.022348975762724876,
-0.004205008503049612,
-0.06350996345281601,
0.014808625914156437,
0.0021668788976967335,
-0.016683995723724365,
0.040694572031497955,
-0.04007268697023392,
0.06693032383918762,
-0.007822141982614994,
0.00544148962944746,
-0.05507564917206764,
0.03908155858516693,
-0.019657382741570473,
0.014478249475359917,
0.0029393762815743685,
0.040694572031497955,
-0.06284920871257782,
0.06937899440526962,
-0.031191397458314896,
-0.0038892077282071114,
0.04275456443428993,
0.03317365422844887,
-0.016577109694480896,
0.08076725900173187,
-0.013419102877378464,
0.002594424644485116,
-0.01042628288269043,
-0.05488131195306778,
0.05954544618725777,
0.03393157571554184,
0.01530419010668993,
0.014487966895103455,
0.048973407596349716,
-0.02574990689754486,
0.026449527591466904,
0.01731559820473194,
0.0029588101897388697,
0.04706888645887375,
0.05507564917206764,
0.04582511633634567,
-0.0078027076087892056,
-0.00665610795840621,
0.0689125806093216,
0.002187527483329177,
-0.022407278418540955,
0.04337644577026367,
0.06218845397233963,
-0.015556830912828445,
0.0276349950581789,
-0.07439293712377548,
0.03531138226389885,
0.004370196722447872,
-0.04753530025482178,
0.023068029433488846,
0.004119985271245241,
0.010892696678638458,
0.0337178036570549,
-0.0004078080819454044,
0.02693537436425686,
0.0184913482517004,
0.014487966895103455,
0.056125082075595856,
-0.018675969913601875,
-0.014653154648840427,
-0.016975505277514458,
0.05946771055459976,
0.00020117114763706923,
-0.004574252292513847,
-0.005635828711092472,
0.06992314755916595,
-0.00513540580868721,
-0.0021608059760183096,
-0.008031056262552738,
-0.00024398644745815545,
-0.05095566436648369,
-0.021999165415763855,
-0.0024061587173491716,
0.007200256921350956,
0.05212169885635376,
0.06957333534955978,
-0.009697511792182922,
0.014138156548142433,
0.009367136284708977,
0.006651249714195728,
0.08504271507263184,
-0.02540009655058384,
-0.08527591824531555,
-0.04617492854595184,
-0.01691720262169838,
-0.0154305100440979,
-0.030569512397050858,
0.015663716942071915,
-0.012797217816114426,
0.0013931671855971217,
-0.006330590229481459,
-0.02979215607047081,
0.0405779667198658,
-0.00573785649612546,
0.026332924142479897,
-0.028392916545271873,
-0.007924169301986694,
-0.026352357119321823,
-0.045242100954055786,
0.023223500698804855,
-0.05099453404545784,
-0.0178403127938509,
0.021241243928670883,
0.06304354965686798,
0.0519273616373539,
0.02534179575741291,
-0.0020964310970157385,
-0.05227717012166977,
0.004153994377702475,
-0.047962844371795654,
0.010523452423512936,
0.010737225413322449,
-0.053326599299907684,
0.014332495629787445,
0.037896089255809784,
0.011291091330349445,
-0.05585300549864769,
-0.01961851492524147,
0.01727673038840294,
0.03152177482843399,
-0.0031288566533476114,
-0.09312721341848373,
-0.009852983057498932,
0.006957333534955978,
-0.006160543765872717,
0.031230265274643898,
-0.01484749373048544,
-0.006277147214859724,
-0.08714157342910767,
-0.015080700628459454,
-0.05099453404545784,
0.019958607852458954,
0.013535706326365471,
0.02596368081867695,
-0.024700477719306946,
-0.029617251828312874,
-0.007613227237015963,
-0.00986270047724247,
0.016120413318276405,
-0.029967062175273895,
-0.03593326732516289,
0.015245888382196426,
-0.03972287476062775,
0.01997804082930088,
-0.012641746550798416,
0.0028640697710216045,
0.038498539477586746,
-0.0024328804574906826,
0.019375590607523918,
-0.060478273779153824,
0.03297931328415871,
-0.02176595851778984,
-0.04901227727532387,
0.044581349939107895,
0.05379301309585571,
-0.022504447028040886,
-0.015916356816887856,
0.06930126249790192,
-0.010513735935091972,
-0.015236171893775463,
-0.011942126788198948,
-0.03488383814692497,
0.04403720051050186,
-0.021280111744999886,
-0.033387426286935806,
-0.03593326732516289,
-0.00440663518384099,
-0.003928075544536114,
-0.02248501405119896,
0.009522607550024986,
0.0007785703055560589,
-0.005752432160079479,
-0.01530419010668993,
-0.030491776764392853,
0.0067678531631827354,
0.020366718992590904,
0.07276049256324768,
-0.018792573362588882,
-0.0341259129345417,
0.012155899778008461,
0.012583444826304913,
0.032532334327697754,
0.053987354040145874,
0.06926239281892776,
-0.0438428595662117,
-0.03744911029934883,
-0.013040142133831978,
0.017616823315620422,
-0.06214958801865578,
-0.01788889802992344,
0.007686104159802198,
-0.0640929788351059,
-0.011485430411994457,
0.008497469127178192,
0.016285602003335953,
-0.032823845744132996,
-0.06055600941181183,
0.02687707357108593,
-0.004073829855769873,
-0.07579217851161957,
-0.06778541952371597,
0.042948901653289795,
0.04609719291329384,
0.024953117594122887,
-0.013088726438581944,
-0.011572882533073425,
0.053676411509513855,
-0.051888491958379745,
-0.08403214812278748,
0.034922704100608826,
0.014215892180800438,
0.01991974003612995,
-0.03459232673048973,
0.04042249545454979,
0.008784119039773941,
-0.0381292961537838,
-0.05142207816243172,
-0.0024802505504339933,
-0.01991974003612995,
0.0308221522718668,
-0.03603043779730797,
0.020425021648406982,
0.053326599299907684,
0.00805049017071724,
-0.03014196641743183,
-0.011145337484776974,
-0.03142460435628891,
-0.08037857711315155,
0.03867344558238983,
0.02295142598450184,
0.009828691370785236,
-0.03622477501630783,
-0.03025856986641884,
-0.01392438355833292,
0.02681877091526985,
0.01152429822832346,
-0.014944663271307945,
0.020716529339551926,
-0.013098442927002907,
-0.01246684230864048,
-0.0026551554910838604,
0.014468532986938953,
-0.023631613701581955,
-0.0032187383621931076,
0.028626123443245888,
-0.08846307545900345,
-0.0008107576868496835,
0.023417839780449867,
-0.08348800241947174,
0.002039344049990177,
-0.01792776584625244,
-0.02631348930299282,
0.08815213292837143,
0.0098578417673707,
0.03198818489909172,
0.004814746789634228,
-0.014604570344090462,
0.025283493101596832,
-0.014983531087636948,
-0.00986270047724247,
0.05993412435054779,
-0.026546696200966835,
0.018316444009542465,
-0.03995608165860176,
-0.017665408551692963,
-0.00125227146781981,
-0.010999582707881927,
0.01019307691603899,
0.01257372833788395,
-0.027576692402362823,
-0.010970432311296463,
0.03107479400932789,
-0.000737880589440465,
0.02411746047437191,
-0.01840389519929886,
0.011689485982060432,
-0.011815806850790977,
-0.04011155292391777,
-0.0519273616373539,
-0.02606084942817688,
-0.048118315637111664,
-0.06125563010573387,
-0.008720959536731243,
-0.018792573362588882,
0.022776521742343903,
0.02207690104842186,
0.04664134234189987,
0.02571103908121586,
0.08496497571468353
]
|
30,411 | networkx.algorithms.shortest_paths.weighted | bellman_ford_path_length | Returns the shortest path length from source to target
in a weighted graph.
Parameters
----------
G : NetworkX graph
source : node label
starting node for path
target : node label
ending node for path
weight : string or function (default="weight")
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number.
Returns
-------
length : number
Shortest path length.
Raises
------
NodeNotFound
If `source` is not in `G`.
NetworkXNoPath
If no path exists between source and target.
Examples
--------
>>> G = nx.path_graph(5)
>>> nx.bellman_ford_path_length(G, 0, 4)
4
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
See Also
--------
dijkstra_path_length, bellman_ford_path
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, source, target, weight='weight', *, backend=None, **backend_kwargs) | [
0.008667515590786934,
-0.004119985271245241,
-0.03422308340668678,
-0.044231537729501724,
-0.0389455184340477,
-0.021785393357276917,
-0.010727508924901485,
0.0405779667198658,
0.07369332015514374,
-0.010572037659585476,
-0.052860185503959656,
0.029714420437812805,
0.02866499125957489,
0.025536134839057922,
-0.027246316894888878,
0.03587496653199196,
0.00007329462096095085,
0.035991568118333817,
-0.0012595591833814979,
0.013720327988266945,
-0.015012681484222412,
-0.056436024606227875,
0.05550319701433182,
0.049595292657613754,
-0.02100803703069687,
-0.009240815415978432,
0.014857210218906403,
-0.04007268697023392,
-0.025788774713873863,
-0.01634390279650688,
0.01778201200067997,
-0.018782855942845345,
-0.006330590229481459,
-0.0055289422161877155,
0.016538241878151894,
0.058534882962703705,
0.007841575890779495,
-0.00303411646746099,
-0.023320671170949936,
-0.04403720051050186,
-0.030180834233760834,
-0.03045290894806385,
0.005698988679796457,
-0.037837788462638855,
0.08006763458251953,
0.08379894495010376,
-0.017509937286376953,
0.008643223904073238,
-0.019346440210938454,
-0.018821723759174347,
0.01514871884137392,
0.0014842635719105601,
-0.009337984956800938,
0.00955661665648222,
-0.007822141982614994,
0.03948966786265373,
-0.03327082470059395,
0.05418169125914574,
0.027304617688059807,
-0.03822646662592888,
0.03948966786265373,
0.010562320239841938,
0.07085596770048141,
0.04011155292391777,
-0.06378203630447388,
-0.023592745885252953,
-0.04664134234189987,
-0.037526845932006836,
-0.03999495133757591,
0.021396715193986893,
0.001006311271339655,
-0.009512890130281448,
-0.01346768718212843,
-0.03552515432238579,
-0.0019020922482013702,
0.03801269456744194,
-0.000060351343563525006,
-0.034825533628463745,
0.011145337484776974,
-0.0398394800722599,
0.043920595198869705,
-0.05647489055991173,
-0.02584707736968994,
-0.07101143896579742,
0.07303256541490555,
0.025069721043109894,
-0.004134560469537973,
0.0026940233074128628,
-0.009036759845912457,
-0.03406761214137077,
-0.036710623651742935,
0.030841587111353874,
-0.0033159079030156136,
0.00043513698619790375,
0.05678583309054375,
0.02677990309894085,
0.009046477265655994,
-0.05701903998851776,
0.05006170645356178,
0.031035926192998886,
0.06852390617132187,
0.004824463743716478,
-0.01453655119985342,
0.036147039383649826,
0.026449527591466904,
-0.06720239669084549,
-0.011019016616046429,
0.015867773443460464,
-0.013885515742003918,
-0.055619798600673676,
-0.022621050477027893,
0.012369672767817974,
0.025944245979189873,
-0.02677990309894085,
0.02345670759677887,
0.0032697522547096014,
0.006724126636981964,
0.04395946487784386,
-0.0005186420166864991,
-0.021124640479683876,
-0.025225192308425903,
0.05254924297332764,
-0.08309932053089142,
-0.0038770614191889763,
0.040500231087207794,
-0.05635828897356987,
0.024739345535635948,
-0.019900305196642876,
0.06626956909894943,
0.01792776584625244,
0.026196885854005814,
0.004856043960899115,
-0.02790706977248192,
0.06560882180929184,
0.03202705457806587,
-0.02458387427031994,
-0.05663036182522774,
0.046835679560899734,
0.06506466865539551,
0.010406848974525928,
0.04256022348999977,
-0.07548123598098755,
0.007724971976131201,
0.02876215986907482,
0.005893327761441469,
-0.02850951999425888,
0.011135620065033436,
0.014031270518898964,
0.031307999044656754,
0.05973978340625763,
0.01545966137200594,
0.002900508465245366,
0.006850447040051222,
0.011621467769145966,
0.001647022319957614,
-0.0681740939617157,
-0.04201607406139374,
0.02044445462524891,
0.005835026036947966,
-0.0005210712552070618,
0.016645127907395363,
-0.0446590855717659,
0.005713564343750477,
0.0148183424025774,
-0.04982849955558777,
0.03488383814692497,
0.02217407152056694,
0.05212169885635376,
-0.02712971344590187,
0.012359955348074436,
-0.005893327761441469,
-0.06413184106349945,
-0.047807373106479645,
-0.02917027287185192,
-0.024447835981845856,
0.003320766380056739,
0.025050286203622818,
-0.002266477793455124,
0.01182552333921194,
-0.01942417584359646,
0.00988699309527874,
-0.02662443183362484,
0.02314576506614685,
-0.013564856722950935,
0.030083665624260902,
0.02917027287185192,
0.02227124013006687,
-0.02161048725247383,
0.0029685271438211203,
0.03478666767477989,
-0.04827378690242767,
-0.09328268468379974,
-0.06059487536549568,
0.08325479179620743,
-0.009085345081984997,
0.006728985346853733,
-0.03729363903403282,
-0.02217407152056694,
-0.027265751734375954,
0.06374316662549973,
-0.009153363294899464,
-0.029306309297680855,
0.0398394800722599,
-0.008837562054395676,
0.00925053283572197,
-0.028859330341219902,
-0.03245459869503975,
0.0086140725761652,
0.0010421425104141235,
0.018510783091187477,
-0.03511704504489899,
-0.04543644189834595,
0.030005929991602898,
-0.029772723093628883,
0.0011903259437531233,
0.01374947838485241,
-0.031754981726408005,
0.040033817291259766,
0.013963251374661922,
-0.05907903239130974,
-0.004413922782987356,
-0.015284756198525429,
-0.00953232403844595,
0.02116350829601288,
0.061799775809049606,
-0.050256043672561646,
0.047030020505189896,
0.030627815052866936,
0.02584707736968994,
-0.07330463826656342,
0.07719141989946365,
-0.032726675271987915,
0.09639210253953934,
-0.014808625914156437,
0.0738099217414856,
-0.047846242785453796,
0.0034495159052312374,
0.04073343798518181,
0.04559190943837166,
0.027868201956152916,
-0.021707657724618912,
-0.02345670759677887,
-0.014653154648840427,
-0.05814620479941368,
0.0059370542876422405,
-0.00008912261546356604,
0.03148290514945984,
-0.012301653623580933,
0.026099717244505882,
-0.006495778448879719,
0.005057670641690493,
0.027673862874507904,
-0.04236588627099991,
-0.05748545378446579,
-0.01292353868484497,
-0.043143242597579956,
-0.02100803703069687,
-0.03748797997832298,
-0.03653571754693985,
-0.06584202498197556,
-0.03224082663655281,
-0.027829334139823914,
-0.06094468757510185,
0.10152265429496765,
-0.0038892077282071114,
0.032629504799842834,
0.031210830435156822,
-0.014342212118208408,
-0.08022310584783554,
0.006626957096159458,
0.042637959122657776,
0.043104372918605804,
-0.006865022238343954,
-0.003619562368839979,
-0.0251474566757679,
0.005193707533180714,
-0.03220196068286896,
0.03484496846795082,
0.012884670868515968,
-0.023029161617159843,
-0.04372625797986984,
-0.008361431770026684,
-0.04123871773481369,
-0.006461769342422485,
0.01797635108232498,
0.02969498746097088,
0.012117031961679459,
-0.03484496846795082,
0.0164507906883955,
0.00665610795840621,
0.07019522041082382,
-0.012165616266429424,
0.010591471567749977,
-0.037740617990493774,
0.062266189604997635,
0.04769077152013779,
-0.003413077211007476,
-0.07287709414958954,
0.016392488032579422,
0.0536375418305397,
0.015449943952262402,
-0.02571103908121586,
0.025633303448557854,
-0.005698988679796457,
-0.04267682880163193,
0.008269120939075947,
0.031191397458314896,
-0.016781166195869446,
-0.0025847076904028654,
-0.03091932274401188,
-0.02141615003347397,
-0.025205757468938828,
0.0017733427230268717,
0.007326577324420214,
0.0036705764941871166,
-0.037274204194545746,
-0.035136476159095764,
0.0073994542472064495,
-0.006758136209100485,
0.03224082663655281,
-0.038964953273534775,
0.0764140635728836,
-0.06832956522703171,
0.02922857366502285,
-0.030530644580721855,
0.029248008504509926,
0.03183271363377571,
0.025672171264886856,
0.03509761020541191,
0.022465579211711884,
0.037896089255809784,
0.022446146234869957,
0.026177452877163887,
0.030841587111353874,
-0.01987115480005741,
0.08970684558153152,
0.07435407489538193,
-0.00544148962944746,
0.000042245941585861146,
-0.003153149038553238,
0.04741869866847992,
0.021746525540947914,
-0.022057468071579933,
0.02380651794373989,
0.006082808133214712,
-0.0438428595662117,
0.03398987650871277,
-0.0389455184340477,
0.0074480390176177025,
-0.04737982898950577,
0.02186312898993492,
0.06797975301742554,
0.01834559440612793,
0.02646896056830883,
0.050605855882167816,
0.0031312857754528522,
-0.010941280983388424,
-0.04061683639883995,
0.02232954278588295,
-0.004931350238621235,
0.008390583097934723,
0.018160972744226456,
0.009114495478570461,
-0.002917513018473983,
-0.0462915301322937,
0.01364259235560894,
0.019356155768036842,
-0.013331649824976921,
-0.01824842393398285,
-0.050605855882167816,
-0.008463460020720959,
-0.06055600941181183,
-0.025108588859438896,
0.05542546138167381,
0.012010145001113415,
0.000449105107691139,
0.016363337635993958,
-0.0074528977274894714,
-0.003529680659994483,
0.044076066464185715,
-0.02197973243892193,
0.05748545378446579,
0.0052228583954274654,
0.046019457280635834,
0.024875381961464882,
-0.04123871773481369,
0.06638617813587189,
0.007389737293124199,
0.03381497412919998,
0.0063597410917282104,
-0.024661609902977943,
-0.01783059537410736,
0.044425878673791885,
0.028606688603758812,
-0.0026697309222072363,
-0.04170513153076172,
0.07186653465032578,
0.03025856986641884,
-0.050566986203193665,
-0.025069721043109894,
0.01584833860397339,
-0.021241243928670883,
-0.0551922544836998,
0.06910692155361176,
0.009721804410219193,
-0.047651905566453934,
0.04594172164797783,
0.027926502749323845,
0.025944245979189873,
0.04854586347937584,
-0.041782867163419724,
-0.002404944272711873,
-0.014624004252254963,
0.017198994755744934,
-0.04388172924518585,
-0.058884695172309875,
-0.06852390617132187,
0.0422104150056839,
0.05678583309054375,
0.002992819296196103,
0.03659401834011078,
-0.029364611953496933,
0.06405410915613174,
-0.0828661173582077,
0.01213646586984396,
-0.04318210855126381,
-0.013020708225667477,
-0.027965370565652847,
-0.0009692653547972441,
0.05083906278014183,
-0.024894816800951958,
-0.023592745885252953,
0.0393536314368248,
-0.05515338480472565,
-0.00710308738052845,
-0.005208283197134733,
0.016178715974092484,
0.002471748273819685,
0.07206087559461594,
-0.034164782613515854,
-0.009410861879587173,
-0.02775159850716591,
-0.026196885854005814,
-0.027013109996914864,
-0.0520050972700119,
-0.07901820540428162,
0.020502755418419838,
-0.022815389558672905,
0.030899887904524803,
-0.03593326732516289,
0.006942757871001959,
-0.03877061605453491,
0.021182943135499954,
0.023184632882475853,
-0.02615801803767681,
0.024972552433609962,
0.016013527289032936,
0.010241661220788956,
-0.11986824870109558,
0.02703254483640194,
0.05080019310116768,
-0.03187158331274986,
0.028528952971100807,
-0.011942126788198948,
-0.04788510873913765,
0.05923450365662575,
0.03439798951148987,
0.0010269597405567765,
-0.0007287709740921855,
-0.025944245979189873,
0.04531983658671379,
-0.010824677534401417,
-0.08550912886857986,
-0.0059370542876422405,
0.022348975762724876,
-0.004205008503049612,
-0.06350996345281601,
0.014808625914156437,
0.0021668788976967335,
-0.016683995723724365,
0.040694572031497955,
-0.04007268697023392,
0.06693032383918762,
-0.007822141982614994,
0.00544148962944746,
-0.05507564917206764,
0.03908155858516693,
-0.019657382741570473,
0.014478249475359917,
0.0029393762815743685,
0.040694572031497955,
-0.06284920871257782,
0.06937899440526962,
-0.031191397458314896,
-0.0038892077282071114,
0.04275456443428993,
0.03317365422844887,
-0.016577109694480896,
0.08076725900173187,
-0.013419102877378464,
0.002594424644485116,
-0.01042628288269043,
-0.05488131195306778,
0.05954544618725777,
0.03393157571554184,
0.01530419010668993,
0.014487966895103455,
0.048973407596349716,
-0.02574990689754486,
0.026449527591466904,
0.01731559820473194,
0.0029588101897388697,
0.04706888645887375,
0.05507564917206764,
0.04582511633634567,
-0.0078027076087892056,
-0.00665610795840621,
0.0689125806093216,
0.002187527483329177,
-0.022407278418540955,
0.04337644577026367,
0.06218845397233963,
-0.015556830912828445,
0.0276349950581789,
-0.07439293712377548,
0.03531138226389885,
0.004370196722447872,
-0.04753530025482178,
0.023068029433488846,
0.004119985271245241,
0.010892696678638458,
0.0337178036570549,
-0.0004078080819454044,
0.02693537436425686,
0.0184913482517004,
0.014487966895103455,
0.056125082075595856,
-0.018675969913601875,
-0.014653154648840427,
-0.016975505277514458,
0.05946771055459976,
0.00020117114763706923,
-0.004574252292513847,
-0.005635828711092472,
0.06992314755916595,
-0.00513540580868721,
-0.0021608059760183096,
-0.008031056262552738,
-0.00024398644745815545,
-0.05095566436648369,
-0.021999165415763855,
-0.0024061587173491716,
0.007200256921350956,
0.05212169885635376,
0.06957333534955978,
-0.009697511792182922,
0.014138156548142433,
0.009367136284708977,
0.006651249714195728,
0.08504271507263184,
-0.02540009655058384,
-0.08527591824531555,
-0.04617492854595184,
-0.01691720262169838,
-0.0154305100440979,
-0.030569512397050858,
0.015663716942071915,
-0.012797217816114426,
0.0013931671855971217,
-0.006330590229481459,
-0.02979215607047081,
0.0405779667198658,
-0.00573785649612546,
0.026332924142479897,
-0.028392916545271873,
-0.007924169301986694,
-0.026352357119321823,
-0.045242100954055786,
0.023223500698804855,
-0.05099453404545784,
-0.0178403127938509,
0.021241243928670883,
0.06304354965686798,
0.0519273616373539,
0.02534179575741291,
-0.0020964310970157385,
-0.05227717012166977,
0.004153994377702475,
-0.047962844371795654,
0.010523452423512936,
0.010737225413322449,
-0.053326599299907684,
0.014332495629787445,
0.037896089255809784,
0.011291091330349445,
-0.05585300549864769,
-0.01961851492524147,
0.01727673038840294,
0.03152177482843399,
-0.0031288566533476114,
-0.09312721341848373,
-0.009852983057498932,
0.006957333534955978,
-0.006160543765872717,
0.031230265274643898,
-0.01484749373048544,
-0.006277147214859724,
-0.08714157342910767,
-0.015080700628459454,
-0.05099453404545784,
0.019958607852458954,
0.013535706326365471,
0.02596368081867695,
-0.024700477719306946,
-0.029617251828312874,
-0.007613227237015963,
-0.00986270047724247,
0.016120413318276405,
-0.029967062175273895,
-0.03593326732516289,
0.015245888382196426,
-0.03972287476062775,
0.01997804082930088,
-0.012641746550798416,
0.0028640697710216045,
0.038498539477586746,
-0.0024328804574906826,
0.019375590607523918,
-0.060478273779153824,
0.03297931328415871,
-0.02176595851778984,
-0.04901227727532387,
0.044581349939107895,
0.05379301309585571,
-0.022504447028040886,
-0.015916356816887856,
0.06930126249790192,
-0.010513735935091972,
-0.015236171893775463,
-0.011942126788198948,
-0.03488383814692497,
0.04403720051050186,
-0.021280111744999886,
-0.033387426286935806,
-0.03593326732516289,
-0.00440663518384099,
-0.003928075544536114,
-0.02248501405119896,
0.009522607550024986,
0.0007785703055560589,
-0.005752432160079479,
-0.01530419010668993,
-0.030491776764392853,
0.0067678531631827354,
0.020366718992590904,
0.07276049256324768,
-0.018792573362588882,
-0.0341259129345417,
0.012155899778008461,
0.012583444826304913,
0.032532334327697754,
0.053987354040145874,
0.06926239281892776,
-0.0438428595662117,
-0.03744911029934883,
-0.013040142133831978,
0.017616823315620422,
-0.06214958801865578,
-0.01788889802992344,
0.007686104159802198,
-0.0640929788351059,
-0.011485430411994457,
0.008497469127178192,
0.016285602003335953,
-0.032823845744132996,
-0.06055600941181183,
0.02687707357108593,
-0.004073829855769873,
-0.07579217851161957,
-0.06778541952371597,
0.042948901653289795,
0.04609719291329384,
0.024953117594122887,
-0.013088726438581944,
-0.011572882533073425,
0.053676411509513855,
-0.051888491958379745,
-0.08403214812278748,
0.034922704100608826,
0.014215892180800438,
0.01991974003612995,
-0.03459232673048973,
0.04042249545454979,
0.008784119039773941,
-0.0381292961537838,
-0.05142207816243172,
-0.0024802505504339933,
-0.01991974003612995,
0.0308221522718668,
-0.03603043779730797,
0.020425021648406982,
0.053326599299907684,
0.00805049017071724,
-0.03014196641743183,
-0.011145337484776974,
-0.03142460435628891,
-0.08037857711315155,
0.03867344558238983,
0.02295142598450184,
0.009828691370785236,
-0.03622477501630783,
-0.03025856986641884,
-0.01392438355833292,
0.02681877091526985,
0.01152429822832346,
-0.014944663271307945,
0.020716529339551926,
-0.013098442927002907,
-0.01246684230864048,
-0.0026551554910838604,
0.014468532986938953,
-0.023631613701581955,
-0.0032187383621931076,
0.028626123443245888,
-0.08846307545900345,
-0.0008107576868496835,
0.023417839780449867,
-0.08348800241947174,
0.002039344049990177,
-0.01792776584625244,
-0.02631348930299282,
0.08815213292837143,
0.0098578417673707,
0.03198818489909172,
0.004814746789634228,
-0.014604570344090462,
0.025283493101596832,
-0.014983531087636948,
-0.00986270047724247,
0.05993412435054779,
-0.026546696200966835,
0.018316444009542465,
-0.03995608165860176,
-0.017665408551692963,
-0.00125227146781981,
-0.010999582707881927,
0.01019307691603899,
0.01257372833788395,
-0.027576692402362823,
-0.010970432311296463,
0.03107479400932789,
-0.000737880589440465,
0.02411746047437191,
-0.01840389519929886,
0.011689485982060432,
-0.011815806850790977,
-0.04011155292391777,
-0.0519273616373539,
-0.02606084942817688,
-0.048118315637111664,
-0.06125563010573387,
-0.008720959536731243,
-0.018792573362588882,
0.022776521742343903,
0.02207690104842186,
0.04664134234189987,
0.02571103908121586,
0.08496497571468353
]
|
30,412 | networkx.algorithms.shortest_paths.weighted | bellman_ford_predecessor_and_distance | Compute shortest path lengths and predecessors on shortest paths
in weighted graphs.
The algorithm has a running time of $O(mn)$ where $n$ is the number of
nodes and $m$ is the number of edges. It is slower than Dijkstra but
can handle negative edge weights.
If a negative cycle is detected, you can use :func:`find_negative_cycle`
to return the cycle and examine it. Shortest paths are not defined when
a negative cycle exists because once reached, the path can cycle forever
to build up arbitrarily low weights.
Parameters
----------
G : NetworkX graph
The algorithm works for all types of graphs, including directed
graphs and multigraphs.
source: node label
Starting node for path
target : node label, optional
Ending node for path
weight : string or function
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number.
heuristic : bool
Determines whether to use a heuristic to early detect negative
cycles at a hopefully negligible cost.
Returns
-------
pred, dist : dictionaries
Returns two dictionaries keyed by node to predecessor in the
path and to the distance from the source respectively.
Raises
------
NodeNotFound
If `source` is not in `G`.
NetworkXUnbounded
If the (di)graph contains a negative (di)cycle, the
algorithm raises an exception to indicate the presence of the
negative (di)cycle. Note: any negative weight edge in an
undirected graph is a negative cycle.
Examples
--------
>>> G = nx.path_graph(5, create_using=nx.DiGraph())
>>> pred, dist = nx.bellman_ford_predecessor_and_distance(G, 0)
>>> sorted(pred.items())
[(0, []), (1, [0]), (2, [1]), (3, [2]), (4, [3])]
>>> sorted(dist.items())
[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
>>> pred, dist = nx.bellman_ford_predecessor_and_distance(G, 0, 1)
>>> sorted(pred.items())
[(0, []), (1, [0]), (2, [1]), (3, [2]), (4, [3])]
>>> sorted(dist.items())
[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
>>> G = nx.cycle_graph(5, create_using=nx.DiGraph())
>>> G[1][2]["weight"] = -7
>>> nx.bellman_ford_predecessor_and_distance(G, 0)
Traceback (most recent call last):
...
networkx.exception.NetworkXUnbounded: Negative cycle detected.
See Also
--------
find_negative_cycle
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
The dictionaries returned only have keys for nodes reachable from
the source.
In the case where the (di)graph is not connected, if a component
not containing the source contains a negative (di)cycle, it
will not be detected.
In NetworkX v2.1 and prior, the source node had predecessor `[None]`.
In NetworkX v2.2 this changed to the source node having predecessor `[]`
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, source, target=None, weight='weight', heuristic=False, *, backend=None, **backend_kwargs) | [
0.008715999312698841,
-0.004066494759172201,
-0.034261554479599,
-0.04415329173207283,
-0.038945067673921585,
-0.02178514003753662,
-0.010727384127676487,
0.04057749733328819,
0.07361473143100739,
-0.010610781610012054,
-0.05285957455635071,
0.02969464287161827,
0.028684092685580254,
0.025535838678479195,
-0.027265433222055435,
0.03587454929947853,
0.00006581636262126267,
0.03599115088582039,
-0.0012801927514374256,
0.01374931912869215,
-0.014993073418736458,
-0.0565519705414772,
0.055502552539110184,
0.04955584928393364,
-0.02100779302418232,
-0.009206699207425117,
0.014857037924230099,
-0.039994485676288605,
-0.025807909667491913,
-0.016382580623030663,
0.01776237040758133,
-0.018821505829691887,
-0.006359667517244816,
-0.005528877954930067,
0.016567200422286987,
0.05861193686723709,
0.007875493727624416,
-0.0030802360270172358,
-0.023378700017929077,
-0.04399782046675682,
-0.03018048405647278,
-0.030452555045485497,
0.005723214708268642,
-0.03781791403889656,
0.08006670325994492,
0.08379796892404556,
-0.01750001683831215,
0.00864312332123518,
-0.019404515624046326,
-0.01881178840994835,
0.015138826332986355,
0.001435662154108286,
-0.009240708313882351,
0.0095905140042305,
-0.007802617270499468,
0.03948920965194702,
-0.03325100243091583,
0.0541810616850853,
0.027304301038384438,
-0.03822602331638336,
0.03948920965194702,
0.010552480816841125,
0.07085514813661575,
0.04011108726263046,
-0.06378129124641418,
-0.02357303723692894,
-0.04656306654214859,
-0.03754584491252899,
-0.04003335162997246,
0.02137703262269497,
0.0010324135655537248,
-0.009507921524345875,
-0.013467530719935894,
-0.03552474081516266,
-0.0019081431673839688,
0.0380316860973835,
-0.000026360705305705778,
-0.03482513129711151,
0.011154924519360065,
-0.039839018136262894,
0.04388121888041496,
-0.0564742349088192,
-0.025866210460662842,
-0.07101061940193176,
0.07299285382032394,
0.025049995630979538,
-0.004100503865629435,
0.002693992108106613,
-0.00908523891121149,
-0.03410608321428299,
-0.036690764129161835,
0.030763493850827217,
-0.0033668826799839735,
0.000488574500195682,
0.05678517371416092,
0.02672129124403,
0.00909009762108326,
-0.057018376886844635,
0.05002225935459137,
0.031132733449339867,
0.068523108959198,
0.004868133459240198,
-0.01456553302705288,
0.03608831763267517,
0.02644922025501728,
-0.06724048405885696,
-0.011038322933018208,
0.01587730646133423,
-0.01390478853136301,
-0.055658020079135895,
-0.02267908863723278,
0.012408396229147911,
0.025866210460662842,
-0.026799026876688004,
0.02347586862742901,
0.0032721436582505703,
0.006753199268132448,
0.04395895451307297,
-0.0005635763518512249,
-0.021124394610524178,
-0.025166597217321396,
0.05254863575100899,
-0.08309835940599442,
-0.003886733204126358,
0.04042202606797218,
-0.056396499276161194,
0.024758491665124893,
-0.01990007422864437,
0.06619106978178024,
0.017898406833410263,
0.02623545005917549,
0.0047879694029688835,
-0.027945611625909805,
0.06560806185007095,
0.032026682049036026,
-0.024603022262454033,
-0.056590836495161057,
0.04687400534749031,
0.06506391614675522,
0.010416445322334766,
0.042559728026390076,
-0.07551922649145126,
0.007729740813374519,
0.028781259432435036,
0.00593212665989995,
-0.028509188443422318,
0.011096623726189137,
0.014050540514290333,
0.03128820285201073,
0.059739090502262115,
0.015430331230163574,
0.002895616227760911,
0.006918385159224272,
0.011660199612379074,
0.0016761537408456206,
-0.06821216642856598,
-0.04201558604836464,
0.02042478322982788,
0.005834958516061306,
-0.0005225834320299327,
0.016625501215457916,
-0.04469743371009827,
0.005732931662350893,
0.014857037924230099,
-0.04982792213559151,
0.03494173288345337,
0.022173812612891197,
0.05215996131300926,
-0.027109965682029724,
0.012437546625733376,
-0.005917551461607218,
-0.0640922337770462,
-0.047845687717199326,
-0.029092198237776756,
-0.024525286629796028,
0.0033595950808376074,
0.025069430470466614,
-0.0022543054074048996,
0.011922554112970829,
-0.019472533836960793,
0.009882019832730293,
-0.02660468965768814,
0.02314549684524536,
-0.01359384972602129,
0.030083315446972847,
0.029150499030947685,
0.022232115268707275,
-0.02162967063486576,
0.002997643081471324,
0.03482513129711151,
-0.04823436215519905,
-0.09328159689903259,
-0.06055530533194542,
0.08325383067131042,
-0.00908523891121149,
0.006719190161675215,
-0.03731263801455498,
-0.022134946659207344,
-0.02724600024521351,
0.06385903060436249,
-0.009138681925833225,
-0.02922823466360569,
0.0399167500436306,
-0.008871468715369701,
0.00922127440571785,
-0.02880069427192211,
-0.03243478760123253,
0.008555672131478786,
0.0009984045755118132,
0.018578585237264633,
-0.03503889963030815,
-0.045397043228149414,
0.029986146837472916,
-0.029733510687947273,
0.0011787733528763056,
0.013788186013698578,
-0.03173517808318138,
0.04007222130894661,
0.014011673629283905,
-0.05907834693789482,
-0.0044478802010416985,
-0.015274861827492714,
-0.009546788409352303,
0.021182697266340256,
0.061837926506996155,
-0.05033319443464279,
0.04702947288751602,
0.03064689226448536,
0.02588564343750477,
-0.07338152825832367,
0.07722938805818558,
-0.0327845960855484,
0.09631325304508209,
-0.014847321435809135,
0.07380906492471695,
-0.047806818038225174,
0.003425183705985546,
0.04069409891963005,
0.04559138044714928,
0.027848444879055023,
-0.02168797142803669,
-0.023437002673745155,
-0.014701568521559238,
-0.058106664568185806,
0.005868967156857252,
-0.00007970839942572638,
0.03142423927783966,
-0.012282077223062515,
0.026099413633346558,
-0.006485986057668924,
0.005043036304414272,
0.02771240845322609,
-0.04236539453268051,
-0.05752365291118622,
-0.012952539138495922,
-0.04322047531604767,
-0.02100779302418232,
-0.03756527602672577,
-0.03649642691016197,
-0.06584126502275467,
-0.032240454107522964,
-0.027848444879055023,
-0.060943979769945145,
0.10152147710323334,
-0.0038988792803138494,
0.03266799449920654,
0.03117160126566887,
-0.014380913227796555,
-0.08014444261789322,
0.006631738506257534,
0.04259859770536423,
0.043026138097047806,
-0.006894093006849289,
-0.0035733655095100403,
-0.025108296424150467,
0.0052033644169569016,
-0.03220158442854881,
0.03488343209028244,
0.012816502712666988,
-0.023009460419416428,
-0.043764617294073105,
-0.008380768820643425,
-0.04123824089765549,
-0.006451977416872978,
0.017888689413666725,
0.029675208032131195,
0.012107173912227154,
-0.03484456241130829,
0.016489466652274132,
0.006675464566797018,
0.07019440084695816,
-0.012107173912227154,
0.010591348633170128,
-0.03775961324572563,
0.06222660094499588,
0.047690216451883316,
-0.003466480178758502,
-0.07287625223398209,
0.016353430226445198,
0.05359805375337601,
0.015498349443078041,
-0.02571074105799198,
0.02561357244849205,
-0.005718356464058161,
-0.04267633333802223,
0.008317609317600727,
0.03121046908199787,
-0.016771255061030388,
-0.0026356910821050406,
-0.030938396230340004,
-0.021396467462182045,
-0.025224899873137474,
0.001747815404087305,
0.0073070586659014225,
0.0036195204593241215,
-0.037273772060871124,
-0.03515550121665001,
0.007379934657365084,
-0.006792066618800163,
0.03220158442854881,
-0.038945067673921585,
0.07645204663276672,
-0.06836763769388199,
0.029208801686763763,
-0.030471989884972572,
0.029247667640447617,
0.03185177966952324,
0.02567187324166298,
0.035116635262966156,
0.02242645062506199,
0.03793451562523842,
0.022504186257719994,
0.026157714426517487,
0.03086066246032715,
-0.019822340458631516,
0.08970580250024796,
0.07435321062803268,
-0.005383125506341457,
0.000027366550057195127,
-0.0031506831292062998,
0.04741814732551575,
0.021765707060694695,
-0.02209607884287834,
0.023767374455928802,
0.006092454306781292,
-0.04388121888041496,
0.033911749720573425,
-0.038945067673921585,
0.007433377671986818,
-0.04734041169285774,
0.021862875670194626,
0.06790123134851456,
0.01827736385166645,
0.026468653231859207,
0.05060526728630066,
0.0031458246521651745,
-0.010921720415353775,
-0.04069409891963005,
0.02230984903872013,
-0.004897283855825663,
0.008390485309064388,
0.018083026632666588,
0.009080381132662296,
-0.002934483578428626,
-0.04629099369049072,
0.013623000122606754,
0.01937536522746086,
-0.013321778737008572,
-0.01822877861559391,
-0.0504886656999588,
-0.008473078720271587,
-0.06055530533194542,
-0.025049995630979538,
0.05542481690645218,
0.01201972272247076,
0.00048310880083590746,
0.016479749232530594,
-0.007389651611447334,
-0.003570936154574156,
0.04411442205309868,
-0.021960042417049408,
0.05740705132484436,
0.005193647462874651,
0.046018920838832855,
0.024913961067795753,
-0.04116050526499748,
0.06646314263343811,
0.007389651611447334,
0.033853448927402496,
0.006345092318952084,
-0.02468075603246689,
-0.017830388620495796,
0.0444253608584404,
0.02870352566242218,
-0.0026599830016493797,
-0.04170464724302292,
0.07186570018529892,
0.03027765266597271,
-0.050566401332616806,
-0.025069430470466614,
0.015838438645005226,
-0.021202130243182182,
-0.05519161373376846,
0.06910611689090729,
0.0096925413236022,
-0.047690216451883316,
0.045902319252491,
0.027906745672225952,
0.0259828120470047,
0.04862303286790848,
-0.04178238287568092,
-0.0023806241806596518,
-0.014623833820223808,
0.0171307772397995,
-0.04388121888041496,
-0.058845143765211105,
-0.06844537705183029,
0.042248789221048355,
0.056746307760477066,
0.0029757802840322256,
0.0365547277033329,
-0.029403137043118477,
0.0639367625117302,
-0.0828651562333107,
0.01215575821697712,
-0.04322047531604767,
-0.013001122511923313,
-0.027945611625909805,
-0.000910345814190805,
0.050838470458984375,
-0.024855660274624825,
-0.023650772869586945,
0.03935317322611809,
-0.05511387810111046,
-0.0071078636683523655,
-0.0052033644169569016,
0.016197960823774338,
0.002462002681568265,
0.07206003367900848,
-0.03410608321428299,
-0.009444762021303177,
-0.02777070924639702,
-0.02619658224284649,
-0.027012797072529793,
-0.05200449004769325,
-0.0790172889828682,
0.020521951839327812,
-0.02279569022357464,
0.030918963253498077,
-0.03593285009264946,
0.007030128967016935,
-0.03880903124809265,
0.021143829450011253,
0.023164929822087288,
-0.026177149266004562,
0.02493339404463768,
0.01602305844426155,
0.010222109034657478,
-0.11986685544252396,
0.027109965682029724,
0.05079960450530052,
-0.03183234483003616,
0.028567489236593246,
-0.01194198802113533,
-0.04792342334985733,
0.05923381447792053,
0.03435872122645378,
0.0010129798902198672,
-0.0007172237383201718,
-0.025963379070162773,
0.04535817727446556,
-0.010824551805853844,
-0.08550813049077988,
-0.005951560568064451,
0.02236814983189106,
-0.004168521612882614,
-0.06354808807373047,
0.014808453619480133,
0.0021947897039353848,
-0.016683802008628845,
0.04069409891963005,
-0.040149953216314316,
0.06700728088617325,
-0.007875493727624416,
0.0054608602076768875,
-0.0549972765147686,
0.03908110409975052,
-0.019628003239631653,
0.014468364417552948,
0.0029466296546161175,
0.04069409891963005,
-0.06284847855567932,
0.069339320063591,
-0.03121046908199787,
-0.003886733204126358,
0.04275406524538994,
0.033173270523548126,
-0.016586635261774063,
0.08076632022857666,
-0.013409229926764965,
0.0026041113305836916,
-0.01044559571892023,
-0.05488067492842674,
0.059467021375894547,
0.0339311808347702,
0.015333162620663643,
0.01456553302705288,
0.049050573259592056,
-0.02571074105799198,
0.02650752104818821,
0.017315397039055824,
0.002968492452055216,
0.047068338841199875,
0.05511387810111046,
0.04578571766614914,
-0.0078074755147099495,
-0.006728907115757465,
0.06891178339719772,
0.002171712229028344,
-0.022387584671378136,
0.04337594285607338,
0.06222660094499588,
-0.015498349443078041,
0.02771240845322609,
-0.07435321062803268,
0.03531097248196602,
0.0043579996563494205,
-0.04749587923288345,
0.023087196052074432,
0.004100503865629435,
0.010882853530347347,
0.03371741250157356,
-0.0003747053851839155,
0.02697392925620079,
0.018461983650922775,
0.014478081837296486,
0.056124430149793625,
-0.018685471266508102,
-0.014701568521559238,
-0.017043326050043106,
0.05954475328326225,
0.00022029882529750466,
-0.004644646309316158,
-0.005694064311683178,
0.06992233544588089,
-0.005169355310499668,
-0.002171712229028344,
-0.008026104420423508,
-0.0002954524534288794,
-0.05103280767798424,
-0.022018345072865486,
-0.0023769803810864687,
0.007258474361151457,
0.05212109535932541,
0.06957252323627472,
-0.00968768261373043,
0.014147709123790264,
0.009396177716553211,
0.006660889368504286,
0.08504172414541245,
-0.025438670068979263,
-0.08527492731809616,
-0.046174392104148865,
-0.016926724463701248,
-0.015420614741742611,
-0.030549723654985428,
0.015682969242334366,
-0.012816502712666988,
0.0013846487272530794,
-0.006369384005665779,
-0.029733510687947273,
0.04053862765431404,
-0.005732931662350893,
0.026274317875504494,
-0.028431454673409462,
-0.007914360612630844,
-0.026371484622359276,
-0.04520270973443985,
0.02326209843158722,
-0.05103280767798424,
-0.01785953901708126,
0.021240998059511185,
0.06296508014202118,
0.051926758140325546,
0.025322066619992256,
-0.002084260806441307,
-0.05227656289935112,
0.004149087704718113,
-0.04800115525722504,
0.010455312207341194,
0.010756534524261951,
-0.053403716534376144,
0.014332328923046589,
0.03791508451104164,
0.011281243525445461,
-0.05585235729813576,
-0.019628003239631653,
0.01728624664247036,
0.031501974910497665,
-0.003165258327499032,
-0.09312613308429718,
-0.009828576818108559,
0.006986402906477451,
-0.006218773312866688,
0.031229902058839798,
-0.014818171039223671,
-0.006291649304330349,
-0.08714056015014648,
-0.015099958516657352,
-0.050993941724300385,
0.019977809861302376,
0.013564699329435825,
0.025905078276991844,
-0.02468075603246689,
-0.029714075848460197,
-0.007642289157956839,
-0.009828576818108559,
0.016100792214274406,
-0.02996671386063099,
-0.03587454929947853,
0.01526514533907175,
-0.03970298171043396,
0.02001667581498623,
-0.012641600333154202,
0.0028251693584024906,
0.03845922648906708,
-0.002387911779806018,
0.019355932250618935,
-0.06039983406662941,
0.03299836441874504,
-0.021804573014378548,
-0.0490117073059082,
0.04461969807744026,
0.05379238724708557,
-0.02258192002773285,
-0.015935607254505157,
0.06930045783519745,
-0.010523330420255661,
-0.01524571143090725,
-0.011951704509556293,
-0.03494173288345337,
0.044075556099414825,
-0.021338166669011116,
-0.03334817290306091,
-0.03589398041367531,
-0.004423588514328003,
-0.0038964501582086086,
-0.022543054074048996,
0.00953707192093134,
0.0007245113956741989,
-0.005684347357600927,
-0.015284578315913677,
-0.0304914228618145,
0.006792066618800163,
0.02038591541349888,
0.07275965064764023,
-0.018821505829691887,
-0.03408665210008621,
0.012165475636720657,
0.012612449936568737,
0.032609693706035614,
0.054025594145059586,
0.0692615881562233,
-0.04384235292673111,
-0.037429243326187134,
-0.012981689535081387,
0.01765548624098301,
-0.06207112967967987,
-0.017937274649739265,
0.0076665813103318214,
-0.06413109600543976,
-0.011485297232866287,
0.008555672131478786,
0.016217393800616264,
-0.032823462039232254,
-0.06055530533194542,
0.02687676064670086,
-0.004100503865629435,
-0.07579129934310913,
-0.06770689785480499,
0.0429484024643898,
0.04609665647149086,
0.025011129677295685,
-0.013098291121423244,
-0.01163104921579361,
0.05375352129340172,
-0.051887888461351395,
-0.08395344018936157,
0.03492229804396629,
0.0141379926353693,
0.019890356808900833,
-0.034591928124427795,
0.04042202606797218,
0.008788875304162502,
-0.03808998689055443,
-0.05142148211598396,
-0.0024741487577557564,
-0.0199583750218153,
0.03080236166715622,
-0.03604945167899132,
0.020463651046156883,
0.05332598090171814,
0.008108696900308132,
-0.030083315446972847,
-0.011154924519360065,
-0.031404804438352585,
-0.08037764579057693,
0.03865356370806694,
0.022970594465732574,
0.009828576818108559,
-0.03618548810482025,
-0.030258219689130783,
-0.01396308932453394,
0.026799026876688004,
0.01157274842262268,
-0.014886188320815563,
0.0206968542188406,
-0.013117725029587746,
-0.012534715235233307,
-0.002594394376501441,
0.014497514814138412,
-0.02367020584642887,
-0.0032332763075828552,
0.028625790029764175,
-0.08846204727888107,
-0.0007645933073945343,
0.023378700017929077,
-0.08348703384399414,
0.00201016990467906,
-0.017898406833410263,
-0.026332618668675423,
0.08822884410619736,
0.009833435527980328,
0.0320461168885231,
0.00479525700211525,
-0.01458496693521738,
0.025283200666308403,
-0.014944489113986492,
-0.009794567711651325,
0.05993342772126198,
-0.02656582184135914,
0.018316229805350304,
-0.03987788408994675,
-0.01769435405731201,
-0.0012407181784510612,
-0.010980021208524704,
0.010163807310163975,
0.012602732516825199,
-0.02755693905055523,
-0.010902286507189274,
0.031035564839839935,
-0.0007068996201269329,
0.024117181077599525,
-0.01839396543800831,
0.01170878391712904,
-0.011844819411635399,
-0.04011108726263046,
-0.0519656240940094,
-0.02604111284017563,
-0.048156626522541046,
-0.061254918575286865,
-0.008730574510991573,
-0.018831223249435425,
0.022776257246732712,
0.022076645866036415,
0.046640798449516296,
0.025691306218504906,
0.08504172414541245
]
|
30,424 | networkx.drawing.layout | bfs_layout | Position nodes according to breadth-first search algorithm.
Parameters
----------
G : NetworkX graph
A position will be assigned to every node in G.
start : node in `G`
Starting node for bfs
center : array-like or None
Coordinate pair around which to center the layout.
Returns
-------
pos : dict
A dictionary of positions keyed by node.
Examples
--------
>>> G = nx.path_graph(4)
>>> pos = nx.bfs_layout(G, 0)
Notes
-----
This algorithm currently only works in two dimensions and does not
try to minimize edge crossings.
| def bfs_layout(G, start, *, align="vertical", scale=1, center=None):
"""Position nodes according to breadth-first search algorithm.
Parameters
----------
G : NetworkX graph
A position will be assigned to every node in G.
start : node in `G`
Starting node for bfs
center : array-like or None
Coordinate pair around which to center the layout.
Returns
-------
pos : dict
A dictionary of positions keyed by node.
Examples
--------
>>> G = nx.path_graph(4)
>>> pos = nx.bfs_layout(G, 0)
Notes
-----
This algorithm currently only works in two dimensions and does not
try to minimize edge crossings.
"""
G, center = _process_params(G, center, 2)
# Compute layers with BFS
layers = dict(enumerate(nx.bfs_layers(G, start)))
if len(G) != sum(len(nodes) for nodes in layers.values()):
raise nx.NetworkXError(
"bfs_layout didn't include all nodes. Perhaps use input graph:\n"
" G.subgraph(nx.node_connected_component(G, start))"
)
# Compute node positions with multipartite_layout
return multipartite_layout(
G, subset_key=layers, align=align, scale=scale, center=center
)
| (G, start, *, align='vertical', scale=1, center=None) | [
0.057836636900901794,
-0.009085276164114475,
-0.032476942986249924,
-0.014728751964867115,
-0.005629995837807655,
0.04766400158405304,
-0.015411720611155033,
0.02659982070326805,
-0.011808163486421108,
-0.022196471691131592,
-0.0018927659839391708,
-0.013533557765185833,
0.0062815118581056595,
0.020614860579371452,
0.006591543555259705,
0.03688029199838638,
0.011637421324849129,
-0.043098900467157364,
0.016121648252010345,
0.02377808280289173,
-0.008649434894323349,
-0.008838149718940258,
0.08087783306837082,
0.027013195678591728,
0.012167620472609997,
-0.032099515199661255,
0.027390625327825546,
-0.003850683569908142,
0.05891500785946846,
0.013335855677723885,
0.07498273998498917,
-0.01666083373129368,
-0.043386463075876236,
-0.017667314037680626,
0.009777231141924858,
0.02661779336631298,
0.06869223713874817,
0.014728751964867115,
0.008707846514880657,
-0.034597739577293396,
0.004517925437539816,
-0.029870878905057907,
-0.01849406398832798,
-0.037167858332395554,
0.02503618225455284,
0.05934635549783707,
0.029834933578968048,
-0.0005835560150444508,
-0.0008172030793502927,
0.06624793261289597,
0.013758217915892601,
-0.055032871663570404,
-0.014180580154061317,
-0.04669347032904625,
0.012176606804132462,
-0.00367544824257493,
-0.01628340408205986,
-0.004875136073678732,
0.03204559534788132,
-0.02981696091592312,
0.07692380249500275,
0.03549638390541077,
0.028361160308122635,
-0.021729178726673126,
-0.032764509320259094,
0.006483706180006266,
-0.0031722083222121,
-0.06552901864051819,
-0.04974885284900665,
0.0046055433340370655,
-0.04820318892598152,
0.023077141493558884,
-0.018691765144467354,
0.05521260201931,
-0.021783096715807915,
0.05995743349194527,
0.05082722380757332,
0.028073593974113464,
-0.018997304141521454,
-0.012005864642560482,
0.016678806394338608,
0.011331883259117603,
0.030284255743026733,
-0.04194863513112068,
0.09158965200185776,
0.032692618668079376,
0.05891500785946846,
0.07678002119064331,
0.0035810908302664757,
-0.058375824242830276,
-0.037778936326503754,
-0.018260417506098747,
0.05981365218758583,
-0.02165728621184826,
0.03943243622779846,
0.015366788022220135,
0.014468145556747913,
-0.04234403744339943,
-0.10064797103404999,
0.04978479817509651,
0.023041196167469025,
0.05629097297787666,
0.007633968722075224,
0.006402828264981508,
-0.05050371214747429,
-0.014432200230658054,
-0.039899732917547226,
-0.02471267059445381,
-0.06200633943080902,
0.005495199467986822,
0.03066168539226055,
-0.017631366848945618,
0.046585630625486374,
0.05420612171292305,
0.017811095342040062,
0.032710589468479156,
0.03238707780838013,
0.031470462679862976,
0.006569077260792255,
-0.017442652955651283,
0.006218606606125832,
-0.013102209195494652,
-0.03788677230477333,
-0.03849785029888153,
0.03567611053586006,
-0.044968076050281525,
0.03608948737382889,
0.036161378026008606,
0.04867048189043999,
-0.04295511543750763,
0.014090715907514095,
-0.01686752215027809,
-0.07332923263311386,
0.03468760475516319,
0.008056330494582653,
-0.025916852056980133,
-0.03731163963675499,
-0.017110155895352364,
-0.020938372239470482,
0.03727569431066513,
0.02129782922565937,
-0.03321383148431778,
0.0005366581026464701,
-0.00846072006970644,
-0.04888615757226944,
0.015474625863134861,
0.03071560338139534,
-0.01720001921057701,
-0.02289741300046444,
0.036808401346206665,
0.02383200079202652,
-0.08490375429391861,
0.05733339861035347,
-0.010666887275874615,
-0.03245897218585014,
-0.008492172695696354,
-0.006294991355389357,
-0.01789197325706482,
-0.0038866291288286448,
0.03723974898457527,
-0.02854088880121708,
-0.002352196956053376,
0.01411767490208149,
-0.023041196167469025,
-0.026096580550074577,
0.04482429102063179,
-0.02695927768945694,
0.04076242819428444,
-0.04230809211730957,
-0.014593956060707569,
0.00924703199416399,
0.011394788511097431,
-0.030481956899166107,
-0.035855840891599655,
0.003774298820644617,
-0.03332166746258736,
0.0407983735203743,
-0.027139006182551384,
0.0007189140887930989,
-0.01722697913646698,
0.018116634339094162,
-0.008096769452095032,
0.07857730984687805,
-0.03222532197833061,
-0.02160336822271347,
0.057225558906793594,
-0.02688738703727722,
0.03067965805530548,
-0.008105755783617496,
0.012131675146520138,
-0.01096343994140625,
-0.03245897218585014,
-0.01755048893392086,
-0.008671901188790798,
-0.027336707338690758,
0.07929622381925583,
0.00909875612705946,
0.008752779103815556,
-0.05355909839272499,
0.032423023134469986,
0.0917334333062172,
-0.02410159446299076,
0.0414094515144825,
-0.01287754811346531,
0.009372842498123646,
0.0401872955262661,
-0.0213158018887043,
-0.012949439696967602,
-0.028918318450450897,
0.0021466324105858803,
-0.04698103293776512,
-0.028720617294311523,
-0.032081540673971176,
-0.04859859123826027,
-0.022987278178334236,
-0.004884122405201197,
-0.013955919072031975,
0.04112188518047333,
0.026402119547128677,
0.006232086569070816,
0.0033429504837840796,
0.03285437449812889,
-0.006236579734832048,
-0.03222532197833061,
0.020183512941002846,
-0.017667314037680626,
0.06567279994487762,
-0.061898503452539444,
0.007764271926134825,
-0.07081303745508194,
0.050000473856925964,
-0.10539280623197556,
0.03314193710684776,
-0.004540391732007265,
0.082818903028965,
-0.05639880895614624,
0.05830392986536026,
0.05230099707841873,
-0.03979189321398735,
0.04827507957816124,
0.027821974828839302,
0.013398760929703712,
-0.03720380365848541,
-0.010855602100491524,
-0.046549685299396515,
-0.021225938573479652,
0.04353024810552597,
-0.08504753559827805,
0.002846450312063098,
0.0051671951077878475,
-0.06854845583438873,
-0.02695927768945694,
0.0235444363206625,
-0.04331457242369652,
0.01910514198243618,
-0.0033699097111821175,
-0.07864920049905777,
0.0045606112107634544,
-0.00859102327376604,
0.014531050808727741,
-0.014611928723752499,
-0.06887196749448776,
-0.005009932443499565,
0.003729366697371006,
0.08224377036094666,
0.07706759124994278,
0.03483138605952263,
0.02282552234828472,
0.01622948609292507,
0.02291538566350937,
0.002848697127774358,
0.010424254462122917,
0.052444782108068466,
0.03688029199838638,
0.04849075525999069,
-0.05391855537891388,
-0.02543158456683159,
-0.011224046349525452,
0.01817055232822895,
0.02535969391465187,
-0.01113418210297823,
-0.06549306958913803,
-0.04130161181092262,
0.0513664111495018,
0.007503665518015623,
0.028738589957356453,
0.01423449907451868,
-0.03375301510095596,
0.014602942392230034,
-0.027947785332798958,
0.05172586813569069,
0.017415693029761314,
-0.04428510740399361,
-0.010747765190899372,
-0.008316936902701855,
0.0196982454508543,
0.02223241701722145,
-0.027642246335744858,
0.008366362191736698,
0.010181620717048645,
0.005346923600882292,
-0.06635577231645584,
0.030284255743026733,
0.05636286363005638,
0.04895804822444916,
0.03265667334198952,
0.00016063236398622394,
-0.023346735164523125,
-0.01627441681921482,
-0.00570638058707118,
-0.04863453656435013,
0.012059783563017845,
-0.00604337127879262,
-0.05945419520139694,
-0.03813839331269264,
-0.006137728691101074,
0.007229579612612724,
0.004893108736723661,
-0.010010878555476665,
-0.009938986971974373,
-0.03071560338139534,
0.06542117893695831,
-0.05772880092263222,
0.06049662083387375,
-0.03184789419174194,
0.0668230652809143,
-0.0024465543683618307,
0.050611551851034164,
0.02852291613817215,
0.022376200184226036,
-0.0021971811074763536,
0.02658184804022312,
0.016157593578100204,
0.00664546201005578,
-0.09755664318799973,
-0.024838481098413467,
0.04730454459786415,
0.008622475899755955,
-0.027983730658888817,
-0.06614009290933609,
0.027192924171686172,
-0.03190181031823158,
-0.01783805526793003,
-0.012922480702400208,
0.027336707338690758,
0.006416308227926493,
0.027462517842650414,
-0.04471645504236221,
-0.008060824126005173,
0.005949013866484165,
0.008514638990163803,
0.022340254858136177,
-0.04503996670246124,
-0.04288322478532791,
-0.03006858192384243,
-0.008128222078084946,
0.0002495137450750917,
-0.07987135648727417,
0.002772312378510833,
0.05916662886738777,
0.061251480132341385,
0.013955919072031975,
-0.0635160580277443,
-0.028433050960302353,
-0.019949866458773613,
0.022196471691131592,
-0.04158917814493179,
0.02259187400341034,
0.07828973978757858,
0.02102823741734028,
0.05575178563594818,
-0.022609848529100418,
-0.09985716640949249,
0.062222011387348175,
-0.019051222130656242,
0.060676347464323044,
-0.01757744885981083,
0.0018534503178671002,
-0.04734049364924431,
0.014171593822538853,
-0.010666887275874615,
-0.014620915055274963,
0.023041196167469025,
0.03224329650402069,
-0.0016703519504517317,
-0.02253795601427555,
0.06405524164438248,
-0.009175141341984272,
0.010352362878620625,
-0.03236910700798035,
-0.06258147209882736,
0.0007110509322956204,
-0.01663387380540371,
0.02940358594059944,
0.0006986946100369096,
0.01814359426498413,
0.07113654911518097,
-0.0017602161969989538,
0.03628718852996826,
-0.036161378026008606,
0.0013917727628722787,
0.013237005099654198,
-0.03156032785773277,
0.01627441681921482,
0.03165019303560257,
-0.07922433316707611,
-0.00423036003485322,
0.00372712011449039,
0.011763231828808784,
0.08885777741670609,
0.01691245287656784,
0.011170127429068089,
-0.019248925149440765,
0.0024577875155955553,
0.004834697116166353,
-0.023652272298932076,
-0.03738353028893471,
0.06207823008298874,
-0.004619022831320763,
-0.038965143263339996,
-0.04396159574389458,
0.0078181903809309,
0.04572293534874916,
-0.04011540487408638,
-0.002217400586232543,
-0.008977439254522324,
0.011592489667236805,
-0.029870878905057907,
-0.003700160887092352,
0.07279004901647568,
-0.0029453011229634285,
0.049029938876628876,
-0.005746819544583559,
0.07124438136816025,
-0.03344747796654701,
-0.051258575171232224,
-0.0028239842504262924,
0.009579529985785484,
0.012122688814997673,
0.007611502893269062,
-0.019356761127710342,
0.006191647611558437,
0.023652272298932076,
-0.0356401652097702,
-0.006739819422364235,
0.009013385511934757,
-0.049641016870737076,
0.007256539072841406,
0.016840562224388123,
-0.0018163813510909677,
-0.03628718852996826,
-0.049101829528808594,
0.06729035824537277,
0.01627441681921482,
-0.015905974432826042,
-0.053127750754356384,
-0.04726859927177429,
-0.04482429102063179,
-0.06628387421369553,
0.029655205085873604,
0.023059168830513954,
-0.040295135229825974,
-0.049928583204746246,
0.03529868274927139,
0.039324600249528885,
-0.025844961404800415,
0.03132668137550354,
0.008492172695696354,
-0.06265336275100708,
-0.03698812797665596,
0.01409970223903656,
-0.0363411046564579,
-0.00848318636417389,
-0.051546137779951096,
0.055032871663570404,
0.028936291113495827,
-0.024568889290094376,
-0.06484604626893997,
-0.01823345758020878,
-0.010091756470501423,
-0.000006432666395994602,
-0.013147140853106976,
0.009211086668074131,
0.07562976330518723,
-0.02444307878613472,
-0.0213158018887043,
0.011664381250739098,
0.023706192150712013,
-0.025629287585616112,
-0.06107174977660179,
0.009768244810402393,
0.0014119921252131462,
0.022753629833459854,
0.05291207507252693,
0.036197323352098465,
0.017370760440826416,
0.00469990074634552,
-0.0513664111495018,
0.0017826822586357594,
-0.015789151191711426,
0.03856974095106125,
-0.010873575694859028,
0.05449368804693222,
0.0369521826505661,
-0.00010123770334757864,
-0.031865864992141724,
-0.007040864787995815,
0.02009364776313305,
0.03950432687997818,
0.01318308711051941,
0.021082155406475067,
0.02758832834661007,
-0.02158539555966854,
0.006272525526583195,
-0.03781488165259361,
0.049641016870737076,
-0.030338173732161522,
0.024658752605319023,
0.040618646889925,
-0.024856453761458397,
-0.03236910700798035,
-0.008033865131437778,
0.03691623732447624,
0.002070247894152999,
-0.01721799187362194,
0.01881757564842701,
0.08130918443202972,
-0.049928583204746246,
0.02032729610800743,
0.009058317169547081,
0.006398335099220276,
0.02289741300046444,
0.02981696091592312,
-0.026186445727944374,
0.01144870650023222,
0.03767109662294388,
0.06146715208888054,
-0.010801684111356735,
-0.07307761907577515,
-0.03420233726501465,
0.02413753978908062,
-0.024550914764404297,
-0.020255403593182564,
0.033681124448776245,
0.05931041017174721,
0.04669347032904625,
0.03350139409303665,
-0.05384666472673416,
0.009256018325686455,
-0.06107174977660179,
-0.007063330616801977,
0.006937521044164896,
-0.012356335297226906,
0.00011050495959352702,
0.011969919316470623,
0.003304758109152317,
0.010729792527854443,
0.05143830180168152,
0.049353450536727905,
-0.00022339692804962397,
-0.026851439848542213,
0.005495199467986822,
-0.0019736438989639282,
0.023113086819648743,
-0.019374733790755272,
-0.03096722438931465,
0.004351676907390356,
-0.052444782108068466,
0.041265666484832764,
0.029870878905057907,
0.025916852056980133,
0.04942534118890762,
0.0029745069332420826,
-0.007656435016542673,
0.04834697023034096,
-0.049389395862817764,
-0.033034101128578186,
0.04543536901473999,
-0.017406707629561424,
-0.1071900874376297,
-0.019015276804566383,
-0.06484604626893997,
0.037167858332395554,
0.03238707780838013,
-0.007598022930324078,
0.06617604196071625,
-0.061898503452539444,
0.007930520921945572,
-0.02255592867732048,
-0.002184824785217643,
-0.002949794288724661,
-0.030014662072062492,
0.1209932416677475,
0.03670056536793709,
0.010118715465068817,
-0.015807123854756355,
-0.03332166746258736,
-0.00014041289978194982,
-0.027462517842650414,
0.006007425952702761,
-0.05700988695025444,
0.0469091422855854,
0.02095634490251541,
0.029223857447504997,
0.019824055954813957,
-0.028109541162848473,
0.025179965421557426,
0.038390010595321655,
0.00766991451382637,
-0.03413044661283493,
0.04284727945923805,
0.03010452724993229,
0.011763231828808784,
-0.007085796911269426,
-0.06484604626893997,
-0.039576221257448196,
0.04291917011141777,
0.02606063522398472,
-0.005418814718723297,
-0.020183512941002846,
0.022034715861082077,
0.0027880386915057898,
0.01883554831147194,
-0.026132525876164436,
0.05693799629807472,
0.04834697023034096,
0.03245897218585014,
-0.03317788615822792,
0.020560942590236664,
0.012751738540828228,
-0.0014558009570464492,
-0.03975594788789749,
-0.016535023227334023,
-0.015142127871513367,
0.04730454459786415,
-0.043422408401966095,
0.009786217473447323,
-0.052157215774059296,
-0.0020680013112723827,
0.04705292731523514,
0.001454677665606141,
-0.03184789419174194,
0.025233883410692215,
-0.03578394651412964,
0.04144539684057236,
-0.07778650522232056,
0.0588790625333786,
-0.04047486186027527,
0.012886534444987774,
0.024227404966950417,
-0.030481956899166107,
-0.0362512432038784,
0.006191647611558437,
-0.029583314433693886,
0.059058792889118195,
0.021100128069519997,
0.01601381041109562,
-0.012769711203873158,
0.009885068982839584,
-0.05830392986536026,
-0.007018398493528366,
-0.00439885538071394,
-0.014360308647155762,
0.001101398840546608,
-0.06114364042878151,
-0.009435746818780899,
0.015223005786538124,
0.012967412360012531,
-0.026204418390989304,
-0.04007945954799652,
-0.01298538502305746,
0.0024151019752025604,
-0.020848508924245834,
-0.009840136393904686,
-0.04054675251245499,
-0.017981838434934616,
0.012769711203873158,
0.030769523233175278,
0.018961358815431595,
0.005993945989757776,
0.023382680490612984,
0.03723974898457527,
0.028091566637158394,
0.028738589957356453,
0.0019579175859689713,
0.027750084176659584,
-0.045219697058200836,
-0.039324600249528885,
0.02223241701722145,
0.05391855537891388,
0.009152675047516823,
-0.010990398935973644,
0.06509766727685928,
-0.023903893306851387,
-0.0076294755563139915,
0.02981696091592312,
0.016040770336985588,
-0.03231518715620041,
0.021747151389718056,
-0.04611833766102791,
0.015501584857702255,
-0.018709739670157433,
-0.020453104749321938,
0.037778936326503754,
-0.023041196167469025,
-0.030481956899166107,
-0.056542590260505676,
0.032135460525751114,
-0.06369578838348389,
0.07735515385866165,
0.02535969391465187,
-0.06200633943080902,
-0.012032824568450451,
-0.014468145556747913,
0.019266897812485695,
0.018547983840107918,
-0.024964291602373123,
-0.022322282195091248,
-0.019015276804566383,
-0.004893108736723661,
-0.04065459221601486,
-0.015142127871513367,
0.024227404966950417,
0.026815494522452354,
-0.026761576533317566,
-0.06908763945102692,
-0.03759920597076416,
-0.04787967726588249,
-0.06567279994487762,
0.01689448021352291,
-0.006438774056732655,
0.05708177760243416,
-0.05226505175232887,
0.04978479817509651,
-0.0256832055747509,
0.018242444843053818,
-0.04608239233493805,
0.01521401945501566,
-0.06322849541902542,
0.01346166618168354,
0.043422408401966095,
-0.00924703199416399,
-0.04234403744339943,
-0.001498486497439444,
-0.02259187400341034,
0.009938986971974373,
-0.025952797383069992,
-0.011098235845565796,
-0.028882373124361038,
0.017442652955651283,
-0.000020254561604815535,
0.0029610274359583855,
0.0027947784401476383,
-0.004893108736723661,
-0.00032407298567704856,
-0.043422408401966095,
0.0012861822033300996,
-0.001350210513919592,
-0.014297403395175934,
-0.082818903028965,
-0.04144539684057236,
-0.07850541919469833,
-0.03763515129685402,
0.04518374800682068,
-0.011367828585207462,
0.022789577022194862,
0.0013749231584370136,
0.0775708258152008
]
|
30,431 | networkx.algorithms.shortest_paths.weighted | bidirectional_dijkstra | Dijkstra's algorithm for shortest paths using bidirectional search.
Parameters
----------
G : NetworkX graph
source : node
Starting node.
target : node
Ending node.
weight : string or function
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number or None to indicate a hidden edge.
Returns
-------
length, path : number and list
length is the distance from source to target.
path is a list of nodes on a path from source to target.
Raises
------
NodeNotFound
If either `source` or `target` is not in `G`.
NetworkXNoPath
If no path exists between source and target.
Examples
--------
>>> G = nx.path_graph(5)
>>> length, path = nx.bidirectional_dijkstra(G, 0, 4)
>>> print(length)
4
>>> print(path)
[0, 1, 2, 3, 4]
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
The weight function can be used to hide edges by returning None.
So ``weight = lambda u, v, d: 1 if d['color']=="red" else None``
will find the shortest red path.
In practice bidirectional Dijkstra is much more than twice as fast as
ordinary Dijkstra.
Ordinary Dijkstra expands nodes in a sphere-like manner from the
source. The radius of this sphere will eventually be the length
of the shortest path. Bidirectional Dijkstra will expand nodes
from both the source and the target, making two spheres of half
this radius. Volume of the first sphere is `\pi*r*r` while the
others are `2*\pi*r/2*r/2`, making up half the volume.
This algorithm is not guaranteed to work if edge weights
are negative or are floating point numbers
(overflows and roundoff errors can cause problems).
See Also
--------
shortest_path
shortest_path_length
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, source, target, weight='weight', *, backend=None, **backend_kwargs) | [
0.008735866285860538,
-0.004112853668630123,
-0.0342632532119751,
-0.044116608798503876,
-0.038966432213783264,
-0.0217667855322361,
-0.010747350752353668,
0.04054063931107521,
0.07361837476491928,
-0.010591872967779636,
-0.05286219343543053,
0.029696114361286163,
0.028704948723316193,
0.025537103414535522,
-0.0272473506629467,
0.0358763262629509,
0.00008920191612560302,
0.0359540656208992,
-0.0012401723070070148,
0.013681979849934578,
-0.015052121132612228,
-0.05655477195978165,
0.05550530180335045,
0.049558307975530624,
-0.02100883424282074,
-0.009226590394973755,
0.014848057180643082,
-0.04003533720970154,
-0.025809189304709435,
-0.01631537266075611,
0.017763251438736916,
-0.018773851916193962,
-0.006306537427008152,
-0.005563162732869387,
0.016538869589567184,
0.05865371227264404,
0.007856449112296104,
-0.003039090195670724,
-0.023340990766882896,
-0.04403887316584587,
-0.03014311008155346,
-0.030492933467030525,
0.005776943638920784,
-0.037819791585206985,
0.08007067441940308,
0.08380212634801865,
-0.017481449991464615,
0.008643551729619503,
-0.019405478611588478,
-0.01883215643465519,
0.015178445726633072,
0.0014879638329148293,
-0.009304328821599483,
0.009552120231091976,
-0.007866166532039642,
0.039530038833618164,
-0.033233217895030975,
0.05418374761939049,
0.027286220341920853,
-0.038208480924367905,
0.039530038833618164,
0.010523851960897446,
0.0708586573600769,
0.04007420688867569,
-0.06374558806419373,
-0.02355477213859558,
-0.04656537249684334,
-0.037547703832387924,
-0.039957597851753235,
0.02133922278881073,
0.0010512920562177896,
-0.009527827613055706,
-0.013487633317708969,
-0.035507068037986755,
-0.001869368483312428,
0.03799470141530037,
-0.00006756570655852556,
-0.03478798642754555,
0.011126325465738773,
-0.03984099254012108,
0.04396113380789757,
-0.05647703632712364,
-0.025770319625735283,
-0.07101413607597351,
0.07307420670986176,
0.02507067285478115,
-0.004112853668630123,
0.002652826951816678,
-0.00912941712886095,
-0.03410777449607849,
-0.03671201691031456,
0.030765019357204437,
-0.0033403269480913877,
0.00041905921534635127,
0.056787990033626556,
0.026742050424218178,
0.00905653741210699,
-0.056982334703207016,
0.049985866993665695,
0.031114842742681503,
0.0685265064239502,
0.004904814530164003,
-0.014566254802048206,
0.036070674657821655,
0.026431096717715263,
-0.06724382191896439,
-0.011038869619369507,
0.015878092497587204,
-0.013876325450837612,
-0.0556219108402729,
-0.02262190915644169,
0.01237014215439558,
0.025984100997447968,
-0.026800354942679405,
0.02351590245962143,
0.003238295204937458,
0.006768109742552042,
0.04396113380789757,
-0.0005669445963576436,
-0.02110600844025612,
-0.025284454226493835,
0.05255123972892761,
-0.08318021893501282,
-0.0039500887505710125,
0.040424030274152756,
-0.05636042729020119,
0.024779153987765312,
-0.019939931109547615,
0.06627208739519119,
0.017947880551218987,
0.026178445667028427,
0.004776060115545988,
-0.02786925993859768,
0.06557244062423706,
0.03204770386219025,
-0.02460424229502678,
-0.0565936416387558,
0.046915195882320404,
0.06506714224815369,
0.010397527366876602,
0.042561840265989304,
-0.07548410445451736,
0.007710689213126898,
0.028802121058106422,
0.005912986118346453,
-0.028491167351603508,
0.011097174137830734,
0.014060954563319683,
0.03130918741226196,
0.059780921787023544,
0.015469965524971485,
0.00289818923920393,
0.006938162725418806,
0.011621908284723759,
0.0016701634740456939,
-0.06821554899215698,
-0.04201766848564148,
0.02044523134827614,
0.005786661058664322,
-0.0004964940599165857,
0.016616608947515488,
-0.04462191089987755,
0.005728357005864382,
0.01485777460038662,
-0.04983039200305939,
0.03496289998292923,
0.022174913436174393,
0.052162546664476395,
-0.027189048007130623,
0.012438163161277771,
-0.005917844828218222,
-0.06413427740335464,
-0.04777032136917114,
-0.02915194444358349,
-0.024448763579130173,
0.0032601591665297747,
0.02507067285478115,
-0.002284783637151122,
0.011845407076179981,
-0.01944434642791748,
0.009882509708404541,
-0.026606008410453796,
0.023204948753118515,
-0.01362367533147335,
0.03008480742573738,
0.02915194444358349,
0.022252650931477547,
-0.021650178357958794,
0.0030099384021013975,
0.03478798642754555,
-0.04827561974525452,
-0.09336396306753159,
-0.06059717759490013,
0.08318021893501282,
-0.009037102572619915,
0.006768109742552042,
-0.03729505464434624,
-0.022116608917713165,
-0.02720848098397255,
0.06374558806419373,
-0.009124558418989182,
-0.029249118641018867,
0.03991872817277908,
-0.008930212818086147,
0.009270318783819675,
-0.028840990737080574,
-0.03249470144510269,
0.008565813302993774,
0.001033072010613978,
0.01849205046892166,
-0.03504063934087753,
-0.04543816298246384,
0.029968200251460075,
-0.029696114361286163,
0.0012401723070070148,
0.013779152184724808,
-0.03169788047671318,
0.039957597851753235,
0.014022085815668106,
-0.05908127501606941,
-0.0044068023562431335,
-0.015246466733515263,
-0.009600707329809666,
0.021183745935559273,
0.06180212274193764,
-0.05029682070016861,
0.04703180491924286,
0.030667845159769058,
0.02588692680001259,
-0.07330742478370667,
0.07719434797763824,
-0.0327279157936573,
0.09631802886724472,
-0.014770318754017353,
0.07377385348081589,
-0.0478869266808033,
0.0034350708592683077,
0.04077385365962982,
0.04559364169836044,
0.02790812775492668,
-0.021708481013774872,
-0.023457597941160202,
-0.01466342806816101,
-0.05810954421758652,
0.005878975614905357,
-0.00011182503658346832,
0.031484100967645645,
-0.012282686308026314,
0.026100708171725273,
-0.006442579906433821,
0.005038427654653788,
0.027655478566884995,
-0.042367491871118546,
-0.05752650275826454,
-0.012933745980262756,
-0.04318374767899513,
-0.021028269082307816,
-0.03752826899290085,
-0.03653710335493088,
-0.06592226773500443,
-0.03226148709654808,
-0.027849825099110603,
-0.0609470009803772,
0.10152650624513626,
-0.003925795201212168,
0.03263074532151222,
0.03123144991695881,
-0.014352474361658096,
-0.08022615313529968,
0.006627209018915892,
0.042795054614543915,
0.04310600832104683,
-0.006884717848151922,
-0.0036172703839838505,
-0.025128977373242378,
0.005164752714335918,
-0.03220318257808685,
0.03486572578549385,
0.01284629013389349,
-0.023030037060379982,
-0.04372791573405266,
-0.008415195159614086,
-0.04124028608202934,
-0.00651545962318778,
0.01792844571173191,
0.02971554920077324,
0.012117492035031319,
-0.03478798642754555,
0.016441697254776955,
0.00670494744554162,
0.07019788026809692,
-0.01218551304191351,
0.010543286800384521,
-0.03774205222725868,
0.06226855516433716,
0.047614842653274536,
-0.00341806560754776,
-0.07276325672864914,
0.016334805637598038,
0.05360070988535881,
0.015469965524971485,
-0.025712015107274055,
0.0256342776119709,
-0.005718640051782131,
-0.04267844557762146,
0.008288869634270668,
0.031212015077471733,
-0.0168498232960701,
-0.002577517880126834,
-0.030959365889430046,
-0.021455831825733185,
-0.025128977373242378,
0.0017855566693469882,
0.007351148873567581,
0.003612411906942725,
-0.037217315286397934,
-0.03515724465250969,
0.007351148873567581,
-0.006772968452423811,
0.03220318257808685,
-0.03894699737429619,
0.07641696184873581,
-0.06825441867113113,
0.029210248962044716,
-0.030551237985491753,
0.029268553480505943,
0.031775619834661484,
0.025673145428299904,
0.03511837497353554,
0.022485867142677307,
0.03785865753889084,
0.02246643230319023,
0.026236750185489655,
0.030862191691994667,
-0.019813604652881622,
0.08971025049686432,
0.07439576089382172,
-0.005436837673187256,
0.000046878452849341556,
-0.0031751326750963926,
0.047381628304719925,
0.021708481013774872,
-0.022116608917713165,
0.02371024899184704,
0.006112190894782543,
-0.04384452477097511,
0.033991169184446335,
-0.038966432213783264,
0.007448322139680386,
-0.04734275862574577,
0.021883392706513405,
0.06798233836889267,
0.018326856195926666,
0.02645053155720234,
0.05060777813196182,
0.003092535538598895,
-0.010941696353256702,
-0.04069611430168152,
0.022310955449938774,
-0.00491939065977931,
0.008376325480639935,
0.01811307482421398,
0.009158569388091564,
-0.0029151944909244776,
-0.04637102782726288,
0.01362367533147335,
0.01934717409312725,
-0.013400177471339703,
-0.018249116837978363,
-0.05056890845298767,
-0.008410336449742317,
-0.06059717759490013,
-0.025031803175807,
0.05550530180335045,
0.012010601349174976,
0.0005071223713457584,
0.01636395789682865,
-0.0073851593770086765,
-0.003507950808852911,
0.044077739119529724,
-0.02200000174343586,
0.05748763680458069,
0.005208480637520552,
0.04594346508383751,
0.02493463084101677,
-0.04124028608202934,
0.06638869643211365,
0.007419169880449772,
0.03373851627111435,
0.006335689220577478,
-0.024662544950842857,
-0.01779240369796753,
0.044349826872348785,
0.028588339686393738,
-0.0026965548750013113,
-0.04166784510016441,
0.07179152220487595,
0.030298588797450066,
-0.05049116909503937,
-0.025051238015294075,
0.015829505398869514,
-0.021222615614533424,
-0.05527208745479584,
0.06910954415798187,
0.009663869626820087,
-0.04765371233224869,
0.04590459540486336,
0.02786925993859768,
0.02596466615796089,
0.04862544313073158,
-0.04178445413708687,
-0.0023941034451127052,
-0.014605124481022358,
0.01718021370470524,
-0.043922264128923416,
-0.0588480606675148,
-0.0685265064239502,
0.042173147201538086,
0.056787990033626556,
0.003002650337293744,
0.03661484271287918,
-0.029365725815296173,
0.06397879868745804,
-0.0828692615032196,
0.012156360782682896,
-0.043222617357969284,
-0.013040636666119099,
-0.02800530195236206,
-0.0009468308999203146,
0.050840992480516434,
-0.02483745664358139,
-0.02361307479441166,
0.03939399495720863,
-0.05511660873889923,
-0.007093640044331551,
-0.005179328843951225,
0.016169611364603043,
0.002469412749633193,
0.0719858705997467,
-0.03410777449607849,
-0.009430654346942902,
-0.02781095542013645,
-0.026236750185489655,
-0.02701413631439209,
-0.051968201994895935,
-0.07906007766723633,
0.020542403683066368,
-0.022874560207128525,
0.030920496210455894,
-0.035934630781412125,
0.006981890648603439,
-0.03871378302574158,
0.021183745935559273,
0.023204948753118515,
-0.026081273332238197,
0.024954065680503845,
0.01598498225212097,
0.01022261567413807,
-0.1197173222899437,
0.027130743488669395,
0.05080212280154228,
-0.03187279403209686,
0.028510602191090584,
-0.011893993243575096,
-0.0479646660387516,
0.05927561968564987,
0.03439929336309433,
0.0009923807810992002,
-0.0007196886581368744,
-0.025945231318473816,
0.04536042734980583,
-0.010854240506887436,
-0.08551236987113953,
-0.005893551744520664,
0.02223321609199047,
-0.004205168224871159,
-0.06355123966932297,
0.014780036173760891,
0.002190039958804846,
-0.01669434644281864,
0.04073498398065567,
-0.04003533720970154,
0.06693286448717117,
-0.007817579433321953,
0.005422261543571949,
-0.05496113374829292,
0.03908304125070572,
-0.01962897554039955,
0.01452738605439663,
0.002941917162388563,
0.04077385365962982,
-0.06296820193529129,
0.06945936381816864,
-0.031192580237984657,
-0.003933083266019821,
0.04275618493556976,
0.03315547853708267,
-0.016616608947515488,
0.0806925818324089,
-0.013458481058478355,
0.0026018109638243914,
-0.010407243855297565,
-0.054805655032396317,
0.05946996808052063,
0.03393286466598511,
0.015246466733515263,
0.014614841900765896,
0.0490141361951828,
-0.025712015107274055,
0.026469966396689415,
0.017277386039495468,
0.0029394878074526787,
0.04703180491924286,
0.05511660873889923,
0.0457879863679409,
-0.007793286815285683,
-0.006695230025798082,
0.06891519576311111,
0.0022034011781215668,
-0.02242756262421608,
0.04337809234857559,
0.062190815806388855,
-0.015615724958479404,
0.027713783085346222,
-0.07439576089382172,
0.03533215820789337,
0.004302341025322676,
-0.04749823734164238,
0.023107774555683136,
0.004107994958758354,
0.010912545025348663,
0.033719081431627274,
-0.00041328955558128655,
0.02687809243798256,
0.01845318078994751,
0.014401060529053211,
0.05620494857430458,
-0.018725266680121422,
-0.014634276740252972,
-0.01703445240855217,
0.05946996808052063,
0.00019768663332797587,
-0.004635159391909838,
-0.005674912128597498,
0.06992579996585846,
-0.005155035760253668,
-0.002162102609872818,
-0.008050795644521713,
-0.0002528020122554153,
-0.05099646747112274,
-0.021980566903948784,
-0.002332155592739582,
0.007200530264526606,
0.05208480730652809,
0.06969258189201355,
-0.009605566039681435,
0.014167845249176025,
0.00939178466796875,
0.0066806538961827755,
0.084968201816082,
-0.025420496240258217,
-0.08535689115524292,
-0.046254418790340424,
-0.016878975555300713,
-0.015431095845997334,
-0.03057067282497883,
0.01566431112587452,
-0.012807421386241913,
0.0014138693222776055,
-0.006403710693120956,
-0.029734984040260315,
0.04057950899004936,
-0.0056846290826797485,
0.026314489543437958,
-0.02833569049835205,
-0.007914752699434757,
-0.02635335735976696,
-0.045166078954935074,
0.023302121087908745,
-0.05103533715009689,
-0.017850708216428757,
0.0212420504540205,
0.06296820193529129,
0.051968201994895935,
0.025342756882309914,
-0.0021268771961331367,
-0.052318025380373,
0.004086130764335394,
-0.0479646660387516,
0.010455830954015255,
0.010698763653635979,
-0.053289756178855896,
0.01433303952217102,
0.03785865753889084,
0.011310954578220844,
-0.055893994867801666,
-0.01967756263911724,
0.017238516360521317,
0.031484100967645645,
-0.0030852474737912416,
-0.09313074499368668,
-0.009829063899815083,
0.006938162725418806,
-0.006209364160895348,
0.031212015077471733,
-0.01485777460038662,
-0.006355124060064554,
-0.0871448814868927,
-0.015052121132612228,
-0.05103533715009689,
0.019978798925876617,
0.013516784645617008,
0.025848057121038437,
-0.02474028430879116,
-0.029676679521799088,
-0.007652385625988245,
-0.009863074868917465,
0.016121026128530502,
-0.029929330572485924,
-0.03581802174448967,
0.015227032825350761,
-0.03970494866371155,
0.02001766860485077,
-0.01258392259478569,
0.0028593200258910656,
0.03851943463087082,
-0.0024681980721652508,
0.01935689151287079,
-0.060480568557977676,
0.03296113386750221,
-0.02180565521121025,
-0.0490141361951828,
0.04462191089987755,
0.05383392423391342,
-0.022583039477467537,
-0.01593639701604843,
0.06930389255285263,
-0.010494699701666832,
-0.015168728306889534,
-0.012000883929431438,
-0.034885160624980927,
0.044077739119529724,
-0.021319789811968803,
-0.03336925804615021,
-0.0359540656208992,
-0.004365503787994385,
-0.003923365846276283,
-0.022485867142677307,
0.009532686322927475,
0.0007500552455894649,
-0.005674912128597498,
-0.01530477125197649,
-0.0304735004901886,
0.006768109742552042,
0.02034805715084076,
0.07276325672864914,
-0.018812721595168114,
-0.034088339656591415,
0.012175795622169971,
0.012574205175042152,
0.03253357112407684,
0.05402827262878418,
0.06930389255285263,
-0.04384452477097511,
-0.037450533360242844,
-0.012992050498723984,
0.01764664426445961,
-0.0620742067694664,
-0.017909010872244835,
0.007632950786501169,
-0.06413427740335464,
-0.01147614885121584,
0.008526943624019623,
0.01622791588306427,
-0.032863959670066833,
-0.06051943823695183,
0.02687809243798256,
-0.004107994958758354,
-0.07579505443572998,
-0.06771025061607361,
0.04295053333044052,
0.04613780975341797,
0.02493463084101677,
-0.013098940253257751,
-0.011612191796302795,
0.05379505455493927,
-0.05189046263694763,
-0.08403533697128296,
0.034943465143442154,
0.014167845249176025,
0.019891344010829926,
-0.03459364175796509,
0.040424030274152756,
0.008789311163127422,
-0.0381307452917099,
-0.05138516053557396,
-0.0024754859041422606,
-0.019978798925876617,
0.030765019357204437,
-0.03599293529987335,
0.02038692682981491,
0.053289756178855896,
0.008055654354393482,
-0.03008480742573738,
-0.011174912564456463,
-0.03140636160969734,
-0.08038163185119629,
0.03871378302574158,
0.023049471899867058,
0.00983878131955862,
-0.03622614964842796,
-0.03027915395796299,
-0.01395406387746334,
0.026800354942679405,
0.01154416985809803,
-0.014916078187525272,
0.020756185054779053,
-0.013040636666119099,
-0.012554771266877651,
-0.0026674028486013412,
0.014537103474140167,
-0.023574206978082657,
-0.0031921379268169403,
0.028588339686393738,
-0.08846643567085266,
-0.0008411550661548972,
0.023438163101673126,
-0.08356890827417374,
0.0020041961688548326,
-0.017899293452501297,
-0.026275619864463806,
0.08815547823905945,
0.009872792288661003,
0.03202826902270317,
0.004749337676912546,
-0.014605124481022358,
0.025284454226493835,
-0.014993816614151001,
-0.00983878131955862,
0.05993640050292015,
-0.026528269052505493,
0.018326856195926666,
-0.03991872817277908,
-0.017704948782920837,
-0.0013251987984403968,
-0.010990283451974392,
0.010212898254394531,
0.012574205175042152,
-0.02753887139260769,
-0.010922262445092201,
0.03107597306370735,
-0.0007190813194029033,
0.024118375033140182,
-0.018365725874900818,
0.011680212803184986,
-0.011825972236692905,
-0.04007420688867569,
-0.051968201994895935,
-0.026081273332238197,
-0.04819788038730621,
-0.06121908500790596,
-0.008687279187142849,
-0.01883215643465519,
0.02271908149123192,
0.022116608917713165,
0.04664311185479164,
0.02569258026778698,
0.084968201816082
]
|
30,434 | networkx.generators.random_graphs | gnp_random_graph | Returns a $G_{n,p}$ random graph, also known as an Erdős-Rényi graph
or a binomial graph.
The $G_{n,p}$ model chooses each of the possible edges with probability $p$.
Parameters
----------
n : int
The number of nodes.
p : float
Probability for edge creation.
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
directed : bool, optional (default=False)
If True, this function returns a directed graph.
See Also
--------
fast_gnp_random_graph
Notes
-----
This algorithm [2]_ runs in $O(n^2)$ time. For sparse graphs (that is, for
small values of $p$), :func:`fast_gnp_random_graph` is a faster algorithm.
:func:`binomial_graph` and :func:`erdos_renyi_graph` are
aliases for :func:`gnp_random_graph`.
>>> nx.binomial_graph is nx.gnp_random_graph
True
>>> nx.erdos_renyi_graph is nx.gnp_random_graph
True
References
----------
.. [1] P. Erdős and A. Rényi, On Random Graphs, Publ. Math. 6, 290 (1959).
.. [2] E. N. Gilbert, Random Graphs, Ann. Math. Stat., 30, 1141 (1959).
| def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None):
"""Returns a random graph using dual Barabási–Albert preferential attachment
A graph of $n$ nodes is grown by attaching new nodes each with either $m_1$
edges (with probability $p$) or $m_2$ edges (with probability $1-p$) that
are preferentially attached to existing nodes with high degree.
Parameters
----------
n : int
Number of nodes
m1 : int
Number of edges to link each new node to existing nodes with probability $p$
m2 : int
Number of edges to link each new node to existing nodes with probability $1-p$
p : float
The probability of attaching $m_1$ edges (as opposed to $m_2$ edges)
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
initial_graph : Graph or None (default)
Initial network for Barabási–Albert algorithm.
A copy of `initial_graph` is used.
It should be connected for most use cases.
If None, starts from an star graph on max(m1, m2) + 1 nodes.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m1` and `m2` do not satisfy ``1 <= m1,m2 < n``, or
`p` does not satisfy ``0 <= p <= 1``, or
the initial graph number of nodes m0 does not satisfy m1, m2 <= m0 <= n.
References
----------
.. [1] N. Moshiri "The dual-Barabasi-Albert model", arXiv:1810.10538.
"""
if m1 < 1 or m1 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m1 >= 1 and m1 < n, m1 = {m1}, n = {n}"
)
if m2 < 1 or m2 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m2 >= 1 and m2 < n, m2 = {m2}, n = {n}"
)
if p < 0 or p > 1:
raise nx.NetworkXError(
f"Dual Barabási–Albert network must have 0 <= p <= 1, p = {p}"
)
# For simplicity, if p == 0 or 1, just return BA
if p == 1:
return barabasi_albert_graph(n, m1, seed)
elif p == 0:
return barabasi_albert_graph(n, m2, seed)
if initial_graph is None:
# Default initial graph : empty graph on max(m1, m2) nodes
G = star_graph(max(m1, m2))
else:
if len(initial_graph) < max(m1, m2) or len(initial_graph) > n:
raise nx.NetworkXError(
f"Barabási–Albert initial graph must have between "
f"max(m1, m2) = {max(m1, m2)} and n = {n} nodes"
)
G = initial_graph.copy()
# Target nodes for new edges
targets = list(G)
# List of existing nodes, with nodes repeated once for each adjacent edge
repeated_nodes = [n for n, d in G.degree() for _ in range(d)]
# Start adding the remaining nodes.
source = len(G)
while source < n:
# Pick which m to use (m1 or m2)
if seed.random() < p:
m = m1
else:
m = m2
# Now choose m unique nodes from the existing nodes
# Pick uniformly from repeated_nodes (preferential attachment)
targets = _random_subset(repeated_nodes, m, seed)
# Add edges to m nodes from the source.
G.add_edges_from(zip([source] * m, targets))
# Add one node to the list for each new edge just created.
repeated_nodes.extend(targets)
# And the new node "source" has m edges to add to the list.
repeated_nodes.extend([source] * m)
source += 1
return G
| (n, p, seed=None, directed=False, *, backend=None, **backend_kwargs) | [
0.0035426956601440907,
0.0014695359859615564,
0.015339704230427742,
0.00493438309058547,
-0.02493061125278473,
-0.04085477814078331,
-0.0648847445845604,
-0.0363323912024498,
0.01213954109698534,
-0.030027877539396286,
0.006457814015448093,
0.041966211050748825,
-0.03683061897754669,
0.10723420977592468,
-0.043039318174123764,
0.013116836547851562,
0.034684401005506516,
0.047446731477975845,
-0.005878143943846226,
0.027325943112373352,
-0.04004994407296181,
0.0020168693736195564,
0.00007623891724506393,
0.07097847014665604,
-0.0345502644777298,
0.010769410990178585,
-0.039110977202653885,
0.010711923241615295,
-0.01561756245791912,
0.059289250522851944,
0.0392451137304306,
-0.12356078624725342,
0.0210022684186697,
0.039015162736177444,
-0.00016812233661767095,
0.010156205855309963,
0.027690034359693527,
0.06116718798875809,
-0.10961037874221802,
-0.03677313029766083,
0.07090181857347488,
-0.055380068719387054,
0.08339586853981018,
0.01308809220790863,
0.024662334471940994,
-0.023895828053355217,
0.03094768524169922,
0.012982698157429695,
-0.0965031236410141,
-0.009878347627818584,
0.016096629202365875,
-0.07051856815814972,
0.026252835988998413,
-0.002394133945927024,
-0.020446551963686943,
0.018415309488773346,
-0.0031714190263301134,
0.044610656797885895,
0.017850011587142944,
0.02533302828669548,
0.06300680339336395,
-0.019565070047974586,
-0.014640267007052898,
-0.035201795399188995,
-0.024470709264278412,
0.022037051618099213,
-0.04855816438794136,
-0.026789389550685883,
-0.001495884614996612,
0.06204867362976074,
0.05035945400595665,
0.06407991051673889,
-0.008077058009803295,
0.05511179193854332,
0.054728537797927856,
0.044304054230451584,
0.04859649017453194,
0.02703850343823433,
-0.05204576626420021,
0.019680045545101166,
0.00426608556881547,
-0.025812095031142235,
0.011794612742960453,
-0.034377798438072205,
0.005518844351172447,
-0.015464261174201965,
0.00606977054849267,
0.003075605956837535,
0.0003443289315328002,
-0.10179201513528824,
-0.04859649017453194,
-0.04982290044426918,
0.05564834550023079,
0.016259511932730675,
0.03158005326986313,
-0.0332472026348114,
-0.006261397153139114,
-0.03232739493250847,
0.0075069693848490715,
-0.024566521868109703,
-0.04507056251168251,
0.04369084909558296,
-0.03813368082046509,
0.0006742858677171171,
0.0064673954620957375,
0.00718120438978076,
-0.052199069410562515,
0.015119333751499653,
0.020868130028247833,
-0.035316769033670425,
-0.11712213605642319,
0.04357587546110153,
0.0797932893037796,
0.018252426758408546,
-0.022880207747220993,
-0.013289299793541431,
0.015013938769698143,
0.011641312390565872,
0.031924981623888016,
0.03223158419132233,
0.016393650323152542,
0.027153480798006058,
-0.03295976296067238,
-0.00022052021813578904,
0.0008006396237760782,
-0.02408745512366295,
0.04821323603391647,
-0.008594449609518051,
-0.012848558835685253,
-0.038785211741924286,
0.010539459064602852,
0.01483189407736063,
-0.04706347733736038,
0.07021196186542511,
-0.012005402706563473,
-0.034377798438072205,
-0.04790663346648216,
0.005739214830100536,
0.06917718052864075,
0.003990622702986002,
-0.0008599240682087839,
-0.06683933734893799,
0.08906801044940948,
0.012838977389037609,
-0.03947506472468376,
-0.021481335163116455,
0.017236806452274323,
-0.05714303255081177,
0.001756975776515901,
-0.012206610292196274,
0.04008826985955238,
-0.0013401880860328674,
0.020868130028247833,
-0.03462691605091095,
-0.03959004208445549,
0.017667965963482857,
-0.04150630906224251,
-0.0004149912274442613,
-0.023244298994541168,
0.014640267007052898,
-0.030641082674264908,
-0.05469021201133728,
0.04878811538219452,
0.05434528365731239,
0.010098718106746674,
-0.03071773424744606,
0.04947797209024429,
0.0018647656543180346,
0.017447596415877342,
-0.03548923507332802,
-0.07435109466314316,
-0.0011683229822665453,
-0.06603450328111649,
-0.06166541948914528,
0.05269729718565941,
-0.0021258569322526455,
-0.026022883132100105,
-0.03102433681488037,
0.02926137112081051,
0.03433947637677193,
0.038267817348241806,
-0.04729342833161354,
0.06775914132595062,
-0.05921259894967079,
-0.03062191978096962,
-0.035412583500146866,
-0.006342838052660227,
0.043000996112823486,
0.018032057210803032,
0.008560915477573872,
0.021347196772694588,
0.02479647286236286,
0.03610244020819664,
0.06089891120791435,
0.025198889896273613,
0.00522182323038578,
0.02514140121638775,
0.014592360705137253,
-0.012953953817486763,
0.011104757897555828,
0.045645441859960556,
0.0022025075741112232,
0.020504038780927658,
0.023148484528064728,
0.027919985353946686,
0.007650689221918583,
-0.03284478932619095,
-0.0420045368373394,
0.023205973207950592,
-0.02723013050854206,
0.004891267511993647,
-0.010481971316039562,
0.02860984206199646,
-0.02701934054493904,
-0.015349285677075386,
-0.06289182603359222,
0.019229723140597343,
0.01720806211233139,
-0.00011954201909247786,
-0.034876029938459396,
0.03207828104496002,
-0.05890599638223648,
0.01092271227389574,
0.025812095031142235,
0.005782330874353647,
0.04372917488217354,
-0.014534872956573963,
0.004038529004901648,
-0.015167240053415298,
0.02891644462943077,
0.033841244876384735,
-0.0007695003296248615,
0.03675397112965584,
-0.02830323949456215,
-0.03920678794384003,
-0.030142853036522865,
0.003070815233513713,
-0.039551716297864914,
-0.03581500053405762,
0.01894228346645832,
-0.029376348480582237,
0.01985250972211361,
-0.0202740877866745,
-0.008939377963542938,
0.022247839719057083,
0.01557923760265112,
0.02828407660126686,
-0.05813949182629585,
-0.06848732382059097,
-0.019871670752763748,
-0.09336044639348984,
-0.012494049966335297,
0.024758148938417435,
0.031503401696681976,
0.026099534705281258,
-0.026521112769842148,
-0.021481335163116455,
0.009710674174129963,
-0.004021761938929558,
0.05859939381480217,
0.007118925917893648,
-0.020350737497210503,
-0.11122003942728043,
0.03171418979763985,
-0.001493489253334701,
-0.00598832918331027,
-0.07074851542711258,
0.06952210515737534,
-0.013519251719117165,
-0.03135010227560997,
0.06189537048339844,
0.0007066228426992893,
0.008829192258417606,
0.00043654919136315584,
0.027000179514288902,
0.023378437384963036,
-0.012407817877829075,
0.019507581368088722,
-0.01964171975851059,
-0.04349922388792038,
-0.04127635434269905,
-0.04342257231473923,
0.02471982315182686,
0.045453812927007675,
-0.005930841434746981,
0.00416787713766098,
-0.023359274491667747,
-0.06208699569106102,
0.024317407980561256,
-0.033534642308950424,
0.01547384262084961,
-0.028533190488815308,
0.005782330874353647,
0.05001452565193176,
-0.0016994877951219678,
-0.004852942191064358,
0.058637719601392746,
0.023493412882089615,
0.020197436213493347,
-0.008905842900276184,
0.03801870346069336,
-0.009624443016946316,
0.09113758057355881,
0.003959483467042446,
-0.016661927103996277,
-0.03207828104496002,
0.013605483807623386,
-0.02535219117999077,
-0.01983334682881832,
0.020082460716366768,
-0.09060102701187134,
0.02514140121638775,
0.05756461247801781,
0.03083270974457264,
-0.009394491091370583,
-0.06733756512403488,
0.011583823710680008,
0.0006724893464706838,
0.04047152400016785,
-0.0038349260576069355,
-0.017342200502753258,
0.0374629870057106,
-0.0013042581267654896,
0.04652692377567291,
-0.01756257191300392,
-0.002210891107097268,
0.04645027220249176,
0.07500262558460236,
0.0013581530656665564,
0.02226700261235237,
-0.042081188410520554,
0.016518207266926765,
-0.010654435493052006,
0.018808145076036453,
-0.08753500133752823,
0.08086639642715454,
-0.027498407289385796,
-0.023263461887836456,
0.06668603420257568,
-0.08592534065246582,
0.021615473553538322,
-0.04675687476992607,
-0.005274520255625248,
-0.010625691153109074,
0.046411946415901184,
0.044074103236198425,
0.012168284505605698,
-0.0041055986657738686,
-0.05698973312973976,
0.06933048367500305,
-0.013653390109539032,
0.041966211050748825,
-0.002680376172065735,
0.02577376924455166,
-0.019133908674120903,
0.03359213098883629,
-0.009887929074466228,
0.004424177575856447,
0.010204113088548183,
0.07028861343860626,
-0.02334011159837246,
-0.005676935892552137,
-0.02774752303957939,
-0.013701297342777252,
0.027613382786512375,
0.006294931750744581,
0.0023665877524763346,
0.04388247802853584,
0.03853609785437584,
-0.052543994039297104,
0.06971373409032822,
-0.06718426197767258,
-0.045147210359573364,
0.049248021095991135,
0.010453227907419205,
-0.028782306239008904,
-0.03773126378655434,
0.020101623609662056,
0.0321166068315506,
0.033093903213739395,
-0.01239823643118143,
-0.039551716297864914,
0.010002905502915382,
0.03959004208445549,
-0.0061607928946614265,
-0.012014984153211117,
0.07262645661830902,
0.003767856629565358,
-0.006558418273925781,
-0.027000179514288902,
0.012867721728980541,
-0.02977876365184784,
0.0733163133263588,
0.006932090036571026,
-0.054958488792181015,
0.005078102927654982,
0.0411997064948082,
-0.026042046025395393,
-0.037118058651685715,
-0.003557067597284913,
0.0025318656116724014,
0.016968529671430588,
-0.05055107921361923,
-0.023608388379216194,
-0.005686517339199781,
-0.033937059342861176,
0.02786249853670597,
0.028015799820423126,
0.011296384036540985,
0.014975613914430141,
-0.015224727801978588,
0.022976022213697433,
-0.019018933176994324,
-0.01167005579918623,
0.023704202845692635,
-0.0010922712972387671,
-0.005892516113817692,
-0.020139949396252632,
0.010903549380600452,
0.015042683109641075,
0.032461535185575485,
-0.007851896807551384,
0.0064865583553910255,
-0.02479647286236286,
0.044112429022789,
0.005767958704382181,
-0.0510876327753067,
0.01964171975851059,
-0.08155625313520432,
0.022132864221930504,
0.054000359028577805,
-0.03959004208445549,
0.03345799446105957,
-0.043000996112823486,
0.024643171578645706,
0.00858007837086916,
0.028897281736135483,
0.005346380174160004,
0.05672145262360573,
-0.022976022213697433,
0.012110796757042408,
0.022190352901816368,
0.011698800139129162,
-0.0574113093316555,
-0.029587136581540108,
-0.045683763921260834,
-0.021711286157369614,
-0.0012335957726463675,
0.016096629202365875,
-0.020523201674222946,
-0.0056386105716228485,
-0.005260148551315069,
0.07113176584243774,
-0.006764416582882404,
-0.0475233793258667,
0.03579583764076233,
0.05974915251135826,
-0.027939148247241974,
-0.03464607894420624,
0.10064225643873215,
0.014764824882149696,
0.006965624634176493,
0.012292842380702496,
0.09581326693296432,
0.034262824803590775,
-0.019133908674120903,
0.05415365844964981,
-0.02004413492977619,
-0.015272635035216808,
0.03798037767410278,
-0.019018933176994324,
0.0001829434622777626,
0.015569656156003475,
-0.03303641453385353,
-0.016767321154475212,
-0.038708560168743134,
-0.009485513903200626,
-0.039743341505527496,
-0.011392197571694851,
-0.011210151948034763,
0.017332620918750763,
0.003971459809690714,
0.010347832925617695,
0.03219325840473175,
0.022937696427106857,
-0.02776668407022953,
-0.03558504581451416,
0.025390515103936195,
0.011986239813268185,
0.002680376172065735,
-0.07312468439340591,
-0.08002324402332306,
0.022343654185533524,
0.03696475923061371,
-0.05150921270251274,
-0.012580282054841518,
-0.01716015674173832,
-0.047983285039663315,
-0.00752613227814436,
-0.07634401321411133,
0.01926804892718792,
-0.011229314841330051,
-0.014697754755616188,
-0.04656524956226349,
0.007406365592032671,
0.0004518194473348558,
-0.002188135404139757,
-0.01746675930917263,
0.002246821066364646,
0.0634283795952797,
-0.00012373385834507644,
-0.023800015449523926,
0.037635453045368195,
0.03684978187084198,
-0.01456361636519432,
0.0162978358566761,
-0.008642356842756271,
0.004630176350474358,
0.05139423534274101,
-0.028782306239008904,
0.03483770415186882,
0.034684401005506516,
0.031426750123500824,
-0.04595204442739487,
0.027536733075976372,
-0.008848355151712894,
0.013959992676973343,
-0.011066432110965252,
0.021519659087061882,
-0.007023112382739782,
-0.02470066025853157,
0.03638987988233566,
0.04004994407296181,
0.02015911228954792,
-0.010807736776769161,
-0.01403664331883192,
0.010060393251478672,
0.00546135613694787,
-0.05227571725845337,
-0.05166251212358475,
0.00825431291013956,
0.0192201416939497,
-0.007593201473355293,
-0.012704838998615742,
-0.0064626047387719154,
-0.013049767352640629,
-0.04066314920783043,
0.0009293886832892895,
-0.012743164785206318,
-0.0192201416939497,
-0.002467191545292735,
0.015042683109641075,
-0.0184919610619545,
-0.022324491292238235,
0.00675483513623476,
-0.05645317584276199,
-0.07795367389917374,
0.04844318702816963,
0.06032403185963631,
0.02458568476140499,
-0.06718426197767258,
0.015023520216345787,
-0.022247839719057083,
0.0017653594259172678,
0.03776958957314491,
0.04307764396071434,
-0.02470066025853157,
-0.001316234702244401,
-0.019555488601326942,
-0.011056850664317608,
0.024010805413126945,
0.034262824803590775,
0.030123692005872726,
0.017687128856778145,
-0.042924344539642334,
-0.007171622943133116,
-0.04974624887108803,
-0.05001452565193176,
-0.009763372130692005,
0.008963331580162048,
0.00001639305082790088,
0.061818718910217285,
-0.022746069356799126,
0.016345743089914322,
0.04422740265727043,
0.028475703671574593,
-0.02935718558728695,
0.01877940073609352,
0.0019438116578385234,
-0.028667328879237175,
-0.07691889256238937,
-0.02249695546925068,
0.03228907287120819,
-0.04457233101129532,
0.004718803334981203,
0.04231113940477371,
0.04771500825881958,
-0.01519598439335823,
-0.05672145262360573,
-0.07550085335969925,
0.03560420870780945,
0.03249986097216606,
0.001974951010197401,
-0.0014886986464262009,
0.05511179193854332,
0.016757739707827568,
-0.003674438688904047,
-0.06312178075313568,
0.025256376713514328,
0.003461254294961691,
-0.03652401641011238,
-0.0017509874887764454,
-0.027172641828656197,
-0.06384996324777603,
-0.03798037767410278,
-0.05396203324198723,
-0.045032236725091934,
0.018654843792319298,
0.02334011159837246,
0.04721677675843239,
-0.035431746393442154,
0.019795021042227745,
0.01821410283446312,
0.0510876327753067,
-0.025371352210640907,
-0.0061655836179852486,
-0.02565879374742508,
-0.025735443457961082,
0.015722956508398056,
-0.0032744184136390686,
0.016661927103996277,
-0.05794786289334297,
0.029184721410274506,
-0.0019078816985711455,
0.02458568476140499,
-0.023838341236114502,
0.051700837910175323,
0.007942919619381428,
0.0020444155670702457,
0.08784160017967224,
-0.06660938262939453,
0.010836480185389519,
-0.06335173547267914,
-0.0037295313086360693,
-0.03788456693291664,
0.00580628402531147,
-0.020197436213493347,
0.01920097880065441,
0.01098020002245903,
-0.02598455734550953,
-0.02228616550564766,
0.050742704421281815,
0.00813454668968916,
-0.003123512491583824,
-0.03272981196641922,
-0.002449226565659046,
0.01779252290725708,
-0.0057056802324950695,
-0.002989373868331313,
-0.03412868455052376,
0.06588120013475418,
0.0046613155864179134,
0.029050583019852638,
0.044112429022789,
0.007813571952283382,
0.05817781761288643,
0.02261193096637726,
-0.03978166729211807,
-0.036581505089998245,
0.007842316292226315,
-0.028111612424254417,
-0.02744092047214508,
-0.006175165064632893,
-0.06511469930410385,
-0.04802161082625389,
0.02989373914897442,
-0.02130887098610401,
-0.004831383936107159,
0.01150717306882143,
0.011986239813268185,
0.07730214297771454,
-0.002893560566008091,
-0.0029510485474020243,
-0.00536075234413147,
0.00159768620505929,
0.050627730786800385,
-0.014736080542206764,
0.018185358494520187,
-0.05721968412399292,
-0.002228856086730957,
0.021500498056411743,
-0.025198889896273613,
0.0234359260648489,
0.050321128219366074,
0.03865107148885727,
0.06384996324777603,
-0.02577376924455166,
-0.017284713685512543,
-0.05377040430903435,
-0.047561705112457275,
0.021193895488977432,
-0.03893851116299629,
-0.036044951528310776,
0.05825446546077728,
-0.07599908113479614,
0.035412583500146866,
-0.051164284348487854,
0.009035191498696804,
-0.03251902386546135,
0.01019453164190054,
-0.018070382997393608,
-0.04530051350593567,
0.049248021095991135,
-0.008565706200897694,
0.0043571083806455135,
-0.040164921432733536,
-0.005595494993031025,
0.03163754194974899,
-0.054536912590265274,
0.001582116587087512,
-0.06185704469680786,
-0.013768366537988186,
0.036140765994787216,
0.00736324954777956,
0.023780852556228638,
-0.008364498615264893,
0.03154172748327255,
-0.05373207852244377,
-0.01208205334842205,
-0.03610244020819664,
0.014170782640576363,
0.03280646353960037,
0.0014084550784900784,
0.015119333751499653,
-0.0038780421018600464,
-0.033956222236156464,
0.011037688702344894,
0.009226817637681961,
0.023608388379216194,
0.008503427729010582,
0.016604438424110413,
0.0034396962728351355,
-0.052199069410562515,
0.044495679438114166,
-0.006117677316069603,
0.0360066257417202,
-0.030238667502999306,
0.00811059307307005,
0.008402823470532894,
0.0003083989431615919,
0.05457523837685585,
-0.01793624274432659,
-0.018626099452376366,
0.05492016300559044,
0.02774752303957939,
0.004943964537233114,
0.04794495925307274,
-0.029203884303569794,
-0.03202079236507416,
-0.07339296489953995,
-0.016326580196619034,
0.013634228147566319,
0.06185704469680786,
-0.04073980078101158,
-0.00227676285430789,
0.020638177171349525,
0.015905002132058144,
0.047140128910541534
]
|
30,435 | networkx.generators.classic | binomial_tree | Returns the Binomial Tree of order n.
The binomial tree of order 0 consists of a single node. A binomial tree of order k
is defined recursively by linking two binomial trees of order k-1: the root of one is
the leftmost child of the root of the other.
.. plot::
>>> nx.draw(nx.binomial_tree(3))
Parameters
----------
n : int
Order of the binomial tree.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : NetworkX graph
A binomial tree of $2^n$ nodes and $2^n - 1$ edges.
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (n, create_using=None, *, backend=None, **backend_kwargs) | [
0.022217122837901115,
-0.006895122118294239,
0.021790895611047745,
-0.05022383853793144,
-0.012715795077383518,
0.06666912883520126,
-0.047630954533815384,
0.007454546168446541,
-0.0007092696614563465,
0.005079214461147785,
0.004164600279182196,
0.06254892796278,
0.016978072002530098,
0.07622373104095459,
0.026994425803422928,
-0.007707618642598391,
0.01481141522526741,
0.011898858472704887,
-0.022998539730906487,
0.03793426975607872,
-0.01989062875509262,
0.015148845501244068,
0.03429357707500458,
0.013834643177688122,
-0.02090292051434517,
0.012005415745079517,
0.022288160398602486,
0.032446589320898056,
-0.03736596927046776,
0.02733185514807701,
0.03315696865320206,
-0.012138611637055874,
0.0011665765196084976,
0.018345553427934647,
0.02067204751074314,
0.04230310767889023,
-0.021524501964449883,
0.053065355867147446,
-0.10456787794828415,
-0.015672750771045685,
0.04631675034761429,
-0.005865071900188923,
0.014775896444916725,
-0.03297937288880348,
0.01212973240762949,
0.02841518446803093,
0.08339856564998627,
0.004519790410995483,
-0.06876474618911743,
-0.01759965531527996,
0.042764853686094284,
0.004255617968738079,
-0.043262120336294174,
-0.0583932027220726,
-0.0018203477375209332,
0.010140668600797653,
-0.00753002380952239,
-0.012262928299605846,
0.05945877358317375,
-0.039958853274583817,
0.03365423530340195,
0.03205588087439537,
0.006304618902504444,
-0.02354908362030983,
-0.05619102716445923,
-0.02182641439139843,
-0.03878672793507576,
-0.06141231954097748,
-0.014234231784939766,
-0.018984895199537277,
0.05409540608525276,
0.04155720770359039,
0.03013785555958748,
-0.009599004872143269,
0.012822352349758148,
0.02633732371032238,
0.03644247353076935,
0.011002004146575928,
-0.010522497817873955,
-0.009030700661242008,
-0.022785427048802376,
-0.03633591905236244,
0.0218974519520998,
-0.048057179898023605,
0.04621019586920738,
0.09824550151824951,
-0.019713034853339195,
0.021009476855397224,
-0.044682879000902176,
-0.02390427328646183,
-0.024437058717012405,
-0.027811361476778984,
-0.026106450706720352,
0.005501002073287964,
-0.012689155526459217,
0.015992421656847,
0.05025935918092728,
-0.0925624668598175,
0.01237836480140686,
-0.0009334832429885864,
-0.037472523748874664,
-0.03333456441760063,
-0.08858434110879898,
-0.0218974519520998,
-0.056652773171663284,
-0.031381018459796906,
-0.02534279227256775,
0.05690140649676323,
-0.01316866185516119,
0.02855726145207882,
-0.019091451540589333,
0.017466459423303604,
0.06613634526729584,
-0.013701447285711765,
0.029729386791586876,
0.042622778564691544,
-0.018221236765384674,
0.03864465281367302,
0.0652838870882988,
-0.022927502170205116,
-0.05846424400806427,
0.04422113299369812,
-0.04027852416038513,
0.029818184673786163,
0.02683459036052227,
-0.00038293900433927774,
0.04457632079720497,
-0.053136397153139114,
0.030173374339938164,
0.021062755957245827,
-0.001531756017357111,
0.018984895199537277,
-0.0009223835077136755,
0.06826747953891754,
-0.03535914421081543,
0.01327521912753582,
-0.07885213941335678,
-0.028450703248381615,
-0.0012476042611524463,
-0.014296390116214752,
0.03386734798550606,
-0.03413373976945877,
0.03878672793507576,
0.04958449676632881,
-0.06066641956567764,
0.015441876836121082,
0.01868298463523388,
0.019162490963935852,
0.013292978517711163,
-0.014465104788541794,
0.023744437843561172,
0.0020645407494157553,
0.09533294290304184,
0.030688399448990822,
-0.022128324955701828,
-0.018434351310133934,
0.027100982144474983,
-0.02232367917895317,
-0.012147491797804832,
0.029818184673786163,
-0.007467865943908691,
0.011907738633453846,
0.03992333635687828,
-0.016640642657876015,
-0.07622373104095459,
-0.0034142620861530304,
-0.006313499063253403,
-0.004335535690188408,
0.006544372066855431,
-0.027100982144474983,
-0.04162824526429176,
-0.0009035140974447131,
0.0012575938599184155,
-0.05594239383935928,
-0.004559749271720648,
-0.0021200391929596663,
-0.03084823489189148,
-0.011117440648376942,
-0.017235584557056427,
-0.025822298601269722,
0.029711628332734108,
-0.07064725458621979,
0.029072286561131477,
-0.04173480346798897,
-0.012040934525430202,
0.0177150908857584,
0.009909795597195625,
0.014109915122389793,
0.029214361682534218,
0.03358319774270058,
0.04667194187641144,
0.025076400488615036,
-0.01292002946138382,
0.05594239383935928,
0.02289198338985443,
-0.058428723365068436,
0.06993687152862549,
0.0361938402056694,
-0.07224560528993607,
0.05519649758934975,
0.07728930562734604,
0.07128659635782242,
0.020441172644495964,
-0.010398182086646557,
0.04844788834452629,
-0.0006665358669124544,
-0.05128940939903259,
-0.04816373810172081,
-0.05175115540623665,
0.028717096894979477,
-0.008045049384236336,
0.019695274531841278,
0.037898752838373184,
0.0445052832365036,
-0.06485766172409058,
0.06961720436811447,
0.03907087817788124,
0.03168293088674545,
0.010060750879347324,
-0.0611281655728817,
-0.03514603152871132,
-0.01566386967897415,
0.003230007365345955,
0.03420477733016014,
-0.008449077606201172,
-0.005749634932726622,
-0.008373599499464035,
-0.016729440540075302,
-0.004617467522621155,
-0.06269100308418274,
0.026514919474720955,
-0.026532677933573723,
0.044185612350702286,
-0.01531756017357111,
0.01255595963448286,
-0.01527316216379404,
0.033529918640851974,
-0.01166798546910286,
-0.0423741452395916,
0.03235779330134392,
-0.05516097694635391,
-0.01946440152823925,
0.007370188366621733,
-0.009297093376517296,
-0.013799124397337437,
0.07970459014177322,
-0.010389301925897598,
0.03143429756164551,
0.0025085280649363995,
-0.011614706367254257,
-0.004413233604282141,
-0.019073693081736565,
0.012760194018483162,
-0.030901513993740082,
0.01889609731733799,
0.03054632432758808,
-0.05690140649676323,
-0.007316910196095705,
0.015211003832519054,
0.042764853686094284,
-0.027562730014324188,
-0.008839786052703857,
-0.058002494275569916,
-0.02841518446803093,
0.06176750734448433,
0.018105801194906235,
-0.06876474618911743,
0.052781205624341965,
-0.059494294226169586,
-0.02862829901278019,
0.05718556046485901,
0.0814095064997673,
0.10534929484128952,
0.004519790410995483,
0.012777953408658504,
-0.05604895204305649,
0.0025440470781177282,
0.03985229507088661,
-0.04287140816450119,
-0.03168293088674545,
-0.05377573519945145,
-0.03715285286307335,
-0.011747903190553188,
0.04280037060379982,
0.02534279227256775,
0.03226899355649948,
0.0499752052128315,
-0.003991445526480675,
0.02562694437801838,
-0.02877037413418293,
0.01974855363368988,
-0.014775896444916725,
-0.036833181977272034,
-0.0031101307831704617,
0.03054632432758808,
0.020228059962391853,
-0.026532677933573723,
0.015335319563746452,
0.0023176134563982487,
0.052497055381536484,
0.09412530064582825,
-0.05310087651014328,
0.03665558993816376,
0.02248351462185383,
0.04535773769021034,
0.026994425803422928,
0.0003787766327150166,
0.010433700866997242,
0.01274243462830782,
0.014758136123418808,
-0.05445059761404991,
0.01427863072603941,
0.00493713840842247,
0.009385890327394009,
-0.010460339486598969,
-0.058641836047172546,
-0.020441172644495964,
-0.021417945623397827,
0.03793426975607872,
0.038182903081178665,
0.019162490963935852,
0.005239049904048443,
-0.052639130502939224,
0.021240349858999252,
-0.05246153473854065,
0.053420547395944595,
-0.010060750879347324,
0.057079002261161804,
-0.049193788319826126,
0.021009476855397224,
0.019055932760238647,
-0.019517680630087852,
-0.031096868216991425,
0.035447943955659866,
-0.07206801325082779,
0.0354834608733654,
0.01388792134821415,
-0.03255314752459526,
-0.01549515500664711,
-0.05111181363463402,
0.029747147113084793,
0.010522497817873955,
-0.015548434108495712,
0.007032758090645075,
-0.03006681799888611,
0.03871569037437439,
0.04692057520151138,
-0.09348595887422562,
-0.03786323219537735,
-0.026781311258673668,
0.031665172427892685,
0.07871006429195404,
-0.026301804929971695,
-0.02985370345413685,
0.0402430035173893,
0.06642049551010132,
0.005416644737124443,
0.012333965860307217,
-0.06418279558420181,
-0.010575776919722557,
-0.003642915515229106,
0.0035696576815098524,
0.062158215790987015,
-0.009829877875745296,
-0.0057274354621768,
0.021080514416098595,
-0.013621529564261436,
0.08695046603679657,
0.011650226078927517,
-0.006442255340516567,
-0.02411738783121109,
-0.073595330119133,
-0.07686307281255722,
0.05033039674162865,
-0.005878391209989786,
0.05416644737124443,
-0.01535307988524437,
-0.03177172690629959,
0.027172019705176353,
-0.0018625265220180154,
-0.04198343679308891,
-0.01976631209254265,
0.042551737278699875,
0.006859603337943554,
0.02633732371032238,
0.000029483529942808673,
0.04116649925708771,
0.019304566085338593,
-0.042693816125392914,
-0.027598248794674873,
-0.05359814316034317,
-0.04645882546901703,
0.06233581155538559,
-0.00501261604949832,
-0.02935643680393696,
0.002181087387725711,
0.09568813443183899,
0.04908723011612892,
-0.052923280745744705,
0.017404301092028618,
0.051786672323942184,
-0.04564189165830612,
0.025520388036966324,
0.002612865064293146,
-0.004746223799884319,
-0.03708181530237198,
0.010620174929499626,
-0.00994531437754631,
-0.026159729808568954,
-0.02662147581577301,
0.020085982978343964,
-0.07871006429195404,
-0.030475284904241562,
-0.00039487116737291217,
0.0715707466006279,
0.006184742320328951,
0.010424820706248283,
0.0009146137745119631,
0.029374197125434875,
0.004639666993170977,
0.023868754506111145,
-0.09384115040302277,
-0.015219883061945438,
0.09689577668905258,
0.05310087651014328,
-0.05072110518813133,
0.02805999480187893,
-0.016347611322999,
-0.012005415745079517,
0.07267183810472488,
0.03422253951430321,
-0.023779958486557007,
0.03598072752356529,
0.006739726755768061,
0.007414587307721376,
-0.061589911580085754,
0.025378311052918434,
0.006153663620352745,
-0.001698251231573522,
0.0013053225120529532,
0.03099031001329422,
-0.005327847320586443,
0.018665224313735962,
-0.021098274737596512,
-0.002623964799568057,
-0.015814825892448425,
0.038253940641880035,
0.03464876487851143,
-0.002267664996907115,
-0.03392062708735466,
-0.0067663658410310745,
-0.03141653910279274,
0.052212901413440704,
0.0002676410658750683,
-0.038822244852781296,
-0.007747577503323555,
0.01896713487803936,
-0.04574844613671303,
-0.05967188626527786,
0.04709816724061966,
-0.010913207195699215,
0.026870109140872955,
-0.02090292051434517,
0.021861933171749115,
-0.016685040667653084,
-0.042409662157297134,
0.028024476021528244,
-0.005798473488539457,
-0.04120201617479324,
-0.07054069638252258,
0.024454819038510323,
0.013142023235559464,
-0.038964323699474335,
-0.03106134943664074,
0.03814738616347313,
-0.034808602184057236,
-0.026426121592521667,
-0.04660090431571007,
-0.00026597612304612994,
-0.030830474570393562,
-0.06077297776937485,
0.015459636226296425,
-0.010176188312470913,
0.0395326241850853,
-0.047062650322914124,
-0.023797716945409775,
0.02317613549530506,
-0.04752439633011818,
0.0019024853827431798,
-0.035447943955659866,
-0.0030568523798137903,
-0.022661110386252403,
-0.015184364281594753,
0.015992421656847,
-0.030688399448990822,
0.07089588791131973,
-0.017466459423303604,
-0.03836049884557724,
-0.0019846230279654264,
-0.009252694435417652,
0.019198009744286537,
-0.002133358735591173,
-0.022004008293151855,
0.014900212176144123,
0.006855163257569075,
0.05810905247926712,
-0.0065621319226920605,
-0.012893389910459518,
0.008275922387838364,
0.04280037060379982,
0.03914191573858261,
0.03857361152768135,
0.024561375379562378,
0.04194791615009308,
-0.022590070962905884,
0.007974010892212391,
-0.021773135289549828,
-0.007743137888610363,
0.043120041489601135,
-0.05732763558626175,
0.04123753681778908,
0.038111865520477295,
0.009803238324820995,
0.04194791615009308,
-0.025289515033364296,
-0.005958308931440115,
0.038467057049274445,
-0.026674754917621613,
0.016223294660449028,
-0.0006398966652341187,
0.022412477061152458,
0.06173199042677879,
-0.03942606970667839,
0.0107711311429739,
-0.04145064949989319,
-0.08091223984956741,
0.03468428552150726,
0.04674297943711281,
0.008164925500750542,
-0.02024581842124462,
0.0026905627455562353,
-0.0022654449567198753,
-0.011144080199301243,
0.0019513240549713373,
0.0011127430479973555,
0.02964058890938759,
0.006064866203814745,
-0.06748606264591217,
0.026355084031820297,
-0.05960084870457649,
0.03429357707500458,
-0.003911527805030346,
0.007467865943908691,
0.006486653815954924,
0.08361168205738068,
-0.006064866203814745,
0.008036169223487377,
-0.026852348819375038,
0.004117981996387243,
0.032393310219049454,
-0.062229253351688385,
0.006468894425779581,
-0.0017182306619361043,
-0.02964058890938759,
0.018718503415584564,
0.0000308189592033159,
0.008719909936189651,
-0.02303405851125717,
0.024738969281315804,
0.007596622221171856,
-0.005589799489825964,
0.06428935378789902,
0.08964990824460983,
-0.009226054884493351,
-0.016072338446974754,
-0.007259191945195198,
-0.04265829548239708,
-0.004781742580235004,
-0.039745740592479706,
-0.01792820543050766,
-0.020281337201595306,
-0.019659755751490593,
0.002606205176562071,
0.0006493313703685999,
-0.002650603884831071,
0.063969686627388,
-0.09426737576723099,
-0.004559749271720648,
-0.01788380742073059,
0.015610592439770699,
0.04507358744740486,
-0.056865889579057693,
0.06421831995248795,
0.03344111889600754,
-0.0437949039041996,
0.010780010372400284,
-0.02005046419799328,
-0.04567740857601166,
0.026532677933573723,
0.005949429236352444,
-0.04681401699781418,
0.08865537494421005,
-0.020885160192847252,
0.03278401866555214,
0.06219373643398285,
0.04301348701119423,
0.03168293088674545,
-0.015992421656847,
-0.016329851001501083,
-0.08453517407178879,
-0.0060293469578027725,
0.05381125584244728,
-0.020991718396544456,
-0.048696521669626236,
-0.05022383853793144,
0.012760194018483162,
-0.028681576251983643,
0.051999788731336594,
-0.065390445291996,
-0.02992474101483822,
-0.015859225764870644,
0.03535914421081543,
-0.015228763222694397,
-0.007703179027885199,
-0.028965728357434273,
0.001172126387245953,
0.018487630411982536,
-0.02898348867893219,
0.0013896800810471177,
0.004106882028281689,
0.010655694641172886,
-0.05487682670354843,
-0.023016300052404404,
-0.03464876487851143,
-0.011543668806552887,
-0.007525584194809198,
0.009350371547043324,
-0.02761600725352764,
0.0038626892492175102,
0.09625643491744995,
-0.043049003928899765,
0.008298122324049473,
-0.029072286561131477,
-0.026248527690768242,
-0.003844929626211524,
-0.031079107895493507,
0.01868298463523388,
-0.03647799417376518,
-0.00654881214722991,
-0.028219830244779587,
-0.039106398820877075,
-0.0028770375065505505,
0.017652934417128563,
0.018878338858485222,
0.04272933304309845,
0.037330448627471924,
-0.034808602184057236,
-0.062442369759082794,
0.005416644737124443,
-0.06173199042677879,
0.053917814046144485,
-0.015637231990695,
0.02976490557193756,
0.06155439466238022,
0.0012131951516494155,
0.06109264865517616,
-0.0036961939185857773,
-0.06148335710167885,
0.006055986043065786,
-0.00036351458402350545,
0.004630787298083305,
0.008142726495862007,
0.03828946128487587,
-0.016898155212402344,
-0.05501890182495117,
-0.015042288228869438,
-0.014891332946717739,
0.02811327390372753,
-0.044611841440200806,
-0.00976771954447031,
0.00941252987831831,
-0.009190536104142666,
0.03285505622625351,
-0.02440153993666172,
-0.019926147535443306,
-0.017821649089455605,
-0.04102442413568497,
-0.051999788731336594,
0.01875402219593525,
0.011152960360050201,
-0.017484217882156372,
0.028219830244779587,
0.010717852041125298,
0.016241053119301796,
-0.019428882747888565,
0.014829174615442753,
-0.015939142554998398,
0.02718978002667427,
0.004248958081007004,
-0.05075662210583687,
0.03662006929516792,
-0.0014229791704565287,
-0.009323732927441597,
0.037685640156269073,
0.017493098974227905,
0.02283870428800583,
-0.03413373976945877,
0.012165251187980175,
-0.04134409502148628,
0.03569657728075981,
-0.07132211327552795,
-0.02324717305600643,
0.004233418498188257,
0.021773135289549828,
-0.08730565756559372,
0.005176891572773457,
0.029782665893435478,
0.005185771267861128,
-0.05185771360993385,
-0.0015117765869945288,
0.03358319774270058,
-0.047346800565719604,
-0.02591109648346901,
0.05111181363463402,
-0.03594520688056946,
0.009061779826879501,
-0.03218019753694534,
-0.03715285286307335,
-0.042196549475193024,
-0.029462995007634163,
-0.021009476855397224,
0.030439766123890877,
0.011889979243278503,
-0.016072338446974754,
0.018949376419186592,
-0.0016771618975326419,
0.02097395807504654,
0.027562730014324188,
-0.01657848432660103,
-0.016667282208800316,
0.0030235531739890575,
-0.0215422622859478,
-0.06656257063150406,
-0.020991718396544456,
-0.016667282208800316,
-0.014509503729641438,
0.008298122324049473,
-0.018434351310133934,
0.0012020955327898264,
0.029249880462884903,
0.04134409502148628,
-0.0026905627455562353,
0.008933023549616337,
0.026568198576569557,
-0.04486047104001045,
-0.024064108729362488,
0.01531756017357111,
-0.005478802602738142,
-0.01783052831888199,
-0.043475233018398285,
-0.022803185507655144,
0.02841518446803093,
0.06404072046279907,
-0.011037522926926613,
-0.04514462500810623,
0.0032921654637902975,
0.04571292921900749,
-0.0031234503258019686
]
|
30,437 | networkx.drawing.layout | bipartite_layout | Position nodes in two straight lines.
Parameters
----------
G : NetworkX graph or list of nodes
A position will be assigned to every node in G.
nodes : list or container
Nodes in one node set of the bipartite graph.
This set will be placed on left or top.
align : string (default='vertical')
The alignment of nodes. Vertical or horizontal.
scale : number (default: 1)
Scale factor for positions.
center : array-like or None
Coordinate pair around which to center the layout.
aspect_ratio : number (default=4/3):
The ratio of the width to the height of the layout.
Returns
-------
pos : dict
A dictionary of positions keyed by node.
Examples
--------
>>> G = nx.bipartite.gnmk_random_graph(3, 5, 10, seed=123)
>>> top = nx.bipartite.sets(G)[0]
>>> pos = nx.bipartite_layout(G, top)
Notes
-----
This algorithm currently only works in two dimensions and does not
try to minimize edge crossings.
| def bipartite_layout(
G, nodes, align="vertical", scale=1, center=None, aspect_ratio=4 / 3
):
"""Position nodes in two straight lines.
Parameters
----------
G : NetworkX graph or list of nodes
A position will be assigned to every node in G.
nodes : list or container
Nodes in one node set of the bipartite graph.
This set will be placed on left or top.
align : string (default='vertical')
The alignment of nodes. Vertical or horizontal.
scale : number (default: 1)
Scale factor for positions.
center : array-like or None
Coordinate pair around which to center the layout.
aspect_ratio : number (default=4/3):
The ratio of the width to the height of the layout.
Returns
-------
pos : dict
A dictionary of positions keyed by node.
Examples
--------
>>> G = nx.bipartite.gnmk_random_graph(3, 5, 10, seed=123)
>>> top = nx.bipartite.sets(G)[0]
>>> pos = nx.bipartite_layout(G, top)
Notes
-----
This algorithm currently only works in two dimensions and does not
try to minimize edge crossings.
"""
import numpy as np
if align not in ("vertical", "horizontal"):
msg = "align must be either vertical or horizontal."
raise ValueError(msg)
G, center = _process_params(G, center=center, dim=2)
if len(G) == 0:
return {}
height = 1
width = aspect_ratio * height
offset = (width / 2, height / 2)
top = dict.fromkeys(nodes)
bottom = [v for v in G if v not in top]
nodes = list(top) + bottom
left_xs = np.repeat(0, len(top))
right_xs = np.repeat(width, len(bottom))
left_ys = np.linspace(0, height, len(top))
right_ys = np.linspace(0, height, len(bottom))
top_pos = np.column_stack([left_xs, left_ys]) - offset
bottom_pos = np.column_stack([right_xs, right_ys]) - offset
pos = np.concatenate([top_pos, bottom_pos])
pos = rescale_layout(pos, scale=scale) + center
if align == "horizontal":
pos = pos[:, ::-1] # swap x and y coords
pos = dict(zip(nodes, pos))
return pos
| (G, nodes, align='vertical', scale=1, center=None, aspect_ratio=1.3333333333333333) | [
0.034744225442409515,
-0.027273939922451973,
-0.028013572096824646,
-0.003356081433594227,
-0.031230971217155457,
0.013137717731297016,
-0.005653563886880875,
0.0025794676039367914,
0.0037952379789203405,
-0.0007049620035104454,
-0.021763678640127182,
0.027218466624617577,
-0.010179189033806324,
0.0542520247399807,
-0.03193362429738045,
-0.011122220195829868,
0.01063221413642168,
-0.04911158233880997,
0.02278067357838154,
0.011676943860948086,
0.013276399113237858,
-0.04045788571238518,
0.07189225405454636,
0.041012607514858246,
-0.006407064385712147,
-0.04123449698090553,
0.022540293633937836,
0.000581015832722187,
0.029659252613782883,
0.047743260860443115,
0.012046759948134422,
-0.048371948301792145,
-0.044821713119745255,
-0.014441319741308689,
0.018416842445731163,
0.026978086680173874,
0.062203072011470795,
0.06349743157625198,
-0.05014706775546074,
-0.02657128870487213,
0.006254515144973993,
-0.03627896308898926,
0.05920756235718727,
-0.03945938125252724,
0.027273939922451973,
0.05432599037885666,
0.026719214394688606,
0.0014665520284324884,
-0.06420008093118668,
0.019526291638612747,
0.047447409480810165,
-0.10125565528869629,
0.01989610679447651,
0.009273139759898186,
-0.03267325460910797,
-0.0072437734343111515,
0.022873127833008766,
0.01926741935312748,
-0.002408427419140935,
-0.025258442386984825,
-0.0262384545058012,
-0.02912301942706108,
0.010382588021457195,
-0.016197945922613144,
-0.016197945922613144,
0.025221459567546844,
-0.049370452761650085,
-0.05084971711039543,
0.0017693390836939216,
-0.005052612628787756,
-0.002903056563809514,
0.009402574971318245,
0.006813862361013889,
0.020081015303730965,
0.002780555048957467,
0.02318747155368328,
0.02795809879899025,
0.03380119428038597,
0.0018155660945922136,
0.012721674516797066,
-0.016965314745903015,
-0.007354718167334795,
0.047114573419094086,
-0.011455054394900799,
0.08468789607286453,
0.016503045335412025,
0.07015412300825119,
0.05377126485109329,
0.035169512033462524,
-0.0722990557551384,
-0.0327102355659008,
-0.0231504887342453,
0.061944201588630676,
0.026682233437895775,
0.007960292510688305,
0.009827863425016403,
-0.0019808276556432247,
-0.032747216522693634,
-0.01019767951220274,
0.019544782117009163,
-0.019156474620103836,
0.01494057197123766,
-0.049000635743141174,
-0.019581763073801994,
-0.05502863973379135,
-0.03886767476797104,
-0.06024304777383804,
0.027015067636966705,
-0.041345443576574326,
-0.039385419338941574,
-0.010918821208178997,
0.040975626558065414,
0.023372380062937737,
0.02218896709382534,
0.03577971085906029,
0.03539140522480011,
0.008907945826649666,
0.005195916630327702,
0.016965314745903015,
-0.002311350777745247,
-0.0411975160241127,
0.0031757960096001625,
-0.04800213500857353,
-0.023668231442570686,
-0.0018860622076317668,
-0.0553244911134243,
0.05395617336034775,
0.055805254727602005,
0.024555791169404984,
-0.05133047699928284,
0.0027389507740736008,
-0.04448888078331947,
-0.05018404871225357,
0.0654204711318016,
-0.0338381752371788,
-0.04016203060746193,
-0.03901560232043266,
0.025998074561357498,
-0.012675447389483452,
0.03964428976178169,
0.004761382471770048,
-0.06449593603610992,
0.024851644411683083,
0.03735142946243286,
-0.019285911694169044,
-0.006578104570508003,
0.04951838031411171,
-0.06142645701766014,
0.020321397110819817,
0.027255449444055557,
0.032654762268066406,
-0.0751466378569603,
0.012546012178063393,
-0.0008679121965542436,
-0.01972969062626362,
0.0019600254017859697,
-0.02168971672654152,
0.015643222257494926,
-0.014533773995935917,
0.027680737897753716,
-0.025776183232665062,
-0.010484287515282631,
0.027107521891593933,
0.03230343759059906,
-0.028235461562871933,
0.020210450515151024,
0.05465882271528244,
0.019248928874731064,
0.003210466355085373,
-0.026959596201777458,
-0.020154979079961777,
-0.043231505900621414,
-0.08158143609762192,
-0.04826100543141365,
0.045154549181461334,
-0.00752113526687026,
0.04833496734499931,
-0.03087964653968811,
0.011945061385631561,
0.04019901156425476,
-0.0009418754489161074,
-0.02845735102891922,
0.06982128322124481,
-0.011861852370202541,
-0.025979582220315933,
0.06357139348983765,
0.02394559420645237,
0.012869601137936115,
-0.016327381134033203,
-0.012240913696587086,
-0.025628257542848587,
-0.0007153630722314119,
-0.021763678640127182,
0.021338390186429024,
-0.010317870415747166,
0.06967335939407349,
-0.00020152090291958302,
0.029344908893108368,
-0.06882277876138687,
0.046485885977745056,
0.08032406121492386,
-0.025646748021245003,
0.059022653847932816,
0.011898834258317947,
0.04863082244992256,
0.01504227053374052,
-0.03050983138382435,
-0.0349661149084568,
-0.0251105148345232,
0.0051774256862699986,
-0.002088305540382862,
-0.025813166052103043,
-0.020173469558358192,
-0.03565027564764023,
-0.024814661592245102,
0.033616285771131516,
-0.06346044689416885,
0.06138947606086731,
-0.028549805283546448,
-0.01429339312016964,
0.032358910888433456,
-0.011011275462806225,
-0.013757159933447838,
-0.004269064869731665,
0.0485568568110466,
-0.023890122771263123,
0.06098267808556557,
-0.06453291326761246,
0.028531314805150032,
-0.04042090103030205,
0.01934138312935829,
-0.03431893512606621,
-0.008676811121404171,
0.02039535902440548,
0.0784749835729599,
-0.05732150003314018,
0.00021394441137090325,
0.008695301599800587,
-0.00021928940259385854,
0.08542752265930176,
-0.007165187504142523,
-0.012712429277598858,
-0.06312761455774307,
0.008417939767241478,
-0.02431541122496128,
0.011815625242888927,
0.0237421952188015,
-0.055842235684394836,
-0.03883069381117821,
0.03363477811217308,
-0.06460687518119812,
-0.04641192406415939,
0.031822677701711655,
-0.017686456441879272,
0.04692966490983963,
0.008570488542318344,
-0.09038306027650833,
-0.03187815099954605,
-0.014367356896400452,
-0.019119493663311005,
0.005829226691275835,
-0.05133047699928284,
-0.07647797465324402,
0.00771066639572382,
0.0971137136220932,
0.0417892225086689,
0.009744655340909958,
0.04981423169374466,
-0.02921547368168831,
0.013017527759075165,
0.05436297133564949,
0.04459982365369797,
0.04064279422163963,
0.03509555011987686,
0.05214407294988632,
0.00547327846288681,
-0.032451365143060684,
0.0014133909717202187,
0.011519772000610828,
-0.011861852370202541,
-0.02239236608147621,
-0.020802156999707222,
-0.05059084668755531,
0.0172426775097847,
0.023427851498126984,
-0.004648126661777496,
0.012361103668808937,
-0.008200672455132008,
-0.00040853125392459333,
-0.05207011103630066,
0.03714802861213684,
0.02444484643638134,
-0.033320434391498566,
0.028438860550522804,
-0.01527340617030859,
0.055435437709093094,
-0.01318394485861063,
0.01741833984851837,
0.010317870415747166,
0.0035086304415017366,
0.023205962032079697,
-0.07529456168413162,
0.014302638359367847,
0.027680737897753716,
0.07429605722427368,
0.04282470792531967,
0.018990058451890945,
-0.0021772924810647964,
0.01084485836327076,
0.012240913696587086,
-0.06701068580150604,
0.004322226159274578,
0.01900854893028736,
-0.0035779711324721575,
-0.03853483870625496,
-0.01542133279144764,
0.0054825241677463055,
0.024426355957984924,
0.025424858555197716,
0.008367089554667473,
-0.002161113079637289,
0.0315822958946228,
-0.08195125311613083,
0.07207716256380081,
-0.02941887266933918,
0.05502863973379135,
0.012610729783773422,
0.03801709786057472,
0.020376868546009064,
0.022133495658636093,
0.018527787178754807,
0.036796703934669495,
-0.004289866890758276,
0.03542838618159294,
-0.09600427001714706,
0.007539626210927963,
0.05695168301463127,
0.02119046449661255,
0.026848651468753815,
-0.038460876792669296,
0.010151452384889126,
-0.0016029217513278127,
-0.025018060579895973,
-0.019822144880890846,
0.07425907999277115,
0.011843361891806126,
-0.014903590083122253,
0.0015520720044150949,
-0.05084971711039543,
0.043564338237047195,
-0.006564236246049404,
0.031526826322078705,
-0.032654762268066406,
-0.04079071804881096,
-0.046781741082668304,
0.010965048335492611,
-0.0009482316672801971,
-0.06723257154226303,
0.013692442327737808,
0.06804616749286652,
-0.03189663961529732,
-0.010965048335492611,
-0.016373608261346817,
0.013563006184995174,
-0.02106102928519249,
0.03990316018462181,
-0.031822677701711655,
0.023464832454919815,
0.09807523339986801,
-0.026848651468753815,
0.05495467782020569,
-0.03465177118778229,
-0.06175929307937622,
0.04781722649931908,
-0.023168981075286865,
0.05207011103630066,
-0.04700363054871559,
0.011122220195829868,
-0.022299911826848984,
0.02657128870487213,
0.008783132769167423,
-0.036204997450113297,
0.057395461946725845,
0.03439290076494217,
0.006217533722519875,
-0.008251522667706013,
0.11316373199224472,
0.01863873191177845,
-0.004974026698619127,
-0.03901560232043266,
-0.0411975160241127,
-0.0009493873221799731,
0.0035594801884144545,
0.010733912698924541,
-0.03542838618159294,
-0.039422400295734406,
0.06172231212258339,
0.01863873191177845,
0.01652153581380844,
-0.07015412300825119,
-0.02440786361694336,
-0.008963418193161488,
-0.014626228250563145,
0.012453557923436165,
-0.0036103299353271723,
-0.031360406428575516,
0.030953610315918922,
0.06427404284477234,
0.04563530907034874,
0.021134991198778152,
-0.008792378008365631,
0.023335397243499756,
0.01934138312935829,
-0.047410428524017334,
-0.0032474477775394917,
-0.010863348841667175,
-0.003353770123794675,
0.05269879847764969,
0.004343028180301189,
-0.04789118841290474,
0.015587749890983105,
-0.004648126661777496,
0.033320434391498566,
-0.05917058140039444,
-0.014459810219705105,
-0.025998074561357498,
-0.04175224155187607,
-0.022207457572221756,
0.00026782776694744825,
0.015781903639435768,
-0.016327381134033203,
-0.013359607197344303,
0.05151538550853729,
0.009393329732120037,
0.023871630430221558,
-0.06397818773984909,
0.058393966406583786,
-0.038165025413036346,
-0.02102404646575451,
0.032321929931640625,
0.02185613289475441,
0.0026788555551320314,
0.010512023232877254,
-0.05824603885412216,
-0.020802156999707222,
0.009929562918841839,
-0.056470923125743866,
0.0049786497838795185,
-0.007396322675049305,
0.018333634361624718,
0.014959062449634075,
-0.016937578096985817,
0.0627947747707367,
-0.025424858555197716,
-0.027384884655475616,
-0.05362333729863167,
0.0006494895787909627,
-0.03718501329421997,
-0.05295766890048981,
0.04959234222769737,
0.046190034598112106,
-0.024259937927126884,
-0.03890465572476387,
0.04016203060746193,
0.014959062449634075,
-0.04822402447462082,
0.010077489539980888,
-0.014043767005205154,
-0.04086468368768692,
0.0031526824459433556,
0.0062406472861766815,
-0.04367528483271599,
-0.01019767951220274,
-0.0514044426381588,
0.047484390437603,
0.010622967965900898,
0.031693242490291595,
-0.02424144744873047,
-0.0502210296690464,
-0.029566800221800804,
-0.031693242490291595,
-0.013424325734376907,
-0.006813862361013889,
0.025628257542848587,
0.0038668899796903133,
0.031859658658504486,
-0.007775384001433849,
0.02030290476977825,
-0.03563178330659866,
-0.033117033541202545,
-0.002896122634410858,
0.0006396663375198841,
-0.00327980681322515,
0.05832000449299812,
0.03320948779582977,
0.008154445327818394,
-0.023095017299056053,
-0.05369730293750763,
0.025129005312919617,
-0.05891171097755432,
0.025591276586055756,
-0.019544782117009163,
0.08956946432590485,
-0.010234661400318146,
0.028975093737244606,
-0.021874623373150826,
0.026589779183268547,
0.04763231799006462,
0.025924110785126686,
0.012194686569273472,
0.014737172983586788,
0.006393196526914835,
0.0036496229004114866,
-0.011945061385631561,
-0.007890951819717884,
0.06294270604848862,
-0.008972663432359695,
0.006781503092497587,
0.08838605135679245,
-0.024925606325268745,
0.035003095865249634,
0.02143084444105625,
0.0231504887342453,
0.01926741935312748,
-0.013710932806134224,
0.03823898732662201,
0.04815005883574486,
-0.04692966490983963,
-0.0067630126141011715,
-0.01351677905768156,
-0.02616449072957039,
0.029696235433220863,
-0.018398351967334747,
-0.004375386983156204,
0.02143084444105625,
0.031952112913131714,
0.035040076822042465,
0.0025309291668236256,
0.016207192093133926,
-0.03322798013687134,
0.0029423495288938284,
-0.008353222161531448,
-0.0389416366815567,
0.027976589277386665,
0.03672274202108383,
0.07240999490022659,
0.013988294638693333,
0.0028221593238413334,
-0.00937021616846323,
-0.0530686154961586,
-0.03130493685603142,
0.01960025541484356,
-0.02126442827284336,
-0.03979221358895302,
0.040088068693876266,
-0.008491902612149715,
-0.044525861740112305,
0.015994546934962273,
0.011353354901075363,
0.05410410091280937,
-0.041012607514858246,
-0.0020663475152105093,
-0.024999570101499557,
-0.016466062515974045,
0.034577809274196625,
-0.035003095865249634,
-0.027736209332942963,
-0.04153035208582878,
0.05684074014425278,
0.03370874002575874,
0.04027297720313072,
0.04896365478634834,
0.015245669521391392,
-0.012546012178063393,
0.01781589165329933,
-0.0434533953666687,
-0.04282470792531967,
0.019674217328429222,
-0.012407330796122551,
-0.07281679660081863,
-0.05824603885412216,
0.010715422220528126,
0.05295766890048981,
0.05273577943444252,
0.02729243040084839,
0.04208507388830185,
-0.059355489909648895,
0.039977122098207474,
0.01416395790874958,
-0.004729023668915033,
-0.007627457845956087,
-0.02352030575275421,
0.09334158897399902,
0.03916352614760399,
-0.007960292510688305,
-0.02039535902440548,
0.005542619153857231,
0.010622967965900898,
-0.034873660653829575,
-0.07196621596813202,
-0.036833684891462326,
0.042306963354349136,
0.013507533818483353,
0.027865644544363022,
0.011492036283016205,
-0.059318505227565765,
0.00950427446514368,
-0.026682233437895775,
-0.006749144289642572,
-0.04896365478634834,
0.021042536944150925,
0.04815005883574486,
0.016096247360110283,
-0.06534650921821594,
-0.059651341289281845,
-0.03542838618159294,
-0.02198556810617447,
0.04304659739136696,
-0.010715422220528126,
-0.054215043783187866,
0.02109801024198532,
-0.004802986979484558,
0.007174432743340731,
-0.02866075001657009,
-0.0020131864584982395,
0.06760238856077194,
-0.003832219634205103,
-0.04397113621234894,
0.030639266595244408,
0.044821713119745255,
-0.0002877631632145494,
-0.04108657315373421,
0.0005420117522589862,
0.03685217723250389,
0.03406006470322609,
-0.0689707100391388,
0.03513253107666969,
-0.021301409229636192,
0.0022732135839760303,
0.05979926884174347,
0.011843361891806126,
-0.04567229002714157,
-0.007890951819717884,
-0.0378691703081131,
0.01956327259540558,
-0.060280028730630875,
0.05957737937569618,
-0.008362467400729656,
0.02745884656906128,
-0.005251388996839523,
-0.006564236246049404,
-0.016105491667985916,
0.023853139951825142,
-0.052920687943696976,
0.01874043233692646,
0.025092024356126785,
0.001571718486957252,
0.035003095865249634,
0.010391833260655403,
-0.051996149122714996,
-0.00012546300422400236,
-0.003899248782545328,
-0.0036496229004114866,
0.012083741836249828,
0.008986531756818295,
0.010077489539980888,
0.00965220108628273,
-0.0191749669611454,
-0.017520038411021233,
-0.03117549978196621,
0.004664306063205004,
-0.04212205857038498,
0.013803387060761452,
-0.033375903964042664,
-0.03761029988527298,
-0.02089461125433445,
-0.027218466624617577,
0.017196450382471085,
-0.009726163931190968,
-0.013498288579285145,
0.06249892711639404,
-0.0000014310511460280395,
-0.003811417380347848,
-0.010308624245226383,
-0.01615171879529953,
0.008385580964386463,
-0.011843361891806126,
-0.05266181752085686,
-0.038054078817367554,
0.01598530262708664,
0.042343948036432266,
-0.020487813279032707,
0.07314962893724442,
-0.0052190301939845085,
0.024370882660150528,
-0.005066480953246355,
-0.0014885099371895194,
-0.005769131705164909,
0.017825137823820114,
-0.031656261533498764,
0.013618478551506996,
-0.013757159933447838,
-0.06749144196510315,
0.0553244911134243,
-0.018398351967334747,
-0.011381091549992561,
-0.07555343210697174,
0.04593116417527199,
-0.06863787025213242,
0.05103462561964989,
-0.016336627304553986,
-0.05750640854239464,
0.03957032412290573,
-0.06420008093118668,
0.030861156061291695,
-0.00033427911694161594,
-0.0021495562978088856,
0.004262130707502365,
-0.08675886690616608,
0.0007673684740439057,
-0.048704784363508224,
-0.019285911694169044,
0.011797134764492512,
0.0046596829779446125,
-0.02603505551815033,
-0.018268916755914688,
0.0158188845962286,
-0.08646301180124283,
-0.023335397243499756,
-0.010558250360190868,
0.014432074502110481,
0.07403718680143356,
-0.0078955739736557,
0.07603419572114944,
-0.03761029988527298,
0.01850929670035839,
-0.031822677701711655,
-0.042935650795698166,
-0.01794532686471939,
0.008533507585525513,
0.038054078817367554,
-0.026460343971848488,
-0.006393196526914835,
0.010382588021457195,
-0.0395333431661129,
0.016105491667985916,
-0.03827596828341484,
0.019674217328429222,
-0.016373608261346817,
-0.003305231686681509,
0.013627724722027779,
0.04888969287276268,
-0.023853139951825142,
-0.012388840317726135,
0.05044291913509369,
-0.05295766890048981,
0.05403013527393341,
-0.0054409196600317955,
-0.031101536005735397,
-0.12285291403532028,
-0.030639266595244408,
-0.0638672485947609,
-0.032118529081344604,
0.026608269661664963,
-0.02666374295949936,
0.02072819322347641,
0.032192494720220566,
0.10125565528869629
]
|
30,443 | networkx.generators.small | bull_graph |
Returns the Bull Graph
The Bull Graph has 5 nodes and 5 edges. It is a planar undirected
graph in the form of a triangle with two disjoint pendant edges [1]_
The name comes from the triangle and pendant edges representing
respectively the body and legs of a bull.
Parameters
----------
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : networkx Graph
A bull graph with 5 nodes
References
----------
.. [1] https://en.wikipedia.org/wiki/Bull_graph.
| def _raise_on_directed(func):
"""
A decorator which inspects the `create_using` argument and raises a
NetworkX exception when `create_using` is a DiGraph (class or instance) for
graph generators that do not support directed outputs.
"""
@wraps(func)
def wrapper(*args, **kwargs):
if kwargs.get("create_using") is not None:
G = nx.empty_graph(create_using=kwargs["create_using"])
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
return func(*args, **kwargs)
return wrapper
| (create_using=None, *, backend=None, **backend_kwargs) | [
0.02052106149494648,
-0.003826453583315015,
0.036479901522397995,
0.005174993071705103,
0.0002132951485691592,
0.039002541452646255,
-0.060078226029872894,
-0.017846345901489258,
0.08022357523441315,
-0.0368913933634758,
0.019215013831853867,
0.010833045467734337,
0.04422673583030701,
-0.02680082991719246,
0.011011956259608269,
0.04515707120299339,
-0.048806849867105484,
0.09403548389673233,
0.02332996018230915,
0.04737556353211403,
-0.009178120642900467,
-0.03184611350297928,
-0.0025740782730281353,
-0.019894873723387718,
0.0007603706326335669,
0.04347531124949455,
-0.025244304910302162,
0.0010136411292478442,
0.0061903116293251514,
0.023687781766057014,
-0.034297190606594086,
-0.04676726832985878,
0.0009113266132771969,
0.06562446057796478,
0.04633788391947746,
0.06276188790798187,
-0.046624138951301575,
0.08093921840190887,
-0.10212225466966629,
-0.07342496514320374,
-0.031255707144737244,
0.0077378894202411175,
0.03207869455218315,
0.011396613903343678,
-0.0013496578903868794,
-0.020002221688628197,
0.009822200052440166,
0.00007624672434758395,
-0.08931224048137665,
-0.0420440249145031,
0.022363843396306038,
0.005568597000092268,
0.05514029040932655,
0.06147373095154762,
0.012344840914011002,
0.04036226496100426,
-0.0097327446565032,
0.028965650126338005,
0.03943192586302757,
-0.016307713463902473,
0.0049737184308469296,
0.05102534219622612,
0.012487969361245632,
-0.024188732728362083,
-0.03299114108085632,
0.000811248377431184,
-0.07821977883577347,
-0.026621919125318527,
-0.021916566416621208,
0.05456777662038803,
0.011664980091154575,
-0.005783289670944214,
0.01718437671661377,
0.009500160813331604,
0.07224415987730026,
-0.030629519373178482,
0.019876983016729355,
-0.010251585394144058,
0.04827011749148369,
-0.023634109646081924,
-0.03599684312939644,
-0.018767736852169037,
-0.022399624809622765,
0.00704908324405551,
0.06197468191385269,
-0.021898675709962845,
-0.051275819540023804,
0.02640722505748272,
0.030182242393493652,
-0.044441428035497665,
-0.0055909608490765095,
-0.03537065535783768,
-0.017408015206456184,
0.005219720769673586,
-0.03220393508672714,
0.059684623032808304,
0.02960972860455513,
-0.05263553932309151,
0.06397847831249237,
-0.011781272478401661,
0.0017879892839118838,
0.00821200292557478,
-0.019107667729258537,
0.033456310629844666,
-0.016254041343927383,
-0.09739901125431061,
0.00984009075909853,
-0.028071096166968346,
-0.01962650753557682,
-0.02338363416492939,
-0.08279988914728165,
-0.01825784146785736,
0.049987662583589554,
0.000976181763689965,
0.0173632875084877,
-0.001127696828916669,
-0.010063729248940945,
-0.018588826060295105,
0.001818180433474481,
-0.03640833497047424,
-0.021719764918088913,
0.02898354083299637,
-0.05653579533100128,
-0.05109690874814987,
0.05646422877907753,
-0.023974038660526276,
-0.0005283457576297224,
-0.016611862927675247,
0.042258717119693756,
0.015198467299342155,
0.018660390749573708,
0.047304000705480576,
-0.029878094792366028,
0.03699874132871628,
0.0043810768984258175,
0.03644411638379097,
-0.05395948141813278,
0.052742887288331985,
-0.014169731177389622,
0.0027954804245382547,
-0.00294308178126812,
-0.018910866230726242,
0.027945857495069504,
0.04261653870344162,
0.013874527998268604,
0.041686203330755234,
-0.05564124137163162,
-0.0227216649800539,
0.02433186024427414,
-0.02842891775071621,
0.05921945720911026,
0.005613324698060751,
0.009039465337991714,
0.01686233840882778,
-0.043153271079063416,
0.03426140546798706,
-0.03318794444203377,
0.025494780391454697,
0.02136194333434105,
0.014357587322592735,
-0.03152407333254814,
-0.022864792495965958,
0.04233027994632721,
0.02332996018230915,
0.015609961934387684,
-0.022274388000369072,
0.01001005619764328,
-0.020038003101944923,
0.007903382182121277,
-0.004305039532482624,
-0.04537176340818405,
-0.022292278707027435,
-0.0057564531452953815,
-0.039288800209760666,
-0.028804630041122437,
0.03023591637611389,
0.03746391087770462,
0.04261653870344162,
-0.03352787345647812,
0.01607513055205345,
0.054424647241830826,
-0.044047825038433075,
-0.01951916143298149,
-0.02832156978547573,
0.04132838174700737,
0.01867828145623207,
0.009884818457067013,
-0.025280088186264038,
0.0032472300808876753,
0.0003916467831004411,
0.017560089007019997,
0.017381178215146065,
0.03250808268785477,
0.04973718523979187,
0.03796485811471939,
-0.09267576783895493,
-0.009374923072755337,
-0.0015274505130946636,
-0.016924956813454628,
0.07457000017166138,
0.05270710587501526,
0.0321502611041069,
0.03605051338672638,
0.014035548083484173,
-0.004799280781298876,
0.047304000705480576,
-0.025136958807706833,
-0.05188411474227905,
-0.05217037349939346,
-0.010349986143410206,
-0.03885941207408905,
-0.034297190606594086,
0.034959159791469574,
0.05152629315853119,
-0.03444031625986099,
0.02315104939043522,
0.02154085412621498,
0.05399526283144951,
-0.010349986143410206,
-0.027212323620915413,
-0.012112257070839405,
-0.01820416748523712,
-0.008082292973995209,
-0.02041371539235115,
0.0626545399427414,
-0.0413641631603241,
0.008122547529637814,
-0.05252819508314133,
0.025637909770011902,
-0.017846345901489258,
0.04104212298989296,
-0.01584254577755928,
0.01684444583952427,
0.02277533710002899,
0.0389309786260128,
-0.047697603702545166,
0.01968018151819706,
-0.045121289789676666,
0.010224749334156513,
0.013606161810457706,
-0.061831552535295486,
-0.0011215467238798738,
0.004445931874215603,
-0.0005487527814693749,
0.08279988914728165,
0.029538163915276527,
-0.009705907665193081,
0.048806849867105484,
0.005948781967163086,
-0.04161464050412178,
-0.04211558774113655,
-0.011459233239293098,
-0.0037660710513591766,
-0.023652000352740288,
0.008435641415417194,
-0.028697283938527107,
-0.059970881789922714,
-0.058790069073438644,
0.03925301507115364,
0.006990937050431967,
-0.03628309816122055,
0.05825333669781685,
-0.05667892470955849,
0.020342150703072548,
0.004568933043628931,
-0.033456310629844666,
-0.025315869599580765,
0.02214914932847023,
-0.03408249467611313,
0.025047503411769867,
-0.022453298792243004,
0.04086321219801903,
0.0739259198307991,
-0.02411716803908348,
0.006566024385392666,
0.020109567791223526,
-0.020038003101944923,
0.011584470979869366,
-0.01340041495859623,
0.034959159791469574,
-0.046230535954236984,
-0.01668342761695385,
-0.052063025534152985,
0.03644411638379097,
-0.07492782175540924,
0.03184611350297928,
0.009768527001142502,
0.012792117893695831,
0.0114950155839324,
-0.01191545557230711,
0.030540063977241516,
0.012022801674902439,
0.0347265750169754,
0.03202502429485321,
-0.04776916652917862,
0.0033366852439939976,
0.026943957433104515,
-0.042079806327819824,
0.033849913626909256,
0.03229339048266411,
0.029305579140782356,
-0.03760703653097153,
-0.008435641415417194,
0.01833835057914257,
0.008672698400914669,
0.003736998187378049,
0.03465501219034195,
-0.027963748201727867,
0.004723243415355682,
-0.01530581433326006,
-0.0655171126127243,
0.03517385199666023,
-0.01555628888309002,
0.0191255584359169,
0.03572847694158554,
0.024689681828022003,
-0.011870727874338627,
-0.037929076701402664,
0.033778347074985504,
0.06938158720731735,
-0.035692691802978516,
0.10555733740329742,
-0.06744935363531113,
0.0013709035702049732,
-0.08308614790439606,
0.048198554664850235,
0.06108012795448303,
0.03857315704226494,
0.056500013917684555,
0.09002788364887238,
0.0021156196016818285,
-0.02842891775071621,
-0.007567924447357655,
-0.01825784146785736,
-0.08716531097888947,
0.027802729979157448,
0.06938158720731735,
-0.04884263128042221,
0.05535498261451721,
-0.017622707411646843,
0.008650334551930428,
0.003819744335487485,
-0.008784517645835876,
0.0018002893775701523,
-0.006673370487987995,
0.032669100910425186,
0.00895895529538393,
-0.023634109646081924,
0.023616217076778412,
0.04490659758448601,
-0.010197912342846394,
0.1102805808186531,
-0.021326160058379173,
0.00981325376778841,
0.04061273857951164,
0.014625953510403633,
-0.024653900414705276,
0.03374256566166878,
-0.027265997603535652,
-0.005233139265328646,
-0.03656935691833496,
-0.040970560163259506,
0.05743034929037094,
0.01393714640289545,
0.06175998970866203,
-0.012112257070839405,
0.032096587121486664,
0.013078375719487667,
0.045729584991931915,
-0.05338696390390396,
-0.03279433771967888,
-0.0698467567563057,
-0.0356748029589653,
-0.00005566500112763606,
0.018275732174515724,
0.009911655448377132,
-0.012273277156054974,
-0.01424129493534565,
0.03739234432578087,
0.06891641765832901,
-0.03651568293571472,
0.01163814403116703,
0.04587271437048912,
-0.0051079015247523785,
0.05714409053325653,
-0.04279544949531555,
0.05367322266101837,
0.08451743423938751,
-0.01752430759370327,
-0.03739234432578087,
-0.009061829186975956,
-0.04032647982239723,
0.029180342331528664,
0.0317387655377388,
-0.03324161469936371,
-0.03342052549123764,
0.014608061872422695,
0.0001255869574379176,
-0.02764170989394188,
0.0037638347130268812,
-0.033849913626909256,
-0.008033092133700848,
-0.016585025936365128,
0.028572045266628265,
0.027069196105003357,
0.022006021812558174,
-0.008471423760056496,
0.015860436484217644,
0.039217233657836914,
-0.007397959008812904,
0.04193667694926262,
-0.013257285580039024,
-0.04111368954181671,
0.007715525571256876,
0.04973718523979187,
0.02994965761899948,
0.009008156135678291,
0.03660513833165169,
0.024045603349804878,
-0.034798137843608856,
0.07185055315494537,
-0.04104212298989296,
0.07700318098068237,
0.03885941207408905,
0.04240184649825096,
-0.039610836654901505,
-0.03139883652329445,
0.007433741353452206,
-0.046230535954236984,
0.02932346984744072,
0.018642500042915344,
-0.04970140382647514,
0.03089788556098938,
-0.052241936326026917,
0.02567369118332863,
-0.01323044952005148,
-0.015359487384557724,
0.0144112603738904,
0.0032539390958845615,
0.05796708166599274,
0.02209547720849514,
-0.007813926786184311,
-0.004875317681580782,
-0.017202267423272133,
-0.01978752762079239,
-0.0363546647131443,
0.02091466635465622,
0.023133158683776855,
0.0012356023071333766,
-0.022328060120344162,
0.06873750686645508,
-0.00034076906740665436,
0.08129703998565674,
0.02338363416492939,
-0.14048071205615997,
-0.010859882459044456,
-0.009093138389289379,
-0.030146460980176926,
-0.024600226432085037,
0.05567702278494835,
0.011834945529699326,
-0.008422222919762135,
-0.10412605106830597,
-0.02417084202170372,
-0.032096587121486664,
0.04043382778763771,
-0.010045838542282581,
0.014608061872422695,
-0.02411716803908348,
0.0016392696416005492,
0.06848703324794769,
-0.041578855365514755,
-0.0054567777551710606,
-0.028500480577349663,
0.005309176165610552,
-0.013391468673944473,
-0.01578887365758419,
-0.0025584236718714237,
0.03544221818447113,
0.01368667185306549,
0.0020887828432023525,
-0.017479579895734787,
0.026049403473734856,
0.0111550847068429,
-0.029341362416744232,
0.004870845004916191,
-0.015091121196746826,
-0.01382085494697094,
0.0029028267599642277,
0.06508772820234299,
-0.05052439495921135,
-0.04004022479057312,
0.017220158129930496,
-0.06540976464748383,
0.03585371375083923,
0.02871517464518547,
-0.04390469565987587,
-0.018928756937384605,
-0.01645084284245968,
-0.07643067091703415,
0.01592305675148964,
-0.02322261407971382,
-0.04036226496100426,
-0.0047724442556500435,
0.041185252368450165,
-0.03170298412442207,
-0.017229104414582253,
0.01413394883275032,
0.006812026724219322,
-0.015609961934387684,
0.006803080905228853,
0.06444364786148071,
0.049200452864170074,
0.08122547715902328,
0.02595994807779789,
0.011146139353513718,
-0.02782062068581581,
-0.018275732174515724,
0.016406115144491196,
-0.039682403206825256,
0.05231350287795067,
0.034243516623973846,
0.00048249991959892213,
-0.010394713841378689,
-0.004097056109458208,
0.013534598052501678,
0.04261653870344162,
-0.002706025028601289,
0.0320071317255497,
0.017640599980950356,
0.010716753080487251,
0.04458455741405487,
0.01676393672823906,
0.05217037349939346,
-0.011700762435793877,
-0.005085537675768137,
-0.0060114008374512196,
0.04894997924566269,
-0.08351553231477737,
-0.015833601355552673,
0.011342940852046013,
-0.012112257070839405,
-0.04322483390569687,
-0.028679391369223595,
0.018374133855104446,
-0.026836611330509186,
0.017560089007019997,
0.008909755386412144,
0.0038465808611363173,
-0.04934358224272728,
-0.03651568293571472,
0.004211111459881067,
-0.0005071001360192895,
-0.005045283120125532,
0.06641166657209396,
0.008744262158870697,
-0.015431051142513752,
0.06179577112197876,
0.01867828145623207,
0.014670681208372116,
-0.061259038746356964,
0.0028357352130115032,
-0.003799616824835539,
-0.039396144449710846,
0.039789747446775436,
-0.017703218385577202,
0.04759025573730469,
-0.021737655624747276,
-0.023508870974183083,
-0.009119975380599499,
-0.04555067420005798,
-0.0492362380027771,
0.010027946904301643,
-0.02579892985522747,
-0.01996643841266632,
0.024743355810642242,
-0.0030057004187256098,
-0.03433297201991081,
0.012997865676879883,
-0.06530242413282394,
-0.05159785971045494,
-0.020199023187160492,
-0.03095155768096447,
0.018588826060295105,
0.013436196371912956,
-0.02451077103614807,
0.0010186730651184916,
-0.011450287885963917,
-0.027069196105003357,
-0.026049403473734856,
-0.054639339447021484,
-0.06254719197750092,
0.021898675709962845,
-0.055605459958314896,
0.013561434112489223,
0.011826000176370144,
0.0008956718957051635,
-0.01671026274561882,
0.049987662583589554,
-0.022417515516281128,
-0.0706697404384613,
0.06337018311023712,
0.018660390749573708,
0.023705672472715378,
0.05149051174521446,
-0.0024533134419471025,
-0.029126668348908424,
-0.061437949538230896,
-0.01705019362270832,
-0.07363966107368469,
-0.06859438121318817,
0.05023813620209694,
-0.017900019884109497,
-0.016021456569433212,
0.00843116920441389,
-0.043940477073192596,
-0.05349431186914444,
0.032669100910425186,
0.005573069676756859,
0.02180922031402588,
0.03157774731516838,
-0.04175776615738869,
-0.05020235478878021,
-0.02114724926650524,
-0.02007378451526165,
0.057788170874118805,
0.009822200052440166,
-0.04021913558244705,
-0.007787090260535479,
0.04569380357861519,
-0.018928756937384605,
-0.010913555510342121,
0.02372356504201889,
0.0028737538959831,
-0.032114479690790176,
-0.06730622053146362,
0.0340467132627964,
0.025727365165948868,
0.024349752813577652,
-0.004065746441483498,
-0.07192211598157883,
0.004651679191738367,
-0.038215335458517075,
-0.0129531379789114,
-0.008650334551930428,
-0.03134516254067421,
0.028911976143717766,
-0.03488759323954582,
0.04759025573730469,
-0.023061593994498253,
0.01379401795566082,
0.0480196438729763,
-0.0006591742858290672,
-0.05170520395040512,
0.055426549166440964,
0.047912295907735825,
-0.032275497913360596,
-0.021165139973163605,
0.0043721310794353485,
-0.021845001727342606,
0.023813020437955856,
-0.0027216796297580004,
0.037929076701402664,
0.003479813924059272,
0.0004858544853050262,
0.03843002766370773,
-0.016093021258711815,
-0.05310070887207985,
-0.025101177394390106,
-0.051848333328962326,
-0.04165042191743851,
-0.018588826060295105,
0.011199812404811382,
-0.010001110844314098,
-0.01786423847079277,
-0.03195345774292946,
0.02114724926650524,
0.011137194000184536,
-0.038501590490341187,
-0.02282901108264923,
-0.03585371375083923,
0.030522173270583153,
-0.05288601666688919,
-0.017640599980950356,
-0.032830122858285904,
-0.03410038724541664,
-0.018141549080610275,
-0.03225760534405708,
0.02697974070906639,
-0.015431051142513752,
-0.0069641005247831345,
-0.01578887365758419,
0.036032624542713165,
0.019501270726323128,
-0.023419415578246117,
-0.06641166657209396,
-0.06820077449083328,
0.014679626561701298,
-0.003153301775455475,
-0.0114950155839324,
0.048699505627155304,
0.01726488582789898,
0.008149384520947933,
0.034851811826229095,
0.030969450250267982,
-0.0713496059179306,
-0.052349284291267395,
0.019089777022600174,
0.0039449818432331085,
0.01642400585114956,
-0.03365311026573181,
-0.02366989105939865,
0.03746391087770462,
0.001657160697504878,
-0.01031420473009348,
-0.05231350287795067,
0.011933346278965473,
0.014402315020561218,
-0.03263331949710846,
-0.03039693459868431,
-0.015225304290652275,
-0.013436196371912956,
-0.017542198300361633,
0.001302693854086101,
-0.0046829888597130775,
-0.03549589216709137,
-0.010269477032124996,
-0.02826789766550064,
0.0363546647131443,
-0.017166486009955406,
0.02359832637012005,
0.03767860308289528,
0.001203174702823162,
0.0633344054222107,
-0.024761246517300606,
0.03644411638379097,
-0.010627297684550285,
0.07442686706781387,
-0.02816055156290531,
0.032275497913360596,
-0.0064094774425029755,
0.007545560598373413,
-0.06451521068811417,
-0.012326950207352638,
0.057000961154699326,
-0.026550354436039925,
0.0184456966817379,
0.08931224048137665,
-0.00048082260764203966,
-0.024045603349804878,
0.04490659758448601,
-0.008243312127888203,
0.02579892985522747,
0.0329553596675396,
0.024206623435020447,
-0.03596105799078941,
0.04075586795806885,
-0.01320361252874136,
0.011199812404811382,
-0.06841547042131424,
-0.015520506538450718,
0.003951691091060638,
0.034690793603658676,
-0.024743355810642242,
-0.04673148691654205,
0.019662290811538696,
0.04422673583030701,
0.0569651797413826
]
|
30,446 | networkx.generators.community | caveman_graph | Returns a caveman graph of `l` cliques of size `k`.
Parameters
----------
l : int
Number of cliques
k : int
Size of cliques
Returns
-------
G : NetworkX Graph
caveman graph
Notes
-----
This returns an undirected graph, it can be converted to a directed
graph using :func:`nx.to_directed`, or a multigraph using
``nx.MultiGraph(nx.caveman_graph(l, k))``. Only the undirected version is
described in [1]_ and it is unclear which of the directed
generalizations is most useful.
Examples
--------
>>> G = nx.caveman_graph(3, 3)
See also
--------
connected_caveman_graph
References
----------
.. [1] Watts, D. J. 'Networks, Dynamics, and the Small-World Phenomenon.'
Amer. J. Soc. 105, 493-527, 1999.
| def _generate_communities(degree_seq, community_sizes, mu, max_iters, seed):
"""Returns a list of sets, each of which represents a community.
``degree_seq`` is the degree sequence that must be met by the
graph.
``community_sizes`` is the community size distribution that must be
met by the generated list of sets.
``mu`` is a float in the interval [0, 1] indicating the fraction of
intra-community edges incident to each node.
``max_iters`` is the number of times to try to add a node to a
community. This must be greater than the length of
``degree_seq``, otherwise this function will always fail. If
the number of iterations exceeds this value,
:exc:`~networkx.exception.ExceededMaxIterations` is raised.
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
The communities returned by this are sets of integers in the set {0,
..., *n* - 1}, where *n* is the length of ``degree_seq``.
"""
# This assumes the nodes in the graph will be natural numbers.
result = [set() for _ in community_sizes]
n = len(degree_seq)
free = list(range(n))
for i in range(max_iters):
v = free.pop()
c = seed.choice(range(len(community_sizes)))
# s = int(degree_seq[v] * (1 - mu) + 0.5)
s = round(degree_seq[v] * (1 - mu))
# If the community is large enough, add the node to the chosen
# community. Otherwise, return it to the list of unaffiliated
# nodes.
if s < community_sizes[c]:
result[c].add(v)
else:
free.append(v)
# If the community is too big, remove a node from it.
if len(result[c]) > community_sizes[c]:
free.append(result[c].pop())
if not free:
return result
msg = "Could not assign communities; try increasing min_community"
raise nx.ExceededMaxIterations(msg)
| (l, k, *, backend=None, **backend_kwargs) | [
-0.0020266559440642595,
0.025790462270379066,
-0.038897089660167694,
-0.01563420332968235,
0.005978865083307028,
0.05996328219771385,
-0.034080907702445984,
-0.04183826968073845,
0.053786806762218475,
-0.012159936130046844,
-0.019981633871793747,
0.019871339201927185,
-0.003292741486802697,
0.05128680542111397,
-0.010128684341907501,
0.015183835290372372,
0.010808832012116909,
-0.04128679633140564,
0.020772075280547142,
0.034117672592401505,
-0.011746332980692387,
-0.018538618460297585,
-0.011718759313225746,
0.016847439110279083,
-0.03610296919941902,
0.02696693316102028,
0.02281251735985279,
0.008322617039084435,
-0.05518386885523796,
-0.0011218988802284002,
-0.026139726862311363,
-0.015661777928471565,
-0.022205900400877,
-0.009880522266030312,
0.002688421169295907,
0.053272102028131485,
0.03718752786517143,
0.08338242024183273,
-0.013455892913043499,
-0.02441178448498249,
-0.01904413290321827,
-0.04915444925427437,
0.0064614019356667995,
-0.013933834619820118,
0.011351112276315689,
0.018897073343396187,
0.01271140668541193,
0.05577210336923599,
-0.06632357835769653,
-0.05022062733769417,
0.010670964606106281,
-0.036231644451618195,
0.03457723185420036,
0.0016337329288944602,
-0.026911785826086998,
0.012297803536057472,
0.0008323765941895545,
0.03856620565056801,
0.06525740772485733,
0.005165445152670145,
-0.014549643732607365,
-0.0023288161028176546,
0.017398910596966743,
-0.009770228527486324,
-0.06672799587249756,
0.0011333877919241786,
-0.06830887496471405,
-0.03915444388985634,
0.036893412470817566,
0.06345593184232712,
0.07430152595043182,
0.043713271617889404,
-0.0020312515553086996,
0.012656260281801224,
0.06996329128742218,
0.045330919325351715,
-0.00002805824260576628,
0.002823991235345602,
-0.005202210042625666,
-0.05816181004047394,
0.020422810688614845,
0.016847439110279083,
0.020845605060458183,
-0.010735302232205868,
0.06970594078302383,
-0.004283091519027948,
0.03382355719804764,
0.008345594629645348,
-0.009430154226720333,
-0.04661768302321434,
0.02272060699760914,
0.0018037698464468122,
0.042058855295181274,
-0.03612135350704193,
0.0007341458112932742,
0.0591544583439827,
-0.018115822225809097,
-0.03382355719804764,
0.036231644451618195,
-0.03485297039151192,
0.04621327295899391,
-0.0063832770101726055,
-0.06279416382312775,
0.020036781206727028,
-0.020900752395391464,
-0.055367689579725266,
0.0011052398476749659,
0.0027941197622567415,
-0.002265626797452569,
-0.03329046815633774,
-0.07544123381376266,
0.045404449105262756,
0.05437504127621651,
-0.0049218786880373955,
0.01086397934705019,
-0.0014464625855907798,
-0.005767467897385359,
0.009549640119075775,
0.01377758476883173,
0.007320777978748083,
-0.041102971881628036,
0.0311764944344759,
-0.0217647235840559,
0.025643402710556984,
0.014338246546685696,
0.009315264411270618,
0.028290463611483574,
0.011194861494004726,
0.03220590949058533,
-0.022904429584741592,
0.021507369354367256,
-0.016121337190270424,
0.005409011617302895,
0.020477958023548126,
-0.0035133298952132463,
-0.042058855295181274,
-0.10330890864133835,
-0.03654414787888527,
0.04834562540054321,
0.0060937548987567425,
-0.012628686614334583,
-0.027628697454929352,
-0.017104793339967728,
0.04408091679215431,
0.009485301561653614,
0.041580915451049805,
0.01082721445709467,
-0.020404428243637085,
0.00528033496811986,
0.008249087259173393,
0.044191211462020874,
-0.004641547799110413,
-0.012444863095879555,
-0.045330919325351715,
-0.031562525779008865,
-0.0062270271591842175,
-0.01702207140624523,
-0.029871346428990364,
-0.002095589879900217,
0.01965075172483921,
-0.024154430255293846,
0.025036783888936043,
-0.026213256642222404,
0.05125004053115845,
-0.009071698412299156,
-0.03711399808526039,
0.060698576271533966,
-0.01689339615404606,
-0.06183828413486481,
-0.027242667973041534,
-0.0111489063128829,
-0.029246347025036812,
-0.03797797113656998,
-0.0584559291601181,
0.030386053025722504,
-0.04893386363983154,
0.02011030912399292,
0.00019473821157589555,
-0.03856620565056801,
0.010689347051084042,
-0.03586399927735329,
-0.009136036969721317,
-0.015119497664272785,
-0.02125001698732376,
-0.0037477051373571157,
0.052242688834667206,
0.05448533594608307,
-0.007375924848020077,
0.05511033907532692,
-0.040514737367630005,
-0.04437503591179848,
-0.04279415309429169,
-0.0509926863014698,
0.07713241130113602,
-0.0012925101909786463,
0.014558834955096245,
-0.024632371962070465,
0.02854781597852707,
-0.10632361471652985,
0.028419140726327896,
0.007182910107076168,
0.022518400102853775,
0.005583643913269043,
-0.04937503859400749,
0.03555149957537651,
-0.022481635212898254,
-0.03404414281249046,
-0.030275758355855942,
0.05128680542111397,
0.03242649510502815,
0.014310672879219055,
-0.02433825470507145,
0.07838241755962372,
0.021580899134278297,
0.015119497664272785,
-0.03981620818376541,
0.01792280748486519,
0.00384421250782907,
-0.014586408622562885,
-0.04937503859400749,
-0.0013039992190897465,
-0.029963258653879166,
0.0570221021771431,
-0.03165443614125252,
0.022095605731010437,
-0.03450370207428932,
-0.015836410224437714,
-0.051102980971336365,
-0.04198532551527023,
-0.01136949472129345,
0.0634191706776619,
-0.039411794394254684,
0.024172812700271606,
-0.00006523586489493027,
-0.022518400102853775,
-0.0169669259339571,
0.016525749117136,
-0.006318938918411732,
-0.02391546033322811,
0.044227976351976395,
-0.08639712631702423,
-0.015431997366249561,
0.02389707788825035,
0.017187513411045074,
0.036250028759241104,
0.0550735741853714,
-0.00790441781282425,
-0.0025735313538461924,
-0.020477958023548126,
0.02705884538590908,
-0.02112133987247944,
-0.06658093631267548,
-0.027352962642908096,
-0.06580887734889984,
0.039448559284210205,
-0.07415447384119034,
-0.056433867663145065,
0.007270226255059242,
0.011452214792370796,
-0.02536766789853573,
-0.028805170208215714,
-0.031084584072232246,
-0.04610297828912735,
0.07867652922868729,
0.005248165689408779,
-0.033125028014183044,
0.0018520235316827893,
0.07242652773857117,
-0.0700000524520874,
0.006985299754887819,
0.040036797523498535,
0.050661806017160416,
0.04911768436431885,
-0.010395228862762451,
0.0007324224570766091,
-0.013079054653644562,
-0.018786778673529625,
0.008694860152900219,
0.012270229868590832,
0.05363974720239639,
0.011029420420527458,
0.042169149965047836,
-0.03711399808526039,
-0.0018899372080340981,
-0.0021093767136335373,
0.01879597082734108,
-0.024246342480182648,
-0.020955899730324745,
-0.007881440222263336,
-0.01274817157536745,
-0.002433365909382701,
-0.02018383890390396,
-0.0029756457079201937,
-0.0032284033950418234,
0.042610328644514084,
0.010229787789285183,
0.03490811586380005,
0.01877758838236332,
0.026691198348999023,
0.03398899734020233,
0.04702209681272507,
-0.041029445827007294,
-0.03724267706274986,
-0.004195775371044874,
0.03707723692059517,
-0.015119497664272785,
-0.004379598889499903,
-0.049632392823696136,
0.016498174518346786,
0.03556988015770912,
-0.04025738313794136,
-0.012683833949267864,
0.04676474258303642,
0.029246347025036812,
0.029485316947102547,
0.004106161184608936,
0.016525749117136,
-0.025000018998980522,
0.026691198348999023,
0.07143387943506241,
-0.013593760319054127,
-0.0024954064283519983,
-0.020827222615480423,
0.003382355673238635,
-0.05463239550590515,
-0.010450376197695732,
-0.02599266730248928,
0.041654445230960846,
-0.0021128233056515455,
-0.008818941190838814,
-0.0570221021771431,
-0.03867650032043457,
0.04878680408000946,
0.04669121280312538,
-0.010477949865162373,
0.036305174231529236,
0.07257358729839325,
-0.0700000524520874,
0.04930150881409645,
-0.07786770910024643,
0.020257368683815002,
-0.007279417477548122,
-0.07011035084724426,
-0.005647982470691204,
0.0010552627500146627,
-0.007398902904242277,
0.034191202372312546,
-0.017472440376877785,
-0.04356621205806732,
-0.018933838233351707,
0.022628694772720337,
0.1016177237033844,
0.012205892242491245,
0.07253681868314743,
0.004223349038511515,
0.11029420793056488,
-0.005468754097819328,
-0.028750022873282433,
0.01805148459970951,
0.02867649309337139,
-0.053308866918087006,
-0.006024820730090141,
0.08264712244272232,
0.027665462344884872,
-0.038897089660167694,
-0.004648440983146429,
-0.009053315967321396,
0.005147062707692385,
0.08845595270395279,
-0.07625006139278412,
-0.004733459558337927,
-0.01593751274049282,
-0.04492650553584099,
0.030367670580744743,
-0.039007384330034256,
0.008662690408527851,
-0.1152942106127739,
0.01572611555457115,
-0.02178310602903366,
0.0006054692203179002,
-0.03404414281249046,
-0.022665459662675858,
0.0337500274181366,
0.03959561884403229,
0.00409007677808404,
-0.05338239669799805,
0.05514710396528244,
0.020441193133592606,
0.00204733619466424,
0.025533108040690422,
-0.031029436737298965,
-0.007771146018058062,
0.018970603123307228,
0.04617650806903839,
0.007876844145357609,
0.01377758476883173,
0.07029417157173157,
-0.007835484109818935,
-0.05867651849985123,
0.033602967858314514,
0.0360662043094635,
-0.0021243123337626457,
0.010726111009716988,
0.05305151268839836,
-0.034613996744155884,
-0.022959576919674873,
0.032003700733184814,
0.01377758476883173,
0.014154423028230667,
0.03797797113656998,
-0.07327211648225784,
-0.0066498215310275555,
0.046838272362947464,
-0.04294120892882347,
-0.04286767914891243,
-0.06441181898117065,
-0.03345590829849243,
0.02854781597852707,
0.10705890506505966,
-0.012886039912700653,
0.09595596045255661,
-0.06091916561126709,
0.055955927819013596,
0.014136040583252907,
-0.003952208906412125,
-0.03496326133608818,
0.02384193055331707,
-0.04768386110663414,
-0.04194856435060501,
-0.01719670556485653,
-0.032573554664850235,
0.004329047631472349,
0.07308829575777054,
-0.06569857895374298,
0.04257356375455856,
-0.01302390731871128,
-0.014641555957496166,
0.016847439110279083,
-0.02972428873181343,
-0.004264709074050188,
0.08904419094324112,
0.017362145707011223,
-0.004774820059537888,
-0.02757355198264122,
0.05194856971502304,
0.015183835290372372,
-0.020294133573770523,
-0.009917287155985832,
-0.0153676588088274,
0.03301473334431648,
0.04783092066645622,
-0.009944860823452473,
0.022003693506121635,
0.004308367148041725,
0.0013338705757632852,
0.039522089064121246,
0.0593382827937603,
0.0222978126257658,
-0.04944856837391853,
-0.010468758642673492,
0.09544125199317932,
-0.0321507602930069,
-0.020827222615480423,
0.06628681719303131,
-0.011691185645759106,
0.04944856837391853,
-0.002872244920581579,
-0.004990812856703997,
0.011645229533314705,
-0.0011891094036400318,
0.0339338518679142,
0.02963237650692463,
-0.03014708310365677,
-0.07227946817874908,
-0.028290463611483574,
-0.03674635291099548,
-0.07750006020069122,
0.008795962668955326,
-0.015312512405216694,
-0.006222431547939777,
-0.01570773310959339,
-0.005197614431381226,
0.060698576271533966,
-0.009512875229120255,
-0.03922797366976738,
-0.04893386363983154,
-0.0016957734478637576,
-0.036819882690906525,
-0.011443023569881916,
0.012132362462580204,
-0.01616729237139225,
-0.09139712899923325,
0.014025745913386345,
0.005174636375159025,
0.03704047203063965,
0.009926478378474712,
0.0019312974764034152,
-0.02648899145424366,
0.036231644451618195,
-0.005431989673525095,
0.015110306441783905,
0.04676474258303642,
0.03165443614125252,
-0.03604782372713089,
0.056948576122522354,
0.015909938141703606,
0.02121325209736824,
-0.045735329389572144,
-0.05051474645733833,
0.0017670050729066133,
0.01567096821963787,
0.00048512217472307384,
-0.0010851341066882014,
-0.022683842107653618,
0.02816178649663925,
0.020514722913503647,
0.04933827370405197,
0.032003700733184814,
0.022610312327742577,
-0.0064430199563503265,
0.02071692794561386,
0.04709562659263611,
-0.02321692928671837,
0.09330889582633972,
-0.017389720305800438,
0.000041611649066908285,
-0.018170969560742378,
-0.04551474004983902,
-0.02110295742750168,
0.01742648519575596,
-0.025772079825401306,
0.010974273085594177,
-0.03886032477021217,
0.0572059266269207,
0.023713253438472748,
-0.022702224552631378,
-0.011277582496404648,
0.025845607742667198,
0.05231621861457825,
0.011847435496747494,
-0.02224266529083252,
-0.016525749117136,
0.04485297575592995,
0.010027581825852394,
0.0010437738383188844,
0.03121325932443142,
0.028455905616283417,
0.02058825083076954,
0.004875923041254282,
-0.03722429275512695,
-0.0422794446349144,
0.042058855295181274,
-0.03330884873867035,
-0.012840083800256252,
0.08992654085159302,
-0.041066210716962814,
-0.03955885395407677,
-0.04988974705338478,
0.03852944076061249,
0.07080888003110886,
0.007564343977719545,
-0.028400758281350136,
-0.06746328622102737,
-0.005381437949836254,
0.036838263273239136,
0.011718759313225746,
-0.016369497403502464,
-0.04143385589122772,
0.008221513591706753,
0.0033984400797635317,
0.01782170496881008,
-0.010128684341907501,
-0.03654414787888527,
0.006328130140900612,
-0.009990816935896873,
-0.03121325932443142,
-0.04676474258303642,
-0.01795957237482071,
0.010753684677183628,
-0.01010111067444086,
-0.022867664694786072,
0.022132370620965958,
0.07573535293340683,
-0.03501841053366661,
0.04194856435060501,
0.045882388949394226,
-0.09117653965950012,
-0.040477972477674484,
0.021231634542346,
0.03875003010034561,
0.02806987427175045,
0.0031847450882196426,
-0.02178310602903366,
-0.010422802530229092,
-0.0676838755607605,
-0.0013051481219008565,
0.011626847088336945,
-0.008014712482690811,
-0.028272081166505814,
-0.03551473468542099,
-0.05610298365354538,
0.026213256642222404,
0.003984378185123205,
0.055992692708969116,
0.027830904349684715,
-0.013612142764031887,
-0.04863974452018738,
-0.03272061422467232,
0.012334568426012993,
0.03080884739756584,
-0.043750032782554626,
0.02279413491487503,
-0.014990820549428463,
-0.06871329247951508,
-0.003044579643756151,
-0.03845591098070145,
-0.025220608338713646,
0.006930152419954538,
0.019503692165017128,
-0.051617689430713654,
0.023198546841740608,
-0.00020536550437100232,
0.006631439086049795,
-0.02128678187727928,
-0.016231629997491837,
0.025000018998980522,
-0.023051489144563675,
-0.0021185679361224174,
0.02218751795589924,
0.029981641098856926,
-0.003173256292939186,
-0.011001846753060818,
0.03911767899990082,
-0.020863987505435944,
0.024080900475382805,
-0.028437523171305656,
0.024209577590227127,
0.0025298732798546553,
0.010156258009374142,
-0.005510114599019289,
-0.0201654564589262,
0.045257389545440674,
-0.01772979274392128,
-0.07669124007225037,
-0.10661773383617401,
-0.0010948997223749757,
0.03299634903669357,
0.05136033520102501,
0.0006353405769914389,
0.020477958023548126,
0.007054233457893133,
-0.0006175326416268945,
0.054779455065727234,
-0.05389710143208504,
0.014751849696040154,
-0.02856619842350483,
-0.035735324025154114,
0.02854781597852707,
0.04297797381877899,
-0.048970628529787064,
0.02976105362176895,
0.04433827102184296,
0.060588281601667404,
-0.004659930244088173,
0.008704051375389099,
0.022996341809630394,
0.01858457364141941,
-0.013318025507032871,
-0.027959581464529037,
0.03805150091648102,
-0.045367684215307236,
-0.012775745242834091,
0.06514710932970047,
-0.01668199896812439,
-0.03704047203063965,
0.04191179946064949,
-0.04125003144145012,
0.014494496397674084,
-0.03812503069639206,
0.04073532670736313,
0.02750002220273018,
0.02338237129151821,
-0.034779440611600876,
-0.0003578817122615874,
-0.006842836271971464,
-0.005588239524513483,
-0.034816205501556396,
-0.053308866918087006,
-0.011865817941725254,
0.005831805989146233,
0.009076293557882309,
-0.010680155828595161,
-0.005133276339620352,
-0.02545957826077938,
-0.02808825671672821,
0.045294154435396194,
-0.033621348440647125,
0.000044268475903663784,
0.005450372118502855,
0.0135478051379323,
0.05569857358932495,
0.028308846056461334,
-0.008639712817966938,
0.046323567628860474,
-0.02181987091898918,
-0.024154430255293846,
-0.03955885395407677,
0.05360298231244087,
0.028915464878082275,
0.011636038310825825,
-0.02073531039059162,
-0.008736220188438892,
0.00009823077562032267,
0.006631439086049795,
-0.03762870654463768,
-0.022610312327742577,
0.02444854937493801,
0.09919125586748123,
-0.012545965611934662,
-0.007481623440980911,
0.009825375862419605,
0.020459575578570366,
0.03391546756029129,
-0.002433365909382701,
-0.06099269539117813,
-0.020496340468525887,
0.05415445566177368,
-0.027702227234840393,
0.03830885514616966,
-0.02816178649663925,
-0.028970610350370407,
0.08117653429508209,
-0.02435663715004921,
0.04279415309429169,
-0.009439345449209213,
-0.05680151656270027,
-0.018446706235408783,
0.02586399018764496,
-0.04702209681272507,
0.0032238077837973833,
-0.06665446609258652,
0.009788610972464085,
-0.040514737367630005,
0.008469675667583942,
-0.023584578186273575,
-0.0275367870926857,
0.043750032782554626,
0.009963243268430233,
-0.006121328566223383,
-0.020937517285346985,
0.007136953994631767,
-0.002277115825563669,
0.02380516566336155,
0.007711403071880341,
-0.04647062346339226,
-0.036856647580862045,
0.003556988202035427,
-0.05422798544168472,
-0.05415445566177368,
-0.07573535293340683,
-0.006810666993260384,
0.012573539279401302,
-0.0063832770101726055,
-0.002851564669981599,
-0.008042286150157452,
0.04117650166153908,
0.040000032633543015,
0.023033106699585915
]
|
30,448 | networkx.algorithms.distance_measures | center | Returns the center of the graph G.
The center is the set of nodes with eccentricity equal to radius.
Parameters
----------
G : NetworkX graph
A graph
e : eccentricity dictionary, optional
A precomputed dictionary of eccentricities.
weight : string, function, or None
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number.
If this is None, every edge has weight/distance/cost 1.
Weights stored as floating point values can lead to small round-off
errors in distances. Use integer weights to avoid this.
Weights should be positive, since they are distances.
Returns
-------
c : list
List of nodes in center
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> list(nx.center(G))
[1, 3, 4]
See Also
--------
barycenter
periphery
| def effective_graph_resistance(G, weight=None, invert_weight=True):
"""Returns the Effective graph resistance of G.
Also known as the Kirchhoff index.
The effective graph resistance is defined as the sum
of the resistance distance of every node pair in G [1]_.
If weight is not provided, then a weight of 1 is used for all edges.
The effective graph resistance of a disconnected graph is infinite.
Parameters
----------
G : NetworkX graph
A graph
weight : string or None, optional (default=None)
The edge data key used to compute the effective graph resistance.
If None, then each edge has weight 1.
invert_weight : boolean (default=True)
Proper calculation of resistance distance requires building the
Laplacian matrix with the reciprocal of the weight. Not required
if the weight is already inverted. Weight cannot be zero.
Returns
-------
RG : float
The effective graph resistance of `G`.
Raises
------
NetworkXNotImplemented
If `G` is a directed graph.
NetworkXError
If `G` does not contain any nodes.
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> round(nx.effective_graph_resistance(G), 10)
10.25
Notes
-----
The implementation is based on Theorem 2.2 in [2]_. Self-loops are ignored.
Multi-edges are contracted in one edge with weight equal to the harmonic sum of the weights.
References
----------
.. [1] Wolfram
"Kirchhoff Index."
https://mathworld.wolfram.com/KirchhoffIndex.html
.. [2] W. Ellens, F. M. Spieksma, P. Van Mieghem, A. Jamakovic, R. E. Kooij.
Effective graph resistance.
Lin. Alg. Appl. 435:2491-2506, 2011.
"""
import numpy as np
if len(G) == 0:
raise nx.NetworkXError("Graph G must contain at least one node.")
# Disconnected graphs have infinite Effective graph resistance
if not nx.is_connected(G):
return float("inf")
# Invert weights
G = G.copy()
if invert_weight and weight is not None:
if G.is_multigraph():
for u, v, k, d in G.edges(keys=True, data=True):
d[weight] = 1 / d[weight]
else:
for u, v, d in G.edges(data=True):
d[weight] = 1 / d[weight]
# Get Laplacian eigenvalues
mu = np.sort(nx.laplacian_spectrum(G, weight=weight))
# Compute Effective graph resistance based on spectrum of the Laplacian
# Self-loops are ignored
return float(np.sum(1 / mu[1:]) * G.number_of_nodes())
| (G, e=None, usebounds=False, weight=None, *, backend=None, **backend_kwargs) | [
0.05050341412425041,
-0.01460190862417221,
0.002688575303182006,
0.05920565873384476,
0.05627957731485367,
-0.009362512268126011,
-0.03188289329409599,
-0.049477383494377136,
0.10077881813049316,
-0.008711744099855423,
0.03178789094090462,
-0.00025027262745425105,
0.015181425027549267,
-0.0045506274327635765,
-0.0597376711666584,
0.04510726407170296,
-0.057001594454050064,
0.0002977739495690912,
-0.005847413558512926,
0.046361297369003296,
0.0052963984198868275,
-0.10412291437387466,
-0.003640976967290044,
0.060573697090148926,
-0.027987783774733543,
0.007414957508444786,
0.020349569618701935,
0.013442876748740673,
-0.0035554745700210333,
0.0004773883556481451,
-0.006654936354607344,
-0.05027540773153305,
-0.02329465188086033,
-0.006521932780742645,
0.022876640781760216,
0.023807667195796967,
0.007091948762536049,
0.007742716930806637,
-0.09257058799266815,
-0.05354350060224533,
-0.011514321900904179,
0.033858947455883026,
0.03212989866733551,
-0.02663874626159668,
0.03323192894458771,
0.017765497788786888,
-0.003809606656432152,
0.018905529752373695,
-0.030400851741433144,
-0.03906509280204773,
0.025840723887085915,
-0.010934806428849697,
-0.046209294348955154,
0.009115505032241344,
0.0019618049263954163,
0.03342193737626076,
0.02604972943663597,
0.054113514721393585,
0.029184816405177116,
-0.07300004363059998,
0.011105811223387718,
-0.08056225627660751,
0.027702774852514267,
0.01686297170817852,
-0.06129571422934532,
0.014962919056415558,
-0.019684551283717155,
-0.00551015418022871,
0.008022974245250225,
0.01382288709282875,
-0.029108814895153046,
-0.0022598758805543184,
0.02608773112297058,
-0.06821191310882568,
0.018744025379419327,
0.026429740712046623,
0.023883668705821037,
-0.013243370689451694,
-0.026885753497481346,
-0.0140983946621418,
0.03176888823509216,
-0.01316736824810505,
0.046323295682668686,
-0.03650002181529999,
0.025441711768507957,
-0.0372980460524559,
0.01105831004679203,
-0.01658746413886547,
0.0259737279266119,
-0.031521882861852646,
-0.006773689761757851,
0.026030728593468666,
0.03380194678902626,
0.037450049072504044,
0.07322805374860764,
0.0010616547660902143,
-0.04989539831876755,
-0.07349405437707901,
0.07071997970342636,
-0.022059617564082146,
-0.013347873464226723,
0.08641441911458969,
-0.018098006024956703,
0.005229896400123835,
0.028690803796052933,
-0.046057287603616714,
-0.01536193024367094,
-0.03435296192765236,
0.05358149856328964,
-0.03119887411594391,
-0.05631757527589798,
0.021717607975006104,
0.016596965491771698,
-0.013699383474886417,
-0.03613901138305664,
0.04514526203274727,
-0.016872473061084747,
0.01526692695915699,
0.0593576617538929,
0.027664775028824806,
0.013148368336260319,
0.03220590204000473,
-0.017698995769023895,
-0.0010082157095894217,
0.010744800791144371,
0.021755609661340714,
0.009562017396092415,
0.0013478501932695508,
-0.011875332333147526,
0.022021615877747536,
0.049249377101659775,
0.00007481459761038423,
0.025213705375790596,
0.04848935827612877,
0.02737976610660553,
0.009842275641858578,
-0.007728466298431158,
0.037488050758838654,
0.06722388416528702,
0.020748581737279892,
-0.010421792045235634,
-0.02329465188086033,
0.023199649527668953,
0.051187433302402496,
0.03176888823509216,
0.008345983922481537,
0.017385486513376236,
0.03955910727381706,
0.039863117039203644,
-0.0028168288990855217,
0.026239734143018723,
-0.014012892730534077,
0.04389122873544693,
-0.010982307605445385,
0.009671270847320557,
0.017280984669923782,
-0.014345401898026466,
0.013860887847840786,
-0.0404331311583519,
-0.03480897471308708,
-0.07429207861423492,
-0.030704859644174576,
0.04016712307929993,
-0.021793609485030174,
0.013860887847840786,
-0.02726576291024685,
0.049515385180711746,
0.015599437057971954,
-0.0649058148264885,
0.028253791853785515,
-0.04510726407170296,
-0.05164344608783722,
-0.03399195149540901,
-0.03872308507561684,
0.03045785240828991,
0.08542639017105103,
0.026619745418429375,
-0.014620909467339516,
0.012160340324044228,
0.0235606599599123,
-0.014962919056415558,
-0.058711644262075424,
-0.0018086131894961,
-0.021508602425456047,
0.028918810188770294,
0.04503126069903374,
0.03461897000670433,
-0.004811884835362434,
0.004662255756556988,
0.00047798213199712336,
0.008203479461371899,
-0.041497163474559784,
0.02538471110165119,
0.0289378110319376,
0.02905181422829628,
-0.014924918301403522,
0.03585400432348251,
0.018354514613747597,
-0.034789975732564926,
0.07056797295808792,
0.029070813208818436,
-0.0009963404154404998,
0.03735504671931267,
0.032034896314144135,
0.005581406410783529,
0.011305316351354122,
-0.00924850907176733,
-0.02901381254196167,
-0.008236730471253395,
0.009984779171645641,
-0.0667678713798523,
0.00509214261546731,
0.0056099072098731995,
-0.03496097773313522,
-0.024244679138064384,
0.02998283877968788,
-0.02648674137890339,
0.008925500325858593,
0.01370888389647007,
-0.06406979262828827,
-0.05475953221321106,
-0.010060781612992287,
-0.009842275641858578,
-0.013072365894913673,
0.044537246227264404,
-0.049287378787994385,
0.022382626309990883,
0.000094705777883064,
0.01421239785850048,
0.007096698507666588,
0.0545315258204937,
0.0031350876670330763,
0.0790422111749649,
-0.051263436675071716,
0.014316900633275509,
-0.021128591150045395,
-0.05981367453932762,
0.07250603288412094,
0.052441466599702835,
0.0411931537091732,
-0.03570200130343437,
-0.06281575560569763,
-0.04282720014452934,
0.058901648968458176,
-0.036310017108917236,
-0.037013035267591476,
0.013851387426257133,
0.001788425026461482,
0.028519798070192337,
0.009001501835882664,
-0.0879344642162323,
-0.06794590502977371,
-0.014050893485546112,
-0.023199649527668953,
0.02760777249932289,
-0.01100130844861269,
-0.08519838750362396,
0.016558963805437088,
-0.018098006024956703,
-0.027322765439748764,
0.014535406604409218,
-0.008360234089195728,
-0.07227802276611328,
-0.004586253315210342,
-0.04829935356974602,
0.010089282877743244,
0.0004114802577532828,
0.010250787250697613,
-0.025517715141177177,
0.05076942220330238,
0.04499325901269913,
0.010345789603888988,
0.013613881543278694,
-0.00948126520961523,
-0.004897387232631445,
0.02014056406915188,
0.02118559367954731,
0.044613249599933624,
-0.005115893203765154,
0.036348018795251846,
-0.08443836122751236,
0.0016031698323786259,
-0.007661964278668165,
0.024472685530781746,
-0.057001594454050064,
0.017394987866282463,
-0.009239008650183678,
-0.0563935786485672,
0.023161647841334343,
-0.00903475284576416,
0.09249459207057953,
0.007742716930806637,
0.0035958506632596254,
0.003405845258384943,
0.07376006245613098,
0.01045979280024767,
-0.013908389024436474,
-0.04829935356974602,
0.016340456902980804,
0.06957995146512985,
0.043169207870960236,
-0.024358682334423065,
0.004624254535883665,
-0.049287378787994385,
0.055557556450366974,
0.04073714092373848,
0.03484697639942169,
-0.0001445821690140292,
0.017261983826756477,
0.05783762037754059,
-0.09614269435405731,
0.004944888409227133,
-0.043093208223581314,
0.022800637409090996,
-0.052555471658706665,
-0.029659830033779144,
0.05004740133881569,
-0.027284763753414154,
0.02010256238281727,
0.025631718337535858,
0.016074450686573982,
0.09705471992492676,
0.014440404251217842,
0.0387800857424736,
-0.07117599248886108,
-0.002365566324442625,
0.019912557676434517,
0.07820618897676468,
0.07942222058773041,
-0.049439385533332825,
-0.04282720014452934,
0.01838301494717598,
-0.010288788005709648,
0.0047335075214505196,
-0.041459161788225174,
0.04225718230009079,
0.10951906442642212,
-0.033858947455883026,
-0.027911782264709473,
-0.029507827013731003,
0.027778778225183487,
0.004241868853569031,
-0.005367650184780359,
-0.0026671995874494314,
-0.00512064341455698,
0.019333040341734886,
0.01705297827720642,
-0.027398766949772835,
-0.03480897471308708,
-0.05308748781681061,
-0.012882360257208347,
0.003909359220415354,
-0.031958892941474915,
0.02682875096797943,
-0.016767969354987144,
0.04556327685713768,
-0.01172332838177681,
-0.047995343804359436,
0.02196461521089077,
0.02375066466629505,
-0.10359089821577072,
0.006384178530424833,
-0.028633801266551018,
-0.019418543204665184,
-0.006906693335622549,
0.012122339569032192,
-0.01643545925617218,
0.017204981297254562,
0.018259510397911072,
-0.04096514731645584,
-0.002365566324442625,
-0.0820062980055809,
-0.07737016677856445,
0.004840385634452105,
0.010915805585682392,
0.037564050406217575,
-0.03399195149540901,
-0.0211475919932127,
-0.01573244109749794,
-0.006379428785294294,
0.009144006296992302,
0.019333040341734886,
-0.044499244540929794,
0.011153312399983406,
0.044765252619981766,
-0.012720855884253979,
0.04894537106156349,
0.004039987921714783,
0.02422567829489708,
-0.0032609663903713226,
-0.04183917120099068,
-0.027550771832466125,
0.06764189153909683,
-0.010830303654074669,
-0.04343521595001221,
0.03477097302675247,
0.061789728701114655,
0.02831079252064228,
-0.04582928121089935,
-0.01421239785850048,
-0.046095289289951324,
-0.007799718528985977,
-0.02141360007226467,
0.008630991913378239,
-0.02667674608528614,
0.015048420988023281,
0.0076667144894599915,
0.04351121932268143,
0.044651251286268234,
0.01441190391778946,
-0.049591388553380966,
0.015675438567996025,
0.013509377837181091,
0.004265619441866875,
-0.01970355212688446,
-0.020121563225984573,
-0.013138867914676666,
0.0023465657141059637,
0.03695603460073471,
0.029925838112831116,
0.02137559838593006,
-0.029659830033779144,
0.07512810081243515,
-0.005980417598038912,
0.022648634389042854,
-0.04670330882072449,
0.00008602193702245131,
-0.020026560872793198,
-0.06646385788917542,
0.054075513035058975,
-0.023826666176319122,
0.0016684841830283403,
0.018924530595541,
-0.031293876469135284,
0.00020692766702268273,
-0.002209999365732074,
0.018003003671765327,
0.01760399341583252,
-0.02010256238281727,
-0.03731704503297806,
0.04016712307929993,
0.01222684234380722,
0.027759777382016182,
-0.04818534851074219,
-0.003346468787640333,
-0.06281575560569763,
-0.006930443923920393,
-0.000914400618057698,
-0.005267897620797157,
-0.03165488690137863,
0.0054911538027226925,
-0.04434724152088165,
0.026695746928453445,
0.028804806992411613,
-0.11704327911138535,
0.029184816405177116,
-0.03714603930711746,
-0.013993891887366772,
-0.06809790432453156,
0.025593716651201248,
0.016216954216361046,
0.03157888352870941,
-0.009096505120396614,
-0.02998283877968788,
-0.01958954893052578,
-0.032927922904491425,
0.007818718440830708,
-0.015570935793220997,
-0.027170760557055473,
-0.021166592836380005,
0.04902137070894241,
-0.020159564912319183,
-0.020007560029625893,
-0.043245211243629456,
0.05650758370757103,
0.012549851089715958,
-0.0912785530090332,
-0.011875332333147526,
0.006227424368262291,
-0.04419523850083351,
-0.020083561539649963,
0.02017856575548649,
0.055633556097745895,
0.023902669548988342,
0.02088158391416073,
-0.0393311008810997,
-0.003954485524445772,
-0.005776161793619394,
0.019855555146932602,
-0.04187717288732529,
-0.015570935793220997,
0.03165488690137863,
0.025631718337535858,
0.012074838392436504,
0.0006828316254541278,
-0.004695506300777197,
0.01228384394198656,
0.0046266294084489346,
0.032775916159152985,
0.014383402653038502,
-0.026410739868879318,
-0.031445879489183426,
-0.015371430665254593,
0.04848935827612877,
0.036937035620212555,
0.03165488690137863,
-0.03860908001661301,
0.007714216131716967,
0.08960650861263275,
0.035340990871191025,
-0.014050893485546112,
0.019143035635352135,
0.07414007931947708,
0.0475013293325901,
0.011846831999719143,
-0.026239734143018723,
-0.036519020795822144,
0.05434152111411095,
0.06524782627820969,
-0.02846279740333557,
-0.01884852722287178,
0.02422567829489708,
0.0005765474052168429,
-0.0018810526235029101,
-0.01678697019815445,
0.008992001414299011,
-0.004419998731464148,
-0.07748416811227798,
-0.0021779360249638557,
-0.015352429822087288,
-0.014383402653038502,
0.019969558343291283,
-0.019447043538093567,
0.0471213199198246,
-0.00040999584598466754,
-0.007799718528985977,
-0.01864902302622795,
-0.04202917590737343,
-0.10222285985946655,
-0.011846831999719143,
-0.015494933351874352,
0.0030353348702192307,
0.014677911065518856,
0.011305316351354122,
0.08246231079101562,
0.020387571305036545,
0.0012374096550047398,
0.002453443594276905,
-0.022496629506349564,
-0.07071997970342636,
-0.044841255992650986,
0.02831079252064228,
-0.020824583247303963,
-0.033858947455883026,
0.061941735446453094,
0.03680403158068657,
-0.05016140267252922,
0.004477000329643488,
0.025422710925340652,
-0.017632493749260902,
-0.016596965491771698,
-0.08732644468545914,
-0.01810750737786293,
-0.06292976438999176,
0.006445930339396,
-0.04039512947201729,
0.032376907765865326,
-0.024985698983073235,
-0.04503126069903374,
0.033934950828552246,
-0.03176888823509216,
0.03245290741324425,
0.07835819572210312,
0.004446124657988548,
-0.0065314327366650105,
-0.01331937313079834,
0.025289708748459816,
-0.06315776705741882,
0.035150982439517975,
-0.06353777647018433,
-0.012711355462670326,
-0.06106770783662796,
0.016368959099054337,
0.04123115539550781,
0.017157480120658875,
0.041649166494607925,
-0.016767969354987144,
0.05346749722957611,
-0.03855207934975624,
-0.01460190862417221,
-0.02433968149125576,
-0.057343605905771255,
0.03828607127070427,
0.0035174735821783543,
-0.0019499296322464943,
-0.03349793702363968,
-0.022059617564082146,
0.008003974333405495,
0.04598128795623779,
0.003222965169698,
-0.05206145718693733,
-0.009357761591672897,
0.01951354555785656,
-0.006944694556295872,
-0.0437772274017334,
0.049477383494377136,
0.005267897620797157,
-0.07033997029066086,
0.036196012049913406,
-0.05323949083685875,
0.0015497308922931552,
-0.02430167980492115,
-0.016188453882932663,
-0.0006103920750319958,
-0.0034319711849093437,
0.012720855884253979,
-0.0022812513634562492,
0.016530463472008705,
-0.04233318567276001,
0.01760399341583252,
-0.004800009541213512,
-0.004712131805717945,
0.03781105950474739,
-0.032775916159152985,
-0.018554018810391426,
0.057001594454050064,
0.040015120059251785,
0.005989917553961277,
-0.03323192894458771,
0.04183917120099068,
-0.00209362106397748,
-0.04214318096637726,
-0.009842275641858578,
0.04225718230009079,
0.0317118875682354,
-0.07128999382257462,
0.04024312645196915,
-0.01748999021947384,
-0.020121563225984573,
0.041687168180942535,
-0.03570200130343437,
0.07596412301063538,
-0.057381607592105865,
-0.0005976260872557759,
-0.06391778588294983,
0.019304540008306503,
0.0489833727478981,
-0.017157480120658875,
-0.005168144591152668,
-0.00566690880805254,
-0.020026560872793198,
0.03184489160776138,
0.03344093635678291,
-0.01790800131857395,
-0.008554989472031593,
0.03594900667667389,
0.026524743065238,
-0.024719692766666412,
0.009571517817676067,
-0.05137743800878525,
0.0011893145274370909,
0.036272015422582626,
0.03332693129777908,
0.011761329136788845,
0.024016672745347023,
0.016986476257443428,
0.033079925924539566,
-0.03625301644206047,
-0.002664824714884162,
-0.06247374787926674,
-0.019760552793741226,
-0.012293344363570213,
0.02293364144861698,
0.031293876469135284,
-0.06874392181634903,
0.0230096448212862,
-0.0032300904858857393,
0.03792506083846092,
-0.0005946572637185454,
-0.02088158391416073,
0.004719256889075041,
0.06726188212633133,
-0.025536714121699333,
-0.004386747721582651,
0.01751849055290222,
-0.02133759669959545,
-0.030704859644174576,
-0.02103358879685402,
0.029260819777846336,
-0.0048878868110477924,
-0.03967311233282089,
-0.04278919845819473,
0.020748581737279892,
-0.0009155881125479937,
0.0578756220638752,
-0.04016712307929993,
-0.04985739663243294,
0.0482233501970768,
0.07030196487903595,
-0.05924366042017937,
0.0790422111749649,
0.025422710925340652,
-0.01662546582520008,
0.02675274945795536,
-0.023959670215845108,
-0.025802722200751305,
-0.07611612975597382,
-0.011248314753174782,
-0.04560127481818199,
0.033972952514886856,
-0.011998835951089859,
-0.023997671902179718,
0.01838301494717598,
-0.004146866034716368,
0.039939116686582565,
0.023845667019486427,
-0.0036481020506471395,
-0.030913865193724632,
-0.04366322234272957,
-0.006303426343947649,
-0.018202509731054306,
-0.00931026041507721,
0.012739856727421284,
0.030400851741433144,
-0.032034896314144135,
0.012122339569032192,
0.07262003421783447,
-0.044651251286268234,
0.006797440350055695,
0.047805339097976685,
-0.02722776308655739,
0.004241868853569031,
0.015599437057971954,
0.03699403628706932,
0.022762637585401535,
0.020786581560969353,
-0.0058426633477211,
0.02831079252064228,
0.03750704973936081,
0.05206145718693733,
0.02593572624027729,
0.041611164808273315,
-0.04753933101892471,
-0.03245290741324425,
0.0013027240056544542,
-0.0070491973310709,
-0.04020512476563454,
0.02329465188086033,
0.019295040518045425,
-0.023028643801808357,
0.05080742388963699,
-0.004740632604807615,
0.03169288858771324,
-0.008863748051226139,
0.05760961398482323,
-0.007851969450712204,
-0.015665939077734947,
-0.05175744742155075,
-0.002624448388814926,
-0.005343899596482515,
-0.0039117345586419106,
-0.06650186330080032,
-0.05175744742155075,
0.014183897525072098,
-0.02924181893467903,
0.008787745609879494,
0.006578934378921986,
0.05460752919316292
]
|
30,452 | networkx.algorithms.planarity | check_planarity | Check if a graph is planar and return a counterexample or an embedding.
A graph is planar iff it can be drawn in a plane without
any edge intersections.
Parameters
----------
G : NetworkX graph
counterexample : bool
A Kuratowski subgraph (to proof non planarity) is only returned if set
to true.
Returns
-------
(is_planar, certificate) : (bool, NetworkX graph) tuple
is_planar is true if the graph is planar.
If the graph is planar `certificate` is a PlanarEmbedding
otherwise it is a Kuratowski subgraph.
Examples
--------
>>> G = nx.Graph([(0, 1), (0, 2)])
>>> is_planar, P = nx.check_planarity(G)
>>> print(is_planar)
True
When `G` is planar, a `PlanarEmbedding` instance is returned:
>>> P.get_data()
{0: [1, 2], 1: [0], 2: [0]}
Notes
-----
A (combinatorial) embedding consists of cyclic orderings of the incident
edges at each vertex. Given such an embedding there are multiple approaches
discussed in literature to drawing the graph (subject to various
constraints, e.g. integer coordinates), see e.g. [2].
The planarity check algorithm and extraction of the combinatorial embedding
is based on the Left-Right Planarity Test [1].
A counterexample is only generated if the corresponding parameter is set,
because the complexity of the counterexample generation is higher.
See also
--------
is_planar :
Check for planarity without creating a `PlanarEmbedding` or counterexample.
References
----------
.. [1] Ulrik Brandes:
The Left-Right Planarity Test
2009
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.217.9208
.. [2] Takao Nishizeki, Md Saidur Rahman:
Planar graph drawing
Lecture Notes Series on Computing: Volume 12
2004
| def sign_recursive(self, e):
"""Recursive version of :meth:`sign`."""
if self.ref[e] is not None:
self.side[e] = self.side[e] * self.sign_recursive(self.ref[e])
self.ref[e] = None
return self.side[e]
| (G, counterexample=False, *, backend=None, **backend_kwargs) | [
-0.020818892866373062,
-0.04132705554366112,
0.08016827702522278,
0.10716723650693893,
-0.025945933535695076,
-0.032160528004169464,
-0.029778266325592995,
0.00808760430663824,
0.016373731195926666,
-0.04208661615848541,
0.006016073282808065,
0.004384742118418217,
0.03247125819325447,
-0.034421950578689575,
-0.0633888691663742,
0.02862166240811348,
-0.00014282239135354757,
0.0011803414672613144,
-0.008152340538799763,
0.013603057712316513,
0.025686992332339287,
0.029571114107966423,
0.04816311225295067,
-0.0034482369665056467,
-0.0540669746696949,
0.020093856379389763,
0.04181041195988655,
-0.019921228289604187,
-0.008022869005799294,
-0.024357760325074196,
-0.02166476845741272,
0.01765117608010769,
-0.006188700906932354,
-0.02955385111272335,
0.03635537996888161,
-0.0479559563100338,
-0.0627674087882042,
0.0436057411134243,
-0.09384038299322128,
0.0031418229918926954,
-0.04788690805435181,
-0.0005696712178178132,
0.006439010612666607,
-0.03670063614845276,
0.01615794748067856,
0.0005421586683951318,
0.05493011325597763,
0.030796770006418228,
0.03172896057367325,
-0.037529248744249344,
0.02311483956873417,
0.0012688131537288427,
0.014362619258463383,
-0.02596319653093815,
-0.012040778063237667,
0.046022526919841766,
0.05013106390833855,
0.008355177938938141,
0.008001291193068027,
0.02245885506272316,
0.07374652475118637,
0.02192370966076851,
-0.0028764079324901104,
0.024685751646757126,
0.007932240143418312,
0.01584721729159355,
0.019696813076734543,
0.010012403130531311,
0.011384792625904083,
0.054964639246463776,
-0.04702376946806908,
-0.029260383918881416,
0.004076170269399881,
0.016839826479554176,
0.026912648230791092,
-0.04239734634757042,
0.042535450309515,
0.017866959795355797,
0.012222036719322205,
-0.059729162603616714,
-0.058071937412023544,
-0.045366544276475906,
0.04391647130250931,
0.053100261837244034,
-0.016261523589491844,
0.0749894455075264,
0.0695689395070076,
0.005295352544635534,
0.011082693934440613,
0.03385227918624878,
-0.02318389154970646,
-0.005321247037500143,
-0.045677270740270615,
-0.008549383841454983,
0.055413469672203064,
0.030088996514678,
0.006995734758675098,
-0.04212114214897156,
-0.015286177396774292,
-0.036873262375593185,
0.04136158153414726,
0.04726544767618179,
-0.03891026973724365,
-0.042052093893289566,
0.0410853773355484,
-0.037805452942848206,
0.048266686499118805,
-0.0494060292840004,
0.017866959795355797,
0.031901586800813675,
0.0072287824004888535,
0.04395099729299545,
0.009321892634034157,
-0.025031007826328278,
-0.052513327449560165,
-0.0007422988419421017,
-0.020508162677288055,
-0.016261523589491844,
0.03531961515545845,
0.03828880935907364,
0.05724332481622696,
-0.027741260826587677,
-0.035216037184000015,
-0.00805307924747467,
-0.042708076536655426,
0.031107500195503235,
0.027326954528689384,
0.029916368424892426,
-0.06021251901984215,
-0.0123515073210001,
0.025479838252067566,
0.025531627237796783,
0.03922099992632866,
0.039393626153469086,
-0.0351642481982708,
0.03331713378429413,
0.05265142768621445,
-0.034024905413389206,
-0.02637750282883644,
0.006913736928254366,
-0.02232075296342373,
-0.01699519157409668,
0.03317902982234955,
0.052168071269989014,
0.045677270740270615,
0.08444944024085999,
-0.01242918986827135,
0.06539134681224823,
-0.019109878689050674,
0.02889786660671234,
-0.005485243164002895,
0.01703834719955921,
0.054826539009809494,
0.01434535626322031,
0.015881743282079697,
0.03217779099941254,
0.04067107290029526,
0.013508112169802189,
-0.06718667596578598,
0.02411608025431633,
0.0016345679759979248,
0.00957220233976841,
-0.026722757145762444,
-0.01781517267227173,
0.02848356030881405,
-0.03247125819325447,
0.017452653497457504,
0.019317032769322395,
-0.047679752111434937,
0.01696929708123207,
-0.021026046946644783,
-0.016149315983057022,
-0.03159085661172867,
0.006590059958398342,
0.038599539548158646,
0.0093736806884408,
0.056759968400001526,
0.04074012115597725,
-0.049129825085401535,
-0.010918698273599148,
0.024737540632486343,
-0.022700533270835876,
0.0450558140873909,
-0.04319143295288086,
0.03638990595936775,
0.01374979130923748,
0.030088996514678,
-0.018194952979683876,
0.0728488638997078,
-0.031245602294802666,
-0.012601817026734352,
0.031901586800813675,
0.03877216577529907,
-0.014517984353005886,
0.02271779626607895,
0.022631483152508736,
-0.01192856952548027,
0.011738679371774197,
0.032574836164712906,
-0.03053782880306244,
-0.019437871873378754,
-0.017970537766814232,
0.020784366875886917,
-0.027862099930644035,
-0.015726378187537193,
0.011419317685067654,
0.01546743605285883,
0.027016224339604378,
-0.0086486442014575,
0.016813931986689568,
0.013473587110638618,
-0.011738679371774197,
-0.0073280432261526585,
-0.030658667907118797,
-0.009718935936689377,
-0.04519391432404518,
0.01434535626322031,
0.011108588427305222,
-0.007578353397548199,
0.03231589496135712,
-0.02689538523554802,
-0.005178829189389944,
-0.0034806046169251204,
-0.05824456363916397,
0.008432860486209393,
-0.0281037800014019,
-0.006007441785186529,
-0.024996481835842133,
-0.01526891440153122,
-0.03238494321703911,
0.005450717639178038,
-0.03034793771803379,
-0.03184979781508446,
-0.05758858099579811,
0.005752815864980221,
-0.02213086374104023,
0.0024815222714096308,
-0.01746128499507904,
0.028138304129242897,
0.034214798361063004,
-0.002807356882840395,
0.013240539468824863,
-0.0027577264700084925,
0.07126069068908691,
0.022286226972937584,
0.02801746502518654,
0.0749894455075264,
0.002449154620990157,
0.027810312807559967,
0.032695673406124115,
0.0014112308854237199,
-0.040049612522125244,
-0.05413602665066719,
0.004220745526254177,
0.04774880409240723,
-0.04619515687227249,
0.04774880409240723,
0.02850082330405712,
0.03683873638510704,
0.03645895794034004,
0.008847166784107685,
-0.04305333271622658,
0.07561090588569641,
-0.044434353709220886,
-0.06770455837249756,
0.023011263459920883,
-0.008652959950268269,
-0.03152180463075638,
0.0012094724224880338,
0.043640267103910446,
0.045953474938869476,
-0.09232126176357269,
0.008018553256988525,
0.03067593090236187,
0.006831738632172346,
-0.004639367572963238,
0.017780646681785583,
0.10537190735340118,
-0.03380049020051956,
-0.003314450616016984,
0.021630242466926575,
-0.0003873332461807877,
-0.024426810443401337,
0.05120135843753815,
-0.09245935827493668,
0.03821975737810135,
-0.008057394996285439,
-0.02100878395140171,
0.027913888916373253,
-0.018695572391152382,
0.03490530699491501,
0.09542855620384216,
0.023166628554463387,
0.014932290650904179,
0.0436057411134243,
-0.035354141145944595,
-0.044434353709220886,
-0.01828126609325409,
0.04626420512795448,
0.04301880672574043,
0.012696762569248676,
0.000037526282540056854,
0.002610993105918169,
-0.035802971571683884,
0.03437016159296036,
-0.022372541949152946,
0.0655985027551651,
-0.0032799250911921263,
0.026532867923378944,
-0.025393525138497353,
-0.061248283833265305,
0.060005366802215576,
-0.031642645597457886,
-0.007030260283499956,
-0.007591300178319216,
-0.0030188257806003094,
0.03067593090236187,
-0.05858981981873512,
0.03438742458820343,
0.06369959563016891,
0.028449034318327904,
0.034024905413389206,
-0.03873763978481293,
0.01507039275020361,
0.03430110961198807,
-0.015648694708943367,
-0.019368819892406464,
-0.0023434201721102,
0.018298529088497162,
-0.002349893795326352,
-0.026446552947163582,
-0.01551059354096651,
0.03966983035206795,
-0.037874504923820496,
-0.08113498985767365,
-0.01566595770418644,
0.040705595165491104,
-0.009399575181305408,
-0.019955754280090332,
-0.029916368424892426,
0.03407669439911842,
-0.0060290200635790825,
-0.012247931212186813,
-0.011522894725203514,
0.0016917508328333497,
0.04056749492883682,
0.04132705554366112,
-0.042777128517627716,
0.04947508126497269,
0.034818995743989944,
0.015173968859016895,
0.05517179146409035,
-0.013456324115395546,
-0.012161617167294025,
-0.008609803393483162,
0.010849647223949432,
-0.036528006196022034,
-0.00016291733481921256,
-0.02166476845741272,
-0.026412028819322586,
0.0494060292840004,
-0.03345523402094841,
-0.036942314356565475,
0.00380212371237576,
0.020974257960915565,
-0.046540409326553345,
-0.06584017723798752,
0.010064191184937954,
-0.023339256644248962,
-0.00521767046302557,
-0.004484002944082022,
-0.06646163761615753,
-0.005998810287564993,
-0.012144354172050953,
-0.027016224339604378,
0.05751952901482582,
0.010677019134163857,
0.0320742130279541,
0.031245602294802666,
-0.06169711798429489,
0.029467537999153137,
0.022372541949152946,
-0.011660996824502945,
0.01305064931511879,
0.011937201023101807,
-0.01821221597492695,
0.08196359872817993,
-0.01103090588003397,
0.06867127120494843,
0.00028807236230932176,
-0.0347844697535038,
-0.07215835154056549,
0.03873763978481293,
-0.03970435634255409,
-0.020318273454904556,
-0.05869339779019356,
0.026550130918622017,
-0.015381122007966042,
-0.05341099202632904,
0.023477358743548393,
0.011099956929683685,
0.060177993029356,
-0.02670549601316452,
-0.05120135843753815,
0.0017262763576582074,
-0.025134583935141563,
0.008752221241593361,
-0.004203482996672392,
0.016908876597881317,
0.01378431636840105,
-0.055689673870801926,
-0.02021469548344612,
-0.00311377109028399,
0.012299719266593456,
0.04847383871674538,
-0.052099019289016724,
-0.008942111395299435,
0.02292495034635067,
-0.03184979781508446,
-0.04698924347758293,
-0.007172678131610155,
-0.0035453401505947113,
-0.02133677527308464,
0.02598045952618122,
0.0001809892855817452,
-0.021975498646497726,
-0.004412794020026922,
-0.018108639866113663,
-0.06981061398983002,
0.12159890681505203,
-0.04957865551114082,
-0.04640230908989906,
0.04792143031954765,
-0.02392619103193283,
0.034957095980644226,
-0.032436732202768326,
-0.01678803749382496,
-0.021561192348599434,
-0.02047363854944706,
0.04916435107588768,
0.05372171849012375,
0.03450826555490494,
-0.051166832447052,
-0.04453793168067932,
0.04446887969970703,
-0.01986944116652012,
-0.008238653652369976,
0.0036640216130763292,
-0.017193712294101715,
-0.018643785268068314,
0.04647136107087135,
0.01639099419116974,
0.08348272740840912,
-0.03297187760472298,
-0.07243455946445465,
-0.009106107987463474,
-0.042535450309515,
-0.013594426214694977,
-0.013896524906158447,
-0.03884121775627136,
-0.023011263459920883,
-0.024892905727028847,
-0.006335434038192034,
-0.025462577119469643,
-0.020956994965672493,
-0.04868099465966225,
0.032954614609479904,
-0.008864428848028183,
-0.05852076783776283,
-0.03815070912241936,
0.046091578900814056,
-0.04629873111844063,
-0.03794355317950249,
0.004479687195271254,
-0.012696762569248676,
-0.018177689984440804,
-0.07402273267507553,
-0.07333222031593323,
-0.021647505462169647,
-0.08728053420782089,
-0.08762578666210175,
-0.03811618313193321,
0.0018535892013460398,
0.017141925171017647,
0.023615460842847824,
-0.04094727709889412,
-0.020784366875886917,
-0.008596856147050858,
0.040981799364089966,
-0.02245885506272316,
-0.017633913084864616,
0.01615794748067856,
-0.0009429784840904176,
0.06874032318592072,
0.005463664885610342,
0.044227201491594315,
-0.04802500829100609,
-0.03777092695236206,
-0.0374947227537632,
-0.003172032767906785,
-0.013818842358887196,
0.003989856224507093,
0.01526891440153122,
0.0014187833294272423,
0.01732318289577961,
0.0011328688124194741,
-0.01809137687087059,
-0.01895451359450817,
-0.01795327477157116,
0.021820133551955223,
0.018264003098011017,
0.0074704610742628574,
0.05983273684978485,
0.04868099465966225,
-0.0010988827561959624,
0.050787050276994705,
-0.0025397841818630695,
0.017029715701937675,
0.05313478782773018,
-0.05185734108090401,
0.04239734634757042,
-0.12512050569057465,
-0.028932392597198486,
0.04792143031954765,
0.05361814424395561,
-0.024892905727028847,
-0.029830055311322212,
-0.03310998156666756,
-0.00654258718714118,
-0.0011415001936256886,
-0.007820031605660915,
0.03728757053613663,
-0.039255525916814804,
-0.00533419381827116,
-0.06874032318592072,
0.010392183437943459,
-0.010150505229830742,
-0.02285589836537838,
0.0247030146420002,
-0.012049408629536629,
0.01828126609325409,
0.008385387249290943,
-0.005890917964279652,
0.010443972423672676,
-0.013093805871903896,
-0.005260827019810677,
-0.016235629096627235,
-0.05751952901482582,
0.05506821721792221,
-0.00783297885209322,
-0.0028656187932938337,
0.001516965334303677,
0.0044753714464604855,
0.005213354714214802,
0.08693527430295944,
0.00825160089880228,
0.028656188398599625,
0.04598800092935562,
-0.004734313115477562,
0.010219556279480457,
0.002647676272317767,
-0.01551059354096651,
0.02603224664926529,
-0.11566051840782166,
-0.02318389154970646,
-0.014474826864898205,
0.05437770485877991,
-0.0212677251547575,
0.03393859416246414,
0.018125900998711586,
-0.021423090249300003,
-0.005515452940016985,
0.0486464686691761,
-0.02107783406972885,
0.005278090015053749,
0.03172896057367325,
-0.0025182056706398726,
-0.009045688435435295,
-0.05772668123245239,
0.009943352080881596,
0.028207356110215187,
-0.10419803857803345,
-0.01133300457149744,
0.023011263459920883,
-0.014854608103632927,
0.04647136107087135,
0.057070694863796234,
0.03590654954314232,
-0.04308785870671272,
0.018264003098011017,
-0.042535450309515,
-0.08065163344144821,
0.02252790704369545,
-0.043295010924339294,
-0.01685708947479725,
0.0019247981254011393,
-0.020836155861616135,
0.01569185219705105,
0.03260936215519905,
-0.018989039584994316,
-0.018367581069469452,
-0.05023464187979698,
0.02549710124731064,
0.0166671983897686,
-0.06525324285030365,
0.00048039035755209625,
0.0400150865316391,
-0.02623940072953701,
-0.04557369649410248,
-0.03704589232802391,
0.022372541949152946,
0.02623940072953701,
0.017478547990322113,
-0.02763768471777439,
-0.0083335991948843,
0.01732318289577961,
-0.025031007826328278,
0.028846077620983124,
-0.05572419986128807,
-0.013672108761966228,
-0.1073743924498558,
0.00821707583963871,
-0.07637046277523041,
-0.03248852118849754,
-0.028915129601955414,
0.01650320179760456,
0.05327288806438446,
0.02881155163049698,
0.000043831234506797045,
0.006797213107347488,
-0.0031029817182570696,
-0.0018891936633735895,
-0.0540669746696949,
-0.008739273995161057,
0.014138203114271164,
-0.022372541949152946,
-0.006011757533997297,
0.006421748083084822,
-0.05344551429152489,
0.08645191788673401,
-0.001472729491069913,
0.004777469672262669,
-0.05037274584174156,
0.02014564536511898,
-0.04937150329351425,
0.03842691332101822,
-0.02437502145767212,
-0.004811995197087526,
-0.05182281509041786,
-0.0024318918585777283,
-0.008747905492782593,
0.08541615307331085,
-0.020387323573231697,
-0.036804210394620895,
0.030365200713276863,
0.0050623053684830666,
0.06860221922397614,
0.0038711747620254755,
-0.004015750251710415,
0.009762092493474483,
-0.012213405221700668,
0.004462424200028181,
-0.04477960988879204,
0.010823752731084824,
-0.026791809126734734,
-0.025686992332339287,
0.016442783176898956,
-0.023960715159773827,
0.021043308079242706,
-0.022217176854610443,
0.00017411114822607487,
-0.037598300725221634,
-0.043571215122938156,
0.036217279732227325,
-0.0022506327368319035,
-0.022631483152508736,
0.043295010924339294,
0.005109778139740229,
0.03102118708193302,
0.029519325122237206,
-0.07008682191371918,
0.03354154899716377,
0.005636292509734631,
0.016261523589491844,
-0.003696389263495803,
-0.027119802311062813,
0.04063654690980911,
0.06221500039100647,
-0.02087068185210228,
-0.04909529909491539,
-0.016356468200683594,
-0.06822244077920914,
0.01175594236701727,
0.02047363854944706,
-0.020991520956158638,
0.039117421954870224,
-0.009805249981582165,
0.008605487644672394,
0.02598045952618122,
0.00622754218056798,
0.07402273267507553,
-0.007198572624474764,
0.02147487737238407,
0.009442731738090515,
0.018902726471424103,
-0.007069101557135582,
0.04629873111844063,
-0.010176398791372776,
0.016149315983057022,
-0.0008572040824219584,
-0.01569185219705105,
0.031366441398859024,
-0.007280570454895496,
-0.001294707297347486,
-0.02689538523554802,
0.030192572623491287,
-0.025031007826328278,
0.017340445891022682,
-0.005200407467782497,
-0.001295786234550178,
-0.08223980665206909,
-0.0282936692237854,
0.04174136370420456,
-0.012161617167294025,
-0.004386899992823601,
0.0013249170733615756,
0.07098448276519775,
0.004751575645059347,
-0.05738142505288124,
-0.004527159966528416,
-0.0569671206176281,
0.011876781471073627,
0.07181309908628464,
0.011816361919045448,
-0.01577816531062126,
0.012023515067994595,
0.017081504687666893,
0.05783025920391083,
-0.054688435047864914,
-0.0410853773355484,
0.044434353709220886,
0.0351642481982708,
-0.023356519639492035,
-0.02026648446917534,
0.044883184134960175,
0.051235880702733994,
-0.06180069223046303,
0.006158491130918264,
0.00659437570720911,
-0.07091543078422546,
0.0248583797365427,
0.04332953691482544,
0.013698003254830837,
-0.0012202615616843104,
-0.055758725851774216,
-0.006693636532872915,
-0.015044498257339,
0.025220897048711777,
0.01023681927472353,
-0.00017316709272563457,
-0.05178828909993172,
-0.047610703855752945,
-0.004928519017994404,
0.0807897299528122,
-0.028656188398599625,
0.06487346440553665,
0.022286226972937584,
0.0396353043615818
]
|
30,457 | networkx.algorithms.cycles | chordless_cycles | Find simple chordless cycles of a graph.
A `simple cycle` is a closed path where no node appears twice. In a simple
cycle, a `chord` is an additional edge between two nodes in the cycle. A
`chordless cycle` is a simple cycle without chords. Said differently, a
chordless cycle is a cycle C in a graph G where the number of edges in the
induced graph G[C] is equal to the length of `C`.
Note that some care must be taken in the case that G is not a simple graph
nor a simple digraph. Some authors limit the definition of chordless cycles
to have a prescribed minimum length; we do not.
1. We interpret self-loops to be chordless cycles, except in multigraphs
with multiple loops in parallel. Likewise, in a chordless cycle of
length greater than 1, there can be no nodes with self-loops.
2. We interpret directed two-cycles to be chordless cycles, except in
multi-digraphs when any edge in a two-cycle has a parallel copy.
3. We interpret parallel pairs of undirected edges as two-cycles, except
when a third (or more) parallel edge exists between the two nodes.
4. Generalizing the above, edges with parallel clones may not occur in
chordless cycles.
In a directed graph, two chordless cycles are distinct if they are not
cyclic permutations of each other. In an undirected graph, two chordless
cycles are distinct if they are not cyclic permutations of each other nor of
the other's reversal.
Optionally, the cycles are bounded in length.
We use an algorithm strongly inspired by that of Dias et al [1]_. It has
been modified in the following ways:
1. Recursion is avoided, per Python's limitations
2. The labeling function is not necessary, because the starting paths
are chosen (and deleted from the host graph) to prevent multiple
occurrences of the same path
3. The search is optionally bounded at a specified length
4. Support for directed graphs is provided by extending cycles along
forward edges, and blocking nodes along forward and reverse edges
5. Support for multigraphs is provided by omitting digons from the set
of forward edges
Parameters
----------
G : NetworkX DiGraph
A directed graph
length_bound : int or None, optional (default=None)
If length_bound is an int, generate all simple cycles of G with length at
most length_bound. Otherwise, generate all simple cycles of G.
Yields
------
list of nodes
Each cycle is represented by a list of nodes along the cycle.
Examples
--------
>>> sorted(list(nx.chordless_cycles(nx.complete_graph(4))))
[[1, 0, 2], [1, 0, 3], [2, 0, 3], [2, 1, 3]]
Notes
-----
When length_bound is None, and the graph is simple, the time complexity is
$O((n+e)(c+1))$ for $n$ nodes, $e$ edges and $c$ chordless cycles.
Raises
------
ValueError
when length_bound < 0.
References
----------
.. [1] Efficient enumeration of chordless cycles
E. Dias and D. Castonguay and H. Longo and W.A.R. Jradi
https://arxiv.org/abs/1309.1051
See Also
--------
simple_cycles
| def recursive_simple_cycles(G):
"""Find simple cycles (elementary circuits) of a directed graph.
A `simple cycle`, or `elementary circuit`, is a closed path where
no node appears twice. Two elementary circuits are distinct if they
are not cyclic permutations of each other.
This version uses a recursive algorithm to build a list of cycles.
You should probably use the iterator version called simple_cycles().
Warning: This recursive version uses lots of RAM!
It appears in NetworkX for pedagogical value.
Parameters
----------
G : NetworkX DiGraph
A directed graph
Returns
-------
A list of cycles, where each cycle is represented by a list of nodes
along the cycle.
Example:
>>> edges = [(0, 0), (0, 1), (0, 2), (1, 2), (2, 0), (2, 1), (2, 2)]
>>> G = nx.DiGraph(edges)
>>> nx.recursive_simple_cycles(G)
[[0], [2], [0, 1, 2], [0, 2], [1, 2]]
Notes
-----
The implementation follows pp. 79-80 in [1]_.
The time complexity is $O((n+e)(c+1))$ for $n$ nodes, $e$ edges and $c$
elementary circuits.
References
----------
.. [1] Finding all the elementary circuits of a directed graph.
D. B. Johnson, SIAM Journal on Computing 4, no. 1, 77-84, 1975.
https://doi.org/10.1137/0204007
See Also
--------
simple_cycles, cycle_basis
"""
# Jon Olav Vik, 2010-08-09
def _unblock(thisnode):
"""Recursively unblock and remove nodes from B[thisnode]."""
if blocked[thisnode]:
blocked[thisnode] = False
while B[thisnode]:
_unblock(B[thisnode].pop())
def circuit(thisnode, startnode, component):
closed = False # set to True if elementary path is closed
path.append(thisnode)
blocked[thisnode] = True
for nextnode in component[thisnode]: # direct successors of thisnode
if nextnode == startnode:
result.append(path[:])
closed = True
elif not blocked[nextnode]:
if circuit(nextnode, startnode, component):
closed = True
if closed:
_unblock(thisnode)
else:
for nextnode in component[thisnode]:
if thisnode not in B[nextnode]: # TODO: use set for speedup?
B[nextnode].append(thisnode)
path.pop() # remove thisnode from path
return closed
path = [] # stack of nodes in current path
blocked = defaultdict(bool) # vertex: blocked from search?
B = defaultdict(list) # graph portions that yield no elementary circuit
result = [] # list to accumulate the circuits found
# Johnson's algorithm exclude self cycle edges like (v, v)
# To be backward compatible, we record those cycles in advance
# and then remove from subG
for v in G:
if G.has_edge(v, v):
result.append([v])
G.remove_edge(v, v)
# Johnson's algorithm requires some ordering of the nodes.
# They might not be sortable so we assign an arbitrary ordering.
ordering = dict(zip(G, range(len(G))))
for s in ordering:
# Build the subgraph induced by s and following nodes in the ordering
subgraph = G.subgraph(node for node in G if ordering[node] >= ordering[s])
# Find the strongly connected component in the subgraph
# that contains the least node according to the ordering
strongcomp = nx.strongly_connected_components(subgraph)
mincomp = min(strongcomp, key=lambda ns: min(ordering[n] for n in ns))
component = G.subgraph(mincomp)
if len(component) > 1:
# smallest node in the component according to the ordering
startnode = min(component, key=ordering.__getitem__)
for node in component:
blocked[node] = False
B[node][:] = []
dummy = circuit(startnode, startnode, component)
return result
| (G, length_bound=None, *, backend=None, **backend_kwargs) | [
0.021046679466962814,
-0.03182382881641388,
-0.04127335920929909,
0.029012398794293404,
-0.03898907080292702,
-0.001068929210305214,
-0.038598597049713135,
-0.014545246958732605,
0.07559623569250107,
-0.05907908454537392,
-0.025049062445759773,
0.03914526104927063,
0.00016656260413583368,
0.0024648825637996197,
-0.02994954213500023,
-0.028407160192728043,
0.0031262519769370556,
0.002977382857352495,
-0.03619716688990593,
0.03889145329594612,
-0.015970485284924507,
-0.042171455919742584,
0.041078120470047,
0.04756002873182297,
-0.01885025016963482,
0.059118133038282394,
-0.0024392574559897184,
0.024229062721133232,
-0.0978533923625946,
-0.020617155358195305,
0.012963817454874516,
0.0020231560338288546,
-0.07957910001277924,
-0.04998098313808441,
0.024326682090759277,
0.06618575751781464,
0.015033342875540257,
0.0523238405585289,
-0.07836861908435822,
0.009093220345675945,
0.031921450048685074,
-0.009966910816729069,
0.011255483143031597,
-0.05037146061658859,
0.04330383613705635,
-0.014672151766717434,
0.02975430339574814,
0.08582671731710434,
-0.01432072278112173,
-0.05439336597919464,
0.05154288932681084,
-0.005740003660321236,
-0.04146859794855118,
0.0011287209345027804,
0.04455336183309555,
0.011138340458273888,
0.010220720432698727,
0.0435771681368351,
0.07258956879377365,
-0.024990491569042206,
-0.013940008357167244,
-0.021808108314871788,
0.02446334809064865,
0.05216765031218529,
-0.058688607066869736,
-0.01495524775236845,
-0.013383579440414906,
-0.04736478999257088,
-0.008346433751285076,
0.0022720848210155964,
0.0037046452052891254,
-0.004785776603966951,
0.017688581719994545,
-0.047794315963983536,
-0.014838104136288166,
-0.05216765031218529,
-0.008502623997628689,
-0.008029171265661716,
-0.0051786936819553375,
-0.02221810817718506,
0.02450239658355713,
-0.011196911334991455,
0.0024026501923799515,
-0.04728669673204422,
0.02905144728720188,
-0.0003822398139163852,
0.015316437929868698,
0.036509547382593155,
-0.04021907225251198,
-0.023740967735648155,
-0.007257980760186911,
-0.02469763346016407,
0.0066673848778009415,
0.09004386514425278,
0.02743097022175789,
0.0033727402333170176,
-0.03561145067214966,
-0.055330511182546616,
0.03078906610608101,
0.0015228580450639129,
0.007077385205775499,
0.0038974429480731487,
-0.11690864711999893,
-0.01337381824851036,
-0.02424858696758747,
-0.026259539648890495,
-0.03362002223730087,
0.023370014503598213,
0.008224410004913807,
-0.08645148575305939,
-0.051777176558971405,
0.056423842906951904,
0.015999771654605865,
-0.03465478494763374,
-0.01086500659584999,
0.05943051353096962,
0.028309540823101997,
-0.02717716060578823,
0.007160361390560865,
-0.014252389781177044,
-0.014535484835505486,
-0.021593347191810608,
-0.041546691209077835,
0.044475264847278595,
0.020831918343901634,
-0.0016424414934590459,
0.009039529599249363,
0.02135905995965004,
0.008727148175239563,
-0.008229291066527367,
0.06192956119775772,
0.03811049833893776,
0.023487158119678497,
0.070363849401474,
-0.0006613694713450968,
-0.02284287102520466,
-0.051816221326589584,
-0.019719060510396957,
-0.019133344292640686,
0.0165171530097723,
-0.01611691527068615,
-0.10503815859556198,
0.012260960415005684,
0.06649813801050186,
0.03951621428132057,
-0.01547262817621231,
0.03576764091849327,
-0.024619538336992264,
0.0028529183473438025,
0.030261922627687454,
0.014467151835560799,
0.0023965490981936455,
0.02573239617049694,
0.0019975309260189533,
0.021905727684497833,
-0.003399585373699665,
-0.040453359484672546,
0.04545145854353905,
-0.04619336128234863,
0.024404777213931084,
-0.031921450048685074,
-0.006364766042679548,
-0.024639062583446503,
0.0069065517745912075,
-0.027977636083960533,
0.019104059785604477,
0.023506680503487587,
-0.008551433682441711,
-0.05212860554456711,
0.025400491431355476,
0.007321433164179325,
0.006467266008257866,
-0.07169147580862045,
0.01118715014308691,
0.0037534546572715044,
0.035650499165058136,
0.01319810375571251,
0.03719288110733032,
0.010660006664693356,
-0.0188404880464077,
-0.021651918068528175,
-0.009332386776804924,
-0.026318112388253212,
-0.015404295176267624,
0.014379294589161873,
0.028739064931869507,
0.06829433143138885,
-0.051152411848306656,
0.05814193934202194,
0.009171315468847752,
-0.06314004212617874,
0.01026953011751175,
0.04498288407921791,
0.057634320110082626,
0.06993433088064194,
-0.03783716633915901,
-0.020343821495771408,
0.029793351888656616,
-0.058688607066869736,
0.08153147995471954,
0.014105960726737976,
0.030691446736454964,
0.053690508008003235,
-0.0022354775574058294,
0.04521717131137848,
0.0326828770339489,
0.014730723574757576,
-0.0055447653867304325,
0.016380487009882927,
0.013549531809985638,
-0.05622860789299011,
-0.05107431858778,
0.03186287730932236,
-0.01655620150268078,
-0.04127335920929909,
0.0263376347720623,
-0.0032995259389281273,
0.019289536401629448,
0.017727630212903023,
-0.0687628984451294,
-0.033190496265888214,
0.01026953011751175,
-0.008897981606423855,
-0.02280382439494133,
-0.009971791878342628,
-0.02512715756893158,
0.03914526104927063,
0.012505007907748222,
0.026845254004001617,
-0.021671442314982414,
0.02784097008407116,
0.004719883669167757,
0.0435771681368351,
-0.011372625827789307,
0.01045500673353672,
-0.05349527299404144,
-0.036743830889463425,
0.00465155066922307,
0.02032429911196232,
-0.0023941085673868656,
-0.04873145744204521,
-0.06973908841609955,
-0.0008620987646281719,
-0.012778340838849545,
0.014515961520373821,
-0.01570691540837288,
0.040453359484672546,
-0.00016961319488473237,
-0.013861913233995438,
-0.0013373817782849073,
-0.08106290549039841,
-0.05185526981949806,
-0.0007217712700366974,
-0.06544385105371475,
0.008473338559269905,
-0.040258120745420456,
-0.045295264571905136,
-0.0269623976200819,
-0.0005143306916579604,
0.011480007320642471,
0.011401912197470665,
0.016800248995423317,
-0.04728669673204422,
0.021886203438043594,
-0.0024368169251829386,
0.008619767613708973,
0.01118715014308691,
0.01734691485762596,
-0.033561449497938156,
0.0269623976200819,
0.07602576166391373,
-0.058688607066869736,
0.011401912197470665,
0.008663696236908436,
-0.047208599746227264,
0.027079541236162186,
-0.005578931886702776,
0.031238114461302757,
-0.022667156532406807,
-0.052636224776506424,
-0.0787590965628624,
0.02743097022175789,
0.0006723516271449625,
-0.004514883738011122,
-0.046974316239356995,
-0.014720961451530457,
0.004788217134773731,
-0.042405739426612854,
0.0006140851764939725,
-0.005676551256328821,
0.0744638592004776,
-0.03369811549782753,
0.05126955732703209,
0.028563350439071655,
0.04463145509362221,
0.0063842898234725,
-0.02092953585088253,
-0.07844671607017517,
0.002366043161600828,
0.026318112388253212,
0.010904054157435894,
-0.0501762218773365,
0.001798632089048624,
-0.026240015402436256,
0.00738488556817174,
-0.04470955207943916,
0.009322624653577805,
-0.02368239499628544,
-0.00007550227746833116,
-0.011675245128571987,
-0.049043841660022736,
0.02403382398188114,
0.011450720950961113,
0.022100966423749924,
-0.004744288511574268,
-0.06021146476268768,
-0.028368113562464714,
-0.021651918068528175,
0.06794290244579315,
0.05236288905143738,
0.015658104792237282,
0.04349907487630844,
-0.04310859739780426,
0.04084383323788643,
-0.059547655284404755,
0.044865742325782776,
0.06376480311155319,
0.052597176283597946,
0.03703669086098671,
0.005373931955546141,
-0.005613098852336407,
0.022862395271658897,
-0.014066913165152073,
0.04306954890489578,
0.003643633099272847,
0.011470245197415352,
0.06271051615476608,
-0.05466670170426369,
-0.022120490670204163,
-0.07989148050546646,
0.07614290714263916,
0.054080985486507416,
-0.01390096079558134,
-0.018762392923235893,
0.002655239775776863,
-0.009122505784034729,
0.04939526692032814,
0.011675245128571987,
-0.020578108727931976,
0.02594715915620327,
0.03289764001965523,
0.06817718595266342,
-0.03600192815065384,
0.019406678155064583,
-0.025049062445759773,
0.029851922765374184,
0.010699054226279259,
-0.00534464605152607,
-0.010660006664693356,
-0.0052226223051548,
0.026200968772172928,
0.03690002113580704,
-0.008121909573674202,
-0.01392048504203558,
0.04849717393517494,
-0.005979170557111502,
-0.017639772966504097,
0.04346002638339996,
0.0019987511914223433,
-0.05497908219695091,
-0.03412764146924019,
-0.00011920208635274321,
0.00607678946107626,
-0.003182383021339774,
0.002208632417023182,
0.035240497440099716,
0.02493192069232464,
-0.016234057024121284,
0.05275336652994156,
0.02700144611299038,
-0.001066488795913756,
-0.00679917074739933,
0.0010847923113033175,
0.011587387882173061,
0.030222875997424126,
-0.002740656491369009,
0.04463145509362221,
0.02700144611299038,
0.08278100192546844,
-0.011382387951016426,
-0.046115268021821976,
-0.050761934369802475,
0.02381906285881996,
0.009078577160835266,
-0.04580288380384445,
-0.01257334090769291,
0.1437734216451645,
0.03549430891871452,
-0.007980362512171268,
-0.013969294726848602,
-0.0002550299104768783,
0.013803341425955296,
0.030281446874141693,
0.02887573279440403,
0.005505717825144529,
-0.028290018439292908,
0.04791145771741867,
0.00018745919805951416,
0.002713811118155718,
-0.007472742814570665,
-0.031238114461302757,
0.009805839508771896,
0.004634466953575611,
-0.017005247995257378,
0.01329572219401598,
-0.05583813041448593,
-0.03785669058561325,
-0.0008840630762279034,
0.07344861328601837,
0.024639062583446503,
0.042796216905117035,
-0.008424528874456882,
0.045724790543317795,
-0.008170719258487225,
0.009591077454388142,
0.02091001346707344,
0.026942873373627663,
0.03346383199095726,
-0.04638860002160072,
0.06825528293848038,
-0.003194585209712386,
-0.029168589040637016,
-0.028953827917575836,
-0.04916098341345787,
-0.019738582894206047,
-0.024639062583446503,
0.043655265122652054,
-0.020578108727931976,
0.05736098811030388,
0.026318112388253212,
-0.021632393822073936,
0.06478004157543182,
-0.009366553276777267,
-0.03559192642569542,
0.051620982587337494,
-0.018479296937584877,
0.00418785959482193,
0.033170972019433975,
0.011968102306127548,
-0.017015010118484497,
0.021300489082932472,
-0.028817160055041313,
0.03096478059887886,
-0.05150384083390236,
-0.12284388393163681,
0.0313357338309288,
0.0179912019520998,
0.01864524930715561,
-0.05041050910949707,
0.025224776938557625,
0.06681051850318909,
0.02221810817718506,
0.01693691499531269,
0.013774055987596512,
-0.053456224501132965,
-0.042796216905117035,
0.011392150074243546,
0.014925961382687092,
-0.021866681054234505,
0.004007264506071806,
0.03449859097599983,
-0.02280382439494133,
-0.08051624149084091,
-0.0326828770339489,
0.030418114736676216,
-0.0211638230830431,
-0.07165242731571198,
-0.013129769824445248,
-0.0017900903476402164,
-0.08121909946203232,
-0.07544004917144775,
-0.01465262845158577,
0.02219858579337597,
-0.017620248720049858,
-0.003758335718885064,
-0.030906209722161293,
0.03914526104927063,
-0.0054178605787456036,
-0.022920966148376465,
-0.05970384553074837,
-0.052206698805093765,
-0.020460965111851692,
-0.02157382294535637,
0.010191434994339943,
0.025478586554527283,
0.0689190924167633,
-0.044280026108026505,
-0.018489059060811996,
0.08871624618768692,
-0.024424301460385323,
0.01246596034616232,
-0.004546610172837973,
-0.0006991968839429319,
0.00868810061365366,
0.04537336155772209,
0.031062399968504906,
0.015296914614737034,
-0.0072189331986010075,
0.02549811080098152,
0.0067259566858410835,
0.028153350576758385,
-0.00607678946107626,
0.019289536401629448,
0.04498288407921791,
0.011021196842193604,
0.0017510427860543132,
-0.013764293864369392,
-0.004197621718049049,
0.03637288138270378,
-0.027079541236162186,
0.012944294139742851,
0.020207155495882034,
0.004929765127599239,
0.05361241474747658,
-0.008478219620883465,
0.019797155633568764,
-0.0005777830956503749,
-0.05056669935584068,
-0.02678668312728405,
-0.00837571918964386,
0.006086551584303379,
0.02032429911196232,
-0.02573239617049694,
0.09613529592752457,
0.010171910747885704,
-0.016878344118595123,
0.04716955125331879,
0.018469534814357758,
-0.058688607066869736,
0.0009560571634210646,
0.022940490394830704,
0.039047643542289734,
0.0707152783870697,
0.009195719845592976,
0.006755242124199867,
0.02048048935830593,
0.05646289139986038,
0.016790486872196198,
-0.032995257526636124,
-0.0367828793823719,
-0.004053633660078049,
0.006682028062641621,
-0.007423933129757643,
-0.027958111837506294,
0.06274956464767456,
-0.08512385934591293,
-0.02071477472782135,
0.014496437273919582,
0.002860239939764142,
0.02448287233710289,
-0.03307335451245308,
0.0034923236817121506,
-0.0657171830534935,
-0.08254671841859818,
0.04115621745586395,
-0.02235477603971958,
0.07532290369272232,
-0.02953954227268696,
0.018567154183983803,
0.03332716226577759,
0.012944294139742851,
-0.002086608437821269,
0.032936688512563705,
-0.02678668312728405,
-0.00101828936021775,
0.03711478412151337,
-0.02050001360476017,
-0.02155429869890213,
0.00094141426961869,
-0.0694657564163208,
-0.007619171403348446,
-0.04431907460093498,
-0.007140837609767914,
0.012514770030975342,
0.05939146503806114,
-0.008112147450447083,
-0.022550014778971672,
0.004121966660022736,
-0.03051573410630226,
-0.007297028321772814,
0.030086209997534752,
-0.05923527479171753,
0.030652400106191635,
-0.005705836694687605,
-0.02051953598856926,
0.03219478204846382,
-0.0027699421625584364,
0.027313826605677605,
-0.0034898831509053707,
-0.014174294658005238,
-0.03198001906275749,
0.015794770792126656,
0.040453359484672546,
0.04998098313808441,
-0.03465478494763374,
0.023506680503487587,
0.019826440140604973,
-0.06306194514036179,
0.04416288435459137,
-0.0188404880464077,
0.001975566614419222,
0.052636224776506424,
-0.00334345456212759,
0.006501432508230209,
-0.06692766398191452,
0.011802149936556816,
-0.04334288462996483,
0.015199295245110989,
-0.024229062721133232,
-0.008034052327275276,
0.006945599336177111,
0.0013239592080935836,
0.013237151317298412,
-0.0280362069606781,
-0.07094956934452057,
0.025615254417061806,
0.02344810962677002,
0.009493458084762096,
0.029441922903060913,
0.06997337937355042,
0.013686198741197586,
-0.004756491165608168,
-0.012241436168551445,
0.05818098783493042,
0.007277504540979862,
-0.0694657564163208,
0.001929197576828301,
-0.002655239775776863,
-0.01318834163248539,
0.08746672421693802,
-0.06649813801050186,
-0.015511676669120789,
-0.052440986037254333,
0.018274297937750816,
-0.0782124325633049,
-0.04549050331115723,
0.031120970845222473,
-0.04478764533996582,
0.019084535539150238,
0.04123431071639061,
-0.031023353338241577,
0.02323334850370884,
0.02989097125828266,
-0.014467151835560799,
-0.005837622564285994,
0.05341717600822449,
0.039848119020462036,
-0.031921450048685074,
0.017708105966448784,
-0.040453359484672546,
0.056423842906951904,
0.005290955770760775,
0.015394533053040504,
-0.012905245646834373,
-0.021066203713417053,
-0.0030139898881316185,
0.07344861328601837,
-0.021300489082932472,
-0.034635260701179504,
0.01537500973790884,
-0.022237632423639297,
-0.0678648054599762,
0.0023221145384013653,
-0.024170491844415665,
-0.07770480960607529,
-0.004014585632830858,
-0.0380324050784111,
0.04080478847026825,
-0.007521552499383688,
-0.01717120036482811,
0.01672215387225151,
0.012270721606910229,
-0.029773827642202377,
-0.03340525925159454,
-0.0006235420587472618,
-0.0025625017005950212,
-0.0021573822014033794,
-0.05341717600822449,
0.03748573735356331,
-0.07860290259122849,
0.0018755070632323623,
0.013159056194126606,
0.03362002223730087,
0.01822548732161522,
-0.014486676082015038,
0.024756206199526787,
0.016614772379398346,
0.010064530186355114,
0.04439717158675194,
-0.05318288877606392,
0.05419812723994255,
-0.013129769824445248,
0.02050001360476017,
0.02887573279440403,
-0.002569823060184717,
0.00011760051711462438,
-0.05146479234099388,
0.005032265093177557,
0.030066685751080513,
0.043811455368995667,
-0.0016265783924609423,
0.009532505646348,
-0.003404466435313225,
-0.003802264342084527,
0.01776667684316635,
-0.06747432798147202,
-0.014564771205186844,
-0.023760490119457245,
-0.046115268021821976,
0.02930525690317154,
-0.005188455805182457,
0.009127386845648289,
-0.02680620737373829,
0.03078906610608101,
-0.022491442039608955,
0.09020005911588669,
0.05111336335539818,
-0.02319430001080036,
0.015004056505858898,
-0.020597631111741066,
-0.04119526222348213,
0.06282766163349152,
-0.011011435650289059,
0.031277161091566086,
0.02532239630818367,
-0.04443621635437012,
-0.02069525048136711,
0.0033385735005140305,
-0.010074292309582233,
0.02973478101193905,
-0.0060719083994627,
-0.0359824039041996,
-0.06282766163349152,
0.029598113149404526,
-0.018254773691296577,
-0.02200334705412388,
0.010952863842248917,
0.06216384842991829,
0.01802048645913601,
-0.09746291488409042,
-0.005720479879528284,
-0.031687162816524506,
-0.027919065207242966,
-0.03953573852777481,
-0.008785719983279705,
0.010191434994339943,
-0.0598209910094738,
-0.00995714869350195,
-0.0514257475733757,
-0.05353431776165962,
-0.013930247165262699,
0.00780464755371213,
0.022081442177295685,
0.023350490257143974,
-0.03430335596203804,
0.029344303533434868,
0.0003245835250709206,
0.055994320660829544
]
|
30,459 | networkx.generators.small | chvatal_graph |
Returns the Chvátal Graph
The Chvátal Graph is an undirected graph with 12 nodes and 24 edges [1]_.
It has 370 distinct (directed) Hamiltonian cycles, giving a unique generalized
LCF notation of order 4, two of order 6 , and 43 of order 1 [2]_.
Parameters
----------
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : networkx Graph
The Chvátal graph with 12 nodes and 24 edges
References
----------
.. [1] https://en.wikipedia.org/wiki/Chv%C3%A1tal_graph
.. [2] https://mathworld.wolfram.com/ChvatalGraph.html
| def _raise_on_directed(func):
"""
A decorator which inspects the `create_using` argument and raises a
NetworkX exception when `create_using` is a DiGraph (class or instance) for
graph generators that do not support directed outputs.
"""
@wraps(func)
def wrapper(*args, **kwargs):
if kwargs.get("create_using") is not None:
G = nx.empty_graph(create_using=kwargs["create_using"])
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
return func(*args, **kwargs)
return wrapper
| (create_using=None, *, backend=None, **backend_kwargs) | [
0.02052106149494648,
-0.003826453583315015,
0.036479901522397995,
0.005174993071705103,
0.0002132951485691592,
0.039002541452646255,
-0.060078226029872894,
-0.017846345901489258,
0.08022357523441315,
-0.0368913933634758,
0.019215013831853867,
0.010833045467734337,
0.04422673583030701,
-0.02680082991719246,
0.011011956259608269,
0.04515707120299339,
-0.048806849867105484,
0.09403548389673233,
0.02332996018230915,
0.04737556353211403,
-0.009178120642900467,
-0.03184611350297928,
-0.0025740782730281353,
-0.019894873723387718,
0.0007603706326335669,
0.04347531124949455,
-0.025244304910302162,
0.0010136411292478442,
0.0061903116293251514,
0.023687781766057014,
-0.034297190606594086,
-0.04676726832985878,
0.0009113266132771969,
0.06562446057796478,
0.04633788391947746,
0.06276188790798187,
-0.046624138951301575,
0.08093921840190887,
-0.10212225466966629,
-0.07342496514320374,
-0.031255707144737244,
0.0077378894202411175,
0.03207869455218315,
0.011396613903343678,
-0.0013496578903868794,
-0.020002221688628197,
0.009822200052440166,
0.00007624672434758395,
-0.08931224048137665,
-0.0420440249145031,
0.022363843396306038,
0.005568597000092268,
0.05514029040932655,
0.06147373095154762,
0.012344840914011002,
0.04036226496100426,
-0.0097327446565032,
0.028965650126338005,
0.03943192586302757,
-0.016307713463902473,
0.0049737184308469296,
0.05102534219622612,
0.012487969361245632,
-0.024188732728362083,
-0.03299114108085632,
0.000811248377431184,
-0.07821977883577347,
-0.026621919125318527,
-0.021916566416621208,
0.05456777662038803,
0.011664980091154575,
-0.005783289670944214,
0.01718437671661377,
0.009500160813331604,
0.07224415987730026,
-0.030629519373178482,
0.019876983016729355,
-0.010251585394144058,
0.04827011749148369,
-0.023634109646081924,
-0.03599684312939644,
-0.018767736852169037,
-0.022399624809622765,
0.00704908324405551,
0.06197468191385269,
-0.021898675709962845,
-0.051275819540023804,
0.02640722505748272,
0.030182242393493652,
-0.044441428035497665,
-0.0055909608490765095,
-0.03537065535783768,
-0.017408015206456184,
0.005219720769673586,
-0.03220393508672714,
0.059684623032808304,
0.02960972860455513,
-0.05263553932309151,
0.06397847831249237,
-0.011781272478401661,
0.0017879892839118838,
0.00821200292557478,
-0.019107667729258537,
0.033456310629844666,
-0.016254041343927383,
-0.09739901125431061,
0.00984009075909853,
-0.028071096166968346,
-0.01962650753557682,
-0.02338363416492939,
-0.08279988914728165,
-0.01825784146785736,
0.049987662583589554,
0.000976181763689965,
0.0173632875084877,
-0.001127696828916669,
-0.010063729248940945,
-0.018588826060295105,
0.001818180433474481,
-0.03640833497047424,
-0.021719764918088913,
0.02898354083299637,
-0.05653579533100128,
-0.05109690874814987,
0.05646422877907753,
-0.023974038660526276,
-0.0005283457576297224,
-0.016611862927675247,
0.042258717119693756,
0.015198467299342155,
0.018660390749573708,
0.047304000705480576,
-0.029878094792366028,
0.03699874132871628,
0.0043810768984258175,
0.03644411638379097,
-0.05395948141813278,
0.052742887288331985,
-0.014169731177389622,
0.0027954804245382547,
-0.00294308178126812,
-0.018910866230726242,
0.027945857495069504,
0.04261653870344162,
0.013874527998268604,
0.041686203330755234,
-0.05564124137163162,
-0.0227216649800539,
0.02433186024427414,
-0.02842891775071621,
0.05921945720911026,
0.005613324698060751,
0.009039465337991714,
0.01686233840882778,
-0.043153271079063416,
0.03426140546798706,
-0.03318794444203377,
0.025494780391454697,
0.02136194333434105,
0.014357587322592735,
-0.03152407333254814,
-0.022864792495965958,
0.04233027994632721,
0.02332996018230915,
0.015609961934387684,
-0.022274388000369072,
0.01001005619764328,
-0.020038003101944923,
0.007903382182121277,
-0.004305039532482624,
-0.04537176340818405,
-0.022292278707027435,
-0.0057564531452953815,
-0.039288800209760666,
-0.028804630041122437,
0.03023591637611389,
0.03746391087770462,
0.04261653870344162,
-0.03352787345647812,
0.01607513055205345,
0.054424647241830826,
-0.044047825038433075,
-0.01951916143298149,
-0.02832156978547573,
0.04132838174700737,
0.01867828145623207,
0.009884818457067013,
-0.025280088186264038,
0.0032472300808876753,
0.0003916467831004411,
0.017560089007019997,
0.017381178215146065,
0.03250808268785477,
0.04973718523979187,
0.03796485811471939,
-0.09267576783895493,
-0.009374923072755337,
-0.0015274505130946636,
-0.016924956813454628,
0.07457000017166138,
0.05270710587501526,
0.0321502611041069,
0.03605051338672638,
0.014035548083484173,
-0.004799280781298876,
0.047304000705480576,
-0.025136958807706833,
-0.05188411474227905,
-0.05217037349939346,
-0.010349986143410206,
-0.03885941207408905,
-0.034297190606594086,
0.034959159791469574,
0.05152629315853119,
-0.03444031625986099,
0.02315104939043522,
0.02154085412621498,
0.05399526283144951,
-0.010349986143410206,
-0.027212323620915413,
-0.012112257070839405,
-0.01820416748523712,
-0.008082292973995209,
-0.02041371539235115,
0.0626545399427414,
-0.0413641631603241,
0.008122547529637814,
-0.05252819508314133,
0.025637909770011902,
-0.017846345901489258,
0.04104212298989296,
-0.01584254577755928,
0.01684444583952427,
0.02277533710002899,
0.0389309786260128,
-0.047697603702545166,
0.01968018151819706,
-0.045121289789676666,
0.010224749334156513,
0.013606161810457706,
-0.061831552535295486,
-0.0011215467238798738,
0.004445931874215603,
-0.0005487527814693749,
0.08279988914728165,
0.029538163915276527,
-0.009705907665193081,
0.048806849867105484,
0.005948781967163086,
-0.04161464050412178,
-0.04211558774113655,
-0.011459233239293098,
-0.0037660710513591766,
-0.023652000352740288,
0.008435641415417194,
-0.028697283938527107,
-0.059970881789922714,
-0.058790069073438644,
0.03925301507115364,
0.006990937050431967,
-0.03628309816122055,
0.05825333669781685,
-0.05667892470955849,
0.020342150703072548,
0.004568933043628931,
-0.033456310629844666,
-0.025315869599580765,
0.02214914932847023,
-0.03408249467611313,
0.025047503411769867,
-0.022453298792243004,
0.04086321219801903,
0.0739259198307991,
-0.02411716803908348,
0.006566024385392666,
0.020109567791223526,
-0.020038003101944923,
0.011584470979869366,
-0.01340041495859623,
0.034959159791469574,
-0.046230535954236984,
-0.01668342761695385,
-0.052063025534152985,
0.03644411638379097,
-0.07492782175540924,
0.03184611350297928,
0.009768527001142502,
0.012792117893695831,
0.0114950155839324,
-0.01191545557230711,
0.030540063977241516,
0.012022801674902439,
0.0347265750169754,
0.03202502429485321,
-0.04776916652917862,
0.0033366852439939976,
0.026943957433104515,
-0.042079806327819824,
0.033849913626909256,
0.03229339048266411,
0.029305579140782356,
-0.03760703653097153,
-0.008435641415417194,
0.01833835057914257,
0.008672698400914669,
0.003736998187378049,
0.03465501219034195,
-0.027963748201727867,
0.004723243415355682,
-0.01530581433326006,
-0.0655171126127243,
0.03517385199666023,
-0.01555628888309002,
0.0191255584359169,
0.03572847694158554,
0.024689681828022003,
-0.011870727874338627,
-0.037929076701402664,
0.033778347074985504,
0.06938158720731735,
-0.035692691802978516,
0.10555733740329742,
-0.06744935363531113,
0.0013709035702049732,
-0.08308614790439606,
0.048198554664850235,
0.06108012795448303,
0.03857315704226494,
0.056500013917684555,
0.09002788364887238,
0.0021156196016818285,
-0.02842891775071621,
-0.007567924447357655,
-0.01825784146785736,
-0.08716531097888947,
0.027802729979157448,
0.06938158720731735,
-0.04884263128042221,
0.05535498261451721,
-0.017622707411646843,
0.008650334551930428,
0.003819744335487485,
-0.008784517645835876,
0.0018002893775701523,
-0.006673370487987995,
0.032669100910425186,
0.00895895529538393,
-0.023634109646081924,
0.023616217076778412,
0.04490659758448601,
-0.010197912342846394,
0.1102805808186531,
-0.021326160058379173,
0.00981325376778841,
0.04061273857951164,
0.014625953510403633,
-0.024653900414705276,
0.03374256566166878,
-0.027265997603535652,
-0.005233139265328646,
-0.03656935691833496,
-0.040970560163259506,
0.05743034929037094,
0.01393714640289545,
0.06175998970866203,
-0.012112257070839405,
0.032096587121486664,
0.013078375719487667,
0.045729584991931915,
-0.05338696390390396,
-0.03279433771967888,
-0.0698467567563057,
-0.0356748029589653,
-0.00005566500112763606,
0.018275732174515724,
0.009911655448377132,
-0.012273277156054974,
-0.01424129493534565,
0.03739234432578087,
0.06891641765832901,
-0.03651568293571472,
0.01163814403116703,
0.04587271437048912,
-0.0051079015247523785,
0.05714409053325653,
-0.04279544949531555,
0.05367322266101837,
0.08451743423938751,
-0.01752430759370327,
-0.03739234432578087,
-0.009061829186975956,
-0.04032647982239723,
0.029180342331528664,
0.0317387655377388,
-0.03324161469936371,
-0.03342052549123764,
0.014608061872422695,
0.0001255869574379176,
-0.02764170989394188,
0.0037638347130268812,
-0.033849913626909256,
-0.008033092133700848,
-0.016585025936365128,
0.028572045266628265,
0.027069196105003357,
0.022006021812558174,
-0.008471423760056496,
0.015860436484217644,
0.039217233657836914,
-0.007397959008812904,
0.04193667694926262,
-0.013257285580039024,
-0.04111368954181671,
0.007715525571256876,
0.04973718523979187,
0.02994965761899948,
0.009008156135678291,
0.03660513833165169,
0.024045603349804878,
-0.034798137843608856,
0.07185055315494537,
-0.04104212298989296,
0.07700318098068237,
0.03885941207408905,
0.04240184649825096,
-0.039610836654901505,
-0.03139883652329445,
0.007433741353452206,
-0.046230535954236984,
0.02932346984744072,
0.018642500042915344,
-0.04970140382647514,
0.03089788556098938,
-0.052241936326026917,
0.02567369118332863,
-0.01323044952005148,
-0.015359487384557724,
0.0144112603738904,
0.0032539390958845615,
0.05796708166599274,
0.02209547720849514,
-0.007813926786184311,
-0.004875317681580782,
-0.017202267423272133,
-0.01978752762079239,
-0.0363546647131443,
0.02091466635465622,
0.023133158683776855,
0.0012356023071333766,
-0.022328060120344162,
0.06873750686645508,
-0.00034076906740665436,
0.08129703998565674,
0.02338363416492939,
-0.14048071205615997,
-0.010859882459044456,
-0.009093138389289379,
-0.030146460980176926,
-0.024600226432085037,
0.05567702278494835,
0.011834945529699326,
-0.008422222919762135,
-0.10412605106830597,
-0.02417084202170372,
-0.032096587121486664,
0.04043382778763771,
-0.010045838542282581,
0.014608061872422695,
-0.02411716803908348,
0.0016392696416005492,
0.06848703324794769,
-0.041578855365514755,
-0.0054567777551710606,
-0.028500480577349663,
0.005309176165610552,
-0.013391468673944473,
-0.01578887365758419,
-0.0025584236718714237,
0.03544221818447113,
0.01368667185306549,
0.0020887828432023525,
-0.017479579895734787,
0.026049403473734856,
0.0111550847068429,
-0.029341362416744232,
0.004870845004916191,
-0.015091121196746826,
-0.01382085494697094,
0.0029028267599642277,
0.06508772820234299,
-0.05052439495921135,
-0.04004022479057312,
0.017220158129930496,
-0.06540976464748383,
0.03585371375083923,
0.02871517464518547,
-0.04390469565987587,
-0.018928756937384605,
-0.01645084284245968,
-0.07643067091703415,
0.01592305675148964,
-0.02322261407971382,
-0.04036226496100426,
-0.0047724442556500435,
0.041185252368450165,
-0.03170298412442207,
-0.017229104414582253,
0.01413394883275032,
0.006812026724219322,
-0.015609961934387684,
0.006803080905228853,
0.06444364786148071,
0.049200452864170074,
0.08122547715902328,
0.02595994807779789,
0.011146139353513718,
-0.02782062068581581,
-0.018275732174515724,
0.016406115144491196,
-0.039682403206825256,
0.05231350287795067,
0.034243516623973846,
0.00048249991959892213,
-0.010394713841378689,
-0.004097056109458208,
0.013534598052501678,
0.04261653870344162,
-0.002706025028601289,
0.0320071317255497,
0.017640599980950356,
0.010716753080487251,
0.04458455741405487,
0.01676393672823906,
0.05217037349939346,
-0.011700762435793877,
-0.005085537675768137,
-0.0060114008374512196,
0.04894997924566269,
-0.08351553231477737,
-0.015833601355552673,
0.011342940852046013,
-0.012112257070839405,
-0.04322483390569687,
-0.028679391369223595,
0.018374133855104446,
-0.026836611330509186,
0.017560089007019997,
0.008909755386412144,
0.0038465808611363173,
-0.04934358224272728,
-0.03651568293571472,
0.004211111459881067,
-0.0005071001360192895,
-0.005045283120125532,
0.06641166657209396,
0.008744262158870697,
-0.015431051142513752,
0.06179577112197876,
0.01867828145623207,
0.014670681208372116,
-0.061259038746356964,
0.0028357352130115032,
-0.003799616824835539,
-0.039396144449710846,
0.039789747446775436,
-0.017703218385577202,
0.04759025573730469,
-0.021737655624747276,
-0.023508870974183083,
-0.009119975380599499,
-0.04555067420005798,
-0.0492362380027771,
0.010027946904301643,
-0.02579892985522747,
-0.01996643841266632,
0.024743355810642242,
-0.0030057004187256098,
-0.03433297201991081,
0.012997865676879883,
-0.06530242413282394,
-0.05159785971045494,
-0.020199023187160492,
-0.03095155768096447,
0.018588826060295105,
0.013436196371912956,
-0.02451077103614807,
0.0010186730651184916,
-0.011450287885963917,
-0.027069196105003357,
-0.026049403473734856,
-0.054639339447021484,
-0.06254719197750092,
0.021898675709962845,
-0.055605459958314896,
0.013561434112489223,
0.011826000176370144,
0.0008956718957051635,
-0.01671026274561882,
0.049987662583589554,
-0.022417515516281128,
-0.0706697404384613,
0.06337018311023712,
0.018660390749573708,
0.023705672472715378,
0.05149051174521446,
-0.0024533134419471025,
-0.029126668348908424,
-0.061437949538230896,
-0.01705019362270832,
-0.07363966107368469,
-0.06859438121318817,
0.05023813620209694,
-0.017900019884109497,
-0.016021456569433212,
0.00843116920441389,
-0.043940477073192596,
-0.05349431186914444,
0.032669100910425186,
0.005573069676756859,
0.02180922031402588,
0.03157774731516838,
-0.04175776615738869,
-0.05020235478878021,
-0.02114724926650524,
-0.02007378451526165,
0.057788170874118805,
0.009822200052440166,
-0.04021913558244705,
-0.007787090260535479,
0.04569380357861519,
-0.018928756937384605,
-0.010913555510342121,
0.02372356504201889,
0.0028737538959831,
-0.032114479690790176,
-0.06730622053146362,
0.0340467132627964,
0.025727365165948868,
0.024349752813577652,
-0.004065746441483498,
-0.07192211598157883,
0.004651679191738367,
-0.038215335458517075,
-0.0129531379789114,
-0.008650334551930428,
-0.03134516254067421,
0.028911976143717766,
-0.03488759323954582,
0.04759025573730469,
-0.023061593994498253,
0.01379401795566082,
0.0480196438729763,
-0.0006591742858290672,
-0.05170520395040512,
0.055426549166440964,
0.047912295907735825,
-0.032275497913360596,
-0.021165139973163605,
0.0043721310794353485,
-0.021845001727342606,
0.023813020437955856,
-0.0027216796297580004,
0.037929076701402664,
0.003479813924059272,
0.0004858544853050262,
0.03843002766370773,
-0.016093021258711815,
-0.05310070887207985,
-0.025101177394390106,
-0.051848333328962326,
-0.04165042191743851,
-0.018588826060295105,
0.011199812404811382,
-0.010001110844314098,
-0.01786423847079277,
-0.03195345774292946,
0.02114724926650524,
0.011137194000184536,
-0.038501590490341187,
-0.02282901108264923,
-0.03585371375083923,
0.030522173270583153,
-0.05288601666688919,
-0.017640599980950356,
-0.032830122858285904,
-0.03410038724541664,
-0.018141549080610275,
-0.03225760534405708,
0.02697974070906639,
-0.015431051142513752,
-0.0069641005247831345,
-0.01578887365758419,
0.036032624542713165,
0.019501270726323128,
-0.023419415578246117,
-0.06641166657209396,
-0.06820077449083328,
0.014679626561701298,
-0.003153301775455475,
-0.0114950155839324,
0.048699505627155304,
0.01726488582789898,
0.008149384520947933,
0.034851811826229095,
0.030969450250267982,
-0.0713496059179306,
-0.052349284291267395,
0.019089777022600174,
0.0039449818432331085,
0.01642400585114956,
-0.03365311026573181,
-0.02366989105939865,
0.03746391087770462,
0.001657160697504878,
-0.01031420473009348,
-0.05231350287795067,
0.011933346278965473,
0.014402315020561218,
-0.03263331949710846,
-0.03039693459868431,
-0.015225304290652275,
-0.013436196371912956,
-0.017542198300361633,
0.001302693854086101,
-0.0046829888597130775,
-0.03549589216709137,
-0.010269477032124996,
-0.02826789766550064,
0.0363546647131443,
-0.017166486009955406,
0.02359832637012005,
0.03767860308289528,
0.001203174702823162,
0.0633344054222107,
-0.024761246517300606,
0.03644411638379097,
-0.010627297684550285,
0.07442686706781387,
-0.02816055156290531,
0.032275497913360596,
-0.0064094774425029755,
0.007545560598373413,
-0.06451521068811417,
-0.012326950207352638,
0.057000961154699326,
-0.026550354436039925,
0.0184456966817379,
0.08931224048137665,
-0.00048082260764203966,
-0.024045603349804878,
0.04490659758448601,
-0.008243312127888203,
0.02579892985522747,
0.0329553596675396,
0.024206623435020447,
-0.03596105799078941,
0.04075586795806885,
-0.01320361252874136,
0.011199812404811382,
-0.06841547042131424,
-0.015520506538450718,
0.003951691091060638,
0.034690793603658676,
-0.024743355810642242,
-0.04673148691654205,
0.019662290811538696,
0.04422673583030701,
0.0569651797413826
]
|
30,460 | networkx.generators.classic | circulant_graph | Returns the circulant graph $Ci_n(x_1, x_2, ..., x_m)$ with $n$ nodes.
The circulant graph $Ci_n(x_1, ..., x_m)$ consists of $n$ nodes $0, ..., n-1$
such that node $i$ is connected to nodes $(i + x) \mod n$ and $(i - x) \mod n$
for all $x$ in $x_1, ..., x_m$. Thus $Ci_n(1)$ is a cycle graph.
.. plot::
>>> nx.draw(nx.circulant_graph(10, [1]))
Parameters
----------
n : integer
The number of nodes in the graph.
offsets : list of integers
A list of node offsets, $x_1$ up to $x_m$, as described above.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
NetworkX Graph of type create_using
Examples
--------
Many well-known graph families are subfamilies of the circulant graphs;
for example, to create the cycle graph on n points, we connect every
node to nodes on either side (with offset plus or minus one). For n = 10,
>>> G = nx.circulant_graph(10, [1])
>>> edges = [
... (0, 9),
... (0, 1),
... (1, 2),
... (2, 3),
... (3, 4),
... (4, 5),
... (5, 6),
... (6, 7),
... (7, 8),
... (8, 9),
... ]
>>> sorted(edges) == sorted(G.edges())
True
Similarly, we can create the complete graph
on 5 points with the set of offsets [1, 2]:
>>> G = nx.circulant_graph(5, [1, 2])
>>> edges = [
... (0, 1),
... (0, 2),
... (0, 3),
... (0, 4),
... (1, 2),
... (1, 3),
... (1, 4),
... (2, 3),
... (2, 4),
... (3, 4),
... ]
>>> sorted(edges) == sorted(G.edges())
True
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (n, offsets, create_using=None, *, backend=None, **backend_kwargs) | [
0.02225247211754322,
-0.006895069498568773,
0.02168417163193226,
-0.0502234548330307,
-0.012653540819883347,
0.06673965603113174,
-0.047559551894664764,
0.007436729967594147,
-0.0006354519282467663,
0.0049814991652965546,
0.004182328004390001,
0.06244189292192459,
0.016960183158516884,
0.07608107477426529,
0.02701197937130928,
-0.007583244703710079,
0.014793542213737965,
0.011836609803140163,
-0.02283853106200695,
0.03800502046942711,
-0.019801679998636246,
0.015130970627069473,
0.03425779566168785,
0.013941093347966671,
-0.020849483087658882,
0.012058601714670658,
0.022216953337192535,
0.03244633972644806,
-0.03736568242311478,
0.027260608971118927,
0.03315671533346176,
-0.01215627882629633,
0.0011676775757223368,
0.018363172188401222,
0.020671889185905457,
0.04237382113933563,
-0.02145330049097538,
0.05313599109649658,
-0.1044960469007492,
-0.01573478803038597,
0.046387434005737305,
-0.005953823681920767,
0.014837941154837608,
-0.03299688175320625,
0.012174038216471672,
0.028450487181544304,
0.0834689661860466,
0.004541954956948757,
-0.06876422464847565,
-0.017555123195052147,
0.04290660098195076,
0.004220066592097282,
-0.04329730570316315,
-0.058321721851825714,
-0.0019435393624007702,
0.010087313130497932,
-0.007561045233160257,
-0.01233387179672718,
0.059493839740753174,
-0.03995854780077934,
0.03365397825837135,
0.032108914107084274,
0.006206894759088755,
-0.023548904806375504,
-0.05622611939907074,
-0.02180848829448223,
-0.03885746747255325,
-0.06141185015439987,
-0.014305160380899906,
-0.018931472674012184,
0.0540594756603241,
0.041485853493213654,
0.030190903693437576,
-0.009634450078010559,
0.012893292121589184,
0.026337122544646263,
0.0364777147769928,
0.01084208581596613,
-0.01046913955360651,
-0.009052830748260021,
-0.02283853106200695,
-0.036211322993040085,
0.022003840655088425,
-0.048056814819574356,
0.046316396445035934,
0.09824474900960922,
-0.019677365198731422,
0.021027076989412308,
-0.04457598179578781,
-0.023992888629436493,
-0.024401353672146797,
-0.027793390676379204,
-0.026106251403689384,
0.0055098398588597775,
-0.0127068180590868,
0.01596565917134285,
0.050330013036727905,
-0.09249071776866913,
0.012351631186902523,
-0.0009695497574284673,
-0.03754327446222305,
-0.03336982801556587,
-0.08865469694137573,
-0.021844007074832916,
-0.05665234103798866,
-0.031434059143066406,
-0.02534259855747223,
0.05682993680238724,
-0.013115284033119678,
0.028539283201098442,
-0.019055787473917007,
0.01742192730307579,
0.06613583862781525,
-0.01362142525613308,
0.029782438650727272,
0.04269348829984665,
-0.018185580149292946,
0.03864435479044914,
0.06521235406398773,
-0.023051641881465912,
-0.058463796973228455,
0.044185273349285126,
-0.040384773164987564,
0.029746919870376587,
0.02686990424990654,
-0.0003812711511272937,
0.04457598179578781,
-0.05313599109649658,
0.030208662152290344,
0.021062595769762993,
-0.0015495037660002708,
0.01896699145436287,
-0.0010544616961851716,
0.06819592416286469,
-0.03530559688806534,
0.01322183944284916,
-0.07885153591632843,
-0.02834393084049225,
-0.0012775636278092861,
-0.014287400990724564,
0.03392036631703377,
-0.03413347899913788,
0.03875091299414635,
0.0495130829513073,
-0.06070147454738617,
0.015477278269827366,
0.01873612031340599,
0.019144585356116295,
0.01331951655447483,
-0.014482754282653332,
0.023690979927778244,
0.002009026939049363,
0.09533222019672394,
0.030723683536052704,
-0.02211039699614048,
-0.018398690968751907,
0.02710077539086342,
-0.02234126813709736,
-0.012147398665547371,
0.029853476211428642,
-0.007463369052857161,
0.011845489963889122,
0.03988751024007797,
-0.016596117988228798,
-0.07615211606025696,
-0.0033232192508876324,
-0.006291251629590988,
-0.004397660028189421,
0.0065665217116475105,
-0.02717181295156479,
-0.04166344553232193,
-0.0009062821045517921,
0.0012575843138620257,
-0.05601300671696663,
-0.004568594042211771,
-0.0020434358157217503,
-0.030865758657455444,
-0.01119727361947298,
-0.017191056162118912,
-0.02591089904308319,
0.029675882309675217,
-0.07064671069383621,
0.029107581824064255,
-0.041770003736019135,
-0.01208524126559496,
0.017697196453809738,
0.00995411816984415,
0.014109807088971138,
0.029125342145562172,
0.03354742005467415,
0.04670710489153862,
0.025093968957662582,
-0.012884411960840225,
0.05601300671696663,
0.022891808301210403,
-0.05842827633023262,
0.06986530125141144,
0.036211322993040085,
-0.0722450539469719,
0.05526711419224739,
0.07743078470230103,
0.07132156938314438,
0.020458776503801346,
-0.010362583212554455,
0.04848304018378258,
-0.0005799539503641427,
-0.051217980682849884,
-0.048127852380275726,
-0.05182179808616638,
0.028716877102851868,
-0.008044987916946411,
0.019677365198731422,
0.037969499826431274,
0.04454046115279198,
-0.06485716253519058,
0.06968770921230316,
0.038999542593955994,
0.03177148476243019,
0.01002515573054552,
-0.061092179268598557,
-0.035181280225515366,
-0.015672631561756134,
0.0032344225328415632,
0.034222278743982315,
-0.008373536169528961,
-0.005767350550740957,
-0.008373536169528961,
-0.016826989129185677,
-0.004586353432387114,
-0.06269052624702454,
0.026550235226750374,
-0.02656799554824829,
0.04422079399228096,
-0.015273044817149639,
0.012609141878783703,
-0.01522864680737257,
0.03345862403512001,
-0.011694535613059998,
-0.04237382113933563,
0.032322026789188385,
-0.05512503907084465,
-0.019499771296977997,
0.007396771106868982,
-0.009394698776304722,
-0.01383453793823719,
0.07970398664474487,
-0.01039810199290514,
0.031434059143066406,
0.0024907495826482773,
-0.011694535613059998,
-0.0044820173643529415,
-0.019055787473917007,
0.01284889318048954,
-0.030919037759304047,
0.0188959538936615,
0.030546089634299278,
-0.05697201192378998,
-0.0074678086675703526,
0.015166489407420158,
0.04269348829984665,
-0.02759803831577301,
-0.008773121051490307,
-0.0580020546913147,
-0.02834393084049225,
0.06176703795790672,
0.01807902380824089,
-0.06869318336248398,
0.05288735777139664,
-0.05952935665845871,
-0.028663598001003265,
0.05704304948449135,
0.08140888065099716,
0.10527745634317398,
0.004477577283978462,
0.012760096229612827,
-0.056119561195373535,
0.0025018490850925446,
0.039851993322372437,
-0.04290660098195076,
-0.03162940964102745,
-0.053917400538921356,
-0.03711705282330513,
-0.01175669301301241,
0.04283556342124939,
0.02532484009861946,
0.032322026789188385,
0.049974825233221054,
-0.004082431551069021,
0.025680027902126312,
-0.028805673122406006,
0.019677365198731422,
-0.014837941154837608,
-0.03683290258049965,
-0.0030990075320005417,
0.030475053936243057,
0.020245663821697235,
-0.026479197666049004,
0.015273044817149639,
0.002346454653888941,
0.052532173693180084,
0.09412457793951035,
-0.05310047045350075,
0.036655306816101074,
0.0224833432585001,
0.045357391238212585,
0.02701197937130928,
0.0004706229083240032,
0.01039810199290514,
0.012760096229612827,
0.014695866033434868,
-0.05448570102453232,
0.014349558390676975,
0.005061415955424309,
0.009323661215603352,
-0.010513538494706154,
-0.05864138901233673,
-0.020441018044948578,
-0.02145330049097538,
0.038040537387132645,
0.038253650069236755,
0.019144585356116295,
0.005256769247353077,
-0.052603207528591156,
0.02129346691071987,
-0.052461136132478714,
0.05334910377860069,
-0.01003403589129448,
0.057149603962898254,
-0.04912237450480461,
0.02100931666791439,
0.019002510234713554,
-0.0195530503988266,
-0.031132148578763008,
0.035394392907619476,
-0.07213850319385529,
0.03551870957016945,
0.013905574567615986,
-0.032552897930145264,
-0.01548615749925375,
-0.051075905561447144,
0.029782438650727272,
0.010531297884881496,
-0.015548314899206161,
0.007050463929772377,
-0.03010210581123829,
0.03864435479044914,
0.04695573449134827,
-0.09348524361848831,
-0.03786294534802437,
-0.0267278291285038,
0.03155837208032608,
0.07870946079492569,
-0.02628384530544281,
-0.029782438650727272,
0.040242698043584824,
0.06641998887062073,
0.005345565732568502,
0.012360511347651482,
-0.06404023617506027,
-0.01058457512408495,
-0.003749443916603923,
0.0035385515075176954,
0.062193259596824646,
-0.009856441989541054,
-0.005758470855653286,
0.02108035422861576,
-0.013568147085607052,
0.08702083677053452,
0.011667896062135696,
-0.006539882626384497,
-0.024152722209692,
-0.0736658051609993,
-0.07679145038127899,
0.05043656751513481,
-0.0057851099409163,
0.05423707142472267,
-0.01544175948947668,
-0.031807005405426025,
0.02717181295156479,
-0.0018902613082900643,
-0.041912078857421875,
-0.019730642437934875,
0.04251589626073837,
0.006917268969118595,
0.02644367888569832,
-0.00003877921699313447,
0.0411306656897068,
0.019304418936371803,
-0.04269348829984665,
-0.027562519535422325,
-0.053633250296115875,
-0.046458471566438675,
0.06240637227892876,
-0.004857183434069157,
-0.029338454827666283,
0.002228799043223262,
0.09561637043952942,
0.049015820026397705,
-0.05288735777139664,
0.017359768971800804,
0.05178627744317055,
-0.04571257904171944,
0.025537952780723572,
0.002623944776132703,
-0.0047195483930408955,
-0.03697497770190239,
0.010593455284833908,
-0.009936358779668808,
-0.02614177018404007,
-0.026603514328598976,
0.01997927390038967,
-0.07870946079492569,
-0.03038625605404377,
-0.0004234496154822409,
0.07153467833995819,
0.006215773988515139,
0.010406982153654099,
0.0009756545769050717,
0.02949828840792179,
0.004621872212737799,
0.023904092609882355,
-0.09384042769670486,
-0.015122090466320515,
0.09682400524616241,
0.05310047045350075,
-0.05072071775794029,
0.027988743036985397,
-0.0163208469748497,
-0.01200532354414463,
0.07267127931118011,
0.03413347899913788,
-0.023850813508033752,
0.035980451852083206,
0.006730795372277498,
0.007356812711805105,
-0.06155392527580261,
0.025378117337822914,
0.006158056203275919,
-0.0017437466885894537,
0.0013275117380544543,
0.031025592237710953,
-0.005301167257130146,
0.01868284121155739,
-0.021062595769762993,
-0.0026461437810212374,
-0.015770306810736656,
0.03814709559082985,
0.03475505858659744,
-0.002339794998988509,
-0.0339558869600296,
-0.006695276591926813,
-0.031434059143066406,
0.05221250280737877,
0.00030412894557230175,
-0.03878642991185188,
-0.007751958444714546,
0.019020268693566322,
-0.04578361660242081,
-0.059706952422857285,
0.04713332653045654,
-0.010930882766842842,
0.026852143928408623,
-0.020831722766160965,
0.02189728431403637,
-0.01672043278813362,
-0.042444858700037,
0.028095299378037453,
-0.005829508416354656,
-0.04116618633270264,
-0.0705401599407196,
0.024472391232848167,
0.013124163262546062,
-0.038999542593955994,
-0.031007833778858185,
0.038182612508535385,
-0.03477281704545021,
-0.026408160105347633,
-0.04656502977013588,
-0.000288034527329728,
-0.03088351897895336,
-0.060736995190382004,
0.015335203148424625,
-0.010176110081374645,
0.039567843079566956,
-0.04716884717345238,
-0.023708738386631012,
0.023175958544015884,
-0.047559551894664764,
0.0018491927767172456,
-0.03542991355061531,
-0.0031189867295324802,
-0.022607658058404922,
-0.015237526968121529,
0.01596565917134285,
-0.030634887516498566,
0.07089534401893616,
-0.01746632531285286,
-0.038395725190639496,
-0.0020012573804706335,
-0.009297022596001625,
0.019304418936371803,
-0.002124462742358446,
-0.022021600976586342,
0.014873459935188293,
0.006979426369071007,
0.05803757160902023,
-0.006655318196862936,
-0.012884411960840225,
0.00828917883336544,
0.042800046503543854,
0.0391061007976532,
0.03857331722974777,
0.024632224813103676,
0.041983116418123245,
-0.022643176838755608,
0.008013908751308918,
-0.021719690412282944,
-0.0076942406594753265,
0.04329730570316315,
-0.057362716645002365,
0.04123722389340401,
0.03821813315153122,
0.00988308060914278,
0.041841041296720505,
-0.025271562859416008,
-0.005936064291745424,
0.03843124583363533,
-0.02665679156780243,
0.016214290633797646,
-0.0005477651138789952,
0.022359028458595276,
0.06169600039720535,
-0.03946128487586975,
0.010779928416013718,
-0.04134377837181091,
-0.0808405801653862,
0.03471953794360161,
0.046742621809244156,
0.008151544257998466,
-0.020316701382398605,
0.002672782866284251,
-0.0022709774784743786,
-0.011099596507847309,
0.0019113505259156227,
0.0011987565085291862,
0.02964036352932453,
0.006140296813100576,
-0.06748554855585098,
0.026337122544646263,
-0.059635914862155914,
0.034222278743982315,
-0.0038981784600764513,
0.007436729967594147,
0.006588720716536045,
0.08368208259344101,
-0.006118097808212042,
0.007996149361133575,
-0.026834385469555855,
0.004186768084764481,
0.03242858126759529,
-0.062193259596824646,
0.006584280636161566,
-0.0017615059623494744,
-0.029604844748973846,
0.01866508275270462,
-0.0000034859672268794384,
0.008679884485900402,
-0.023016123101115227,
0.02466774359345436,
0.007569924928247929,
-0.005603076424449682,
0.06421782821416855,
0.08972026407718658,
-0.009279263205826283,
-0.016054457053542137,
-0.0072591365315020084,
-0.04269348829984665,
-0.004741747863590717,
-0.039709918200969696,
-0.01793694868683815,
-0.020334461703896523,
-0.019641846418380737,
0.002570666605606675,
0.0005610845983028412,
-0.002583986148238182,
0.06393367797136307,
-0.09433769434690475,
-0.004639631602913141,
-0.01786591112613678,
0.015610473230481148,
0.04503772407770157,
-0.05690097436308861,
0.06435990333557129,
0.03354742005467415,
-0.04372353106737137,
0.01072665024548769,
-0.020174626260995865,
-0.045641541481018066,
0.02651471644639969,
0.005931624677032232,
-0.046813659369945526,
0.08865469694137573,
-0.02086724154651165,
0.032908085733652115,
0.062264297157526016,
0.042942121624946594,
0.03155837208032608,
-0.016045577824115753,
-0.016303088515996933,
-0.08453452587127686,
-0.0060692597180604935,
0.05373980849981308,
-0.02093827910721302,
-0.04869615286588669,
-0.050187937915325165,
0.012724577449262142,
-0.028716877102851868,
0.05189283564686775,
-0.06531890481710434,
-0.029995551332831383,
-0.015832465142011642,
0.03542991355061531,
-0.01522864680737257,
-0.007743078749626875,
-0.02900102734565735,
0.0012187357060611248,
0.018469728529453278,
-0.029107581824064255,
0.0012997627491131425,
0.004060232546180487,
0.010673372074961662,
-0.05491192638874054,
-0.022962845861911774,
-0.03463074192404747,
-0.0115702198818326,
-0.007547725923359394,
0.009439096786081791,
-0.027544759213924408,
0.0038826388772577047,
0.09625570476055145,
-0.0430486761033535,
0.008329137228429317,
-0.029089823365211487,
-0.026301603764295578,
-0.0038182612042874098,
-0.031149908900260925,
0.018700601533055305,
-0.03654875233769417,
-0.006531002931296825,
-0.028130818158388138,
-0.0391061007976532,
-0.002901434665545821,
0.01772383600473404,
0.01880715601146221,
0.04276452586054802,
0.037294644862413406,
-0.034808333963155746,
-0.06240637227892876,
0.0054476819932460785,
-0.06173151731491089,
0.05381084606051445,
-0.015610473230481148,
0.029817957431077957,
0.06162496283650398,
0.0011965365847572684,
0.06105666235089302,
-0.003685066243633628,
-0.06148288771510124,
0.006033740937709808,
-0.0004462038050405681,
0.0046485112980008125,
0.008098266087472439,
0.038253650069236755,
-0.016942424699664116,
-0.055089518427848816,
-0.01501553412526846,
-0.014882339164614677,
0.028166336938738823,
-0.04461149871349335,
-0.009856441989541054,
0.009483495727181435,
-0.0091194286942482,
0.03281928971409798,
-0.024436872452497482,
-0.0199082363396883,
-0.01786591112613678,
-0.04098859056830406,
-0.05199939012527466,
0.018718359991908073,
0.011117355898022652,
-0.01749296486377716,
0.028219614177942276,
0.010771049186587334,
0.016303088515996933,
-0.0195530503988266,
0.014873459935188293,
-0.01599229872226715,
0.027189573273062706,
0.004233386367559433,
-0.05079175531864166,
0.03669082745909691,
-0.0014362878864631057,
-0.009341420605778694,
0.03768534958362579,
0.01746632531285286,
0.022820770740509033,
-0.03420451655983925,
0.012111879885196686,
-0.04141481593251228,
0.035696301609277725,
-0.07132156938314438,
-0.023193717002868652,
0.0042555853724479675,
0.02175520919263363,
-0.08716291189193726,
0.0052123707719147205,
0.029693640768527985,
0.005265648942440748,
-0.05192835256457329,
-0.0014917858643457294,
0.03361845761537552,
-0.04727540165185928,
-0.025822101160883904,
0.05111142247915268,
-0.035980451852083206,
0.009070590138435364,
-0.032108914107084274,
-0.037152569741010666,
-0.042196229100227356,
-0.029480529949069023,
-0.021027076989412308,
0.030439535155892372,
0.011792211793363094,
-0.016054457053542137,
0.018931472674012184,
-0.0016316407127305865,
0.020973797887563705,
0.02759803831577301,
-0.016560599207878113,
-0.016640515998005867,
0.002959152450785041,
-0.02145330049097538,
-0.06656206399202347,
-0.020902760326862335,
-0.016658274456858635,
-0.014473874121904373,
0.008329137228429317,
-0.01845197007060051,
0.0011621278245002031,
0.02928517572581768,
0.04134377837181091,
-0.00279265851713717,
0.008964034728705883,
0.02649695798754692,
-0.04471805691719055,
-0.024063926190137863,
0.015281924977898598,
-0.0055142794735729694,
-0.01786591112613678,
-0.04354593902826309,
-0.02283853106200695,
0.02834393084049225,
0.06404023617506027,
-0.010966401547193527,
-0.045144278556108475,
0.003292140318080783,
0.0456770621240139,
-0.003096787491813302
]
|
30,461 | networkx.generators.classic | circular_ladder_graph | Returns the circular ladder graph $CL_n$ of length n.
$CL_n$ consists of two concentric n-cycles in which
each of the n pairs of concentric nodes are joined by an edge.
Node labels are the integers 0 to n-1
.. plot::
>>> nx.draw(nx.circular_ladder_graph(5))
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (n, create_using=None, *, backend=None, **backend_kwargs) | [
0.02225247211754322,
-0.006895069498568773,
0.02168417163193226,
-0.0502234548330307,
-0.012653540819883347,
0.06673965603113174,
-0.047559551894664764,
0.007436729967594147,
-0.0006354519282467663,
0.0049814991652965546,
0.004182328004390001,
0.06244189292192459,
0.016960183158516884,
0.07608107477426529,
0.02701197937130928,
-0.007583244703710079,
0.014793542213737965,
0.011836609803140163,
-0.02283853106200695,
0.03800502046942711,
-0.019801679998636246,
0.015130970627069473,
0.03425779566168785,
0.013941093347966671,
-0.020849483087658882,
0.012058601714670658,
0.022216953337192535,
0.03244633972644806,
-0.03736568242311478,
0.027260608971118927,
0.03315671533346176,
-0.01215627882629633,
0.0011676775757223368,
0.018363172188401222,
0.020671889185905457,
0.04237382113933563,
-0.02145330049097538,
0.05313599109649658,
-0.1044960469007492,
-0.01573478803038597,
0.046387434005737305,
-0.005953823681920767,
0.014837941154837608,
-0.03299688175320625,
0.012174038216471672,
0.028450487181544304,
0.0834689661860466,
0.004541954956948757,
-0.06876422464847565,
-0.017555123195052147,
0.04290660098195076,
0.004220066592097282,
-0.04329730570316315,
-0.058321721851825714,
-0.0019435393624007702,
0.010087313130497932,
-0.007561045233160257,
-0.01233387179672718,
0.059493839740753174,
-0.03995854780077934,
0.03365397825837135,
0.032108914107084274,
0.006206894759088755,
-0.023548904806375504,
-0.05622611939907074,
-0.02180848829448223,
-0.03885746747255325,
-0.06141185015439987,
-0.014305160380899906,
-0.018931472674012184,
0.0540594756603241,
0.041485853493213654,
0.030190903693437576,
-0.009634450078010559,
0.012893292121589184,
0.026337122544646263,
0.0364777147769928,
0.01084208581596613,
-0.01046913955360651,
-0.009052830748260021,
-0.02283853106200695,
-0.036211322993040085,
0.022003840655088425,
-0.048056814819574356,
0.046316396445035934,
0.09824474900960922,
-0.019677365198731422,
0.021027076989412308,
-0.04457598179578781,
-0.023992888629436493,
-0.024401353672146797,
-0.027793390676379204,
-0.026106251403689384,
0.0055098398588597775,
-0.0127068180590868,
0.01596565917134285,
0.050330013036727905,
-0.09249071776866913,
0.012351631186902523,
-0.0009695497574284673,
-0.03754327446222305,
-0.03336982801556587,
-0.08865469694137573,
-0.021844007074832916,
-0.05665234103798866,
-0.031434059143066406,
-0.02534259855747223,
0.05682993680238724,
-0.013115284033119678,
0.028539283201098442,
-0.019055787473917007,
0.01742192730307579,
0.06613583862781525,
-0.01362142525613308,
0.029782438650727272,
0.04269348829984665,
-0.018185580149292946,
0.03864435479044914,
0.06521235406398773,
-0.023051641881465912,
-0.058463796973228455,
0.044185273349285126,
-0.040384773164987564,
0.029746919870376587,
0.02686990424990654,
-0.0003812711511272937,
0.04457598179578781,
-0.05313599109649658,
0.030208662152290344,
0.021062595769762993,
-0.0015495037660002708,
0.01896699145436287,
-0.0010544616961851716,
0.06819592416286469,
-0.03530559688806534,
0.01322183944284916,
-0.07885153591632843,
-0.02834393084049225,
-0.0012775636278092861,
-0.014287400990724564,
0.03392036631703377,
-0.03413347899913788,
0.03875091299414635,
0.0495130829513073,
-0.06070147454738617,
0.015477278269827366,
0.01873612031340599,
0.019144585356116295,
0.01331951655447483,
-0.014482754282653332,
0.023690979927778244,
0.002009026939049363,
0.09533222019672394,
0.030723683536052704,
-0.02211039699614048,
-0.018398690968751907,
0.02710077539086342,
-0.02234126813709736,
-0.012147398665547371,
0.029853476211428642,
-0.007463369052857161,
0.011845489963889122,
0.03988751024007797,
-0.016596117988228798,
-0.07615211606025696,
-0.0033232192508876324,
-0.006291251629590988,
-0.004397660028189421,
0.0065665217116475105,
-0.02717181295156479,
-0.04166344553232193,
-0.0009062821045517921,
0.0012575843138620257,
-0.05601300671696663,
-0.004568594042211771,
-0.0020434358157217503,
-0.030865758657455444,
-0.01119727361947298,
-0.017191056162118912,
-0.02591089904308319,
0.029675882309675217,
-0.07064671069383621,
0.029107581824064255,
-0.041770003736019135,
-0.01208524126559496,
0.017697196453809738,
0.00995411816984415,
0.014109807088971138,
0.029125342145562172,
0.03354742005467415,
0.04670710489153862,
0.025093968957662582,
-0.012884411960840225,
0.05601300671696663,
0.022891808301210403,
-0.05842827633023262,
0.06986530125141144,
0.036211322993040085,
-0.0722450539469719,
0.05526711419224739,
0.07743078470230103,
0.07132156938314438,
0.020458776503801346,
-0.010362583212554455,
0.04848304018378258,
-0.0005799539503641427,
-0.051217980682849884,
-0.048127852380275726,
-0.05182179808616638,
0.028716877102851868,
-0.008044987916946411,
0.019677365198731422,
0.037969499826431274,
0.04454046115279198,
-0.06485716253519058,
0.06968770921230316,
0.038999542593955994,
0.03177148476243019,
0.01002515573054552,
-0.061092179268598557,
-0.035181280225515366,
-0.015672631561756134,
0.0032344225328415632,
0.034222278743982315,
-0.008373536169528961,
-0.005767350550740957,
-0.008373536169528961,
-0.016826989129185677,
-0.004586353432387114,
-0.06269052624702454,
0.026550235226750374,
-0.02656799554824829,
0.04422079399228096,
-0.015273044817149639,
0.012609141878783703,
-0.01522864680737257,
0.03345862403512001,
-0.011694535613059998,
-0.04237382113933563,
0.032322026789188385,
-0.05512503907084465,
-0.019499771296977997,
0.007396771106868982,
-0.009394698776304722,
-0.01383453793823719,
0.07970398664474487,
-0.01039810199290514,
0.031434059143066406,
0.0024907495826482773,
-0.011694535613059998,
-0.0044820173643529415,
-0.019055787473917007,
0.01284889318048954,
-0.030919037759304047,
0.0188959538936615,
0.030546089634299278,
-0.05697201192378998,
-0.0074678086675703526,
0.015166489407420158,
0.04269348829984665,
-0.02759803831577301,
-0.008773121051490307,
-0.0580020546913147,
-0.02834393084049225,
0.06176703795790672,
0.01807902380824089,
-0.06869318336248398,
0.05288735777139664,
-0.05952935665845871,
-0.028663598001003265,
0.05704304948449135,
0.08140888065099716,
0.10527745634317398,
0.004477577283978462,
0.012760096229612827,
-0.056119561195373535,
0.0025018490850925446,
0.039851993322372437,
-0.04290660098195076,
-0.03162940964102745,
-0.053917400538921356,
-0.03711705282330513,
-0.01175669301301241,
0.04283556342124939,
0.02532484009861946,
0.032322026789188385,
0.049974825233221054,
-0.004082431551069021,
0.025680027902126312,
-0.028805673122406006,
0.019677365198731422,
-0.014837941154837608,
-0.03683290258049965,
-0.0030990075320005417,
0.030475053936243057,
0.020245663821697235,
-0.026479197666049004,
0.015273044817149639,
0.002346454653888941,
0.052532173693180084,
0.09412457793951035,
-0.05310047045350075,
0.036655306816101074,
0.0224833432585001,
0.045357391238212585,
0.02701197937130928,
0.0004706229083240032,
0.01039810199290514,
0.012760096229612827,
0.014695866033434868,
-0.05448570102453232,
0.014349558390676975,
0.005061415955424309,
0.009323661215603352,
-0.010513538494706154,
-0.05864138901233673,
-0.020441018044948578,
-0.02145330049097538,
0.038040537387132645,
0.038253650069236755,
0.019144585356116295,
0.005256769247353077,
-0.052603207528591156,
0.02129346691071987,
-0.052461136132478714,
0.05334910377860069,
-0.01003403589129448,
0.057149603962898254,
-0.04912237450480461,
0.02100931666791439,
0.019002510234713554,
-0.0195530503988266,
-0.031132148578763008,
0.035394392907619476,
-0.07213850319385529,
0.03551870957016945,
0.013905574567615986,
-0.032552897930145264,
-0.01548615749925375,
-0.051075905561447144,
0.029782438650727272,
0.010531297884881496,
-0.015548314899206161,
0.007050463929772377,
-0.03010210581123829,
0.03864435479044914,
0.04695573449134827,
-0.09348524361848831,
-0.03786294534802437,
-0.0267278291285038,
0.03155837208032608,
0.07870946079492569,
-0.02628384530544281,
-0.029782438650727272,
0.040242698043584824,
0.06641998887062073,
0.005345565732568502,
0.012360511347651482,
-0.06404023617506027,
-0.01058457512408495,
-0.003749443916603923,
0.0035385515075176954,
0.062193259596824646,
-0.009856441989541054,
-0.005758470855653286,
0.02108035422861576,
-0.013568147085607052,
0.08702083677053452,
0.011667896062135696,
-0.006539882626384497,
-0.024152722209692,
-0.0736658051609993,
-0.07679145038127899,
0.05043656751513481,
-0.0057851099409163,
0.05423707142472267,
-0.01544175948947668,
-0.031807005405426025,
0.02717181295156479,
-0.0018902613082900643,
-0.041912078857421875,
-0.019730642437934875,
0.04251589626073837,
0.006917268969118595,
0.02644367888569832,
-0.00003877921699313447,
0.0411306656897068,
0.019304418936371803,
-0.04269348829984665,
-0.027562519535422325,
-0.053633250296115875,
-0.046458471566438675,
0.06240637227892876,
-0.004857183434069157,
-0.029338454827666283,
0.002228799043223262,
0.09561637043952942,
0.049015820026397705,
-0.05288735777139664,
0.017359768971800804,
0.05178627744317055,
-0.04571257904171944,
0.025537952780723572,
0.002623944776132703,
-0.0047195483930408955,
-0.03697497770190239,
0.010593455284833908,
-0.009936358779668808,
-0.02614177018404007,
-0.026603514328598976,
0.01997927390038967,
-0.07870946079492569,
-0.03038625605404377,
-0.0004234496154822409,
0.07153467833995819,
0.006215773988515139,
0.010406982153654099,
0.0009756545769050717,
0.02949828840792179,
0.004621872212737799,
0.023904092609882355,
-0.09384042769670486,
-0.015122090466320515,
0.09682400524616241,
0.05310047045350075,
-0.05072071775794029,
0.027988743036985397,
-0.0163208469748497,
-0.01200532354414463,
0.07267127931118011,
0.03413347899913788,
-0.023850813508033752,
0.035980451852083206,
0.006730795372277498,
0.007356812711805105,
-0.06155392527580261,
0.025378117337822914,
0.006158056203275919,
-0.0017437466885894537,
0.0013275117380544543,
0.031025592237710953,
-0.005301167257130146,
0.01868284121155739,
-0.021062595769762993,
-0.0026461437810212374,
-0.015770306810736656,
0.03814709559082985,
0.03475505858659744,
-0.002339794998988509,
-0.0339558869600296,
-0.006695276591926813,
-0.031434059143066406,
0.05221250280737877,
0.00030412894557230175,
-0.03878642991185188,
-0.007751958444714546,
0.019020268693566322,
-0.04578361660242081,
-0.059706952422857285,
0.04713332653045654,
-0.010930882766842842,
0.026852143928408623,
-0.020831722766160965,
0.02189728431403637,
-0.01672043278813362,
-0.042444858700037,
0.028095299378037453,
-0.005829508416354656,
-0.04116618633270264,
-0.0705401599407196,
0.024472391232848167,
0.013124163262546062,
-0.038999542593955994,
-0.031007833778858185,
0.038182612508535385,
-0.03477281704545021,
-0.026408160105347633,
-0.04656502977013588,
-0.000288034527329728,
-0.03088351897895336,
-0.060736995190382004,
0.015335203148424625,
-0.010176110081374645,
0.039567843079566956,
-0.04716884717345238,
-0.023708738386631012,
0.023175958544015884,
-0.047559551894664764,
0.0018491927767172456,
-0.03542991355061531,
-0.0031189867295324802,
-0.022607658058404922,
-0.015237526968121529,
0.01596565917134285,
-0.030634887516498566,
0.07089534401893616,
-0.01746632531285286,
-0.038395725190639496,
-0.0020012573804706335,
-0.009297022596001625,
0.019304418936371803,
-0.002124462742358446,
-0.022021600976586342,
0.014873459935188293,
0.006979426369071007,
0.05803757160902023,
-0.006655318196862936,
-0.012884411960840225,
0.00828917883336544,
0.042800046503543854,
0.0391061007976532,
0.03857331722974777,
0.024632224813103676,
0.041983116418123245,
-0.022643176838755608,
0.008013908751308918,
-0.021719690412282944,
-0.0076942406594753265,
0.04329730570316315,
-0.057362716645002365,
0.04123722389340401,
0.03821813315153122,
0.00988308060914278,
0.041841041296720505,
-0.025271562859416008,
-0.005936064291745424,
0.03843124583363533,
-0.02665679156780243,
0.016214290633797646,
-0.0005477651138789952,
0.022359028458595276,
0.06169600039720535,
-0.03946128487586975,
0.010779928416013718,
-0.04134377837181091,
-0.0808405801653862,
0.03471953794360161,
0.046742621809244156,
0.008151544257998466,
-0.020316701382398605,
0.002672782866284251,
-0.0022709774784743786,
-0.011099596507847309,
0.0019113505259156227,
0.0011987565085291862,
0.02964036352932453,
0.006140296813100576,
-0.06748554855585098,
0.026337122544646263,
-0.059635914862155914,
0.034222278743982315,
-0.0038981784600764513,
0.007436729967594147,
0.006588720716536045,
0.08368208259344101,
-0.006118097808212042,
0.007996149361133575,
-0.026834385469555855,
0.004186768084764481,
0.03242858126759529,
-0.062193259596824646,
0.006584280636161566,
-0.0017615059623494744,
-0.029604844748973846,
0.01866508275270462,
-0.0000034859672268794384,
0.008679884485900402,
-0.023016123101115227,
0.02466774359345436,
0.007569924928247929,
-0.005603076424449682,
0.06421782821416855,
0.08972026407718658,
-0.009279263205826283,
-0.016054457053542137,
-0.0072591365315020084,
-0.04269348829984665,
-0.004741747863590717,
-0.039709918200969696,
-0.01793694868683815,
-0.020334461703896523,
-0.019641846418380737,
0.002570666605606675,
0.0005610845983028412,
-0.002583986148238182,
0.06393367797136307,
-0.09433769434690475,
-0.004639631602913141,
-0.01786591112613678,
0.015610473230481148,
0.04503772407770157,
-0.05690097436308861,
0.06435990333557129,
0.03354742005467415,
-0.04372353106737137,
0.01072665024548769,
-0.020174626260995865,
-0.045641541481018066,
0.02651471644639969,
0.005931624677032232,
-0.046813659369945526,
0.08865469694137573,
-0.02086724154651165,
0.032908085733652115,
0.062264297157526016,
0.042942121624946594,
0.03155837208032608,
-0.016045577824115753,
-0.016303088515996933,
-0.08453452587127686,
-0.0060692597180604935,
0.05373980849981308,
-0.02093827910721302,
-0.04869615286588669,
-0.050187937915325165,
0.012724577449262142,
-0.028716877102851868,
0.05189283564686775,
-0.06531890481710434,
-0.029995551332831383,
-0.015832465142011642,
0.03542991355061531,
-0.01522864680737257,
-0.007743078749626875,
-0.02900102734565735,
0.0012187357060611248,
0.018469728529453278,
-0.029107581824064255,
0.0012997627491131425,
0.004060232546180487,
0.010673372074961662,
-0.05491192638874054,
-0.022962845861911774,
-0.03463074192404747,
-0.0115702198818326,
-0.007547725923359394,
0.009439096786081791,
-0.027544759213924408,
0.0038826388772577047,
0.09625570476055145,
-0.0430486761033535,
0.008329137228429317,
-0.029089823365211487,
-0.026301603764295578,
-0.0038182612042874098,
-0.031149908900260925,
0.018700601533055305,
-0.03654875233769417,
-0.006531002931296825,
-0.028130818158388138,
-0.0391061007976532,
-0.002901434665545821,
0.01772383600473404,
0.01880715601146221,
0.04276452586054802,
0.037294644862413406,
-0.034808333963155746,
-0.06240637227892876,
0.0054476819932460785,
-0.06173151731491089,
0.05381084606051445,
-0.015610473230481148,
0.029817957431077957,
0.06162496283650398,
0.0011965365847572684,
0.06105666235089302,
-0.003685066243633628,
-0.06148288771510124,
0.006033740937709808,
-0.0004462038050405681,
0.0046485112980008125,
0.008098266087472439,
0.038253650069236755,
-0.016942424699664116,
-0.055089518427848816,
-0.01501553412526846,
-0.014882339164614677,
0.028166336938738823,
-0.04461149871349335,
-0.009856441989541054,
0.009483495727181435,
-0.0091194286942482,
0.03281928971409798,
-0.024436872452497482,
-0.0199082363396883,
-0.01786591112613678,
-0.04098859056830406,
-0.05199939012527466,
0.018718359991908073,
0.011117355898022652,
-0.01749296486377716,
0.028219614177942276,
0.010771049186587334,
0.016303088515996933,
-0.0195530503988266,
0.014873459935188293,
-0.01599229872226715,
0.027189573273062706,
0.004233386367559433,
-0.05079175531864166,
0.03669082745909691,
-0.0014362878864631057,
-0.009341420605778694,
0.03768534958362579,
0.01746632531285286,
0.022820770740509033,
-0.03420451655983925,
0.012111879885196686,
-0.04141481593251228,
0.035696301609277725,
-0.07132156938314438,
-0.023193717002868652,
0.0042555853724479675,
0.02175520919263363,
-0.08716291189193726,
0.0052123707719147205,
0.029693640768527985,
0.005265648942440748,
-0.05192835256457329,
-0.0014917858643457294,
0.03361845761537552,
-0.04727540165185928,
-0.025822101160883904,
0.05111142247915268,
-0.035980451852083206,
0.009070590138435364,
-0.032108914107084274,
-0.037152569741010666,
-0.042196229100227356,
-0.029480529949069023,
-0.021027076989412308,
0.030439535155892372,
0.011792211793363094,
-0.016054457053542137,
0.018931472674012184,
-0.0016316407127305865,
0.020973797887563705,
0.02759803831577301,
-0.016560599207878113,
-0.016640515998005867,
0.002959152450785041,
-0.02145330049097538,
-0.06656206399202347,
-0.020902760326862335,
-0.016658274456858635,
-0.014473874121904373,
0.008329137228429317,
-0.01845197007060051,
0.0011621278245002031,
0.02928517572581768,
0.04134377837181091,
-0.00279265851713717,
0.008964034728705883,
0.02649695798754692,
-0.04471805691719055,
-0.024063926190137863,
0.015281924977898598,
-0.0055142794735729694,
-0.01786591112613678,
-0.04354593902826309,
-0.02283853106200695,
0.02834393084049225,
0.06404023617506027,
-0.010966401547193527,
-0.045144278556108475,
0.003292140318080783,
0.0456770621240139,
-0.003096787491813302
]
|
30,462 | networkx.drawing.layout | circular_layout | Position nodes on a circle.
Parameters
----------
G : NetworkX graph or list of nodes
A position will be assigned to every node in G.
scale : number (default: 1)
Scale factor for positions.
center : array-like or None
Coordinate pair around which to center the layout.
dim : int
Dimension of layout.
If dim>2, the remaining dimensions are set to zero
in the returned positions.
If dim<2, a ValueError is raised.
Returns
-------
pos : dict
A dictionary of positions keyed by node
Raises
------
ValueError
If dim < 2
Examples
--------
>>> G = nx.path_graph(4)
>>> pos = nx.circular_layout(G)
Notes
-----
This algorithm currently only works in two dimensions and does not
try to minimize edge crossings.
| def circular_layout(G, scale=1, center=None, dim=2):
# dim=2 only
"""Position nodes on a circle.
Parameters
----------
G : NetworkX graph or list of nodes
A position will be assigned to every node in G.
scale : number (default: 1)
Scale factor for positions.
center : array-like or None
Coordinate pair around which to center the layout.
dim : int
Dimension of layout.
If dim>2, the remaining dimensions are set to zero
in the returned positions.
If dim<2, a ValueError is raised.
Returns
-------
pos : dict
A dictionary of positions keyed by node
Raises
------
ValueError
If dim < 2
Examples
--------
>>> G = nx.path_graph(4)
>>> pos = nx.circular_layout(G)
Notes
-----
This algorithm currently only works in two dimensions and does not
try to minimize edge crossings.
"""
import numpy as np
if dim < 2:
raise ValueError("cannot handle dimensions < 2")
G, center = _process_params(G, center, dim)
paddims = max(0, (dim - 2))
if len(G) == 0:
pos = {}
elif len(G) == 1:
pos = {nx.utils.arbitrary_element(G): center}
else:
# Discard the extra angle since it matches 0 radians.
theta = np.linspace(0, 1, len(G) + 1)[:-1] * 2 * np.pi
theta = theta.astype(np.float32)
pos = np.column_stack(
[np.cos(theta), np.sin(theta), np.zeros((len(G), paddims))]
)
pos = rescale_layout(pos, scale=scale) + center
pos = dict(zip(G, pos))
return pos
| (G, scale=1, center=None, dim=2) | [
0.04227089509367943,
0.00865085143595934,
-0.034965936094522476,
0.0003174962184857577,
0.003892656648531556,
0.04147333279252052,
0.016948236152529716,
0.025540176779031754,
0.06877177953720093,
-0.04444606974720955,
0.01409331988543272,
-0.007984704338014126,
0.025340786203742027,
0.020772919058799744,
-0.010830557905137539,
-0.021733621135354042,
0.04009572044014931,
-0.022458679974079132,
-0.025123268365859985,
0.003638886148110032,
0.03531033918261528,
-0.013812359422445297,
0.015008705668151379,
0.007744528353214264,
-0.05423435941338539,
-0.007576858624815941,
-0.005596543662250042,
0.020718539133667946,
0.01588783971965313,
-0.005755149759352207,
0.06714039295911789,
0.01983034424483776,
-0.04792635142803192,
0.024887625128030777,
0.003221977734938264,
0.052820492535829544,
0.038826871663331985,
0.06634283065795898,
-0.027298443019390106,
-0.017772991210222244,
0.010522408410906792,
-0.0013402248732745647,
0.011002759449183941,
-0.054089345037937164,
0.07051191478967667,
0.07808877527713776,
-0.0018398353131487966,
0.019177790731191635,
-0.014401469379663467,
0.01824427768588066,
0.006330664735287428,
-0.02718968503177166,
-0.04589618742465973,
-0.03672420233488083,
-0.029074836522340775,
-0.037703029811382294,
0.02296622097492218,
0.04749131575226784,
-0.019848469644784927,
-0.02082729898393154,
0.018090203404426575,
-0.00328995194286108,
0.023945048451423645,
-0.011954397894442081,
-0.07968389987945557,
0.018905894830822945,
0.044011037796735764,
-0.05191417038440704,
0.009588895365595818,
-0.06366011500358582,
0.0013254971709102392,
0.019902849569916725,
-0.008206753060221672,
-0.04324972629547119,
0.04230714961886406,
-0.031304389238357544,
0.05920100584626198,
0.033243920654058456,
-0.007250582799315453,
0.0004367343208286911,
-0.027044672518968582,
-0.013567652553319931,
0.01856149174273014,
0.028676053509116173,
0.04633122310042381,
0.014020814560353756,
0.04506237059831619,
0.026174603030085564,
-0.020772919058799744,
-0.012090346775949001,
0.0007329885847866535,
-0.031612541526556015,
0.049630239605903625,
-0.04698377475142479,
0.03163066506385803,
0.013957371935248375,
0.021026689559221268,
-0.0293286070227623,
0.005061813164502382,
0.002299794228747487,
-0.012217232026159763,
0.003806555876508355,
-0.09135734289884567,
-0.05010152608156204,
-0.05999857187271118,
-0.015760954469442368,
-0.019630951806902885,
-0.025667062029242516,
-0.032609496265649796,
0.053038012236356735,
0.002997662639245391,
0.04517113044857979,
0.014038940891623497,
0.01252538152039051,
0.04651248827576637,
0.05097159743309021,
0.005524037405848503,
0.030615584924817085,
-0.024162566289305687,
-0.03163066506385803,
-0.051805414259433746,
0.038971882313489914,
-0.018126456066966057,
-0.0003571478300727904,
0.01789081282913685,
-0.010667419992387295,
0.009117607958614826,
0.04451857879757881,
0.010513344779610634,
0.01248006522655487,
-0.007726402021944523,
-0.034113992005586624,
0.07714620232582092,
0.011818449944257736,
0.029618630185723305,
-0.0385005921125412,
-0.01988472230732441,
0.008315511979162693,
-0.05108035355806351,
0.035219706594944,
0.021407345309853554,
-0.028494790196418762,
-0.050862837582826614,
0.03405961021780968,
-0.006407702341675758,
0.03802930563688278,
0.020301630720496178,
-0.03137689456343651,
0.004563335329294205,
-0.00600438890978694,
0.034295257180929184,
-0.042234644293785095,
0.10013054311275482,
0.0402044802904129,
0.0055421642027795315,
-0.002902498934417963,
-0.0013912055874243379,
-0.016694465652108192,
-0.040820781141519547,
0.036144156008958817,
-0.07446348667144775,
0.004252919927239418,
-0.004821637645363808,
-0.01252538152039051,
0.020138492807745934,
0.0015169578837230802,
0.056482039391994476,
-0.04614995792508125,
-0.05260297656059265,
-0.0004367343208286911,
-0.008687104098498821,
-0.02356439270079136,
0.03032556176185608,
-0.025268280878663063,
0.025630809366703033,
0.004540677182376385,
0.015008705668151379,
0.00025192942121066153,
-0.02314748428761959,
-0.03560036048293114,
0.0036932656075805426,
-0.0033352680038660765,
0.07953888922929764,
0.02827727235853672,
-0.03926190361380577,
0.08874712884426117,
0.041147056967020035,
-0.024996383115649223,
-0.018869642168283463,
-0.029111089184880257,
-0.02682715654373169,
0.03346144035458565,
-0.01784549653530121,
0.06253627687692642,
0.023854417726397514,
0.04027698561549187,
0.004649436101317406,
0.0356728658080101,
-0.05238546058535576,
0.05782339721918106,
0.049630239605903625,
0.022458679974079132,
0.03621666133403778,
-0.020573528483510017,
-0.009679527953267097,
-0.02541329152882099,
-0.005596543662250042,
0.04894143342971802,
-0.0020120367407798767,
0.021661115810275078,
-0.040820781141519547,
0.02079104632139206,
0.009996741078794003,
-0.0677204430103302,
-0.02990865334868431,
0.07181701809167862,
-0.01527153979986906,
0.011247466318309307,
-0.008610066957771778,
-0.01997535489499569,
0.03422274813055992,
0.02546767145395279,
-0.005700770765542984,
-0.028947951272130013,
0.033751461654901505,
-0.04930396005511284,
0.038246821612119675,
-0.04379351809620857,
0.029074836522340775,
-0.05633702874183655,
0.05151538923382759,
-0.05938227102160454,
-0.01751922070980072,
-0.024633854627609253,
0.06569027900695801,
-0.06155744567513466,
0.027244064956903458,
0.048723913729190826,
0.021751748397946358,
0.05905599519610405,
0.0008479782845824957,
-0.019775964319705963,
-0.06869927048683167,
0.04045825079083443,
-0.0019112082663923502,
0.01711137406527996,
0.038609351962804794,
-0.02709905244410038,
-0.004388868343085051,
-0.018942147493362427,
-0.08519434928894043,
-0.023709405213594437,
-0.030615584924817085,
-0.006076894700527191,
0.002092472743242979,
0.04625871777534485,
-0.08816708624362946,
0.025884579867124557,
-0.020537275820970535,
-0.002764284610748291,
-0.023582519963383675,
-0.030162423849105835,
-0.017482968047261238,
0.013921118341386318,
0.08200409263372421,
0.040421996265649796,
0.002852651057764888,
0.008365360088646412,
-0.011138707399368286,
0.009507326409220695,
0.05133412405848503,
0.04071202129125595,
0.03264574706554413,
0.0006457550334744155,
0.06989561766386032,
0.031159378588199615,
-0.0016551720909774303,
0.0344221405684948,
0.027117179706692696,
-0.0044341846369206905,
-0.05742461606860161,
-0.03032556176185608,
0.009679527953267097,
-0.013966434635221958,
-0.015026832930743694,
0.015334982424974442,
0.01910528540611267,
-0.005279330536723137,
0.0247426126152277,
-0.00012249519932083786,
0.047273799777030945,
-0.022096149623394012,
-0.041690848767757416,
0.01792706549167633,
-0.01359484251588583,
0.03036181442439556,
-0.02037413790822029,
0.014918074011802673,
-0.02410818636417389,
0.005655454471707344,
0.046004947274923325,
-0.039153147488832474,
-0.0006763433921150863,
0.008809457533061504,
0.10999134182929993,
0.061521194875240326,
0.03427712991833687,
-0.02628336288034916,
0.017727674916386604,
0.031104998663067818,
-0.04335848242044449,
-0.013150744140148163,
-0.011265592649579048,
0.009588895365595818,
-0.03976944461464882,
0.03444026783108711,
0.019413435831665993,
-0.011174960061907768,
0.0639863908290863,
-0.004393399693071842,
0.012670393101871014,
-0.0041169715113937855,
-0.08809457719326019,
0.04712878540158272,
-0.0357816256582737,
0.018688376992940903,
-0.009049633517861366,
0.09556268155574799,
0.02764284610748291,
0.045461151748895645,
-0.01937718130648136,
0.024216946214437485,
-0.05383557453751564,
-0.009788286872208118,
-0.05187791958451271,
-0.05253047123551369,
0.023038726300001144,
0.009480136446654797,
-0.016277557238936424,
-0.030742470175027847,
0.011591869406402111,
-0.08287415653467178,
0.006194716319441795,
-0.015398425050079823,
0.021624863147735596,
0.018452731892466545,
0.05089908838272095,
-0.003228774992749095,
0.007332151755690575,
-0.0353284627199173,
0.028440410271286964,
0.08664446324110031,
-0.05166039988398552,
-0.02541329152882099,
-0.02374565787613392,
0.04444606974720955,
0.007033064961433411,
-0.055720727890729904,
0.011011822149157524,
0.021896759048104286,
0.0577508918941021,
-0.011365287937223911,
0.00908135436475277,
-0.019268423318862915,
-0.021044816821813583,
0.047273799777030945,
-0.07475350797176361,
0.04002321511507034,
0.08729701489210129,
0.010730862617492676,
0.04506237059831619,
-0.01946781389415264,
-0.09940548986196518,
0.010105499066412449,
-0.04085703194141388,
0.08417926728725433,
-0.020410390570759773,
-0.01593315601348877,
-0.05387182906270027,
-0.04680250957608223,
0.010721798986196518,
-0.04593244194984436,
0.022494932636618614,
0.039153147488832474,
-0.031884435564279556,
-0.022494932636618614,
0.06213749200105667,
0.033243920654058456,
-0.009788286872208118,
0.006262690760195255,
-0.05568447336554527,
-0.048180121928453445,
0.050681572407484055,
0.007608579937368631,
-0.03304453194141388,
0.04698377475142479,
-0.015652194619178772,
0.028259145095944405,
-0.054850656539201736,
-0.022839335724711418,
-0.02465198002755642,
-0.014319900423288345,
0.037376753985881805,
-0.00425745127722621,
0.018942147493362427,
-0.019630951806902885,
0.0027189685497432947,
0.01237130630761385,
0.04970274493098259,
0.11455920338630676,
-0.016467886045575142,
-0.00540168397128582,
0.07584109157323837,
-0.02169736847281456,
0.042415909469127655,
-0.044554829597473145,
-0.07257833331823349,
0.02845853753387928,
0.019685331732034683,
-0.05343679338693619,
-0.031395021826028824,
-0.019395308569073677,
0.006752104964107275,
-0.004454576876014471,
-0.012806341983377934,
0.007853287272155285,
0.05274798721075058,
0.01946781389415264,
0.00643489183858037,
0.05637327954173088,
-0.0006927705253474414,
0.0688442811369896,
0.03458527848124504,
0.0017979178810492158,
-0.007400125730782747,
0.0002990865323226899,
0.032754506915807724,
-0.03291764482855797,
-0.004826168995350599,
0.024815119802951813,
-0.011745943687856197,
0.04760007560253143,
0.004495361354202032,
-0.03741300478577614,
0.011990650556981564,
0.04770883545279503,
-0.06231875717639923,
-0.004393399693071842,
0.025123268365859985,
-0.005741555243730545,
0.014909010380506516,
-0.035564105957746506,
0.0325007364153862,
-0.006462081801146269,
-0.038101810961961746,
-0.03144940361380577,
-0.08033645898103714,
-0.02265807054936886,
-0.0997680202126503,
0.0015169578837230802,
-0.0035958357620984316,
-0.005075407680124044,
-0.0688442811369896,
-0.019848469644784927,
0.0039447699673473835,
0.02187863364815712,
0.045461151748895645,
0.007517947815358639,
-0.06793796271085739,
-0.02749783545732498,
0.024996383115649223,
-0.06108615919947624,
-0.05082658305764198,
-0.0347665436565876,
-0.03587225824594498,
-0.007739997003227472,
0.030887482687830925,
0.006811016239225864,
-0.07004062831401825,
0.007952982559800148,
-0.013123554177582264,
-0.0013662816490978003,
0.00495758606120944,
0.03904438763856888,
-0.016368189826607704,
0.037376753985881805,
0.038246821612119675,
0.025866452604532242,
-0.033697083592414856,
-0.023945048451423645,
-0.029201721772551537,
0.017990507185459137,
-0.016902919858694077,
0.02619273029267788,
0.027515960857272148,
-0.004252919927239418,
-0.04810761660337448,
-0.04651248827576637,
-0.01683947816491127,
0.004363944288343191,
0.00441379239782691,
-0.0549231618642807,
0.05227670073509216,
0.015434677712619305,
0.008206753060221672,
0.002635133685544133,
-0.02900233119726181,
0.039551928639411926,
0.043503496795892715,
0.03984194993972778,
0.007132760714739561,
0.0365791879594326,
0.00009658002818468958,
-0.027117179706692696,
0.00148410361725837,
0.043322231620550156,
-0.013440767303109169,
0.04263342544436455,
0.008360828272998333,
-0.0804089605808258,
-0.0010887202806770802,
0.0007007008534856141,
-0.004107908345758915,
0.07149074226617813,
-0.041690848767757416,
0.018498048186302185,
0.06347884982824326,
-0.044772349298000336,
-0.03005366586148739,
-0.0475638210773468,
-0.018633997067809105,
0.009842665866017342,
-0.03141314908862114,
-0.023129358887672424,
-0.006820079404860735,
0.026935914531350136,
0.059164755046367645,
-0.03627103939652443,
-0.012035966850817204,
0.008795863017439842,
-0.0228755883872509,
0.024905750527977943,
-0.016803225502371788,
-0.0056056068278849125,
0.06090489402413368,
0.018307721242308617,
0.06155744567513466,
-0.06576278060674667,
-0.018579617142677307,
-0.054488129913806915,
-0.014555544592440128,
0.003124547889456153,
-0.027117179706692696,
-0.04263342544436455,
0.037558019161224365,
0.011193087324500084,
-0.047998856753110886,
-0.03451277315616608,
0.029473617672920227,
-0.0036366202402859926,
0.004010478500276804,
-0.03172129765152931,
-0.04397478327155113,
-0.01816270872950554,
0.03308078274130821,
-0.045461151748895645,
-0.034657783806324005,
-0.04161834344267845,
0.051587894558906555,
0.053219277411699295,
0.019177790731191635,
0.0034644189290702343,
0.04506237059831619,
-0.008936342783272266,
0.0705481693148613,
-0.041219562292099,
-0.000642922765109688,
0.04281469061970711,
-0.008990722708404064,
-0.03271825239062309,
0.007744528353214264,
-0.03317141532897949,
0.01241662260144949,
0.029129216447472572,
-0.00657990388572216,
0.037195488810539246,
-0.05060906708240509,
0.0293286070227623,
0.006280817091464996,
-0.037159234285354614,
0.00914479698985815,
-0.020990436896681786,
0.052820492535829544,
0.022585565224289894,
-0.02428945153951645,
-0.0475638210773468,
-0.016948236152529716,
0.01906903274357319,
-0.027606593444943428,
0.022277414798736572,
-0.07924886792898178,
0.023038726300001144,
-0.007454505190253258,
0.021352965384721756,
-0.08316418528556824,
-0.020501023158431053,
0.02401755563914776,
-0.01865212433040142,
0.01973971165716648,
-0.01815364696085453,
0.010069246403872967,
0.000765276316087693,
-0.02718968503177166,
-0.04966649040579796,
-0.0027280317153781652,
-0.06775669753551483,
-0.006670536007732153,
0.0540168397128582,
-0.010069246403872967,
0.017220133915543556,
0.013132617808878422,
-0.004672094248235226,
-0.030071791261434555,
-0.05441562086343765,
-0.014501165598630905,
0.07152699679136276,
0.002485590288415551,
-0.01765516959130764,
-0.017102312296628952,
0.004989307373762131,
0.021389218047261238,
0.016585707664489746,
-0.06985936313867569,
0.03413211926817894,
0.011691564694046974,
-0.05379932373762131,
-0.008469587191939354,
-0.02782411128282547,
0.039878204464912415,
0.0621737465262413,
0.03585413098335266,
-0.05111660808324814,
-0.025630809366703033,
-0.004622246604412794,
-0.0020120367407798767,
-0.06210124120116234,
0.07729121297597885,
-0.03694171831011772,
-0.00018083972099702805,
0.024996383115649223,
-0.01712043769657612,
-0.013241376727819443,
0.044591084122657776,
-0.02677277661859989,
0.0001588897139299661,
0.04520738124847412,
-0.003319407347589731,
-0.0007290234207175672,
0.04194461926817894,
-0.05876597389578819,
-0.03371521085500717,
0.010440838523209095,
-0.016277557238936424,
0.03424087539315224,
-0.00753607414662838,
-0.02990865334868431,
0.00986985582858324,
-0.03599914163351059,
0.006416765507310629,
-0.024579474702477455,
-0.012117535807192326,
-0.0033216732554137707,
0.03482092171907425,
0.019630951806902885,
-0.010785241611301899,
0.0032469015568494797,
0.059889812022447586,
0.045678671449422836,
-0.006484739948064089,
0.03563661500811577,
0.038826871663331985,
0.004343552049249411,
-0.01934092864394188,
0.016168799251317978,
-0.03400523215532303,
0.013241376727819443,
0.03685108572244644,
-0.07214329391717911,
0.04147333279252052,
0.042379654943943024,
0.05046405643224716,
0.01200877781957388,
0.06170245632529259,
-0.029527997598052025,
0.0003461020241957158,
0.001049068639986217,
-0.0522041954100132,
0.038645606487989426,
0.020845424383878708,
-0.011265592649579048,
0.044192299246788025,
-0.04143707826733589,
-0.02332874946296215,
0.000828718941193074,
-0.033243920654058456,
-0.04919520393013954,
-0.08164156228303909,
0.028367904946208,
0.007594985421746969,
0.07671116292476654,
-0.009552642703056335,
-0.006389576010406017,
0.011202150024473667,
-0.0678291991353035,
0.002503716852515936,
-0.00873695220798254,
0.0030112576205283403,
-0.015434677712619305,
-0.05564822256565094,
-0.010114562697708607,
-0.01520809717476368,
-0.025667062029242516,
0.0005607872735708952,
0.07852380722761154,
-0.022911841049790382,
-0.012045030482113361,
0.00753607414662838,
-0.046730004251003265,
-0.0586572140455246,
-0.0006944698398001492,
-0.01246193889528513,
0.08229411393404007,
-0.009226365946233273,
0.05354555323719978,
-0.053038012236356735,
-0.007844223640859127,
-0.035110946744680405,
-0.019322803243994713,
-0.06293505430221558,
0.020301630720496178,
-0.0023496418725699186,
-0.035219706594944,
-0.03976944461464882,
-0.019685331732034683,
0.01036833319813013,
-0.038609351962804794,
-0.02187863364815712,
-0.04161834344267845,
0.025340786203742027,
0.018942147493362427,
-0.014111446216702461,
0.029111089184880257,
-0.013649221509695053,
-0.017002616077661514,
-0.027080925181508064,
-0.018353037536144257,
-0.04335848242044449,
0.028802938759326935,
-0.008972596377134323,
-0.047056280076503754,
-0.049775250256061554,
-0.07366591691970825,
-0.043104711920022964,
0.02573956735432148,
-0.0018013166263699532,
0.013884865678846836,
0.028494790196418762,
0.06699538230895996
]
|
30,474 | networkx.algorithms.planar_drawing | combinatorial_embedding_to_pos | Assigns every node a (x, y) position based on the given embedding
The algorithm iteratively inserts nodes of the input graph in a certain
order and rearranges previously inserted nodes so that the planar drawing
stays valid. This is done efficiently by only maintaining relative
positions during the node placements and calculating the absolute positions
at the end. For more information see [1]_.
Parameters
----------
embedding : nx.PlanarEmbedding
This defines the order of the edges
fully_triangulate : bool
If set to True the algorithm adds edges to a copy of the input
embedding and makes it chordal.
Returns
-------
pos : dict
Maps each node to a tuple that defines the (x, y) position
References
----------
.. [1] M. Chrobak and T.H. Payne:
A Linear-time Algorithm for Drawing a Planar Graph on a Grid 1989
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.51.6677
| def combinatorial_embedding_to_pos(embedding, fully_triangulate=False):
"""Assigns every node a (x, y) position based on the given embedding
The algorithm iteratively inserts nodes of the input graph in a certain
order and rearranges previously inserted nodes so that the planar drawing
stays valid. This is done efficiently by only maintaining relative
positions during the node placements and calculating the absolute positions
at the end. For more information see [1]_.
Parameters
----------
embedding : nx.PlanarEmbedding
This defines the order of the edges
fully_triangulate : bool
If set to True the algorithm adds edges to a copy of the input
embedding and makes it chordal.
Returns
-------
pos : dict
Maps each node to a tuple that defines the (x, y) position
References
----------
.. [1] M. Chrobak and T.H. Payne:
A Linear-time Algorithm for Drawing a Planar Graph on a Grid 1989
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.51.6677
"""
if len(embedding.nodes()) < 4:
# Position the node in any triangle
default_positions = [(0, 0), (2, 0), (1, 1)]
pos = {}
for i, v in enumerate(embedding.nodes()):
pos[v] = default_positions[i]
return pos
embedding, outer_face = triangulate_embedding(embedding, fully_triangulate)
# The following dicts map a node to another node
# If a node is not in the key set it means that the node is not yet in G_k
# If a node maps to None then the corresponding subtree does not exist
left_t_child = {}
right_t_child = {}
# The following dicts map a node to an integer
delta_x = {}
y_coordinate = {}
node_list = get_canonical_ordering(embedding, outer_face)
# 1. Phase: Compute relative positions
# Initialization
v1, v2, v3 = node_list[0][0], node_list[1][0], node_list[2][0]
delta_x[v1] = 0
y_coordinate[v1] = 0
right_t_child[v1] = v3
left_t_child[v1] = None
delta_x[v2] = 1
y_coordinate[v2] = 0
right_t_child[v2] = None
left_t_child[v2] = None
delta_x[v3] = 1
y_coordinate[v3] = 1
right_t_child[v3] = v2
left_t_child[v3] = None
for k in range(3, len(node_list)):
vk, contour_nbrs = node_list[k]
wp = contour_nbrs[0]
wp1 = contour_nbrs[1]
wq = contour_nbrs[-1]
wq1 = contour_nbrs[-2]
adds_mult_tri = len(contour_nbrs) > 2
# Stretch gaps:
delta_x[wp1] += 1
delta_x[wq] += 1
delta_x_wp_wq = sum(delta_x[x] for x in contour_nbrs[1:])
# Adjust offsets
delta_x[vk] = (-y_coordinate[wp] + delta_x_wp_wq + y_coordinate[wq]) // 2
y_coordinate[vk] = (y_coordinate[wp] + delta_x_wp_wq + y_coordinate[wq]) // 2
delta_x[wq] = delta_x_wp_wq - delta_x[vk]
if adds_mult_tri:
delta_x[wp1] -= delta_x[vk]
# Install v_k:
right_t_child[wp] = vk
right_t_child[vk] = wq
if adds_mult_tri:
left_t_child[vk] = wp1
right_t_child[wq1] = None
else:
left_t_child[vk] = None
# 2. Phase: Set absolute positions
pos = {}
pos[v1] = (0, y_coordinate[v1])
remaining_nodes = [v1]
while remaining_nodes:
parent_node = remaining_nodes.pop()
# Calculate position for left child
set_position(
parent_node, left_t_child, remaining_nodes, delta_x, y_coordinate, pos
)
# Calculate position for right child
set_position(
parent_node, right_t_child, remaining_nodes, delta_x, y_coordinate, pos
)
return pos
| (embedding, fully_triangulate=False) | [
0.04007839784026146,
-0.005325356964021921,
-0.06926615536212921,
0.05616400018334389,
-0.004509080667048693,
0.025453224778175354,
-0.034591350704431534,
0.015271934680640697,
0.004882012028247118,
-0.02253236249089241,
-0.03713667020201683,
0.028457539156079292,
-0.0398697629570961,
0.04264458268880844,
-0.017295675352215767,
0.0033511673100292683,
0.06075392663478851,
-0.007046579383313656,
-0.04222731664776802,
-0.006791003979742527,
0.0175460334867239,
-0.06400860100984573,
-0.00782373733818531,
0.046775516122579575,
-0.035112932324409485,
-0.0341949462890625,
-0.0038179836701601744,
0.02301221899688244,
-0.04003667086362839,
-0.013519417494535446,
0.02925034426152706,
-0.035425882786512375,
-0.020195674151182175,
-0.06521867215633392,
-0.02294962853193283,
0.0004058563499711454,
-0.0072030541487038136,
0.026600705459713936,
-0.038680557161569595,
-0.01533452421426773,
0.016283804550766945,
-0.03555105999112129,
-0.014061863534152508,
-0.03388199582695961,
0.04074602201581001,
0.04007839784026146,
0.031899984925985336,
0.02129099704325199,
-0.0209780465811491,
-0.023971930146217346,
0.044939544051885605,
-0.12100713700056076,
0.03313091769814491,
-0.0010646801674738526,
-0.053076233714818954,
0.01041600201278925,
-0.0002324301894987002,
0.05841723829507828,
0.02253236249089241,
-0.05445320904254913,
0.010212584398686886,
0.03578055649995804,
-0.014875532127916813,
0.040892064571380615,
-0.027497828006744385,
-0.030502142384648323,
0.018474450334906578,
-0.04631652310490608,
-0.016492437571287155,
0.02138488180935383,
-0.014510424807667732,
-0.010702872648835182,
0.05403594300150871,
-0.08170067518949509,
0.050405729562044144,
-0.006066004280000925,
0.06133809685707092,
0.02443092316389084,
0.028874805197119713,
0.04427191987633705,
-0.07427334040403366,
-0.013362943194806576,
0.03219207003712654,
-0.005393162835389376,
0.06672082841396332,
0.06939133256673813,
0.06033666059374809,
0.04990500956773758,
-0.021781284362077713,
-0.04034962132573128,
-0.014635603874921799,
-0.03603091835975647,
0.019914017990231514,
0.020988479256629944,
0.008282729424536228,
0.005335788708180189,
0.05090644955635071,
-0.07418989390134811,
-0.011881648562848568,
-0.0223237294703722,
-0.018808264285326004,
0.07431507110595703,
-0.08483017235994339,
-0.02274099551141262,
-0.007249996531754732,
-0.00472553726285696,
-0.04911220446228981,
0.0012107233051210642,
0.02705969847738743,
-0.034633077681064606,
-0.08224312216043472,
0.002390151610597968,
0.024910779669880867,
0.033068329095840454,
-0.00436825305223465,
-0.03502947837114334,
-0.03477912023663521,
0.03498775139451027,
-0.0132899209856987,
0.010911505669355392,
0.054328031837940216,
-0.00525233568623662,
-0.02035214751958847,
0.01228848285973072,
-0.029605021700263023,
-0.009878772310912609,
0.07903017848730087,
0.07089348882436752,
-0.022031644359230995,
-0.057540979236364365,
0.029396388679742813,
-0.030376963317394257,
0.007385607808828354,
0.05950212851166725,
-0.013018698431551456,
0.0167219340801239,
0.0041205016896128654,
-0.014333086088299751,
-0.04744314029812813,
-0.005758270621299744,
0.0428532175719738,
-0.0758589580655098,
0.04898702725768089,
0.011485246010124683,
-0.037115808576345444,
0.029751064255833626,
-0.01709747314453125,
-0.03934818133711815,
-0.026496389880776405,
-0.04694242402911186,
0.021969053894281387,
-0.04233163222670555,
0.028353223577141762,
-0.0214266087859869,
0.0132899209856987,
-0.02221941389143467,
0.017055746167898178,
-0.026037396863102913,
0.013582007959485054,
0.06776399165391922,
-0.00443084305152297,
-0.0315035805106163,
0.027956821024417877,
0.037574801594018936,
0.016836682334542274,
0.009435426443815231,
0.04164314270019531,
-0.05983594059944153,
-0.014510424807667732,
-0.007307370193302631,
-0.006415464449673891,
0.013477691449224949,
-0.03465393930673599,
0.0004237857647240162,
-0.010775893926620483,
0.00399010581895709,
-0.01910034939646721,
-0.010410785675048828,
0.033005740493535995,
0.005367083474993706,
-0.022094232961535454,
-0.027247468009591103,
0.05403594300150871,
-0.018213659524917603,
-0.012851792387664318,
0.06818126142024994,
0.09196542203426361,
0.0011168384226039052,
0.06993377953767776,
0.010984526947140694,
-0.03402804210782051,
-0.006957910023629665,
0.01355071272701025,
0.08453808724880219,
0.04873666539788246,
0.06743018329143524,
0.050864722579717636,
-0.0038414548616856337,
-0.04560717195272446,
0.0506143644452095,
-0.004970680922269821,
-0.04318702965974808,
0.06425896286964417,
-0.0039092605002224445,
0.003791904542595148,
0.0343409888446331,
-0.02353380061686039,
0.027602143585681915,
-0.014573014341294765,
0.04268630966544151,
-0.01213200856000185,
-0.0379294790327549,
0.028353223577141762,
-0.004788127262145281,
-0.03851364925503731,
-0.044146738946437836,
-0.07761146873235703,
0.04460573196411133,
0.01851617731153965,
-0.011912943795323372,
0.011495677754282951,
0.02432660572230816,
0.016429847106337547,
-0.0477769561111927,
0.02831149660050869,
-0.036531634628772736,
0.019121212884783745,
-0.0038153757341206074,
-0.023784160614013672,
-0.02626689337193966,
0.04544026404619217,
-0.04174746200442314,
-0.027915094047784805,
-0.009232009761035442,
0.039953216910362244,
-0.06964169442653656,
-0.04187263920903206,
-0.005351436324417591,
0.04306184872984886,
0.017076609656214714,
-0.036635953933000565,
-0.043353933840990067,
-0.003046041587367654,
-0.015897832810878754,
-0.02311653457581997,
0.05921004340052605,
0.05737407132983208,
-0.01575179025530815,
0.005317533388733864,
0.019475890323519707,
-0.06321579217910767,
-0.02620430290699005,
-0.027017971500754356,
-0.009127693250775337,
0.018464019522070885,
-0.044146738946437836,
-0.011568699032068253,
-0.0012322386028245091,
0.02793595753610134,
0.0049889362417161465,
0.001710790558718145,
-0.020466895774006844,
-0.020758982747793198,
0.009972657077014446,
0.05616400018334389,
-0.023450348526239395,
0.008746937848627567,
0.01789027824997902,
-0.05445320904254913,
-0.01526150293648243,
0.0024292704183608294,
0.044522278010845184,
-0.023074809461832047,
0.014614740386605263,
0.007396039552986622,
-0.0033172646071761847,
0.0000032700775136618176,
0.052492059767246246,
0.011693879030644894,
0.008507010526955128,
-0.05290932580828667,
-0.0021606553345918655,
-0.028645308688282967,
-0.004975896794348955,
-0.04606616497039795,
-0.01221546158194542,
-0.029271207749843597,
-0.04952947050333023,
0.055705007165670395,
-0.04170573502779007,
0.006029493175446987,
-0.0029286856297403574,
0.012173734605312347,
0.01717049442231655,
0.05290932580828667,
0.01121402345597744,
-0.0482359454035759,
-0.01820322871208191,
-0.0034737393725663424,
0.01706617884337902,
0.07544168829917908,
-0.034278400242328644,
0.04581580311059952,
-0.022657543420791626,
0.02242804691195488,
0.08428772538900375,
0.03273451700806618,
-0.0018437940161675215,
0.0209780465811491,
-0.04128846898674965,
-0.029897106811404228,
-0.030293509364128113,
-0.021656103432178497,
0.01668020710349083,
0.018745673820376396,
-0.049612924456596375,
0.030022287741303444,
-0.07414816319942474,
0.06363306194543839,
0.05666472017765045,
-0.0021319682709872723,
0.007140464149415493,
-0.008939923718571663,
0.0753999650478363,
0.022615816444158554,
-0.029375525191426277,
0.06788917630910873,
0.011287044733762741,
0.06822298467159271,
0.000014842688869975973,
-0.021760420873761177,
0.02411797270178795,
-0.05866759642958641,
0.020894594490528107,
-0.05395248904824257,
-0.02073811925947666,
0.007641183212399483,
0.02024783194065094,
0.02647552639245987,
-0.04544026404619217,
0.08896110951900482,
0.05019709840416908,
-0.028290633112192154,
0.02322085201740265,
0.04856976121664047,
0.008413124829530716,
0.033276960253715515,
0.0019024721113964915,
-0.007599456701427698,
0.04973810538649559,
-0.02436833269894123,
0.040579117834568024,
-0.035905737429857254,
0.013863662257790565,
-0.04343738779425621,
0.02883307822048664,
0.03336041420698166,
-0.09371794015169144,
-0.031211495399475098,
0.041517965495586395,
0.025286318734288216,
-0.0256827212870121,
-0.007401255425065756,
0.044355373829603195,
-0.04489782080054283,
-0.022240277379751205,
-0.02747696451842785,
0.00965970754623413,
0.0652603954076767,
0.004123109392821789,
0.05028054863214493,
-0.05161580070853233,
-0.02411797270178795,
0.07001723349094391,
-0.026538116857409477,
0.06359133124351501,
-0.021864736452698708,
0.022448910400271416,
-0.013728050515055656,
-0.06534384936094284,
0.021468333899974823,
-0.013446396216750145,
0.006822298746556044,
0.026871928945183754,
-0.027664734050631523,
-0.01615862548351288,
0.1182531788945198,
-0.0030043150763958693,
0.0017407814739271998,
-0.017817256972193718,
-0.06325752288103104,
0.006472838576883078,
0.09263304620981216,
-0.024618692696094513,
0.016461143270134926,
0.01640898548066616,
0.05290932580828667,
0.02945897728204727,
-0.004396940115839243,
-0.025453224778175354,
0.04139278456568718,
-0.035175520926713943,
-0.023867614567279816,
0.017671214416623116,
0.017775529995560646,
-0.016774091869592667,
0.04281149059534073,
0.012883086688816547,
0.04228990525007248,
0.017347833141684532,
-0.06225608289241791,
0.02336689457297325,
0.08754239976406097,
-0.02038344368338585,
-0.04485609382390976,
-0.05862586945295334,
-0.04233163222670555,
0.05971075966954231,
0.020268695428967476,
-0.01195466984063387,
-0.011485246010124683,
-0.006232910323888063,
0.04080861434340477,
0.014333086088299751,
-0.010176073759794235,
-0.005095860920846462,
-0.019538478925824165,
-0.03571796789765358,
-0.03507120534777641,
0.04133019596338272,
-0.03323523327708244,
-0.05094817653298378,
0.04581580311059952,
-0.006994421128183603,
-0.00610773079097271,
0.015824811533093452,
0.0531596839427948,
0.023825887590646744,
0.003236419288441539,
0.027164015918970108,
0.00342158111743629,
0.021885599941015244,
0.006598018109798431,
-0.033005740493535995,
0.03922300040721893,
0.04448055475950241,
-0.06609492748975754,
-0.013362943194806576,
-0.023241715505719185,
0.016283804550766945,
0.04986328259110451,
0.006874457001686096,
0.03617696091532707,
-0.011568699032068253,
-0.019089918583631516,
0.002365376567468047,
-0.06780572235584259,
-0.0024723010137677193,
-0.04564889892935753,
0.008470498956739902,
0.03187911957502365,
0.026705022901296616,
0.024243153631687164,
0.03465393930673599,
-0.019976608455181122,
-0.042102135717868805,
0.0031060236506164074,
-0.020675528794527054,
-0.04260285571217537,
-0.027873367071151733,
0.05666472017765045,
-0.013477691449224949,
-0.02100934274494648,
-0.037220124155282974,
0.03644818440079689,
-0.019288118928670883,
-0.03250502049922943,
-0.033485595136880875,
-0.019569775089621544,
-0.06417550891637802,
-0.04694242402911186,
-0.048194222152233124,
0.007985427975654602,
-0.013269058428704739,
-0.006509349215775728,
0.022553225979208946,
-0.003726706840097904,
0.003932731691747904,
-0.03863883018493652,
-0.014322654344141483,
-0.0637582391500473,
-0.01074459869414568,
0.027393510565161705,
0.022991355508565903,
-0.0077924421057105064,
0.015230207704007626,
0.0021554394625127316,
-0.05140716955065727,
0.016210783272981644,
-0.034633077681064606,
0.030126603320240974,
-0.00044432305730879307,
0.029500704258680344,
-0.017973732203245163,
0.04066256806254387,
0.010994958691298962,
0.011266181245446205,
0.03260933607816696,
-0.004908090922981501,
0.04164314270019531,
-0.006405032705515623,
-0.04381292685866356,
0.08086614310741425,
-0.03824242576956749,
0.00048572366358712316,
0.05361867696046829,
-0.013623734004795551,
0.02705969847738743,
0.021823011338710785,
-0.03557192534208298,
0.011349634267389774,
0.03354818373918533,
0.05520428717136383,
0.05946040153503418,
-0.008892981335520744,
0.07882153987884521,
0.01299783494323492,
-0.033902861177921295,
-0.012893518432974815,
-0.027539554983377457,
-0.04249854013323784,
0.006837946362793446,
-0.012444958090782166,
0.03849278762936592,
0.031169768422842026,
0.033902861177921295,
0.03713667020201683,
-0.01375934574753046,
0.01706617884337902,
-0.03200430050492287,
0.015762222930788994,
-0.02411797270178795,
-0.02118667960166931,
-0.051240261644124985,
0.022240277379751205,
0.026934519410133362,
0.04702587425708771,
-0.03198343887925148,
-0.04160141944885254,
-0.0029469409491866827,
0.010546397417783737,
0.014072295278310776,
-0.006582370959222317,
0.026350347325205803,
0.014719056896865368,
-0.013008266687393188,
-0.008574815467000008,
-0.03845106065273285,
0.03031437285244465,
0.023700706660747528,
-0.012893518432974815,
-0.006321579683572054,
-0.018849991261959076,
-0.05557982996106148,
0.03004315122961998,
-0.001759036909788847,
-0.035697102546691895,
-0.03997408226132393,
0.009258088655769825,
0.025182001292705536,
0.03634386509656906,
0.01462517213076353,
0.002070682356134057,
-0.05921004340052605,
-0.03696976602077484,
-0.025703584775328636,
-0.04606616497039795,
-0.04133019596338272,
0.004159620031714439,
-0.040579117834568024,
0.02021653577685356,
-0.02457696571946144,
0.03769998252391815,
0.045982711017131805,
0.053660403937101364,
0.09179851412773132,
0.023346031084656715,
0.08595678955316544,
0.032484155148267746,
-0.05053091049194336,
-0.03761652857065201,
-0.007729852106422186,
0.08140859007835388,
0.007719420362263918,
-0.001015129848383367,
-0.007620319724082947,
-0.0037188830319792032,
0.036260414868593216,
0.035279836505651474,
-0.07360571622848511,
-0.019601069390773773,
-0.019642796367406845,
0.00807931274175644,
0.07711075246334076,
-0.04097551852464676,
-0.0570402592420578,
0.010233447887003422,
-0.025620130822062492,
0.017639918252825737,
-0.0334438681602478,
0.0033720305655151606,
-0.0456906259059906,
0.017535602673888206,
-0.06146327778697014,
-0.0828690230846405,
-0.05078126862645149,
-0.04865321144461632,
0.03924386575818062,
-0.020226968452334404,
-0.01441653911024332,
-0.005296669900417328,
-0.022198550403118134,
-0.05090644955635071,
-0.03046041540801525,
-0.0195593424141407,
0.03571796789765358,
0.046191342175006866,
-0.04669206216931343,
0.014280928298830986,
0.06959996372461319,
0.03471652790904045,
0.0018268425483256578,
-0.015480567701160908,
-0.02925034426152706,
-0.029771927744150162,
-0.010176073759794235,
0.03749134764075279,
-0.02599566988646984,
0.016972294077277184,
0.07414816319942474,
-0.0285201296210289,
0.003267714288085699,
-0.010019599460065365,
-0.019757544621825218,
0.00043356543756090105,
-0.03104458935558796,
0.06275680661201477,
-0.021760420873761177,
-0.008006290532648563,
0.03961940482258797,
-0.0004554066981654614,
0.04990500956773758,
0.009482369758188725,
-0.05341004580259323,
-0.029709337279200554,
0.04806904122233391,
-0.01730610616505146,
-0.012392799369990826,
0.003231203416362405,
0.008439204655587673,
0.030856819823384285,
0.026976244524121284,
-0.019465457648038864,
0.0056487382389605045,
-0.0036667247768491507,
0.01086977869272232,
0.039681993424892426,
-0.004558630753308535,
0.007870679721236229,
-0.0009218970080837607,
-0.014802510850131512,
-0.06513521820306778,
0.0002484036376699805,
-0.0007432550191879272,
-0.03901436924934387,
-0.017431287094950676,
0.017848551273345947,
0.026329483836889267,
-0.0049341702833771706,
-0.02672588638961315,
0.050447456538677216,
0.06475967913866043,
-0.009732728824019432,
-0.013811503536999226,
0.003241635160520673,
-0.004582101944833994,
0.03056473284959793,
-0.017775529995560646,
-0.0019142077071592212,
-0.0766100361943245,
0.03671940416097641,
0.013665460981428623,
0.04769350215792656,
0.010702872648835182,
-0.010525533929467201,
-0.019632363691926003,
-0.008898196741938591,
0.011057548224925995,
0.018610062077641487,
-0.04427191987633705,
0.009096398018300533,
-0.04815249517560005,
-0.05416112393140793,
0.027497828006744385,
-0.02148919738829136,
-0.01730610616505146,
-0.039202138781547546,
0.01237193588167429,
0.008746937848627567,
0.03811724856495857,
-0.002704405225813389,
-0.014291360042989254,
0.002156743546947837,
-0.04226904362440109,
-0.015835244208574295,
0.004063127562403679,
-0.02263667993247509,
0.03375681862235069,
-0.007364744320511818,
-0.020758982747793198,
-0.011610426008701324,
0.022073369473218918,
0.015730926766991615,
0.04053739085793495,
-0.006780572235584259,
-0.010358627885580063,
0.03651077300310135,
-0.08341147005558014,
-0.03423667326569557,
-0.03744962066411972,
-0.05015537142753601,
0.03346472978591919,
0.003802336286753416,
0.01396797876805067,
-0.011088843457400799,
0.016586322337388992,
0.02069639228284359,
-0.02184387482702732,
-0.07748629152774811,
0.03333955258131027,
-0.008162765763700008,
-0.02547408826649189,
-0.08044888079166412,
0.003682372160255909,
0.009002513252198696,
0.046817243099212646,
-0.025557540357112885,
0.004928954411298037,
-0.011036684736609459,
-0.001493029878474772,
0.05053091049194336,
0.0214266087859869,
0.008872117847204208,
-0.029375525191426277,
0.01702445186674595,
-0.006295500323176384,
0.005481831729412079,
-0.0070883058942854404,
-0.027184877544641495,
-0.08704168349504471,
-0.06951650977134705,
-0.07648485153913498,
-0.05971075966954231,
0.045774076133966446,
-0.03046041540801525,
0.024389196187257767,
0.0506143644452095,
0.09471938014030457
]
|
30,476 | networkx.classes.function | common_neighbors | Returns the common neighbors of two nodes in a graph.
Parameters
----------
G : graph
A NetworkX undirected graph.
u, v : nodes
Nodes in the graph.
Returns
-------
cnbors : set
Set of common neighbors of u and v in the graph.
Raises
------
NetworkXError
If u or v is not a node in the graph.
Examples
--------
>>> G = nx.complete_graph(5)
>>> sorted(nx.common_neighbors(G, 0, 1))
[2, 3, 4]
| def set_edge_attributes(G, values, name=None):
"""Sets edge attributes from a given value or dictionary of values.
.. Warning:: The call order of arguments `values` and `name`
switched between v1.x & v2.x.
Parameters
----------
G : NetworkX Graph
values : scalar value, dict-like
What the edge attribute should be set to. If `values` is
not a dictionary, then it is treated as a single attribute value
that is then applied to every edge in `G`. This means that if
you provide a mutable object, like a list, updates to that object
will be reflected in the edge attribute for each edge. The attribute
name will be `name`.
If `values` is a dict or a dict of dict, it should be keyed
by edge tuple to either an attribute value or a dict of attribute
key/value pairs used to update the edge's attributes.
For multigraphs, the edge tuples must be of the form ``(u, v, key)``,
where `u` and `v` are nodes and `key` is the edge key.
For non-multigraphs, the keys must be tuples of the form ``(u, v)``.
name : string (optional, default=None)
Name of the edge attribute to set if values is a scalar.
Examples
--------
After computing some property of the edges of a graph, you may want
to assign a edge attribute to store the value of that property for
each edge::
>>> G = nx.path_graph(3)
>>> bb = nx.edge_betweenness_centrality(G, normalized=False)
>>> nx.set_edge_attributes(G, bb, "betweenness")
>>> G.edges[1, 2]["betweenness"]
2.0
If you provide a list as the second argument, updates to the list
will be reflected in the edge attribute for each edge::
>>> labels = []
>>> nx.set_edge_attributes(G, labels, "labels")
>>> labels.append("foo")
>>> G.edges[0, 1]["labels"]
['foo']
>>> G.edges[1, 2]["labels"]
['foo']
If you provide a dictionary of dictionaries as the second argument,
the entire dictionary will be used to update edge attributes::
>>> G = nx.path_graph(3)
>>> attrs = {(0, 1): {"attr1": 20, "attr2": "nothing"}, (1, 2): {"attr2": 3}}
>>> nx.set_edge_attributes(G, attrs)
>>> G[0][1]["attr1"]
20
>>> G[0][1]["attr2"]
'nothing'
>>> G[1][2]["attr2"]
3
The attributes of one Graph can be used to set those of another.
>>> H = nx.path_graph(3)
>>> nx.set_edge_attributes(H, G.edges)
Note that if the dict contains edges that are not in `G`, they are
silently ignored::
>>> G = nx.Graph([(0, 1)])
>>> nx.set_edge_attributes(G, {(1, 2): {"weight": 2.0}})
>>> (1, 2) in G.edges()
False
For multigraphs, the `values` dict is expected to be keyed by 3-tuples
including the edge key::
>>> MG = nx.MultiGraph()
>>> edges = [(0, 1), (0, 1)]
>>> MG.add_edges_from(edges) # Returns list of edge keys
[0, 1]
>>> attributes = {(0, 1, 0): {"cost": 21}, (0, 1, 1): {"cost": 7}}
>>> nx.set_edge_attributes(MG, attributes)
>>> MG[0][1][0]["cost"]
21
>>> MG[0][1][1]["cost"]
7
If MultiGraph attributes are desired for a Graph, you must convert the 3-tuple
multiedge to a 2-tuple edge and the last multiedge's attribute value will
overwrite the previous values. Continuing from the previous case we get::
>>> H = nx.path_graph([0, 1, 2])
>>> nx.set_edge_attributes(H, {(u, v): ed for u, v, ed in MG.edges.data()})
>>> nx.get_edge_attributes(H, "cost")
{(0, 1): 7}
"""
if name is not None:
# `values` does not contain attribute names
try:
# if `values` is a dict using `.items()` => {edge: value}
if G.is_multigraph():
for (u, v, key), value in values.items():
try:
G._adj[u][v][key][name] = value
except KeyError:
pass
else:
for (u, v), value in values.items():
try:
G._adj[u][v][name] = value
except KeyError:
pass
except AttributeError:
# treat `values` as a constant
for u, v, data in G.edges(data=True):
data[name] = values
else:
# `values` consists of doct-of-dict {edge: {attr: value}} shape
if G.is_multigraph():
for (u, v, key), d in values.items():
try:
G._adj[u][v][key].update(d)
except KeyError:
pass
else:
for (u, v), d in values.items():
try:
G._adj[u][v].update(d)
except KeyError:
pass
nx._clear_cache(G)
| (G, u, v) | [
0.06647477298974991,
0.0003319421666674316,
0.005219504702836275,
0.0026503046974539757,
-0.07714924961328506,
-0.026665259152650833,
-0.04294906556606293,
0.02530478499829769,
0.0782376229763031,
-0.02314896136522293,
-0.021851278841495514,
0.014305890537798405,
0.07915855944156647,
0.07890740036964417,
0.00961226038634777,
0.04039556533098221,
0.01567682810127735,
0.036146704107522964,
0.02064778469502926,
0.028779223561286926,
0.02923968993127346,
-0.06823292374610901,
-0.030223416164517403,
-0.014776823110878468,
0.03838625177741051,
-0.02530478499829769,
-0.00891632679849863,
0.05086073651909828,
0.054502617567777634,
0.03505832701921463,
-0.02455129288136959,
-0.08560510724782944,
-0.06383755058050156,
-0.025974556803703308,
0.07342364639043808,
-0.028695501387119293,
-0.03116528131067753,
0.01858614571392536,
-0.06580500304698944,
-0.004625605884939432,
0.009000048041343689,
-0.036167632788419724,
-0.027942009270191193,
-0.002032859716564417,
0.06429801881313324,
0.06111660599708557,
-0.017372185364365578,
0.01682799682021141,
0.024781526997685432,
-0.05529796704649925,
0.0022277734242379665,
-0.025388507172465324,
0.044874656945466995,
0.055632855743169785,
-0.013070999644696712,
0.03962114080786705,
-0.023860592395067215,
0.050944458693265915,
-0.037779271602630615,
-0.019287312403321266,
0.01119773369282484,
-0.01910940371453762,
0.0007129398290999234,
-0.03593740239739418,
-0.08284229785203934,
0.022814074531197548,
-0.0352257676422596,
-0.011187268421053886,
-0.03049551136791706,
0.0049814218655228615,
-0.024237338453531265,
-0.018136143684387207,
0.006080265156924725,
-0.04123277589678764,
-0.025514088571071625,
0.06831664592027664,
-0.028423408046364784,
0.08037251979112625,
-0.0008319811895489693,
-0.017633814364671707,
0.0010360520100221038,
0.03277691826224327,
0.011009360663592815,
-0.033342037349939346,
0.002478937618434429,
0.04680024832487106,
-0.040186259895563126,
0.04822351410984993,
0.04236301779747009,
-0.059693340212106705,
-0.024593153968453407,
0.006022706627845764,
-0.019057078287005424,
0.0136047238484025,
0.012034947983920574,
0.011291920207440853,
0.03049551136791706,
-0.07656320184469223,
-0.0024370769970119,
0.018282655626535416,
-0.013322164304554462,
-0.060446832329034805,
0.006378522142767906,
0.003267749911174178,
-0.03520483896136284,
-0.09100513905286789,
-0.030558302998542786,
-0.055256109684705734,
0.0067291054874658585,
-0.09251212328672409,
-0.03983044624328613,
-0.007644807919859886,
0.08707023411989212,
-0.031060630455613136,
-0.010779127478599548,
0.032462961971759796,
-0.0028988525737076998,
-0.058814264833927155,
0.0025600427761673927,
0.018638471141457558,
0.0021767558064311743,
0.04608861729502678,
0.020595459267497063,
0.06647477298974991,
0.021830348297953606,
0.007859344594180584,
0.022479189559817314,
0.03932811692357063,
0.02189313992857933,
-0.06676779687404633,
-0.01847102865576744,
-0.03191877529025078,
0.011993086896836758,
0.03911881148815155,
0.03671182319521904,
-0.03493274375796318,
-0.06358638405799866,
0.013991935178637505,
0.06312591582536697,
-0.02327454276382923,
0.0018117829458788037,
-0.012757044285535812,
0.03520483896136284,
-0.021809417754411697,
-0.02618386037647724,
-0.02848619781434536,
-0.007932600565254688,
-0.03972579166293144,
-0.026790840551257133,
0.021600114181637764,
-0.00885876826941967,
-0.00854481291025877,
0.008393067866563797,
0.0056197973899543285,
-0.011407037265598774,
-0.009361096657812595,
-0.06283289194107056,
0.022374536842107773,
0.004358744248747826,
0.028381546959280968,
-0.0514049232006073,
-0.020815227180719376,
0.01671287976205349,
-0.02138034626841545,
0.023860592395067215,
0.00493171252310276,
0.03457693010568619,
-0.02203965187072754,
0.007827948778867722,
0.025723392143845558,
0.027062933892011642,
-0.05672123283147812,
0.005740146618336439,
-0.0053293886594474316,
-0.004581129178404808,
0.004554965998977423,
0.078488789498806,
-0.04604675620794296,
0.004154673311859369,
0.048432815819978714,
0.00468839704990387,
-0.0013277686666697264,
0.013740770518779755,
0.04163045436143875,
0.03432576358318329,
-0.023609427735209465,
-0.0008345974492840469,
0.013521002605557442,
0.0359792597591877,
0.00828841608017683,
0.04621420055627823,
-0.02748154103755951,
-0.024216407909989357,
0.04089789092540741,
0.02430013008415699,
-0.011543084867298603,
0.013154720887541771,
-0.03700484707951546,
0.013102395460009575,
0.07413528114557266,
0.032337382435798645,
-0.051572367548942566,
0.041065335273742676,
0.0238187313079834,
0.06283289194107056,
-0.014714031480252743,
0.07308875769376755,
-0.060949161648750305,
-0.022604770958423615,
-0.01798962987959385,
-0.017665211111307144,
-0.016493111848831177,
0.027669914066791534,
0.013405885547399521,
0.00848725438117981,
0.007875042036175728,
-0.007351783104240894,
0.03945370018482208,
-0.017801256850361824,
-0.01620008610188961,
-0.02798387035727501,
-0.004277639091014862,
0.033237386494874954,
-0.003170947078615427,
0.02999318204820156,
-0.050567712634801865,
0.008816907182335854,
-0.03443041443824768,
0.03794671222567558,
0.025995487347245216,
0.048432815819978714,
0.01550938468426466,
0.040688589215278625,
-0.0038511832244694233,
0.0006285643903538585,
0.005308458581566811,
0.03643972799181938,
-0.011260525323450565,
0.0035503096878528595,
0.041316498070955276,
0.01182564441114664,
-0.04780490696430206,
-0.05860496312379837,
0.030411789193749428,
0.006676779594272375,
-0.020982669666409492,
0.02340012416243553,
0.00905760657042265,
-0.02419547736644745,
0.0018327132565900683,
-0.05278632789850235,
0.019287312403321266,
-0.02289779670536518,
0.03064202331006527,
-0.03782113268971443,
0.0034953674767166376,
0.008633767254650593,
-0.025597810745239258,
0.013991935178637505,
-0.013280303217470646,
0.00537909846752882,
-0.038407180458307266,
-0.050944458693265915,
0.032965291291475296,
0.034890882670879364,
0.005813403055071831,
0.034744370728731155,
0.0024030650965869427,
-0.12122855335474014,
-0.010407613590359688,
0.07509807497262955,
-0.03315366432070732,
-0.005666890647262335,
0.004366592969745398,
0.01176285371184349,
0.02201872132718563,
0.0013526234542950988,
-0.03553972393274307,
-0.020030338317155838,
-0.048935145139694214,
0.015572176314890385,
-0.03317459672689438,
-0.041965339332818985,
0.056763093918561935,
0.003791008610278368,
0.009470980614423752,
-0.014703566208481789,
0.025848975405097008,
0.014284959994256496,
-0.014881474897265434,
0.09720052033662796,
0.02289779670536518,
-0.03560251370072365,
0.01570822298526764,
0.0389932319521904,
0.022479189559817314,
-0.02126522921025753,
-0.006619221065193415,
0.039244394749403,
0.0478886254131794,
0.07970274984836578,
0.0064046853221952915,
0.06371196359395981,
0.029721088707447052,
0.008162833750247955,
-0.024886179715394974,
0.06647477298974991,
0.03520483896136284,
-0.01007272768765688,
0.060949161648750305,
-0.027942009270191193,
0.040311843156814575,
-0.058395661413669586,
0.02011406049132347,
0.045628149062395096,
0.029909461736679077,
0.028821082785725594,
-0.022500120103359222,
0.022876866161823273,
0.0009503684123046696,
-0.02798387035727501,
0.0013735538814216852,
-0.04558628797531128,
-0.02138034626841545,
-0.006116893142461777,
0.025535019114613533,
0.058814264833927155,
0.06727012246847153,
0.03076760657131672,
-0.02356756664812565,
-0.04215371236205101,
-0.01518496498465538,
0.034493207931518555,
0.021066391840577126,
-0.0005216234130784869,
0.08397254347801208,
-0.005640727933496237,
0.020574528723955154,
0.026769910007715225,
-0.017267534509301186,
0.010282031260430813,
0.054628197103738785,
-0.0478886254131794,
-0.02128615975379944,
0.00395583501085639,
0.009973309002816677,
0.000247893767664209,
-0.0020681796595454216,
-0.004466012120246887,
0.020909413695335388,
-0.0574328638613224,
0.07107944786548615,
-0.0026764676440507174,
0.013782631605863571,
-0.04529326409101486,
0.0034613555762916803,
-0.025346646085381508,
-0.08384695649147034,
0.014148912392556667,
-0.029679227620363235,
-0.02277221344411373,
0.010768662206828594,
0.03453506901860237,
-0.025346646085381508,
0.018167538568377495,
0.00125909096095711,
-0.023232681676745415,
0.03838625177741051,
0.02886294387280941,
-0.04629792273044586,
0.061702653765678406,
-0.05236772075295448,
-0.00281774764880538,
0.0486421212553978,
0.010768662206828594,
0.01883731037378311,
-0.04470721632242203,
0.012369832955300808,
0.018554750829935074,
0.026790840551257133,
-0.022876866161823273,
-0.03660717234015465,
0.0091203972697258,
0.0476374626159668,
0.06647477298974991,
-0.028946666046977043,
0.13328443467617035,
-0.018784983083605766,
0.016807066276669502,
-0.01594892144203186,
-0.005044213030487299,
-0.015645431354641914,
0.016660554334521294,
-0.008911093696951866,
-0.03493274375796318,
-0.02406989596784115,
0.028402477502822876,
-0.0012106895446777344,
-0.046130478382110596,
-0.06433987617492676,
-0.07112130522727966,
-0.018324516713619232,
0.04391186311841011,
0.023735010996460915,
0.04062579944729805,
-0.015415198169648647,
0.051321204751729965,
0.05228399857878685,
0.053414236754179,
0.03114435262978077,
0.013740770518779755,
-0.011616340838372707,
-0.055004943162202835,
-0.014944265596568584,
0.022625701501965523,
0.009277375414967537,
0.02771177515387535,
-0.04142114892601967,
0.054753780364990234,
-0.0011583637678995728,
0.0509025976061821,
0.0020956506486982107,
0.00937156192958355,
-0.016901252791285515,
0.021212903782725334,
-0.04328395053744316,
0.001103421556763351,
0.000607634021434933,
-0.034974604845047,
0.04202812910079956,
-0.019412893801927567,
-0.016493111848831177,
0.015760548412799835,
0.015007056295871735,
0.033969949930906296,
0.0024239954072982073,
0.01424309890717268,
-0.04947933182120323,
-0.004094498697668314,
-0.042467668652534485,
-0.05303749069571495,
-0.03700484707951546,
-0.02605827897787094,
-0.08681906759738922,
-0.057684026658535004,
-0.07229340821504593,
-0.01580240949988365,
0.013070999644696712,
0.07241898775100708,
-0.03851183131337166,
-0.003924439661204815,
0.020040804520249367,
0.04089789092540741,
0.010925639420747757,
-0.03390715643763542,
0.04533512517809868,
-0.0033828667365014553,
-0.021558254957199097,
0.019789639860391617,
0.03660717234015465,
-0.019391963258385658,
-0.05048399046063423,
-0.06140962988138199,
0.0023795184679329395,
-0.014284959994256496,
0.03480716049671173,
0.06597244739532471,
-0.004685780964791775,
-0.017026834189891815,
-0.004366592969745398,
0.038176946341991425,
-0.08129345625638962,
0.011616340838372707,
-0.006619221065193415,
0.0010864157229661942,
-0.019831500947475433,
-0.028067590668797493,
-0.00616921903565526,
-0.06367010623216629,
-0.054753780364990234,
0.044874656945466995,
-0.024279199540615082,
0.030055973678827286,
0.011312850750982761,
0.07480505108833313,
0.014284959994256496,
0.01335355918854475,
-0.03304901346564293,
-0.02314896136522293,
0.05952589958906174,
-0.013144255615770817,
-0.07945158332586288,
-0.005959915462881327,
0.0076709710992872715,
0.021495463326573372,
0.032965291291475296,
-0.031186211854219437,
-0.01684892736375332,
0.0002837042848113924,
-0.05379098281264305,
-0.04273976385593414,
-0.040311843156814575,
-0.00295641110278666,
-0.02356756664812565,
0.023316403850913048,
0.020459411665797234,
-0.025660602375864983,
-0.009973309002816677,
0.04696769267320633,
-0.011354711838066578,
0.03566530719399452,
0.005933752749115229,
0.037402525544166565,
0.024907110258936882,
0.01562450174242258,
0.003893044078722596,
0.007309922482818365,
0.025472229346632957,
0.02888387441635132,
-0.05927473306655884,
0.009350631386041641,
-0.0061116605065763,
-0.008016321808099747,
0.01618962176144123,
-0.047386299818754196,
-0.00918318796902895,
0.025388507172465324,
-0.04165138304233551,
0.02926062047481537,
-0.018031490966677666,
0.018554750829935074,
0.0799957737326622,
-0.01386635284870863,
0.0509025976061821,
0.02823503315448761,
0.0016181771643459797,
0.08146090060472488,
0.008220392279326916,
-0.0073674810118973255,
0.013458210974931717,
0.015111708082258701,
0.044874656945466995,
-0.02151639387011528,
0.021600114181637764,
-0.027125725522637367,
-0.03476530313491821,
-0.009586097672581673,
-0.04089789092540741,
0.04947933182120323,
-0.08991675823926926,
-0.038176946341991425,
0.005546540953218937,
-0.0020498656667768955,
-0.016932647675275803,
-0.016744274646043777,
-0.06739570945501328,
0.0379885733127594,
-0.013384955003857613,
-0.015007056295871735,
0.023065239191055298,
-0.04818165302276611,
-0.022939657792448997,
0.017246603965759277,
-0.016922183334827423,
0.032735057175159454,
0.0007724604802206159,
-0.01937103271484375,
0.0036706591490656137,
-0.016503576189279556,
0.012652392499148846,
-0.0483909547328949,
0.0569305345416069,
0.02607920952141285,
0.006504104472696781,
0.01013028621673584,
0.0056459601037204266,
0.009418655186891556,
-0.002951178466901183,
-0.010255868546664715,
-0.019036147743463516,
-0.01746637187898159,
0.035372279584407806,
-0.03403273969888687,
0.015425663441419601,
0.05810263380408287,
0.027021074667572975,
-0.004288104362785816,
0.10121913999319077,
-0.04378627985715866,
0.019894292578101158,
-0.03593740239739418,
-0.018784983083605766,
0.019779175519943237,
-0.016493111848831177,
-0.04479093477129936,
-0.01032389234751463,
-0.013280303217470646,
-0.018282655626535416,
-0.018031490966677666,
0.03733973205089569,
-0.061953816562891006,
-0.008042484521865845,
0.016660554334521294,
0.027000144124031067,
-0.040311843156814575,
-0.012422159314155579,
0.02647688426077366,
-0.028046660125255585,
-0.027816427871584892,
-0.033990878611803055,
0.023965243250131607,
0.048935145139694214,
0.005010201130062342,
-0.015394267626106739,
0.017445441335439682,
-0.048558399081230164,
-0.030809465795755386,
0.08991675823926926,
-0.0506514310836792,
-0.010077960789203644,
-0.05630262568593025,
-0.08217252790927887,
-0.06392127275466919,
-0.03212807700037956,
0.01519542932510376,
0.02064778469502926,
-0.025493159890174866,
-0.014232633635401726,
-0.0674375668168068,
-0.01833498105406761,
0.002909317845478654,
-0.07342364639043808,
-0.016765205189585686,
-0.0332164540886879,
0.03338389843702316,
-0.08899582177400589,
0.030558302998542786,
0.015666361898183823,
-0.006038404069840908,
0.03838625177741051,
0.006054101977497339,
0.04345139488577843,
-0.00854481291025877,
-0.002478937618434429,
-0.04529326409101486,
0.0549212209880352,
0.012547741644084454,
-0.08757255971431732,
0.013855887576937675,
0.014536123722791672,
0.04098161309957504,
0.011993086896836758,
-0.025367576628923416,
0.006033171433955431,
0.02633037231862545,
0.03556065261363983,
-0.04378627985715866,
-0.036544378846883774,
-0.00022091323626227677,
-0.016126830130815506,
-0.012736114673316479,
-0.00010792208922794089,
0.04219557344913483,
0.001220500678755343,
0.0033436224330216646,
0.02898852713406086,
-0.029700158163905144,
0.006765733473002911,
0.05257702246308327,
0.010925639420747757,
-0.04998166114091873,
-0.018690796568989754,
0.014661706052720547,
0.00975354015827179,
-0.03671182319521904,
-0.029302481561899185,
0.019643127918243408,
-0.001972684869542718,
0.05814449489116669,
0.04922816902399063,
-0.014567519538104534,
0.05705611780285835,
0.014923335053026676,
-0.013395420275628567,
-0.0036471125204116106,
-0.007561086677014828,
0.005551773589104414,
0.005776775069534779,
-0.00031313757062889636,
0.020480342209339142,
0.0007790012168698013,
-0.06986548751592636,
0.0057663097977638245,
0.0048218281008303165,
-0.029469924047589302,
-0.04192347824573517,
0.0034535068552941084,
-0.012348903343081474,
0.02580711431801319,
0.02178848721086979,
0.008534347638487816,
0.04269790276885033,
-0.05814449489116669,
0.0011112703941762447,
0.008497719652950764,
-0.04213278368115425,
-0.09251212328672409,
0.02277221344411373,
0.0030819931998848915,
-0.02367221936583519,
-0.04495837911963463,
0.010282031260430813,
0.013573328033089638,
-0.017665211111307144,
0.041588593274354935,
-0.008403533138334751,
-0.00547851761803031,
-0.06086543947458267,
-0.06228870525956154,
0.05278632789850235,
-0.03378157690167427,
0.04403744265437126,
0.032588545233011246,
-0.015739617869257927,
-0.05764216557145119,
-0.043870002031326294,
-0.008461091667413712,
0.011543084867298603,
0.03129086270928383,
-0.032965291291475296,
-0.0267071183770895,
0.06605616211891174,
-0.0041756038554012775,
0.045125823467969894,
-0.06613988429307938,
-0.05990264564752579,
-0.031437378376722336,
-0.004413686227053404,
0.007283759769052267,
0.08137717843055725,
-0.018188469111919403,
-0.011260525323450565,
-0.045753732323646545,
-0.020208247005939484,
-0.047930486500263214,
-0.018303586170077324,
-0.04173510521650314,
0.06253986805677414,
-0.00268954923376441,
-0.000911124050617218,
0.020595459267497063,
0.028779223561286926,
-0.031060630455613136,
0.019203590229153633,
0.0832609087228775,
-0.06115846335887909,
0.033614132553339005,
-0.019538475200533867,
0.02896759659051895,
-0.03074667602777481,
-0.029051316902041435,
0.03851183131337166,
0.004128510132431984,
-0.030160626396536827,
-0.032190870493650436,
0.051697950810194016,
0.017037300392985344,
0.04213278368115425
]
|
30,484 | networkx.generators.classic | complete_graph | Return the complete graph `K_n` with n nodes.
A complete graph on `n` nodes means that all pairs
of distinct nodes have an edge connecting them.
.. plot::
>>> nx.draw(nx.complete_graph(5))
Parameters
----------
n : int or iterable container of nodes
If n is an integer, nodes are from range(n).
If n is a container of nodes, those nodes appear in the graph.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Examples
--------
>>> G = nx.complete_graph(9)
>>> len(G)
9
>>> G.size()
36
>>> G = nx.complete_graph(range(11, 14))
>>> list(G.nodes())
[11, 12, 13]
>>> G = nx.complete_graph(4, nx.DiGraph())
>>> G.is_directed()
True
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (n, create_using=None, *, backend=None, **backend_kwargs) | [
0.02225247211754322,
-0.006895069498568773,
0.02168417163193226,
-0.0502234548330307,
-0.012653540819883347,
0.06673965603113174,
-0.047559551894664764,
0.007436729967594147,
-0.0006354519282467663,
0.0049814991652965546,
0.004182328004390001,
0.06244189292192459,
0.016960183158516884,
0.07608107477426529,
0.02701197937130928,
-0.007583244703710079,
0.014793542213737965,
0.011836609803140163,
-0.02283853106200695,
0.03800502046942711,
-0.019801679998636246,
0.015130970627069473,
0.03425779566168785,
0.013941093347966671,
-0.020849483087658882,
0.012058601714670658,
0.022216953337192535,
0.03244633972644806,
-0.03736568242311478,
0.027260608971118927,
0.03315671533346176,
-0.01215627882629633,
0.0011676775757223368,
0.018363172188401222,
0.020671889185905457,
0.04237382113933563,
-0.02145330049097538,
0.05313599109649658,
-0.1044960469007492,
-0.01573478803038597,
0.046387434005737305,
-0.005953823681920767,
0.014837941154837608,
-0.03299688175320625,
0.012174038216471672,
0.028450487181544304,
0.0834689661860466,
0.004541954956948757,
-0.06876422464847565,
-0.017555123195052147,
0.04290660098195076,
0.004220066592097282,
-0.04329730570316315,
-0.058321721851825714,
-0.0019435393624007702,
0.010087313130497932,
-0.007561045233160257,
-0.01233387179672718,
0.059493839740753174,
-0.03995854780077934,
0.03365397825837135,
0.032108914107084274,
0.006206894759088755,
-0.023548904806375504,
-0.05622611939907074,
-0.02180848829448223,
-0.03885746747255325,
-0.06141185015439987,
-0.014305160380899906,
-0.018931472674012184,
0.0540594756603241,
0.041485853493213654,
0.030190903693437576,
-0.009634450078010559,
0.012893292121589184,
0.026337122544646263,
0.0364777147769928,
0.01084208581596613,
-0.01046913955360651,
-0.009052830748260021,
-0.02283853106200695,
-0.036211322993040085,
0.022003840655088425,
-0.048056814819574356,
0.046316396445035934,
0.09824474900960922,
-0.019677365198731422,
0.021027076989412308,
-0.04457598179578781,
-0.023992888629436493,
-0.024401353672146797,
-0.027793390676379204,
-0.026106251403689384,
0.0055098398588597775,
-0.0127068180590868,
0.01596565917134285,
0.050330013036727905,
-0.09249071776866913,
0.012351631186902523,
-0.0009695497574284673,
-0.03754327446222305,
-0.03336982801556587,
-0.08865469694137573,
-0.021844007074832916,
-0.05665234103798866,
-0.031434059143066406,
-0.02534259855747223,
0.05682993680238724,
-0.013115284033119678,
0.028539283201098442,
-0.019055787473917007,
0.01742192730307579,
0.06613583862781525,
-0.01362142525613308,
0.029782438650727272,
0.04269348829984665,
-0.018185580149292946,
0.03864435479044914,
0.06521235406398773,
-0.023051641881465912,
-0.058463796973228455,
0.044185273349285126,
-0.040384773164987564,
0.029746919870376587,
0.02686990424990654,
-0.0003812711511272937,
0.04457598179578781,
-0.05313599109649658,
0.030208662152290344,
0.021062595769762993,
-0.0015495037660002708,
0.01896699145436287,
-0.0010544616961851716,
0.06819592416286469,
-0.03530559688806534,
0.01322183944284916,
-0.07885153591632843,
-0.02834393084049225,
-0.0012775636278092861,
-0.014287400990724564,
0.03392036631703377,
-0.03413347899913788,
0.03875091299414635,
0.0495130829513073,
-0.06070147454738617,
0.015477278269827366,
0.01873612031340599,
0.019144585356116295,
0.01331951655447483,
-0.014482754282653332,
0.023690979927778244,
0.002009026939049363,
0.09533222019672394,
0.030723683536052704,
-0.02211039699614048,
-0.018398690968751907,
0.02710077539086342,
-0.02234126813709736,
-0.012147398665547371,
0.029853476211428642,
-0.007463369052857161,
0.011845489963889122,
0.03988751024007797,
-0.016596117988228798,
-0.07615211606025696,
-0.0033232192508876324,
-0.006291251629590988,
-0.004397660028189421,
0.0065665217116475105,
-0.02717181295156479,
-0.04166344553232193,
-0.0009062821045517921,
0.0012575843138620257,
-0.05601300671696663,
-0.004568594042211771,
-0.0020434358157217503,
-0.030865758657455444,
-0.01119727361947298,
-0.017191056162118912,
-0.02591089904308319,
0.029675882309675217,
-0.07064671069383621,
0.029107581824064255,
-0.041770003736019135,
-0.01208524126559496,
0.017697196453809738,
0.00995411816984415,
0.014109807088971138,
0.029125342145562172,
0.03354742005467415,
0.04670710489153862,
0.025093968957662582,
-0.012884411960840225,
0.05601300671696663,
0.022891808301210403,
-0.05842827633023262,
0.06986530125141144,
0.036211322993040085,
-0.0722450539469719,
0.05526711419224739,
0.07743078470230103,
0.07132156938314438,
0.020458776503801346,
-0.010362583212554455,
0.04848304018378258,
-0.0005799539503641427,
-0.051217980682849884,
-0.048127852380275726,
-0.05182179808616638,
0.028716877102851868,
-0.008044987916946411,
0.019677365198731422,
0.037969499826431274,
0.04454046115279198,
-0.06485716253519058,
0.06968770921230316,
0.038999542593955994,
0.03177148476243019,
0.01002515573054552,
-0.061092179268598557,
-0.035181280225515366,
-0.015672631561756134,
0.0032344225328415632,
0.034222278743982315,
-0.008373536169528961,
-0.005767350550740957,
-0.008373536169528961,
-0.016826989129185677,
-0.004586353432387114,
-0.06269052624702454,
0.026550235226750374,
-0.02656799554824829,
0.04422079399228096,
-0.015273044817149639,
0.012609141878783703,
-0.01522864680737257,
0.03345862403512001,
-0.011694535613059998,
-0.04237382113933563,
0.032322026789188385,
-0.05512503907084465,
-0.019499771296977997,
0.007396771106868982,
-0.009394698776304722,
-0.01383453793823719,
0.07970398664474487,
-0.01039810199290514,
0.031434059143066406,
0.0024907495826482773,
-0.011694535613059998,
-0.0044820173643529415,
-0.019055787473917007,
0.01284889318048954,
-0.030919037759304047,
0.0188959538936615,
0.030546089634299278,
-0.05697201192378998,
-0.0074678086675703526,
0.015166489407420158,
0.04269348829984665,
-0.02759803831577301,
-0.008773121051490307,
-0.0580020546913147,
-0.02834393084049225,
0.06176703795790672,
0.01807902380824089,
-0.06869318336248398,
0.05288735777139664,
-0.05952935665845871,
-0.028663598001003265,
0.05704304948449135,
0.08140888065099716,
0.10527745634317398,
0.004477577283978462,
0.012760096229612827,
-0.056119561195373535,
0.0025018490850925446,
0.039851993322372437,
-0.04290660098195076,
-0.03162940964102745,
-0.053917400538921356,
-0.03711705282330513,
-0.01175669301301241,
0.04283556342124939,
0.02532484009861946,
0.032322026789188385,
0.049974825233221054,
-0.004082431551069021,
0.025680027902126312,
-0.028805673122406006,
0.019677365198731422,
-0.014837941154837608,
-0.03683290258049965,
-0.0030990075320005417,
0.030475053936243057,
0.020245663821697235,
-0.026479197666049004,
0.015273044817149639,
0.002346454653888941,
0.052532173693180084,
0.09412457793951035,
-0.05310047045350075,
0.036655306816101074,
0.0224833432585001,
0.045357391238212585,
0.02701197937130928,
0.0004706229083240032,
0.01039810199290514,
0.012760096229612827,
0.014695866033434868,
-0.05448570102453232,
0.014349558390676975,
0.005061415955424309,
0.009323661215603352,
-0.010513538494706154,
-0.05864138901233673,
-0.020441018044948578,
-0.02145330049097538,
0.038040537387132645,
0.038253650069236755,
0.019144585356116295,
0.005256769247353077,
-0.052603207528591156,
0.02129346691071987,
-0.052461136132478714,
0.05334910377860069,
-0.01003403589129448,
0.057149603962898254,
-0.04912237450480461,
0.02100931666791439,
0.019002510234713554,
-0.0195530503988266,
-0.031132148578763008,
0.035394392907619476,
-0.07213850319385529,
0.03551870957016945,
0.013905574567615986,
-0.032552897930145264,
-0.01548615749925375,
-0.051075905561447144,
0.029782438650727272,
0.010531297884881496,
-0.015548314899206161,
0.007050463929772377,
-0.03010210581123829,
0.03864435479044914,
0.04695573449134827,
-0.09348524361848831,
-0.03786294534802437,
-0.0267278291285038,
0.03155837208032608,
0.07870946079492569,
-0.02628384530544281,
-0.029782438650727272,
0.040242698043584824,
0.06641998887062073,
0.005345565732568502,
0.012360511347651482,
-0.06404023617506027,
-0.01058457512408495,
-0.003749443916603923,
0.0035385515075176954,
0.062193259596824646,
-0.009856441989541054,
-0.005758470855653286,
0.02108035422861576,
-0.013568147085607052,
0.08702083677053452,
0.011667896062135696,
-0.006539882626384497,
-0.024152722209692,
-0.0736658051609993,
-0.07679145038127899,
0.05043656751513481,
-0.0057851099409163,
0.05423707142472267,
-0.01544175948947668,
-0.031807005405426025,
0.02717181295156479,
-0.0018902613082900643,
-0.041912078857421875,
-0.019730642437934875,
0.04251589626073837,
0.006917268969118595,
0.02644367888569832,
-0.00003877921699313447,
0.0411306656897068,
0.019304418936371803,
-0.04269348829984665,
-0.027562519535422325,
-0.053633250296115875,
-0.046458471566438675,
0.06240637227892876,
-0.004857183434069157,
-0.029338454827666283,
0.002228799043223262,
0.09561637043952942,
0.049015820026397705,
-0.05288735777139664,
0.017359768971800804,
0.05178627744317055,
-0.04571257904171944,
0.025537952780723572,
0.002623944776132703,
-0.0047195483930408955,
-0.03697497770190239,
0.010593455284833908,
-0.009936358779668808,
-0.02614177018404007,
-0.026603514328598976,
0.01997927390038967,
-0.07870946079492569,
-0.03038625605404377,
-0.0004234496154822409,
0.07153467833995819,
0.006215773988515139,
0.010406982153654099,
0.0009756545769050717,
0.02949828840792179,
0.004621872212737799,
0.023904092609882355,
-0.09384042769670486,
-0.015122090466320515,
0.09682400524616241,
0.05310047045350075,
-0.05072071775794029,
0.027988743036985397,
-0.0163208469748497,
-0.01200532354414463,
0.07267127931118011,
0.03413347899913788,
-0.023850813508033752,
0.035980451852083206,
0.006730795372277498,
0.007356812711805105,
-0.06155392527580261,
0.025378117337822914,
0.006158056203275919,
-0.0017437466885894537,
0.0013275117380544543,
0.031025592237710953,
-0.005301167257130146,
0.01868284121155739,
-0.021062595769762993,
-0.0026461437810212374,
-0.015770306810736656,
0.03814709559082985,
0.03475505858659744,
-0.002339794998988509,
-0.0339558869600296,
-0.006695276591926813,
-0.031434059143066406,
0.05221250280737877,
0.00030412894557230175,
-0.03878642991185188,
-0.007751958444714546,
0.019020268693566322,
-0.04578361660242081,
-0.059706952422857285,
0.04713332653045654,
-0.010930882766842842,
0.026852143928408623,
-0.020831722766160965,
0.02189728431403637,
-0.01672043278813362,
-0.042444858700037,
0.028095299378037453,
-0.005829508416354656,
-0.04116618633270264,
-0.0705401599407196,
0.024472391232848167,
0.013124163262546062,
-0.038999542593955994,
-0.031007833778858185,
0.038182612508535385,
-0.03477281704545021,
-0.026408160105347633,
-0.04656502977013588,
-0.000288034527329728,
-0.03088351897895336,
-0.060736995190382004,
0.015335203148424625,
-0.010176110081374645,
0.039567843079566956,
-0.04716884717345238,
-0.023708738386631012,
0.023175958544015884,
-0.047559551894664764,
0.0018491927767172456,
-0.03542991355061531,
-0.0031189867295324802,
-0.022607658058404922,
-0.015237526968121529,
0.01596565917134285,
-0.030634887516498566,
0.07089534401893616,
-0.01746632531285286,
-0.038395725190639496,
-0.0020012573804706335,
-0.009297022596001625,
0.019304418936371803,
-0.002124462742358446,
-0.022021600976586342,
0.014873459935188293,
0.006979426369071007,
0.05803757160902023,
-0.006655318196862936,
-0.012884411960840225,
0.00828917883336544,
0.042800046503543854,
0.0391061007976532,
0.03857331722974777,
0.024632224813103676,
0.041983116418123245,
-0.022643176838755608,
0.008013908751308918,
-0.021719690412282944,
-0.0076942406594753265,
0.04329730570316315,
-0.057362716645002365,
0.04123722389340401,
0.03821813315153122,
0.00988308060914278,
0.041841041296720505,
-0.025271562859416008,
-0.005936064291745424,
0.03843124583363533,
-0.02665679156780243,
0.016214290633797646,
-0.0005477651138789952,
0.022359028458595276,
0.06169600039720535,
-0.03946128487586975,
0.010779928416013718,
-0.04134377837181091,
-0.0808405801653862,
0.03471953794360161,
0.046742621809244156,
0.008151544257998466,
-0.020316701382398605,
0.002672782866284251,
-0.0022709774784743786,
-0.011099596507847309,
0.0019113505259156227,
0.0011987565085291862,
0.02964036352932453,
0.006140296813100576,
-0.06748554855585098,
0.026337122544646263,
-0.059635914862155914,
0.034222278743982315,
-0.0038981784600764513,
0.007436729967594147,
0.006588720716536045,
0.08368208259344101,
-0.006118097808212042,
0.007996149361133575,
-0.026834385469555855,
0.004186768084764481,
0.03242858126759529,
-0.062193259596824646,
0.006584280636161566,
-0.0017615059623494744,
-0.029604844748973846,
0.01866508275270462,
-0.0000034859672268794384,
0.008679884485900402,
-0.023016123101115227,
0.02466774359345436,
0.007569924928247929,
-0.005603076424449682,
0.06421782821416855,
0.08972026407718658,
-0.009279263205826283,
-0.016054457053542137,
-0.0072591365315020084,
-0.04269348829984665,
-0.004741747863590717,
-0.039709918200969696,
-0.01793694868683815,
-0.020334461703896523,
-0.019641846418380737,
0.002570666605606675,
0.0005610845983028412,
-0.002583986148238182,
0.06393367797136307,
-0.09433769434690475,
-0.004639631602913141,
-0.01786591112613678,
0.015610473230481148,
0.04503772407770157,
-0.05690097436308861,
0.06435990333557129,
0.03354742005467415,
-0.04372353106737137,
0.01072665024548769,
-0.020174626260995865,
-0.045641541481018066,
0.02651471644639969,
0.005931624677032232,
-0.046813659369945526,
0.08865469694137573,
-0.02086724154651165,
0.032908085733652115,
0.062264297157526016,
0.042942121624946594,
0.03155837208032608,
-0.016045577824115753,
-0.016303088515996933,
-0.08453452587127686,
-0.0060692597180604935,
0.05373980849981308,
-0.02093827910721302,
-0.04869615286588669,
-0.050187937915325165,
0.012724577449262142,
-0.028716877102851868,
0.05189283564686775,
-0.06531890481710434,
-0.029995551332831383,
-0.015832465142011642,
0.03542991355061531,
-0.01522864680737257,
-0.007743078749626875,
-0.02900102734565735,
0.0012187357060611248,
0.018469728529453278,
-0.029107581824064255,
0.0012997627491131425,
0.004060232546180487,
0.010673372074961662,
-0.05491192638874054,
-0.022962845861911774,
-0.03463074192404747,
-0.0115702198818326,
-0.007547725923359394,
0.009439096786081791,
-0.027544759213924408,
0.0038826388772577047,
0.09625570476055145,
-0.0430486761033535,
0.008329137228429317,
-0.029089823365211487,
-0.026301603764295578,
-0.0038182612042874098,
-0.031149908900260925,
0.018700601533055305,
-0.03654875233769417,
-0.006531002931296825,
-0.028130818158388138,
-0.0391061007976532,
-0.002901434665545821,
0.01772383600473404,
0.01880715601146221,
0.04276452586054802,
0.037294644862413406,
-0.034808333963155746,
-0.06240637227892876,
0.0054476819932460785,
-0.06173151731491089,
0.05381084606051445,
-0.015610473230481148,
0.029817957431077957,
0.06162496283650398,
0.0011965365847572684,
0.06105666235089302,
-0.003685066243633628,
-0.06148288771510124,
0.006033740937709808,
-0.0004462038050405681,
0.0046485112980008125,
0.008098266087472439,
0.038253650069236755,
-0.016942424699664116,
-0.055089518427848816,
-0.01501553412526846,
-0.014882339164614677,
0.028166336938738823,
-0.04461149871349335,
-0.009856441989541054,
0.009483495727181435,
-0.0091194286942482,
0.03281928971409798,
-0.024436872452497482,
-0.0199082363396883,
-0.01786591112613678,
-0.04098859056830406,
-0.05199939012527466,
0.018718359991908073,
0.011117355898022652,
-0.01749296486377716,
0.028219614177942276,
0.010771049186587334,
0.016303088515996933,
-0.0195530503988266,
0.014873459935188293,
-0.01599229872226715,
0.027189573273062706,
0.004233386367559433,
-0.05079175531864166,
0.03669082745909691,
-0.0014362878864631057,
-0.009341420605778694,
0.03768534958362579,
0.01746632531285286,
0.022820770740509033,
-0.03420451655983925,
0.012111879885196686,
-0.04141481593251228,
0.035696301609277725,
-0.07132156938314438,
-0.023193717002868652,
0.0042555853724479675,
0.02175520919263363,
-0.08716291189193726,
0.0052123707719147205,
0.029693640768527985,
0.005265648942440748,
-0.05192835256457329,
-0.0014917858643457294,
0.03361845761537552,
-0.04727540165185928,
-0.025822101160883904,
0.05111142247915268,
-0.035980451852083206,
0.009070590138435364,
-0.032108914107084274,
-0.037152569741010666,
-0.042196229100227356,
-0.029480529949069023,
-0.021027076989412308,
0.030439535155892372,
0.011792211793363094,
-0.016054457053542137,
0.018931472674012184,
-0.0016316407127305865,
0.020973797887563705,
0.02759803831577301,
-0.016560599207878113,
-0.016640515998005867,
0.002959152450785041,
-0.02145330049097538,
-0.06656206399202347,
-0.020902760326862335,
-0.016658274456858635,
-0.014473874121904373,
0.008329137228429317,
-0.01845197007060051,
0.0011621278245002031,
0.02928517572581768,
0.04134377837181091,
-0.00279265851713717,
0.008964034728705883,
0.02649695798754692,
-0.04471805691719055,
-0.024063926190137863,
0.015281924977898598,
-0.0055142794735729694,
-0.01786591112613678,
-0.04354593902826309,
-0.02283853106200695,
0.02834393084049225,
0.06404023617506027,
-0.010966401547193527,
-0.045144278556108475,
0.003292140318080783,
0.0456770621240139,
-0.003096787491813302
]
|
30,485 | networkx.generators.classic | complete_multipartite_graph | Returns the complete multipartite graph with the specified subset sizes.
.. plot::
>>> nx.draw(nx.complete_multipartite_graph(1, 2, 3))
Parameters
----------
subset_sizes : tuple of integers or tuple of node iterables
The arguments can either all be integer number of nodes or they
can all be iterables of nodes. If integers, they represent the
number of nodes in each subset of the multipartite graph.
If iterables, each is used to create the nodes for that subset.
The length of subset_sizes is the number of subsets.
Returns
-------
G : NetworkX Graph
Returns the complete multipartite graph with the specified subsets.
For each node, the node attribute 'subset' is an integer
indicating which subset contains the node.
Examples
--------
Creating a complete tripartite graph, with subsets of one, two, and three
nodes, respectively.
>>> G = nx.complete_multipartite_graph(1, 2, 3)
>>> [G.nodes[u]["subset"] for u in G]
[0, 1, 1, 2, 2, 2]
>>> list(G.edges(0))
[(0, 1), (0, 2), (0, 3), (0, 4), (0, 5)]
>>> list(G.edges(2))
[(2, 0), (2, 3), (2, 4), (2, 5)]
>>> list(G.edges(4))
[(4, 0), (4, 1), (4, 2)]
>>> G = nx.complete_multipartite_graph("a", "bc", "def")
>>> [G.nodes[u]["subset"] for u in sorted(G)]
[0, 1, 1, 2, 2, 2]
Notes
-----
This function generalizes several other graph builder functions.
- If no subset sizes are given, this returns the null graph.
- If a single subset size `n` is given, this returns the empty graph on
`n` nodes.
- If two subset sizes `m` and `n` are given, this returns the complete
bipartite graph on `m + n` nodes.
- If subset sizes `1` and `n` are given, this returns the star graph on
`n + 1` nodes.
See also
--------
complete_bipartite_graph
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (*subset_sizes, backend=None, **backend_kwargs) | [
0.02225247211754322,
-0.006895069498568773,
0.02168417163193226,
-0.0502234548330307,
-0.012653540819883347,
0.06673965603113174,
-0.047559551894664764,
0.007436729967594147,
-0.0006354519282467663,
0.0049814991652965546,
0.004182328004390001,
0.06244189292192459,
0.016960183158516884,
0.07608107477426529,
0.02701197937130928,
-0.007583244703710079,
0.014793542213737965,
0.011836609803140163,
-0.02283853106200695,
0.03800502046942711,
-0.019801679998636246,
0.015130970627069473,
0.03425779566168785,
0.013941093347966671,
-0.020849483087658882,
0.012058601714670658,
0.022216953337192535,
0.03244633972644806,
-0.03736568242311478,
0.027260608971118927,
0.03315671533346176,
-0.01215627882629633,
0.0011676775757223368,
0.018363172188401222,
0.020671889185905457,
0.04237382113933563,
-0.02145330049097538,
0.05313599109649658,
-0.1044960469007492,
-0.01573478803038597,
0.046387434005737305,
-0.005953823681920767,
0.014837941154837608,
-0.03299688175320625,
0.012174038216471672,
0.028450487181544304,
0.0834689661860466,
0.004541954956948757,
-0.06876422464847565,
-0.017555123195052147,
0.04290660098195076,
0.004220066592097282,
-0.04329730570316315,
-0.058321721851825714,
-0.0019435393624007702,
0.010087313130497932,
-0.007561045233160257,
-0.01233387179672718,
0.059493839740753174,
-0.03995854780077934,
0.03365397825837135,
0.032108914107084274,
0.006206894759088755,
-0.023548904806375504,
-0.05622611939907074,
-0.02180848829448223,
-0.03885746747255325,
-0.06141185015439987,
-0.014305160380899906,
-0.018931472674012184,
0.0540594756603241,
0.041485853493213654,
0.030190903693437576,
-0.009634450078010559,
0.012893292121589184,
0.026337122544646263,
0.0364777147769928,
0.01084208581596613,
-0.01046913955360651,
-0.009052830748260021,
-0.02283853106200695,
-0.036211322993040085,
0.022003840655088425,
-0.048056814819574356,
0.046316396445035934,
0.09824474900960922,
-0.019677365198731422,
0.021027076989412308,
-0.04457598179578781,
-0.023992888629436493,
-0.024401353672146797,
-0.027793390676379204,
-0.026106251403689384,
0.0055098398588597775,
-0.0127068180590868,
0.01596565917134285,
0.050330013036727905,
-0.09249071776866913,
0.012351631186902523,
-0.0009695497574284673,
-0.03754327446222305,
-0.03336982801556587,
-0.08865469694137573,
-0.021844007074832916,
-0.05665234103798866,
-0.031434059143066406,
-0.02534259855747223,
0.05682993680238724,
-0.013115284033119678,
0.028539283201098442,
-0.019055787473917007,
0.01742192730307579,
0.06613583862781525,
-0.01362142525613308,
0.029782438650727272,
0.04269348829984665,
-0.018185580149292946,
0.03864435479044914,
0.06521235406398773,
-0.023051641881465912,
-0.058463796973228455,
0.044185273349285126,
-0.040384773164987564,
0.029746919870376587,
0.02686990424990654,
-0.0003812711511272937,
0.04457598179578781,
-0.05313599109649658,
0.030208662152290344,
0.021062595769762993,
-0.0015495037660002708,
0.01896699145436287,
-0.0010544616961851716,
0.06819592416286469,
-0.03530559688806534,
0.01322183944284916,
-0.07885153591632843,
-0.02834393084049225,
-0.0012775636278092861,
-0.014287400990724564,
0.03392036631703377,
-0.03413347899913788,
0.03875091299414635,
0.0495130829513073,
-0.06070147454738617,
0.015477278269827366,
0.01873612031340599,
0.019144585356116295,
0.01331951655447483,
-0.014482754282653332,
0.023690979927778244,
0.002009026939049363,
0.09533222019672394,
0.030723683536052704,
-0.02211039699614048,
-0.018398690968751907,
0.02710077539086342,
-0.02234126813709736,
-0.012147398665547371,
0.029853476211428642,
-0.007463369052857161,
0.011845489963889122,
0.03988751024007797,
-0.016596117988228798,
-0.07615211606025696,
-0.0033232192508876324,
-0.006291251629590988,
-0.004397660028189421,
0.0065665217116475105,
-0.02717181295156479,
-0.04166344553232193,
-0.0009062821045517921,
0.0012575843138620257,
-0.05601300671696663,
-0.004568594042211771,
-0.0020434358157217503,
-0.030865758657455444,
-0.01119727361947298,
-0.017191056162118912,
-0.02591089904308319,
0.029675882309675217,
-0.07064671069383621,
0.029107581824064255,
-0.041770003736019135,
-0.01208524126559496,
0.017697196453809738,
0.00995411816984415,
0.014109807088971138,
0.029125342145562172,
0.03354742005467415,
0.04670710489153862,
0.025093968957662582,
-0.012884411960840225,
0.05601300671696663,
0.022891808301210403,
-0.05842827633023262,
0.06986530125141144,
0.036211322993040085,
-0.0722450539469719,
0.05526711419224739,
0.07743078470230103,
0.07132156938314438,
0.020458776503801346,
-0.010362583212554455,
0.04848304018378258,
-0.0005799539503641427,
-0.051217980682849884,
-0.048127852380275726,
-0.05182179808616638,
0.028716877102851868,
-0.008044987916946411,
0.019677365198731422,
0.037969499826431274,
0.04454046115279198,
-0.06485716253519058,
0.06968770921230316,
0.038999542593955994,
0.03177148476243019,
0.01002515573054552,
-0.061092179268598557,
-0.035181280225515366,
-0.015672631561756134,
0.0032344225328415632,
0.034222278743982315,
-0.008373536169528961,
-0.005767350550740957,
-0.008373536169528961,
-0.016826989129185677,
-0.004586353432387114,
-0.06269052624702454,
0.026550235226750374,
-0.02656799554824829,
0.04422079399228096,
-0.015273044817149639,
0.012609141878783703,
-0.01522864680737257,
0.03345862403512001,
-0.011694535613059998,
-0.04237382113933563,
0.032322026789188385,
-0.05512503907084465,
-0.019499771296977997,
0.007396771106868982,
-0.009394698776304722,
-0.01383453793823719,
0.07970398664474487,
-0.01039810199290514,
0.031434059143066406,
0.0024907495826482773,
-0.011694535613059998,
-0.0044820173643529415,
-0.019055787473917007,
0.01284889318048954,
-0.030919037759304047,
0.0188959538936615,
0.030546089634299278,
-0.05697201192378998,
-0.0074678086675703526,
0.015166489407420158,
0.04269348829984665,
-0.02759803831577301,
-0.008773121051490307,
-0.0580020546913147,
-0.02834393084049225,
0.06176703795790672,
0.01807902380824089,
-0.06869318336248398,
0.05288735777139664,
-0.05952935665845871,
-0.028663598001003265,
0.05704304948449135,
0.08140888065099716,
0.10527745634317398,
0.004477577283978462,
0.012760096229612827,
-0.056119561195373535,
0.0025018490850925446,
0.039851993322372437,
-0.04290660098195076,
-0.03162940964102745,
-0.053917400538921356,
-0.03711705282330513,
-0.01175669301301241,
0.04283556342124939,
0.02532484009861946,
0.032322026789188385,
0.049974825233221054,
-0.004082431551069021,
0.025680027902126312,
-0.028805673122406006,
0.019677365198731422,
-0.014837941154837608,
-0.03683290258049965,
-0.0030990075320005417,
0.030475053936243057,
0.020245663821697235,
-0.026479197666049004,
0.015273044817149639,
0.002346454653888941,
0.052532173693180084,
0.09412457793951035,
-0.05310047045350075,
0.036655306816101074,
0.0224833432585001,
0.045357391238212585,
0.02701197937130928,
0.0004706229083240032,
0.01039810199290514,
0.012760096229612827,
0.014695866033434868,
-0.05448570102453232,
0.014349558390676975,
0.005061415955424309,
0.009323661215603352,
-0.010513538494706154,
-0.05864138901233673,
-0.020441018044948578,
-0.02145330049097538,
0.038040537387132645,
0.038253650069236755,
0.019144585356116295,
0.005256769247353077,
-0.052603207528591156,
0.02129346691071987,
-0.052461136132478714,
0.05334910377860069,
-0.01003403589129448,
0.057149603962898254,
-0.04912237450480461,
0.02100931666791439,
0.019002510234713554,
-0.0195530503988266,
-0.031132148578763008,
0.035394392907619476,
-0.07213850319385529,
0.03551870957016945,
0.013905574567615986,
-0.032552897930145264,
-0.01548615749925375,
-0.051075905561447144,
0.029782438650727272,
0.010531297884881496,
-0.015548314899206161,
0.007050463929772377,
-0.03010210581123829,
0.03864435479044914,
0.04695573449134827,
-0.09348524361848831,
-0.03786294534802437,
-0.0267278291285038,
0.03155837208032608,
0.07870946079492569,
-0.02628384530544281,
-0.029782438650727272,
0.040242698043584824,
0.06641998887062073,
0.005345565732568502,
0.012360511347651482,
-0.06404023617506027,
-0.01058457512408495,
-0.003749443916603923,
0.0035385515075176954,
0.062193259596824646,
-0.009856441989541054,
-0.005758470855653286,
0.02108035422861576,
-0.013568147085607052,
0.08702083677053452,
0.011667896062135696,
-0.006539882626384497,
-0.024152722209692,
-0.0736658051609993,
-0.07679145038127899,
0.05043656751513481,
-0.0057851099409163,
0.05423707142472267,
-0.01544175948947668,
-0.031807005405426025,
0.02717181295156479,
-0.0018902613082900643,
-0.041912078857421875,
-0.019730642437934875,
0.04251589626073837,
0.006917268969118595,
0.02644367888569832,
-0.00003877921699313447,
0.0411306656897068,
0.019304418936371803,
-0.04269348829984665,
-0.027562519535422325,
-0.053633250296115875,
-0.046458471566438675,
0.06240637227892876,
-0.004857183434069157,
-0.029338454827666283,
0.002228799043223262,
0.09561637043952942,
0.049015820026397705,
-0.05288735777139664,
0.017359768971800804,
0.05178627744317055,
-0.04571257904171944,
0.025537952780723572,
0.002623944776132703,
-0.0047195483930408955,
-0.03697497770190239,
0.010593455284833908,
-0.009936358779668808,
-0.02614177018404007,
-0.026603514328598976,
0.01997927390038967,
-0.07870946079492569,
-0.03038625605404377,
-0.0004234496154822409,
0.07153467833995819,
0.006215773988515139,
0.010406982153654099,
0.0009756545769050717,
0.02949828840792179,
0.004621872212737799,
0.023904092609882355,
-0.09384042769670486,
-0.015122090466320515,
0.09682400524616241,
0.05310047045350075,
-0.05072071775794029,
0.027988743036985397,
-0.0163208469748497,
-0.01200532354414463,
0.07267127931118011,
0.03413347899913788,
-0.023850813508033752,
0.035980451852083206,
0.006730795372277498,
0.007356812711805105,
-0.06155392527580261,
0.025378117337822914,
0.006158056203275919,
-0.0017437466885894537,
0.0013275117380544543,
0.031025592237710953,
-0.005301167257130146,
0.01868284121155739,
-0.021062595769762993,
-0.0026461437810212374,
-0.015770306810736656,
0.03814709559082985,
0.03475505858659744,
-0.002339794998988509,
-0.0339558869600296,
-0.006695276591926813,
-0.031434059143066406,
0.05221250280737877,
0.00030412894557230175,
-0.03878642991185188,
-0.007751958444714546,
0.019020268693566322,
-0.04578361660242081,
-0.059706952422857285,
0.04713332653045654,
-0.010930882766842842,
0.026852143928408623,
-0.020831722766160965,
0.02189728431403637,
-0.01672043278813362,
-0.042444858700037,
0.028095299378037453,
-0.005829508416354656,
-0.04116618633270264,
-0.0705401599407196,
0.024472391232848167,
0.013124163262546062,
-0.038999542593955994,
-0.031007833778858185,
0.038182612508535385,
-0.03477281704545021,
-0.026408160105347633,
-0.04656502977013588,
-0.000288034527329728,
-0.03088351897895336,
-0.060736995190382004,
0.015335203148424625,
-0.010176110081374645,
0.039567843079566956,
-0.04716884717345238,
-0.023708738386631012,
0.023175958544015884,
-0.047559551894664764,
0.0018491927767172456,
-0.03542991355061531,
-0.0031189867295324802,
-0.022607658058404922,
-0.015237526968121529,
0.01596565917134285,
-0.030634887516498566,
0.07089534401893616,
-0.01746632531285286,
-0.038395725190639496,
-0.0020012573804706335,
-0.009297022596001625,
0.019304418936371803,
-0.002124462742358446,
-0.022021600976586342,
0.014873459935188293,
0.006979426369071007,
0.05803757160902023,
-0.006655318196862936,
-0.012884411960840225,
0.00828917883336544,
0.042800046503543854,
0.0391061007976532,
0.03857331722974777,
0.024632224813103676,
0.041983116418123245,
-0.022643176838755608,
0.008013908751308918,
-0.021719690412282944,
-0.0076942406594753265,
0.04329730570316315,
-0.057362716645002365,
0.04123722389340401,
0.03821813315153122,
0.00988308060914278,
0.041841041296720505,
-0.025271562859416008,
-0.005936064291745424,
0.03843124583363533,
-0.02665679156780243,
0.016214290633797646,
-0.0005477651138789952,
0.022359028458595276,
0.06169600039720535,
-0.03946128487586975,
0.010779928416013718,
-0.04134377837181091,
-0.0808405801653862,
0.03471953794360161,
0.046742621809244156,
0.008151544257998466,
-0.020316701382398605,
0.002672782866284251,
-0.0022709774784743786,
-0.011099596507847309,
0.0019113505259156227,
0.0011987565085291862,
0.02964036352932453,
0.006140296813100576,
-0.06748554855585098,
0.026337122544646263,
-0.059635914862155914,
0.034222278743982315,
-0.0038981784600764513,
0.007436729967594147,
0.006588720716536045,
0.08368208259344101,
-0.006118097808212042,
0.007996149361133575,
-0.026834385469555855,
0.004186768084764481,
0.03242858126759529,
-0.062193259596824646,
0.006584280636161566,
-0.0017615059623494744,
-0.029604844748973846,
0.01866508275270462,
-0.0000034859672268794384,
0.008679884485900402,
-0.023016123101115227,
0.02466774359345436,
0.007569924928247929,
-0.005603076424449682,
0.06421782821416855,
0.08972026407718658,
-0.009279263205826283,
-0.016054457053542137,
-0.0072591365315020084,
-0.04269348829984665,
-0.004741747863590717,
-0.039709918200969696,
-0.01793694868683815,
-0.020334461703896523,
-0.019641846418380737,
0.002570666605606675,
0.0005610845983028412,
-0.002583986148238182,
0.06393367797136307,
-0.09433769434690475,
-0.004639631602913141,
-0.01786591112613678,
0.015610473230481148,
0.04503772407770157,
-0.05690097436308861,
0.06435990333557129,
0.03354742005467415,
-0.04372353106737137,
0.01072665024548769,
-0.020174626260995865,
-0.045641541481018066,
0.02651471644639969,
0.005931624677032232,
-0.046813659369945526,
0.08865469694137573,
-0.02086724154651165,
0.032908085733652115,
0.062264297157526016,
0.042942121624946594,
0.03155837208032608,
-0.016045577824115753,
-0.016303088515996933,
-0.08453452587127686,
-0.0060692597180604935,
0.05373980849981308,
-0.02093827910721302,
-0.04869615286588669,
-0.050187937915325165,
0.012724577449262142,
-0.028716877102851868,
0.05189283564686775,
-0.06531890481710434,
-0.029995551332831383,
-0.015832465142011642,
0.03542991355061531,
-0.01522864680737257,
-0.007743078749626875,
-0.02900102734565735,
0.0012187357060611248,
0.018469728529453278,
-0.029107581824064255,
0.0012997627491131425,
0.004060232546180487,
0.010673372074961662,
-0.05491192638874054,
-0.022962845861911774,
-0.03463074192404747,
-0.0115702198818326,
-0.007547725923359394,
0.009439096786081791,
-0.027544759213924408,
0.0038826388772577047,
0.09625570476055145,
-0.0430486761033535,
0.008329137228429317,
-0.029089823365211487,
-0.026301603764295578,
-0.0038182612042874098,
-0.031149908900260925,
0.018700601533055305,
-0.03654875233769417,
-0.006531002931296825,
-0.028130818158388138,
-0.0391061007976532,
-0.002901434665545821,
0.01772383600473404,
0.01880715601146221,
0.04276452586054802,
0.037294644862413406,
-0.034808333963155746,
-0.06240637227892876,
0.0054476819932460785,
-0.06173151731491089,
0.05381084606051445,
-0.015610473230481148,
0.029817957431077957,
0.06162496283650398,
0.0011965365847572684,
0.06105666235089302,
-0.003685066243633628,
-0.06148288771510124,
0.006033740937709808,
-0.0004462038050405681,
0.0046485112980008125,
0.008098266087472439,
0.038253650069236755,
-0.016942424699664116,
-0.055089518427848816,
-0.01501553412526846,
-0.014882339164614677,
0.028166336938738823,
-0.04461149871349335,
-0.009856441989541054,
0.009483495727181435,
-0.0091194286942482,
0.03281928971409798,
-0.024436872452497482,
-0.0199082363396883,
-0.01786591112613678,
-0.04098859056830406,
-0.05199939012527466,
0.018718359991908073,
0.011117355898022652,
-0.01749296486377716,
0.028219614177942276,
0.010771049186587334,
0.016303088515996933,
-0.0195530503988266,
0.014873459935188293,
-0.01599229872226715,
0.027189573273062706,
0.004233386367559433,
-0.05079175531864166,
0.03669082745909691,
-0.0014362878864631057,
-0.009341420605778694,
0.03768534958362579,
0.01746632531285286,
0.022820770740509033,
-0.03420451655983925,
0.012111879885196686,
-0.04141481593251228,
0.035696301609277725,
-0.07132156938314438,
-0.023193717002868652,
0.0042555853724479675,
0.02175520919263363,
-0.08716291189193726,
0.0052123707719147205,
0.029693640768527985,
0.005265648942440748,
-0.05192835256457329,
-0.0014917858643457294,
0.03361845761537552,
-0.04727540165185928,
-0.025822101160883904,
0.05111142247915268,
-0.035980451852083206,
0.009070590138435364,
-0.032108914107084274,
-0.037152569741010666,
-0.042196229100227356,
-0.029480529949069023,
-0.021027076989412308,
0.030439535155892372,
0.011792211793363094,
-0.016054457053542137,
0.018931472674012184,
-0.0016316407127305865,
0.020973797887563705,
0.02759803831577301,
-0.016560599207878113,
-0.016640515998005867,
0.002959152450785041,
-0.02145330049097538,
-0.06656206399202347,
-0.020902760326862335,
-0.016658274456858635,
-0.014473874121904373,
0.008329137228429317,
-0.01845197007060051,
0.0011621278245002031,
0.02928517572581768,
0.04134377837181091,
-0.00279265851713717,
0.008964034728705883,
0.02649695798754692,
-0.04471805691719055,
-0.024063926190137863,
0.015281924977898598,
-0.0055142794735729694,
-0.01786591112613678,
-0.04354593902826309,
-0.02283853106200695,
0.02834393084049225,
0.06404023617506027,
-0.010966401547193527,
-0.045144278556108475,
0.003292140318080783,
0.0456770621240139,
-0.003096787491813302
]
|
30,490 | networkx.algorithms.dag | compute_v_structures | Iterate through the graph to compute all v-structures.
V-structures are triples in the directed graph where
two parent nodes point to the same child and the two parent nodes
are not adjacent.
Parameters
----------
G : graph
A networkx DiGraph.
Returns
-------
vstructs : iterator of tuples
The v structures within the graph. Each v structure is a 3-tuple with the
parent, collider, and other parent.
Examples
--------
>>> G = nx.DiGraph()
>>> G.add_edges_from([(1, 2), (0, 5), (3, 1), (2, 4), (3, 1), (4, 5), (1, 5)])
>>> sorted(nx.compute_v_structures(G))
[(0, 5, 1), (0, 5, 4), (1, 5, 4)]
Notes
-----
`Wikipedia: Collider in causal graphs <https://en.wikipedia.org/wiki/Collider_(statistics)>`_
| def transitive_closure_dag(G, topo_order=None):
"""Returns the transitive closure of a directed acyclic graph.
This function is faster than the function `transitive_closure`, but fails
if the graph has a cycle.
The transitive closure of G = (V,E) is a graph G+ = (V,E+) such that
for all v, w in V there is an edge (v, w) in E+ if and only if there
is a non-null path from v to w in G.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
topo_order: list or tuple, optional
A topological order for G (if None, the function will compute one)
Returns
-------
NetworkX DiGraph
The transitive closure of `G`
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` has a cycle
Examples
--------
>>> DG = nx.DiGraph([(1, 2), (2, 3)])
>>> TC = nx.transitive_closure_dag(DG)
>>> TC.edges()
OutEdgeView([(1, 2), (1, 3), (2, 3)])
Notes
-----
This algorithm is probably simple enough to be well-known but I didn't find
a mention in the literature.
"""
if topo_order is None:
topo_order = list(topological_sort(G))
TC = G.copy()
# idea: traverse vertices following a reverse topological order, connecting
# each vertex to its descendants at distance 2 as we go
for v in reversed(topo_order):
TC.add_edges_from((v, u) for u in nx.descendants_at_distance(TC, v, 2))
return TC
| (G, *, backend=None, **backend_kwargs) | [
-0.03266729414463043,
0.021180087700486183,
-0.02476874180138111,
0.007968920283019543,
-0.0362735390663147,
-0.030996110290288925,
-0.01892838440835476,
-0.012648242525756359,
0.09302350878715515,
-0.07761341333389282,
0.012155681848526001,
0.028199071064591408,
0.0005280179320834577,
-0.01179505791515112,
-0.03152385354042053,
0.022429080680012703,
-0.013993986882269382,
-0.017257198691368103,
0.0031994422897696495,
0.02943047136068344,
0.0009411417995579541,
-0.06410319358110428,
0.013510222546756268,
-0.023853987455368042,
-0.015709152445197105,
0.01653594896197319,
-0.047074683010578156,
0.032069187611341476,
-0.06069045141339302,
-0.03133034706115723,
0.031154433265328407,
-0.04542108625173569,
-0.09049034118652344,
0.013501427136361599,
0.05266875773668289,
0.08092060685157776,
-0.000371893955161795,
0.018171953037381172,
-0.01715165004134178,
-0.06040899083018303,
0.012199660763144493,
-0.01841823384165764,
-0.011487207375466824,
-0.0325089730322361,
0.04591364786028862,
0.013475039973855019,
-0.009129955433309078,
0.03806786611676216,
-0.03739939257502556,
-0.04953748360276222,
0.08640912920236588,
-0.03722347691655159,
-0.005787582136690617,
-0.010598840191960335,
0.0153133450075984,
0.03905298560857773,
0.019508901983499527,
0.059459052979946136,
0.06821958720684052,
-0.01778494194149971,
-0.009947956539690495,
-0.05516674369573593,
-0.009059589356184006,
0.035481926053762436,
-0.05097997933626175,
0.021268045529723167,
-0.03683646768331528,
-0.06002197787165642,
-0.021162496879696846,
0.007291649933904409,
-0.013615771196782589,
0.020247742533683777,
0.0055720871314406395,
-0.07606536895036697,
-0.027354681864380836,
-0.07641719281673431,
0.027987973764538765,
-0.045209988951683044,
-0.02853330783545971,
-0.03511250391602516,
-0.034408848732709885,
-0.06839550286531448,
0.023449383676052094,
-0.00835153367370367,
0.06135892868041992,
-0.02795279026031494,
0.03368759900331497,
-0.0014183095190674067,
-0.0676918476819992,
-0.04074176400899887,
0.007828189060091972,
-0.03437366336584091,
-0.031224798411130905,
0.032772842794656754,
0.037469759583473206,
-0.008830900304019451,
-0.000948288303334266,
-0.04851717874407768,
0.01008868869394064,
0.009983140043914318,
0.03894743695855141,
0.007489553652703762,
-0.0854240134358406,
-0.006231766194105148,
0.023203102871775627,
-0.04535071924328804,
-0.01750347763299942,
0.016852594912052155,
-0.01738033816218376,
-0.08753498643636703,
-0.0025023818016052246,
-0.0012940700398758054,
0.09787874668836594,
-0.03891225531697273,
0.03155903518199921,
0.013132006861269474,
0.007766618859022856,
0.000716850976459682,
-0.00036419768002815545,
-0.005690829362720251,
0.014143514446914196,
0.022182799875736237,
0.0010791246313601732,
0.012709812261164188,
-0.007265262771397829,
0.00804368406534195,
0.00934984814375639,
0.0276713278144598,
0.03439125791192055,
-0.010862711817026138,
0.060936734080314636,
-0.013738911598920822,
0.03324781358242035,
0.08169462531805038,
0.051718819886446,
0.003834933042526245,
-0.032350651919841766,
0.015392506495118141,
-0.02033570036292076,
0.022763317450881004,
-0.010097484104335308,
-0.061394110321998596,
-0.02153191715478897,
0.04932638630270958,
0.04978376254439354,
0.00397786358371377,
-0.005827162880450487,
-0.013316716998815536,
0.011926993727684021,
0.019297804683446884,
0.008527448400855064,
0.003876712638884783,
-0.014847171492874622,
0.032579340040683746,
0.00015502452151849866,
-0.007841382175683975,
-0.04362675920128822,
0.0724063515663147,
-0.053724244236946106,
0.01210290752351284,
-0.03127757087349892,
0.047250594943761826,
-0.040038108825683594,
0.024733558297157288,
0.016659090295433998,
-0.001907571335323155,
0.11406286805868149,
0.006236163899302483,
-0.031506262719631195,
0.03141830489039421,
-0.056855518370866776,
-0.030714645981788635,
-0.007291649933904409,
-0.004886021371930838,
-0.006174593698233366,
0.029870256781578064,
0.003823938313871622,
0.030538732185959816,
-0.016069777309894562,
0.021778197959065437,
-0.01654474437236786,
0.0005359890637919307,
-0.04573773220181465,
0.02119768038392067,
0.03243860602378845,
0.03108406625688076,
0.041234325617551804,
-0.040038108825683594,
0.0769801214337349,
-0.020951399579644203,
-0.05495564639568329,
0.012665833346545696,
0.03789195045828819,
0.023273469880223274,
0.07529134303331375,
-0.056011129170656204,
-0.029923031106591225,
0.03715311363339424,
-0.047707974910736084,
0.07152678072452545,
0.06396245956420898,
0.015049473382532597,
0.07198415696620941,
0.033318180590867996,
0.023713255301117897,
0.08155389875173569,
0.03433848172426224,
-0.033036716282367706,
-0.023713255301117897,
0.008641792461276054,
-0.01300886645913124,
-0.025525173172354698,
0.010642818175256252,
-0.03996774181723595,
-0.051718819886446,
0.032245103269815445,
-0.038278963416814804,
0.013475039973855019,
0.0480949841439724,
0.0019152675522491336,
-0.026299195364117622,
0.03715311363339424,
0.02568349614739418,
-0.01687898300588131,
0.07043610513210297,
-0.07754305005073547,
-0.00044555807835422456,
0.01127611007541418,
0.020300516858696938,
-0.05956460162997246,
0.011029830202460289,
-0.007181703578680754,
0.032808028161525726,
-0.01971999928355217,
0.06199222058057785,
-0.04436559975147247,
-0.0351300984621048,
0.0032126358710229397,
0.0188756100833416,
0.017925672233104706,
-0.05073370039463043,
-0.006007475312799215,
-0.024592826142907143,
0.010546065866947174,
-0.01703730598092079,
-0.00518507556989789,
0.026633433997631073,
0.005959098692983389,
0.0325089730322361,
0.026387153193354607,
-0.051226262003183365,
-0.03567543253302574,
-0.04865790903568268,
-0.029641568660736084,
-0.03097851760685444,
-0.012604263611137867,
-0.004096605349332094,
-0.056855518370866776,
-0.005330204963684082,
0.01733635924756527,
0.0003204939712304622,
0.017239606007933617,
-0.057594358921051025,
0.06923989206552505,
0.008874879218637943,
-0.029518429189920425,
0.03414497524499893,
-0.08183535933494568,
-0.06681226938962936,
-0.0055720871314406395,
-0.016659090295433998,
0.0038591211196035147,
0.04408413916826248,
0.0054357536137104034,
0.003689803648740053,
-0.04091767966747284,
0.015498055145144463,
0.016043389216065407,
-0.0029795493464916945,
-0.029905440285801888,
-0.04183243215084076,
0.029236966744065285,
-0.031242389231920242,
-0.023167921230196953,
-0.06269587576389313,
-0.00639008916914463,
-0.011346476152539253,
-0.026897305622696877,
0.02211243472993374,
0.018541373312473297,
0.07648756355047226,
0.0026431132573634386,
0.07296927273273468,
0.02478633262217045,
0.06301252543926239,
0.035376377403736115,
0.02647511102259159,
-0.0254548080265522,
-0.002396833151578903,
0.033036716282367706,
0.07353220134973526,
0.00951696652919054,
-0.016386421397328377,
-0.05185955390334129,
0.001837205607444048,
0.004586966708302498,
0.009886386804282665,
-0.007986512035131454,
-0.02943047136068344,
0.040143657475709915,
-0.05164845660328865,
-0.049924492835998535,
-0.07040092349052429,
0.04506925866007805,
-0.06916952133178711,
-0.03416256979107857,
-0.03268488869071007,
-0.049361567944288254,
0.05442790314555168,
0.011768670752644539,
0.0023418599739670753,
0.015621194615960121,
-0.00858462043106556,
-0.006566003430634737,
-0.07648756355047226,
0.04682840034365654,
0.009719268418848515,
0.05784064158797264,
0.05857948213815689,
0.010238215327262878,
-0.005646850913763046,
0.03859560936689377,
0.005242247600108385,
0.057136982679367065,
-0.003085097996518016,
0.07068239152431488,
0.09661216288805008,
-0.029958214610815048,
0.015295753255486488,
-0.028199071064591408,
0.04563218355178833,
0.04186761751770973,
-0.02876199781894684,
0.009675289504230022,
-0.012349187396466732,
0.010018322616815567,
0.003030124818906188,
-0.00140621536411345,
0.037082746624946594,
-0.02285127528011799,
0.04313420131802559,
0.03817341476678848,
-0.01818954385817051,
0.027319500222802162,
-0.03919371962547302,
0.06575678288936615,
0.04911528900265694,
-0.008654986508190632,
0.014979107305407524,
0.02784724347293377,
0.0034369267523288727,
-0.0221652090549469,
0.019420944154262543,
-0.0362735390663147,
0.05516674369573593,
0.0032676090486347675,
-0.009041997604072094,
0.03743457421660423,
-0.02091621607542038,
-0.04450633376836777,
0.01698453165590763,
-0.011346476152539253,
0.0407065823674202,
0.00928827840834856,
-0.051296625286340714,
0.030468367040157318,
0.04777833819389343,
-0.05404089018702507,
0.05302058532834053,
0.036062441766262054,
-0.02000146172940731,
0.017635414376854897,
-0.008114049211144447,
0.03127757087349892,
0.020388474687933922,
0.015295753255486488,
0.043556395918130875,
0.008606609888374805,
0.02351974882185459,
-0.027829650789499283,
-0.0056028724648058414,
-0.027020445093512535,
0.04542108625173569,
-0.004026239737868309,
0.000395807292079553,
-0.034232933074235916,
0.06614379584789276,
0.04461188241839409,
0.025753861293196678,
0.002953162183985114,
-0.014512934722006321,
0.007625887170433998,
0.022006886079907417,
0.008967234753072262,
0.023678071796894073,
-0.03342372924089432,
0.012173273600637913,
0.036801282316446304,
0.061745937913656235,
0.04886900633573532,
-0.003621636889874935,
0.006319723092019558,
0.032069187611341476,
-0.01716044545173645,
-0.020212559029459953,
-0.01977277360856533,
-0.07113976776599884,
0.0029311729595065117,
0.05872021242976189,
0.0023330640979111195,
0.04897455498576164,
0.02897309511899948,
0.028427759185433388,
-0.03898262232542038,
0.0046485369093716145,
-0.03407461196184158,
0.03143589571118355,
0.0392289012670517,
-0.010299785993993282,
0.09196802228689194,
0.010704388841986656,
-0.032069187611341476,
0.013246350921690464,
-0.03330058604478836,
0.00008575824904255569,
0.020986583083868027,
0.014187492430210114,
0.008193210698664188,
0.04007329046726227,
0.06614379584789276,
-0.007696253247559071,
0.04024920612573624,
-0.025243710726499557,
-0.06090154871344566,
-0.011979768052697182,
-0.029465654864907265,
0.008998019620776176,
0.03289598599076271,
0.04911528900265694,
-0.02227075770497322,
0.04626547545194626,
0.0464765727519989,
-0.006715530529618263,
-0.011610347777605057,
-0.08514254540205002,
0.05003004148602486,
0.024680783972144127,
-0.005317011382430792,
-0.11863664537668228,
0.0101414630189538,
0.008593415841460228,
-0.03215714544057846,
0.05959978327155113,
-0.04528035596013069,
-0.016298465430736542,
-0.02221798337996006,
0.0026189249474555254,
0.000970827357377857,
-0.040882498025894165,
-0.032596930861473083,
0.05136699229478836,
-0.032755251973867416,
-0.05921277403831482,
-0.04397859051823616,
0.04489334300160408,
0.015216591767966747,
-0.05312613397836685,
0.033318180590867996,
0.057312898337841034,
-0.03335336223244667,
0.020705120638012886,
-0.02960638701915741,
0.003511690301820636,
0.01113537885248661,
0.0026299196761101484,
0.0008718755561858416,
0.015295753255486488,
-0.02045883983373642,
0.011205744929611683,
-0.0004617751983460039,
0.0015909255016595125,
-0.022974414750933647,
-0.005928313825279474,
-0.011513594537973404,
0.006222970318049192,
0.039017803966999054,
-0.015841087326407433,
-0.035992078483104706,
0.009481783956289291,
0.006165798287838697,
-0.0015722345560789108,
0.04211389645934105,
-0.01813676953315735,
0.021056948229670525,
-0.0009680786752142012,
-0.03620317578315735,
0.009569740854203701,
0.026334378868341446,
0.0127274040132761,
0.013993986882269382,
0.04109359532594681,
0.022816091775894165,
0.008830900304019451,
0.0339866541326046,
0.010150258429348469,
0.014811988919973373,
-0.023343835026025772,
0.004881623201072216,
0.02432895451784134,
-0.029483245685696602,
0.004186761565506458,
0.013167189434170723,
0.020705120638012886,
0.08056877553462982,
-0.011293701827526093,
-0.013017662800848484,
0.021391185000538826,
-0.03416256979107857,
-0.006966208573430777,
-0.0029839472845196724,
0.000460400857264176,
0.032368242740631104,
-0.013906029984354973,
0.05724253132939339,
-0.0036370293237268925,
-0.05280948802828789,
-0.008030490018427372,
-0.024416912347078323,
-0.11610347777605057,
0.0005799676291644573,
0.014064352959394455,
0.048270899802446365,
0.015929045155644417,
0.013228759169578552,
0.03915853425860405,
-0.010801141150295734,
0.04626547545194626,
-0.04091767966747284,
-0.02812870591878891,
-0.010809937492012978,
-0.07895036041736603,
0.031172024086117744,
-0.012692220509052277,
0.025331666693091393,
0.03630872443318367,
-0.03425052389502525,
-0.027002854272723198,
0.049748580902814865,
-0.02142636850476265,
0.01048449520021677,
-0.057312898337841034,
-0.009736859239637852,
-0.06589751690626144,
-0.05302058532834053,
0.01463607419282198,
0.006895842961966991,
0.05115589499473572,
-0.009077181108295918,
0.0321747362613678,
-0.02290404960513115,
0.013914825394749641,
-0.08148352801799774,
0.012041337788105011,
-0.0020878834184259176,
-0.02091621607542038,
0.05073370039463043,
-0.012472327798604965,
0.01179505791515112,
0.03722347691655159,
-0.06178112328052521,
-0.01989591307938099,
-0.035763390362262726,
0.018330276012420654,
0.03887707367539406,
0.007581908721476793,
-0.011381658725440502,
-0.0007525836117565632,
0.03425052389502525,
0.0020944802090525627,
-0.03936963155865669,
0.018224727362394333,
-0.04042511805891991,
0.01959685981273651,
0.006843068636953831,
-0.0017976248636841774,
-0.015665173530578613,
-0.010862711817026138,
0.06741037964820862,
-0.01716044545173645,
-0.023431792855262756,
-0.03863079100847244,
0.005400570575147867,
0.02825184538960457,
0.016799820587038994,
-0.06938061863183975,
0.0019592461176216602,
0.008034888654947281,
-0.03739939257502556,
0.06948617100715637,
-0.03982701152563095,
-0.0021736416965723038,
0.01744190789759159,
-0.036625370383262634,
-0.04436559975147247,
-0.04911528900265694,
-0.010616431012749672,
-0.07508024573326111,
0.028937911614775658,
-0.07916145771741867,
0.004325294401496649,
0.018453415483236313,
-0.02568349614739418,
0.014855967834591866,
-0.03388110548257828,
-0.039123352617025375,
0.08085023611783981,
0.033670008182525635,
-0.04689876735210419,
0.0020988781470805407,
0.0531965009868145,
-0.03233305737376213,
-0.020881034433841705,
-0.006319723092019558,
0.03595689311623573,
0.015761926770210266,
-0.07958365231752396,
0.00137433095369488,
0.024293772876262665,
-0.018365459516644478,
-0.02784724347293377,
-0.10695593059062958,
0.04496371001005173,
-0.039475180208683014,
0.00080975575838238,
-0.0509096160531044,
-0.02074030227959156,
0.009780838154256344,
-0.04644139111042023,
-0.005163086578249931,
-0.0428527370095253,
-0.013061640784144402,
0.0188756100833416,
0.037082746624946594,
0.004243934061378241,
0.013431061059236526,
0.06684745848178864,
0.04176206886768341,
-0.04471743106842041,
0.03456716984510422,
0.011496002785861492,
0.0783170685172081,
0.013686137273907661,
0.01852378249168396,
-0.01994868740439415,
-0.001963644055649638,
0.02573627047240734,
0.05013559013605118,
-0.06646044552326202,
-0.0048728277906775475,
-0.04257127270102501,
-0.024469686672091484,
0.02313273772597313,
0.012665833346545696,
-0.027759285643696785,
-0.0224994458258152,
-0.0050971186719834805,
0.03697719797492027,
0.02920178323984146,
0.012322800233960152,
-0.029923031106591225,
0.02744263969361782,
0.06445501744747162,
0.007084950804710388,
-0.04573773220181465,
-0.014987902715802193,
-0.01457450445741415,
-0.014011578634381294,
-0.039123352617025375,
0.06389209628105164,
-0.05330204963684082,
0.03849006071686745,
-0.002238510176539421,
0.007274058647453785,
-0.016447992995381355,
0.05784064158797264,
0.00563805503770709,
-0.001755845150910318,
0.014618483372032642,
0.015981819480657578,
-0.019051523879170418,
-0.005180677864700556,
0.0022604994010180235,
0.03403942659497261,
0.0369420163333416,
-0.025665905326604843,
-0.005558893550187349,
-0.0343208909034729,
-0.03143589571118355,
0.002088983077555895,
0.01709887571632862,
-0.03461994603276253,
-0.032368242740631104,
-0.006095432210713625,
0.015955431386828423,
0.017705779522657394,
-0.04904492199420929,
-0.04130469262599945,
0.006508831400424242,
-0.04426005110144615,
-0.0021901337895542383,
0.01903393305838108,
0.03249138221144676,
-0.05745362862944603,
0.021461552008986473,
0.024223407730460167,
0.05192991718649864,
0.022816091775894165,
-0.03595689311623573,
-0.03143589571118355,
-0.029289741069078445,
-0.011970971710979939,
0.04858754575252533,
0.021795788779854774,
0.008052479475736618,
-0.019983870908617973,
-0.0037755619268864393,
-0.04777833819389343,
0.03358205035328865,
-0.041339874267578125,
0.032755251973867416,
-0.0351300984621048,
0.015445280820131302,
-0.05506119504570961,
0.02176060527563095,
-0.010194237343966961,
-0.01796085573732853,
-0.025595538318157196,
-0.0008449386223219335,
0.015295753255486488,
-0.0188052449375391,
0.004564977716654539,
0.006412078160792589,
0.004802461713552475,
-0.08401669561862946,
-0.01862933114171028,
-0.01022941991686821,
-0.057136982679367065,
-0.020423656329512596,
-0.06227368116378784,
-0.06104228273034096,
-0.04422486945986748,
-0.013000071048736572,
0.015436484478414059,
-0.026228830218315125,
0.05618704482913017,
0.014363407157361507,
0.03419775143265724,
0.04960784688591957
]
|
30,493 | networkx.generators.degree_seq | configuration_model | Returns a random graph with the given degree sequence.
The configuration model generates a random pseudograph (graph with
parallel edges and self loops) by randomly assigning edges to
match the given degree sequence.
Parameters
----------
deg_sequence : list of nonnegative integers
Each list entry corresponds to the degree of a node.
create_using : NetworkX graph constructor, optional (default MultiGraph)
Graph type to create. If graph instance, then cleared before populated.
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
Returns
-------
G : MultiGraph
A graph with the specified degree sequence.
Nodes are labeled starting at 0 with an index
corresponding to the position in deg_sequence.
Raises
------
NetworkXError
If the degree sequence does not have an even sum.
See Also
--------
is_graphical
Notes
-----
As described by Newman [1]_.
A non-graphical degree sequence (not realizable by some simple
graph) is allowed since this function returns graphs with self
loops and parallel edges. An exception is raised if the degree
sequence does not have an even sum.
This configuration model construction process can lead to
duplicate edges and loops. You can remove the self-loops and
parallel edges (see below) which will likely result in a graph
that doesn't have the exact degree sequence specified.
The density of self-loops and parallel edges tends to decrease as
the number of nodes increases. However, typically the number of
self-loops will approach a Poisson distribution with a nonzero mean,
and similarly for the number of parallel edges. Consider a node
with *k* stubs. The probability of being joined to another stub of
the same node is basically (*k* - *1*) / *N*, where *k* is the
degree and *N* is the number of nodes. So the probability of a
self-loop scales like *c* / *N* for some constant *c*. As *N* grows,
this means we expect *c* self-loops. Similarly for parallel edges.
References
----------
.. [1] M.E.J. Newman, "The structure and function of complex networks",
SIAM REVIEW 45-2, pp 167-256, 2003.
Examples
--------
You can create a degree sequence following a particular distribution
by using the one of the distribution functions in
:mod:`~networkx.utils.random_sequence` (or one of your own). For
example, to create an undirected multigraph on one hundred nodes
with degree sequence chosen from the power law distribution:
>>> sequence = nx.random_powerlaw_tree_sequence(100, tries=5000)
>>> G = nx.configuration_model(sequence)
>>> len(G)
100
>>> actual_degrees = [d for v, d in G.degree()]
>>> actual_degrees == sequence
True
The returned graph is a multigraph, which may have parallel
edges. To remove any parallel edges from the returned graph:
>>> G = nx.Graph(G)
Similarly, to remove self-loops:
>>> G.remove_edges_from(nx.selfloop_edges(G))
| def generate(self):
# remaining_degree is mapping from int->remaining degree
self.remaining_degree = dict(enumerate(self.degree))
# add all nodes to make sure we get isolated nodes
self.graph = nx.Graph()
self.graph.add_nodes_from(self.remaining_degree)
# remove zero degree nodes
for n, d in list(self.remaining_degree.items()):
if d == 0:
del self.remaining_degree[n]
if len(self.remaining_degree) > 0:
# build graph in three phases according to how many unmatched edges
self.phase1()
self.phase2()
self.phase3()
return self.graph
| (deg_sequence, create_using=None, seed=None, *, backend=None, **backend_kwargs) | [
-0.022538358345627785,
0.003679639892652631,
-0.03035815805196762,
-0.021201949566602707,
-0.01601884886622429,
0.048544157296419144,
-0.0715881884098053,
-0.039225414395332336,
0.034222908318042755,
-0.03135143592953682,
0.03236277028918266,
0.08040126413106918,
-0.03398813307285309,
0.04030898958444595,
-0.013716252520680428,
0.005083772353827953,
0.023928947746753693,
0.013634984381496906,
-0.014411547221243382,
0.0017348485998809338,
-0.019197335466742516,
-0.015413853339850903,
-0.006952939089387655,
0.03350052610039711,
-0.03398813307285309,
-0.0049302661791443825,
-0.0168315302580595,
0.013418269343674183,
-0.02894951030611992,
-0.018113762140274048,
-0.05851304903626442,
0.0013397953007370234,
-0.027288028970360756,
0.004386221058666706,
0.013490508310496807,
0.04644924774765968,
-0.018691668286919594,
0.02680042013525963,
-0.05183100327849388,
0.02950935810804367,
0.09701607376337051,
-0.02925652451813221,
-0.03579409420490265,
0.015612509101629257,
-0.02396506629884243,
-0.030881885439157486,
0.039767201989889145,
0.037563931196928024,
-0.000534732942469418,
-0.07845082879066467,
0.021292246878147125,
-0.018059583380818367,
0.009445161558687687,
0.015377734787762165,
0.010772541165351868,
0.01517907902598381,
-0.010826719924807549,
0.016939887776970863,
0.08336303383111954,
0.02147284336388111,
-0.020894937217235565,
-0.012750064954161644,
0.00041254860116168857,
-0.0006557885790243745,
-0.029419060796499252,
0.02096717618405819,
-0.04886922985315323,
-0.024380436167120934,
0.009553519077599049,
0.05670708790421486,
0.051000259816646576,
-0.012876482680439949,
0.05128921568393707,
-0.0020903965923935175,
0.05356472358107567,
-0.01957658678293228,
0.009526429697871208,
-0.027685340493917465,
0.0205156859010458,
-0.029978906735777855,
-0.03189322352409363,
-0.003460667561739683,
-0.021039413288235664,
-0.001567797502502799,
0.05316741019487381,
0.038466911762952805,
0.0027992352843284607,
-0.0421510674059391,
-0.03803348168730736,
-0.05071130767464638,
-0.01912509836256504,
-0.02721579000353813,
-0.004862542729824781,
0.012623648159205914,
0.03825019672513008,
-0.01706630550324917,
-0.03825019672513008,
-0.05197547748684883,
0.03969496116042137,
-0.023007908836007118,
-0.01731913909316063,
0.025391772389411926,
-0.1437542736530304,
0.03411455079913139,
0.022375822067260742,
-0.06570076197385788,
-0.0041243573650717735,
-0.04496835917234421,
0.035613495856523514,
-0.010221723467111588,
-0.049844447523355484,
0.04691879451274872,
0.07205773144960403,
0.040164511650800705,
-0.010718362405896187,
0.02076851949095726,
-0.0010158515069633722,
-0.02082269825041294,
0.025879381224513054,
0.021057473495602608,
-0.033663060516119,
0.023531636223196983,
-0.018691668286919594,
0.056996043771505356,
0.003061099210754037,
0.022646715864539146,
0.015513181686401367,
-0.030592933297157288,
0.06898760795593262,
-0.0523366704583168,
0.05500948801636696,
0.005467538721859455,
0.02596968039870262,
-0.007864948362112045,
-0.06613419204950333,
-0.012704916298389435,
-0.016939887776970863,
-0.042006589472293854,
0.022556418552994728,
0.051505930721759796,
-0.012732005678117275,
-0.03955048695206642,
0.009941800497472286,
0.048002369701862335,
0.010194634087383747,
0.044354334473609924,
-0.007214803248643875,
0.0089846421033144,
-0.015793105587363243,
-0.0346563383936882,
0.028570258989930153,
-0.010194634087383747,
0.009273595176637173,
-0.0027586012147367,
-0.006907790433615446,
0.023838648572564125,
-0.0021682786755263805,
0.033030975610017776,
-0.0509280227124691,
-0.002249546814709902,
-0.03749169409275055,
0.002774403430521488,
0.008880799636244774,
0.017400408163666725,
0.0016976007027551532,
-0.02979831025004387,
0.09658264368772507,
-0.05670708790421486,
-0.025572368875145912,
-0.008424795232713223,
-0.03843079134821892,
-0.04258449375629425,
-0.04464328661561012,
-0.02501252107322216,
-0.033825598657131195,
0.007210288196802139,
0.020280910655856133,
0.006533054169267416,
-0.004474261775612831,
0.0512169748544693,
0.0038534633349627256,
-0.03398813307285309,
-0.03720273822546005,
-0.029834430664777756,
0.03915317356586456,
-0.014203861355781555,
0.06284734606742859,
0.005584925878793001,
0.05497336760163307,
-0.05056682974100113,
-0.039911676198244095,
0.007449577562510967,
0.05273398011922836,
0.0857468992471695,
0.08011230826377869,
-0.017355259507894516,
0.028985630720853806,
0.06566464155912399,
-0.06765119731426239,
0.05107250064611435,
0.03239889070391655,
-0.010447468608617783,
0.024181781336665154,
-0.03810571879148483,
-0.02506669983267784,
0.020678222179412842,
-0.02936488203704357,
-0.009336804039776325,
0.011829026974737644,
0.03373530134558678,
-0.01522422768175602,
-0.002557688392698765,
0.0710102766752243,
0.009779264219105244,
-0.05381755530834198,
0.001190803712233901,
0.020298970863223076,
0.013960056938230991,
0.013761402107775211,
-0.04117584973573685,
-0.04652148485183716,
0.0033387653529644012,
-0.006623351946473122,
-0.07700605690479279,
-0.012804243713617325,
-0.03256142884492874,
-0.03418678790330887,
-0.04402926191687584,
-0.10561244189739227,
0.001005128608085215,
0.06913208216428757,
-0.03413261100649834,
-0.03602886572480202,
-0.01237984374165535,
0.024398496374487877,
0.029924727976322174,
-0.01777965947985649,
-0.005408844910562038,
-0.013409240171313286,
0.03201964125037193,
-0.043306879699230194,
-0.056743208318948746,
0.009372923523187637,
0.03369918093085289,
0.04688267782330513,
0.06472554057836533,
0.021581200882792473,
-0.036263640969991684,
0.007147079799324274,
0.0370582640171051,
-0.048399679362773895,
-0.05168652534484863,
-0.026547586545348167,
-0.022104928269982338,
0.0064698453061282635,
-0.05266174301505089,
-0.022231345996260643,
-0.03900869935750961,
0.03545096144080162,
0.013273793272674084,
0.02122000977396965,
0.05157816782593727,
-0.08661375939846039,
0.026276692748069763,
0.0346563383936882,
-0.0026502436958253384,
-0.003957306034862995,
0.014700500294566154,
-0.05323965102434158,
-0.0079597607254982,
0.010700302198529243,
0.05277010053396225,
0.01647033914923668,
-0.00973411463201046,
0.03620946407318115,
-0.018041523173451424,
0.012018651701509953,
0.04847192019224167,
-0.04283732920885086,
0.021942391991615295,
-0.046160291880369186,
0.011648430489003658,
-0.0011625855695456266,
-0.0006811848725192249,
-0.06577300280332565,
0.048255205154418945,
0.009842472150921822,
-0.03839467093348503,
0.029437119141221046,
-0.06129422411322594,
0.0012415962992236018,
0.008199050091207027,
-0.014574083499610424,
0.04012839123606682,
0.09441550076007843,
-0.014158712700009346,
-0.003826373955234885,
-0.004871572367846966,
0.0011050207540392876,
0.06403928250074387,
0.06245003640651703,
-0.020858818665146828,
0.0017822550144046545,
-0.035270363092422485,
-0.002948226872831583,
-0.005919028073549271,
0.025897441431879997,
0.0011580707505345345,
0.04467940703034401,
0.011386566795408726,
-0.06302794069051743,
-0.014041325077414513,
0.09289849549531937,
0.020280910655856133,
0.021129712462425232,
-0.043559711426496506,
-0.013535656966269016,
-0.04417373985052109,
0.06729000806808472,
0.0549011304974556,
0.0018296614289283752,
0.05298681557178497,
-0.0645088255405426,
0.013978117145597935,
-0.08690270781517029,
0.04746058210730553,
0.037816766649484634,
0.0370582640171051,
-0.0017337199533358216,
-0.0475328229367733,
-0.05616530030965805,
-0.0014763708459213376,
-0.01608205772936344,
0.03120695799589157,
-0.07014341652393341,
0.020533746108412743,
0.09102029353380203,
-0.048544157296419144,
0.003751878160983324,
-0.016036909073591232,
0.0987497940659523,
0.0072418926283717155,
-0.050891902297735214,
0.029491297900676727,
0.006812977604568005,
-0.00916072353720665,
0.03035815805196762,
-0.04204270988702774,
-0.02215910702943802,
0.010926047340035439,
-0.020407328382134438,
0.09159820526838303,
-0.006108653731644154,
0.06512285768985748,
0.047352224588394165,
0.04449881240725517,
0.01165746059268713,
0.009725085459649563,
-0.050855785608291626,
0.03015950322151184,
-0.010790600441396236,
0.016416160389780998,
-0.02950935810804367,
0.04796625301241875,
-0.011269179172813892,
-0.047894012182950974,
0.042006589472293854,
0.058946479111909866,
0.03389783576130867,
-0.021906273439526558,
0.0018274040194228292,
-0.0427289716899395,
-0.04334299638867378,
0.02291760966181755,
-0.01107955351471901,
0.025951620191335678,
0.007923642173409462,
0.004397508222609758,
0.06779567152261734,
-0.03590245172381401,
-0.026132216677069664,
-0.00486705731600523,
-0.004189823288470507,
0.024795806035399437,
0.016795411705970764,
-0.032976798713207245,
0.06645926088094711,
0.00626667495816946,
0.060138408094644547,
-0.016009820625185966,
0.0009114445419982076,
-0.0359385684132576,
0.02591550163924694,
-0.015540271066129208,
0.023152384907007217,
0.030791588127613068,
0.0693126767873764,
0.022700894623994827,
-0.04048958420753479,
-0.008546696975827217,
-0.017942195758223534,
-0.06566464155912399,
0.008722778409719467,
0.05547903850674629,
-0.007616628892719746,
-0.08220721781253815,
0.07801739871501923,
0.03918929398059845,
0.059741098433732986,
-0.037311095744371414,
-0.028588319197297096,
0.01170260924845934,
-0.008795016445219517,
0.002263091504573822,
0.03411455079913139,
-0.05316741019487381,
0.013761402107775211,
-0.018980620428919792,
0.06089691072702408,
0.01642519049346447,
0.060030050575733185,
0.03660677373409271,
0.0653756856918335,
0.010366200469434261,
0.012686857022345066,
0.027035195380449295,
-0.021201949566602707,
0.013589835725724697,
-0.05081966519355774,
0.07245504856109619,
-0.010944106616079807,
-0.014890125952661037,
0.009869561530649662,
-0.050494592636823654,
0.012388873845338821,
-0.02410954236984253,
0.016054969280958176,
-0.01817696914076805,
-0.021292246878147125,
0.0055262320674955845,
0.03573991358280182,
0.0027924629393965006,
0.02405536361038685,
-0.019793301820755005,
0.03666095435619354,
-0.011097613722085953,
-0.020389268174767494,
-0.0152784064412117,
-0.02764922007918358,
0.0261683352291584,
0.01667802408337593,
0.0072238328866660595,
0.03140561282634735,
-0.020642103627324104,
-0.037672288715839386,
0.08213498443365097,
0.01437542773783207,
-0.04030898958444595,
-0.05511784553527832,
0.0052372789941728115,
0.05591246858239174,
0.022448061034083366,
-0.035324543714523315,
0.06432823091745377,
-0.03330187126994133,
-0.014483785256743431,
-0.0008335626334883273,
0.006790402811020613,
-0.0424400195479393,
0.003528391011059284,
0.004668402019888163,
0.0009594153380021453,
-0.019287634640932083,
-0.08964776992797852,
-0.008605390787124634,
-0.04150092229247093,
-0.025373714044690132,
-0.01917927712202072,
0.00823516957461834,
-0.054539937525987625,
-0.04417373985052109,
-0.007765620481222868,
0.0034674399066716433,
0.03454798087477684,
-0.03879198431968689,
0.04020063206553459,
-0.017535854130983353,
-0.026674004271626472,
-0.03555931895971298,
-0.04449881240725517,
-0.06078855320811272,
-0.08162931352853775,
-0.03265172615647316,
0.01385169941931963,
0.014185802079737186,
0.044209856539964676,
-0.009752174839377403,
-0.03555931895971298,
-0.0022314870730042458,
-0.02391088753938675,
-0.0016592241590842605,
0.0017732252599671483,
0.006894245743751526,
0.02246612124145031,
0.017246901988983154,
0.006912305019795895,
-0.03064711205661297,
-0.0376361683011055,
0.01100731547921896,
0.03983943909406662,
0.03485499322414398,
0.0072418926283717155,
-0.0013894591247662902,
0.0478217750787735,
0.0035554803907871246,
0.010032097809016705,
0.007318645715713501,
0.00040492971311323345,
-0.02481386624276638,
-0.009454191662371159,
0.01088089868426323,
0.027739519253373146,
0.006691075395792723,
0.03180292621254921,
-0.005020563956350088,
0.0376361683011055,
-0.04377642646431923,
-0.0701795369386673,
0.014104533940553665,
-0.010826719924807549,
0.03915317356586456,
0.004219170194119215,
0.005413359962403774,
0.09232058376073837,
-0.016389071941375732,
-0.06328077614307404,
0.06320853531360626,
-0.04482388496398926,
-0.06588135659694672,
-0.0506390705704689,
-0.0020881392993032932,
0.007557935081422329,
-0.009454191662371159,
-0.020190613344311714,
0.0010141584789380431,
0.009336804039776325,
0.08365198969841003,
-0.016063999384641647,
0.03503559157252312,
-0.030015025287866592,
-0.030033085495233536,
0.0458352193236351,
-0.017581002786755562,
-0.0509280227124691,
0.12446664273738861,
-0.01365304458886385,
-0.021797915920615196,
0.003627718659117818,
0.028732795268297195,
0.019432110711932182,
0.004704521037638187,
-0.03864750638604164,
-0.06396704167127609,
-0.02680042013525963,
-0.003812829265370965,
-0.006474360357969999,
-0.014086474664509296,
-0.0062124961987137794,
0.0037247887812554836,
0.04778565466403961,
0.008754382841289043,
-0.03425902873277664,
0.011187911033630371,
-0.01957658678293228,
0.006442755926400423,
-0.039767201989889145,
-0.009400012902915478,
0.022556418552994728,
0.0179692842066288,
-0.025590429082512856,
0.003708986798301339,
0.00450586574152112,
-0.014203861355781555,
-0.014483785256743431,
0.004135644529014826,
0.024488793686032295,
-0.04594357684254646,
0.023441338911652565,
0.08162931352853775,
0.002019287087023258,
-0.003896354930475354,
-0.043957024812698364,
0.0020317030139267445,
-0.002449330873787403,
-0.07433324307203293,
0.04688267782330513,
-0.03084576688706875,
-0.005183100234717131,
-0.04431821405887604,
-0.01667802408337593,
-0.05038623511791229,
0.07859530299901962,
0.01786995679140091,
0.09102029353380203,
-0.020750461146235466,
0.04258449375629425,
-0.016461309045553207,
0.010375230573117733,
-0.0173281691968441,
-0.018041523173451424,
0.0005265497020445764,
-0.004912206437438726,
-0.0013465676456689835,
-0.04030898958444595,
-0.0407424196600914,
-0.043306879699230194,
-0.014005206525325775,
0.007354765199124813,
-0.03687766566872597,
-0.0037789675407111645,
-0.021129712462425232,
-0.012948720715939999,
-0.06403928250074387,
0.006952939089387655,
-0.004663886968046427,
0.022448061034083366,
0.05540679767727852,
-0.007205773610621691,
0.0249041635543108,
0.024127602577209473,
0.009553519077599049,
-0.059090953320264816,
-0.07505562156438828,
-0.019757183268666267,
-0.00001061705916072242,
-0.015350645408034325,
0.01568474806845188,
0.027396386489272118,
0.025391772389411926,
-0.02725191041827202,
-0.075272336602211,
0.0404534637928009,
-0.052625622600317,
-0.04746058210730553,
-0.05750171095132828,
-0.024579090997576714,
0.01510684099048376,
0.03393395617604256,
-0.017842868342995644,
-0.02342327870428562,
-0.01872778683900833,
0.009833442978560925,
0.06241391599178314,
-0.027847876772284508,
0.014890125952661037,
-0.00763920322060585,
0.015043632127344608,
0.006943909451365471,
0.040164511650800705,
-0.04048958420753479,
0.006388577166944742,
0.02665594406425953,
0.08776956796646118,
-0.005950632505118847,
0.018185999244451523,
0.04023674875497818,
0.04496835917234421,
-0.03149591013789177,
-0.04222330451011658,
-0.013743341900408268,
-0.02790205553174019,
-0.042403899133205414,
0.06765119731426239,
0.01298484019935131,
-0.05652649328112602,
0.016542578116059303,
-0.011901265010237694,
0.004952840507030487,
0.03620946407318115,
0.030466515570878983,
0.017210781574249268,
0.032326653599739075,
-0.02246612124145031,
-0.07292459160089493,
-0.009959859773516655,
-0.0123076057061553,
-0.04258449375629425,
-0.03839467093348503,
0.0039663356728851795,
-0.0021558627486228943,
-0.02956353686749935,
0.0022935669403523207,
0.057393353432416916,
0.006099624093621969,
0.009598667733371258,
0.021129712462425232,
-0.031730685383081436,
-0.017084365710616112,
0.02495834231376648,
-0.030087264254689217,
0.037166621536016464,
-0.01856525056064129,
-0.014465725980699062,
0.030231740325689316,
-0.006492420099675655,
-0.008686658926308155,
0.011287239380180836,
0.006176377180963755,
-0.03537872061133385,
0.0173281691968441,
-0.0145018445327878,
0.002316141501069069,
-0.0069348798133432865,
0.04818296432495117,
-0.011819996871054173,
-0.005860334727913141,
0.0033071611542254686,
0.07657262682914734,
-0.03030397929251194,
-0.024723568931221962,
-0.0018827114254236221,
0.016515487805008888,
-0.01315640565007925,
0.04594357684254646,
-0.025536250323057175,
0.044354334473609924,
0.0006766699953004718,
-0.046304769814014435,
-0.018493011593818665,
-0.019847480580210686,
-0.026330871507525444,
0.04070629924535751,
0.0037902549374848604,
-0.028985630720853806,
0.0037834825925529003,
-0.008077148348093033,
0.02011837437748909,
0.05836857110261917,
-0.021978512406349182,
0.033121272921562195,
-0.017897047102451324,
0.008307407610118389,
-0.025427892804145813,
0.03723885864019394,
0.0076888673938810825,
-0.010438438504934311,
0.03189322352409363,
0.01731913909316063,
0.0033049036283046007,
0.010438438504934311,
0.02880503423511982,
-0.0036141739692538977,
0.031586211174726486,
0.025536250323057175,
-0.04482388496398926,
-0.023025967180728912,
-0.012768125161528587,
-0.025247296318411827,
-0.02710743248462677,
-0.08610808849334717,
-0.032922618091106415,
-0.03270590305328369,
0.04453492909669876,
0.011874175630509853,
-0.012208277359604836,
0.04034510627388954,
0.06942103803157806,
-0.004695491399616003
]
|
30,495 | networkx.generators.community | connected_caveman_graph | Returns a connected caveman graph of `l` cliques of size `k`.
The connected caveman graph is formed by creating `n` cliques of size
`k`, then a single edge in each clique is rewired to a node in an
adjacent clique.
Parameters
----------
l : int
number of cliques
k : int
size of cliques (k at least 2 or NetworkXError is raised)
Returns
-------
G : NetworkX Graph
connected caveman graph
Raises
------
NetworkXError
If the size of cliques `k` is smaller than 2.
Notes
-----
This returns an undirected graph, it can be converted to a directed
graph using :func:`nx.to_directed`, or a multigraph using
``nx.MultiGraph(nx.caveman_graph(l, k))``. Only the undirected version is
described in [1]_ and it is unclear which of the directed
generalizations is most useful.
Examples
--------
>>> G = nx.connected_caveman_graph(3, 3)
References
----------
.. [1] Watts, D. J. 'Networks, Dynamics, and the Small-World Phenomenon.'
Amer. J. Soc. 105, 493-527, 1999.
| def _generate_communities(degree_seq, community_sizes, mu, max_iters, seed):
"""Returns a list of sets, each of which represents a community.
``degree_seq`` is the degree sequence that must be met by the
graph.
``community_sizes`` is the community size distribution that must be
met by the generated list of sets.
``mu`` is a float in the interval [0, 1] indicating the fraction of
intra-community edges incident to each node.
``max_iters`` is the number of times to try to add a node to a
community. This must be greater than the length of
``degree_seq``, otherwise this function will always fail. If
the number of iterations exceeds this value,
:exc:`~networkx.exception.ExceededMaxIterations` is raised.
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
The communities returned by this are sets of integers in the set {0,
..., *n* - 1}, where *n* is the length of ``degree_seq``.
"""
# This assumes the nodes in the graph will be natural numbers.
result = [set() for _ in community_sizes]
n = len(degree_seq)
free = list(range(n))
for i in range(max_iters):
v = free.pop()
c = seed.choice(range(len(community_sizes)))
# s = int(degree_seq[v] * (1 - mu) + 0.5)
s = round(degree_seq[v] * (1 - mu))
# If the community is large enough, add the node to the chosen
# community. Otherwise, return it to the list of unaffiliated
# nodes.
if s < community_sizes[c]:
result[c].add(v)
else:
free.append(v)
# If the community is too big, remove a node from it.
if len(result[c]) > community_sizes[c]:
free.append(result[c].pop())
if not free:
return result
msg = "Could not assign communities; try increasing min_community"
raise nx.ExceededMaxIterations(msg)
| (l, k, *, backend=None, **backend_kwargs) | [
-0.0020266559440642595,
0.025790462270379066,
-0.038897089660167694,
-0.01563420332968235,
0.005978865083307028,
0.05996328219771385,
-0.034080907702445984,
-0.04183826968073845,
0.053786806762218475,
-0.012159936130046844,
-0.019981633871793747,
0.019871339201927185,
-0.003292741486802697,
0.05128680542111397,
-0.010128684341907501,
0.015183835290372372,
0.010808832012116909,
-0.04128679633140564,
0.020772075280547142,
0.034117672592401505,
-0.011746332980692387,
-0.018538618460297585,
-0.011718759313225746,
0.016847439110279083,
-0.03610296919941902,
0.02696693316102028,
0.02281251735985279,
0.008322617039084435,
-0.05518386885523796,
-0.0011218988802284002,
-0.026139726862311363,
-0.015661777928471565,
-0.022205900400877,
-0.009880522266030312,
0.002688421169295907,
0.053272102028131485,
0.03718752786517143,
0.08338242024183273,
-0.013455892913043499,
-0.02441178448498249,
-0.01904413290321827,
-0.04915444925427437,
0.0064614019356667995,
-0.013933834619820118,
0.011351112276315689,
0.018897073343396187,
0.01271140668541193,
0.05577210336923599,
-0.06632357835769653,
-0.05022062733769417,
0.010670964606106281,
-0.036231644451618195,
0.03457723185420036,
0.0016337329288944602,
-0.026911785826086998,
0.012297803536057472,
0.0008323765941895545,
0.03856620565056801,
0.06525740772485733,
0.005165445152670145,
-0.014549643732607365,
-0.0023288161028176546,
0.017398910596966743,
-0.009770228527486324,
-0.06672799587249756,
0.0011333877919241786,
-0.06830887496471405,
-0.03915444388985634,
0.036893412470817566,
0.06345593184232712,
0.07430152595043182,
0.043713271617889404,
-0.0020312515553086996,
0.012656260281801224,
0.06996329128742218,
0.045330919325351715,
-0.00002805824260576628,
0.002823991235345602,
-0.005202210042625666,
-0.05816181004047394,
0.020422810688614845,
0.016847439110279083,
0.020845605060458183,
-0.010735302232205868,
0.06970594078302383,
-0.004283091519027948,
0.03382355719804764,
0.008345594629645348,
-0.009430154226720333,
-0.04661768302321434,
0.02272060699760914,
0.0018037698464468122,
0.042058855295181274,
-0.03612135350704193,
0.0007341458112932742,
0.0591544583439827,
-0.018115822225809097,
-0.03382355719804764,
0.036231644451618195,
-0.03485297039151192,
0.04621327295899391,
-0.0063832770101726055,
-0.06279416382312775,
0.020036781206727028,
-0.020900752395391464,
-0.055367689579725266,
0.0011052398476749659,
0.0027941197622567415,
-0.002265626797452569,
-0.03329046815633774,
-0.07544123381376266,
0.045404449105262756,
0.05437504127621651,
-0.0049218786880373955,
0.01086397934705019,
-0.0014464625855907798,
-0.005767467897385359,
0.009549640119075775,
0.01377758476883173,
0.007320777978748083,
-0.041102971881628036,
0.0311764944344759,
-0.0217647235840559,
0.025643402710556984,
0.014338246546685696,
0.009315264411270618,
0.028290463611483574,
0.011194861494004726,
0.03220590949058533,
-0.022904429584741592,
0.021507369354367256,
-0.016121337190270424,
0.005409011617302895,
0.020477958023548126,
-0.0035133298952132463,
-0.042058855295181274,
-0.10330890864133835,
-0.03654414787888527,
0.04834562540054321,
0.0060937548987567425,
-0.012628686614334583,
-0.027628697454929352,
-0.017104793339967728,
0.04408091679215431,
0.009485301561653614,
0.041580915451049805,
0.01082721445709467,
-0.020404428243637085,
0.00528033496811986,
0.008249087259173393,
0.044191211462020874,
-0.004641547799110413,
-0.012444863095879555,
-0.045330919325351715,
-0.031562525779008865,
-0.0062270271591842175,
-0.01702207140624523,
-0.029871346428990364,
-0.002095589879900217,
0.01965075172483921,
-0.024154430255293846,
0.025036783888936043,
-0.026213256642222404,
0.05125004053115845,
-0.009071698412299156,
-0.03711399808526039,
0.060698576271533966,
-0.01689339615404606,
-0.06183828413486481,
-0.027242667973041534,
-0.0111489063128829,
-0.029246347025036812,
-0.03797797113656998,
-0.0584559291601181,
0.030386053025722504,
-0.04893386363983154,
0.02011030912399292,
0.00019473821157589555,
-0.03856620565056801,
0.010689347051084042,
-0.03586399927735329,
-0.009136036969721317,
-0.015119497664272785,
-0.02125001698732376,
-0.0037477051373571157,
0.052242688834667206,
0.05448533594608307,
-0.007375924848020077,
0.05511033907532692,
-0.040514737367630005,
-0.04437503591179848,
-0.04279415309429169,
-0.0509926863014698,
0.07713241130113602,
-0.0012925101909786463,
0.014558834955096245,
-0.024632371962070465,
0.02854781597852707,
-0.10632361471652985,
0.028419140726327896,
0.007182910107076168,
0.022518400102853775,
0.005583643913269043,
-0.04937503859400749,
0.03555149957537651,
-0.022481635212898254,
-0.03404414281249046,
-0.030275758355855942,
0.05128680542111397,
0.03242649510502815,
0.014310672879219055,
-0.02433825470507145,
0.07838241755962372,
0.021580899134278297,
0.015119497664272785,
-0.03981620818376541,
0.01792280748486519,
0.00384421250782907,
-0.014586408622562885,
-0.04937503859400749,
-0.0013039992190897465,
-0.029963258653879166,
0.0570221021771431,
-0.03165443614125252,
0.022095605731010437,
-0.03450370207428932,
-0.015836410224437714,
-0.051102980971336365,
-0.04198532551527023,
-0.01136949472129345,
0.0634191706776619,
-0.039411794394254684,
0.024172812700271606,
-0.00006523586489493027,
-0.022518400102853775,
-0.0169669259339571,
0.016525749117136,
-0.006318938918411732,
-0.02391546033322811,
0.044227976351976395,
-0.08639712631702423,
-0.015431997366249561,
0.02389707788825035,
0.017187513411045074,
0.036250028759241104,
0.0550735741853714,
-0.00790441781282425,
-0.0025735313538461924,
-0.020477958023548126,
0.02705884538590908,
-0.02112133987247944,
-0.06658093631267548,
-0.027352962642908096,
-0.06580887734889984,
0.039448559284210205,
-0.07415447384119034,
-0.056433867663145065,
0.007270226255059242,
0.011452214792370796,
-0.02536766789853573,
-0.028805170208215714,
-0.031084584072232246,
-0.04610297828912735,
0.07867652922868729,
0.005248165689408779,
-0.033125028014183044,
0.0018520235316827893,
0.07242652773857117,
-0.0700000524520874,
0.006985299754887819,
0.040036797523498535,
0.050661806017160416,
0.04911768436431885,
-0.010395228862762451,
0.0007324224570766091,
-0.013079054653644562,
-0.018786778673529625,
0.008694860152900219,
0.012270229868590832,
0.05363974720239639,
0.011029420420527458,
0.042169149965047836,
-0.03711399808526039,
-0.0018899372080340981,
-0.0021093767136335373,
0.01879597082734108,
-0.024246342480182648,
-0.020955899730324745,
-0.007881440222263336,
-0.01274817157536745,
-0.002433365909382701,
-0.02018383890390396,
-0.0029756457079201937,
-0.0032284033950418234,
0.042610328644514084,
0.010229787789285183,
0.03490811586380005,
0.01877758838236332,
0.026691198348999023,
0.03398899734020233,
0.04702209681272507,
-0.041029445827007294,
-0.03724267706274986,
-0.004195775371044874,
0.03707723692059517,
-0.015119497664272785,
-0.004379598889499903,
-0.049632392823696136,
0.016498174518346786,
0.03556988015770912,
-0.04025738313794136,
-0.012683833949267864,
0.04676474258303642,
0.029246347025036812,
0.029485316947102547,
0.004106161184608936,
0.016525749117136,
-0.025000018998980522,
0.026691198348999023,
0.07143387943506241,
-0.013593760319054127,
-0.0024954064283519983,
-0.020827222615480423,
0.003382355673238635,
-0.05463239550590515,
-0.010450376197695732,
-0.02599266730248928,
0.041654445230960846,
-0.0021128233056515455,
-0.008818941190838814,
-0.0570221021771431,
-0.03867650032043457,
0.04878680408000946,
0.04669121280312538,
-0.010477949865162373,
0.036305174231529236,
0.07257358729839325,
-0.0700000524520874,
0.04930150881409645,
-0.07786770910024643,
0.020257368683815002,
-0.007279417477548122,
-0.07011035084724426,
-0.005647982470691204,
0.0010552627500146627,
-0.007398902904242277,
0.034191202372312546,
-0.017472440376877785,
-0.04356621205806732,
-0.018933838233351707,
0.022628694772720337,
0.1016177237033844,
0.012205892242491245,
0.07253681868314743,
0.004223349038511515,
0.11029420793056488,
-0.005468754097819328,
-0.028750022873282433,
0.01805148459970951,
0.02867649309337139,
-0.053308866918087006,
-0.006024820730090141,
0.08264712244272232,
0.027665462344884872,
-0.038897089660167694,
-0.004648440983146429,
-0.009053315967321396,
0.005147062707692385,
0.08845595270395279,
-0.07625006139278412,
-0.004733459558337927,
-0.01593751274049282,
-0.04492650553584099,
0.030367670580744743,
-0.039007384330034256,
0.008662690408527851,
-0.1152942106127739,
0.01572611555457115,
-0.02178310602903366,
0.0006054692203179002,
-0.03404414281249046,
-0.022665459662675858,
0.0337500274181366,
0.03959561884403229,
0.00409007677808404,
-0.05338239669799805,
0.05514710396528244,
0.020441193133592606,
0.00204733619466424,
0.025533108040690422,
-0.031029436737298965,
-0.007771146018058062,
0.018970603123307228,
0.04617650806903839,
0.007876844145357609,
0.01377758476883173,
0.07029417157173157,
-0.007835484109818935,
-0.05867651849985123,
0.033602967858314514,
0.0360662043094635,
-0.0021243123337626457,
0.010726111009716988,
0.05305151268839836,
-0.034613996744155884,
-0.022959576919674873,
0.032003700733184814,
0.01377758476883173,
0.014154423028230667,
0.03797797113656998,
-0.07327211648225784,
-0.0066498215310275555,
0.046838272362947464,
-0.04294120892882347,
-0.04286767914891243,
-0.06441181898117065,
-0.03345590829849243,
0.02854781597852707,
0.10705890506505966,
-0.012886039912700653,
0.09595596045255661,
-0.06091916561126709,
0.055955927819013596,
0.014136040583252907,
-0.003952208906412125,
-0.03496326133608818,
0.02384193055331707,
-0.04768386110663414,
-0.04194856435060501,
-0.01719670556485653,
-0.032573554664850235,
0.004329047631472349,
0.07308829575777054,
-0.06569857895374298,
0.04257356375455856,
-0.01302390731871128,
-0.014641555957496166,
0.016847439110279083,
-0.02972428873181343,
-0.004264709074050188,
0.08904419094324112,
0.017362145707011223,
-0.004774820059537888,
-0.02757355198264122,
0.05194856971502304,
0.015183835290372372,
-0.020294133573770523,
-0.009917287155985832,
-0.0153676588088274,
0.03301473334431648,
0.04783092066645622,
-0.009944860823452473,
0.022003693506121635,
0.004308367148041725,
0.0013338705757632852,
0.039522089064121246,
0.0593382827937603,
0.0222978126257658,
-0.04944856837391853,
-0.010468758642673492,
0.09544125199317932,
-0.0321507602930069,
-0.020827222615480423,
0.06628681719303131,
-0.011691185645759106,
0.04944856837391853,
-0.002872244920581579,
-0.004990812856703997,
0.011645229533314705,
-0.0011891094036400318,
0.0339338518679142,
0.02963237650692463,
-0.03014708310365677,
-0.07227946817874908,
-0.028290463611483574,
-0.03674635291099548,
-0.07750006020069122,
0.008795962668955326,
-0.015312512405216694,
-0.006222431547939777,
-0.01570773310959339,
-0.005197614431381226,
0.060698576271533966,
-0.009512875229120255,
-0.03922797366976738,
-0.04893386363983154,
-0.0016957734478637576,
-0.036819882690906525,
-0.011443023569881916,
0.012132362462580204,
-0.01616729237139225,
-0.09139712899923325,
0.014025745913386345,
0.005174636375159025,
0.03704047203063965,
0.009926478378474712,
0.0019312974764034152,
-0.02648899145424366,
0.036231644451618195,
-0.005431989673525095,
0.015110306441783905,
0.04676474258303642,
0.03165443614125252,
-0.03604782372713089,
0.056948576122522354,
0.015909938141703606,
0.02121325209736824,
-0.045735329389572144,
-0.05051474645733833,
0.0017670050729066133,
0.01567096821963787,
0.00048512217472307384,
-0.0010851341066882014,
-0.022683842107653618,
0.02816178649663925,
0.020514722913503647,
0.04933827370405197,
0.032003700733184814,
0.022610312327742577,
-0.0064430199563503265,
0.02071692794561386,
0.04709562659263611,
-0.02321692928671837,
0.09330889582633972,
-0.017389720305800438,
0.000041611649066908285,
-0.018170969560742378,
-0.04551474004983902,
-0.02110295742750168,
0.01742648519575596,
-0.025772079825401306,
0.010974273085594177,
-0.03886032477021217,
0.0572059266269207,
0.023713253438472748,
-0.022702224552631378,
-0.011277582496404648,
0.025845607742667198,
0.05231621861457825,
0.011847435496747494,
-0.02224266529083252,
-0.016525749117136,
0.04485297575592995,
0.010027581825852394,
0.0010437738383188844,
0.03121325932443142,
0.028455905616283417,
0.02058825083076954,
0.004875923041254282,
-0.03722429275512695,
-0.0422794446349144,
0.042058855295181274,
-0.03330884873867035,
-0.012840083800256252,
0.08992654085159302,
-0.041066210716962814,
-0.03955885395407677,
-0.04988974705338478,
0.03852944076061249,
0.07080888003110886,
0.007564343977719545,
-0.028400758281350136,
-0.06746328622102737,
-0.005381437949836254,
0.036838263273239136,
0.011718759313225746,
-0.016369497403502464,
-0.04143385589122772,
0.008221513591706753,
0.0033984400797635317,
0.01782170496881008,
-0.010128684341907501,
-0.03654414787888527,
0.006328130140900612,
-0.009990816935896873,
-0.03121325932443142,
-0.04676474258303642,
-0.01795957237482071,
0.010753684677183628,
-0.01010111067444086,
-0.022867664694786072,
0.022132370620965958,
0.07573535293340683,
-0.03501841053366661,
0.04194856435060501,
0.045882388949394226,
-0.09117653965950012,
-0.040477972477674484,
0.021231634542346,
0.03875003010034561,
0.02806987427175045,
0.0031847450882196426,
-0.02178310602903366,
-0.010422802530229092,
-0.0676838755607605,
-0.0013051481219008565,
0.011626847088336945,
-0.008014712482690811,
-0.028272081166505814,
-0.03551473468542099,
-0.05610298365354538,
0.026213256642222404,
0.003984378185123205,
0.055992692708969116,
0.027830904349684715,
-0.013612142764031887,
-0.04863974452018738,
-0.03272061422467232,
0.012334568426012993,
0.03080884739756584,
-0.043750032782554626,
0.02279413491487503,
-0.014990820549428463,
-0.06871329247951508,
-0.003044579643756151,
-0.03845591098070145,
-0.025220608338713646,
0.006930152419954538,
0.019503692165017128,
-0.051617689430713654,
0.023198546841740608,
-0.00020536550437100232,
0.006631439086049795,
-0.02128678187727928,
-0.016231629997491837,
0.025000018998980522,
-0.023051489144563675,
-0.0021185679361224174,
0.02218751795589924,
0.029981641098856926,
-0.003173256292939186,
-0.011001846753060818,
0.03911767899990082,
-0.020863987505435944,
0.024080900475382805,
-0.028437523171305656,
0.024209577590227127,
0.0025298732798546553,
0.010156258009374142,
-0.005510114599019289,
-0.0201654564589262,
0.045257389545440674,
-0.01772979274392128,
-0.07669124007225037,
-0.10661773383617401,
-0.0010948997223749757,
0.03299634903669357,
0.05136033520102501,
0.0006353405769914389,
0.020477958023548126,
0.007054233457893133,
-0.0006175326416268945,
0.054779455065727234,
-0.05389710143208504,
0.014751849696040154,
-0.02856619842350483,
-0.035735324025154114,
0.02854781597852707,
0.04297797381877899,
-0.048970628529787064,
0.02976105362176895,
0.04433827102184296,
0.060588281601667404,
-0.004659930244088173,
0.008704051375389099,
0.022996341809630394,
0.01858457364141941,
-0.013318025507032871,
-0.027959581464529037,
0.03805150091648102,
-0.045367684215307236,
-0.012775745242834091,
0.06514710932970047,
-0.01668199896812439,
-0.03704047203063965,
0.04191179946064949,
-0.04125003144145012,
0.014494496397674084,
-0.03812503069639206,
0.04073532670736313,
0.02750002220273018,
0.02338237129151821,
-0.034779440611600876,
-0.0003578817122615874,
-0.006842836271971464,
-0.005588239524513483,
-0.034816205501556396,
-0.053308866918087006,
-0.011865817941725254,
0.005831805989146233,
0.009076293557882309,
-0.010680155828595161,
-0.005133276339620352,
-0.02545957826077938,
-0.02808825671672821,
0.045294154435396194,
-0.033621348440647125,
0.000044268475903663784,
0.005450372118502855,
0.0135478051379323,
0.05569857358932495,
0.028308846056461334,
-0.008639712817966938,
0.046323567628860474,
-0.02181987091898918,
-0.024154430255293846,
-0.03955885395407677,
0.05360298231244087,
0.028915464878082275,
0.011636038310825825,
-0.02073531039059162,
-0.008736220188438892,
0.00009823077562032267,
0.006631439086049795,
-0.03762870654463768,
-0.022610312327742577,
0.02444854937493801,
0.09919125586748123,
-0.012545965611934662,
-0.007481623440980911,
0.009825375862419605,
0.020459575578570366,
0.03391546756029129,
-0.002433365909382701,
-0.06099269539117813,
-0.020496340468525887,
0.05415445566177368,
-0.027702227234840393,
0.03830885514616966,
-0.02816178649663925,
-0.028970610350370407,
0.08117653429508209,
-0.02435663715004921,
0.04279415309429169,
-0.009439345449209213,
-0.05680151656270027,
-0.018446706235408783,
0.02586399018764496,
-0.04702209681272507,
0.0032238077837973833,
-0.06665446609258652,
0.009788610972464085,
-0.040514737367630005,
0.008469675667583942,
-0.023584578186273575,
-0.0275367870926857,
0.043750032782554626,
0.009963243268430233,
-0.006121328566223383,
-0.020937517285346985,
0.007136953994631767,
-0.002277115825563669,
0.02380516566336155,
0.007711403071880341,
-0.04647062346339226,
-0.036856647580862045,
0.003556988202035427,
-0.05422798544168472,
-0.05415445566177368,
-0.07573535293340683,
-0.006810666993260384,
0.012573539279401302,
-0.0063832770101726055,
-0.002851564669981599,
-0.008042286150157452,
0.04117650166153908,
0.040000032633543015,
0.023033106699585915
]
|
30,498 | networkx.generators.random_graphs | connected_watts_strogatz_graph | Returns a connected Watts–Strogatz small-world graph.
Attempts to generate a connected graph by repeated generation of
Watts–Strogatz small-world graphs. An exception is raised if the maximum
number of tries is exceeded.
Parameters
----------
n : int
The number of nodes
k : int
Each node is joined with its `k` nearest neighbors in a ring
topology.
p : float
The probability of rewiring each edge
tries : int
Number of attempts to generate a connected graph.
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
Notes
-----
First create a ring over $n$ nodes [1]_. Then each node in the ring is joined
to its $k$ nearest neighbors (or $k - 1$ neighbors if $k$ is odd).
Then shortcuts are created by replacing some edges as follows: for each
edge $(u, v)$ in the underlying "$n$-ring with $k$ nearest neighbors"
with probability $p$ replace it with a new edge $(u, w)$ with uniformly
random choice of existing node $w$.
The entire process is repeated until a connected graph results.
See Also
--------
newman_watts_strogatz_graph
watts_strogatz_graph
References
----------
.. [1] Duncan J. Watts and Steven H. Strogatz,
Collective dynamics of small-world networks,
Nature, 393, pp. 440--442, 1998.
| def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None):
"""Returns a random graph using dual Barabási–Albert preferential attachment
A graph of $n$ nodes is grown by attaching new nodes each with either $m_1$
edges (with probability $p$) or $m_2$ edges (with probability $1-p$) that
are preferentially attached to existing nodes with high degree.
Parameters
----------
n : int
Number of nodes
m1 : int
Number of edges to link each new node to existing nodes with probability $p$
m2 : int
Number of edges to link each new node to existing nodes with probability $1-p$
p : float
The probability of attaching $m_1$ edges (as opposed to $m_2$ edges)
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
initial_graph : Graph or None (default)
Initial network for Barabási–Albert algorithm.
A copy of `initial_graph` is used.
It should be connected for most use cases.
If None, starts from an star graph on max(m1, m2) + 1 nodes.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m1` and `m2` do not satisfy ``1 <= m1,m2 < n``, or
`p` does not satisfy ``0 <= p <= 1``, or
the initial graph number of nodes m0 does not satisfy m1, m2 <= m0 <= n.
References
----------
.. [1] N. Moshiri "The dual-Barabasi-Albert model", arXiv:1810.10538.
"""
if m1 < 1 or m1 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m1 >= 1 and m1 < n, m1 = {m1}, n = {n}"
)
if m2 < 1 or m2 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m2 >= 1 and m2 < n, m2 = {m2}, n = {n}"
)
if p < 0 or p > 1:
raise nx.NetworkXError(
f"Dual Barabási–Albert network must have 0 <= p <= 1, p = {p}"
)
# For simplicity, if p == 0 or 1, just return BA
if p == 1:
return barabasi_albert_graph(n, m1, seed)
elif p == 0:
return barabasi_albert_graph(n, m2, seed)
if initial_graph is None:
# Default initial graph : empty graph on max(m1, m2) nodes
G = star_graph(max(m1, m2))
else:
if len(initial_graph) < max(m1, m2) or len(initial_graph) > n:
raise nx.NetworkXError(
f"Barabási–Albert initial graph must have between "
f"max(m1, m2) = {max(m1, m2)} and n = {n} nodes"
)
G = initial_graph.copy()
# Target nodes for new edges
targets = list(G)
# List of existing nodes, with nodes repeated once for each adjacent edge
repeated_nodes = [n for n, d in G.degree() for _ in range(d)]
# Start adding the remaining nodes.
source = len(G)
while source < n:
# Pick which m to use (m1 or m2)
if seed.random() < p:
m = m1
else:
m = m2
# Now choose m unique nodes from the existing nodes
# Pick uniformly from repeated_nodes (preferential attachment)
targets = _random_subset(repeated_nodes, m, seed)
# Add edges to m nodes from the source.
G.add_edges_from(zip([source] * m, targets))
# Add one node to the list for each new edge just created.
repeated_nodes.extend(targets)
# And the new node "source" has m edges to add to the list.
repeated_nodes.extend([source] * m)
source += 1
return G
| (n, k, p, tries=100, seed=None, *, backend=None, **backend_kwargs) | [
0.003530837595462799,
0.0014564106240868568,
0.015340219251811504,
0.004924967419356108,
-0.024988939985632896,
-0.04081782326102257,
-0.06484860181808472,
-0.036333613097667694,
0.012130367569625378,
-0.030048049986362457,
0.006453240290284157,
0.04192929342389107,
-0.03681269288063049,
0.1072378158569336,
-0.04307909309864044,
0.013107695616781712,
0.034666404128074646,
0.04740999639034271,
-0.00589750474318862,
0.02734602615237236,
-0.04005129262804985,
0.0020085531286895275,
0.00010427528468426317,
0.07101918011903763,
-0.03455142676830292,
0.010750609450042248,
-0.039188943803310394,
0.010750609450042248,
-0.015618087723851204,
0.05929124355316162,
0.039284758269786835,
-0.12348829209804535,
0.02100297436118126,
0.03905479982495308,
-0.00010053245205199346,
0.010175710543990135,
0.02772929146885872,
0.06120757386088371,
-0.10953740775585175,
-0.03677436709403992,
0.07094252854585648,
-0.05542025715112686,
0.08339866995811462,
0.01306936889886856,
0.024701490998268127,
-0.023896632716059685,
0.03094872459769249,
0.01299271546304226,
-0.09650636464357376,
-0.009878680109977722,
0.01611633226275444,
-0.07048261165618896,
0.026253717020154,
-0.0023594810627400875,
-0.020408911630511284,
0.018473418429493904,
-0.0031811073422431946,
0.044612158089876175,
0.017821867018938065,
0.025353042408823967,
0.06300891935825348,
-0.019556144252419472,
-0.014621595852077007,
-0.035222139209508896,
-0.02441404014825821,
0.02199946530163288,
-0.04859812185168266,
-0.026751963421702385,
-0.0014731785049661994,
0.06205075606703758,
0.05036114528775215,
0.06400541216135025,
-0.008115656673908234,
0.05515196919441223,
0.0547303780913353,
0.044343870133161545,
0.04863644763827324,
0.027001086622476578,
-0.05204751715064049,
0.01969986967742443,
0.004191971383988857,
-0.02577463537454605,
0.011823754757642746,
-0.03435979411005974,
0.005490284878760576,
-0.015455199405550957,
0.0060508111491799355,
0.0031379899010062218,
0.00034733477514237165,
-0.10187208652496338,
-0.04855979606509209,
-0.04982457309961319,
0.05565021559596062,
0.01628880202770233,
0.031638603657484055,
-0.03324832022190094,
-0.0062759798020124435,
-0.03232848271727562,
0.007483267690986395,
-0.024548184126615524,
-0.045072074979543686,
0.04365399107336998,
-0.03819245100021362,
0.000650354428216815,
0.00649635773152113,
0.0071862367913126945,
-0.052162494510412216,
0.015148586593568325,
0.02088799513876438,
-0.03535628318786621,
-0.11712607741355896,
0.043615665286779404,
0.07971931993961334,
0.018253041431307793,
-0.02293846756219864,
-0.013289746828377247,
0.015024024993181229,
0.011622539721429348,
0.03198354318737984,
0.03223266452550888,
0.0163367111235857,
0.027116065844893456,
-0.03296087309718132,
-0.00021004769951105118,
0.0007749158539809287,
-0.024069102481007576,
0.048214856535196304,
-0.008609111420810223,
-0.012887317687273026,
-0.03874818608164787,
0.01053981389850378,
0.01483239233493805,
-0.04706505686044693,
0.07021432369947433,
-0.011986642144620419,
-0.03445560857653618,
-0.047946568578481674,
0.005748989060521126,
0.06914117932319641,
0.004038664977997541,
-0.0008569587371312082,
-0.06680325418710709,
0.08907100558280945,
0.012877736240625381,
-0.03951472043991089,
-0.02146289311349392,
0.017218222841620445,
-0.05706829950213432,
0.0017917683580890298,
-0.01215911190956831,
0.040012966841459274,
-0.00130070885643363,
0.020830504596233368,
-0.034570589661598206,
-0.039553046226501465,
0.017658978700637817,
-0.04150770232081413,
-0.0003650009457487613,
-0.023225916549563408,
0.014669504016637802,
-0.030622949823737144,
-0.05469205230474472,
0.04878975450992584,
0.05430878326296806,
0.010108639486134052,
-0.030718766152858734,
0.04947963356971741,
0.001845665043219924,
0.01744818314909935,
-0.03547126427292824,
-0.07435359060764313,
-0.0011893220944330096,
-0.06599839776754379,
-0.061667490750551224,
0.05269906669855118,
-0.002158266492187977,
-0.026023758575320244,
-0.03104454278945923,
0.029300682246685028,
0.03434062749147415,
0.038269106298685074,
-0.04725669324398041,
0.06776142120361328,
-0.05921458825469017,
-0.030622949823737144,
-0.03539460897445679,
-0.006390959490090609,
0.042964112013578415,
0.018032662570476532,
0.008575575426220894,
0.021309586241841316,
0.02475897967815399,
0.03612281754612923,
0.060900960117578506,
0.025257226079702377,
0.005279488395899534,
0.025103919208049774,
0.0145928505808115,
-0.012916062958538532,
0.011124294251203537,
0.0456853024661541,
0.0021690456196665764,
0.0205430556088686,
0.02318759076297283,
0.027920924127101898,
0.007713227067142725,
-0.03280756622552872,
-0.04196762293577194,
0.023168426007032394,
-0.027231045067310333,
0.004874663893133402,
-0.010520650073885918,
0.028591640293598175,
-0.027058575302362442,
-0.015359383076429367,
-0.06289394199848175,
0.01921120658516884,
0.01717989705502987,
-0.00012785512080881745,
-0.0348963662981987,
0.032098524272441864,
-0.058792997151613235,
0.010884753428399563,
0.025812961161136627,
0.005772943142801523,
0.04376897215843201,
-0.01460243295878172,
0.004021896980702877,
-0.015158168040215969,
0.028994068503379822,
0.0337848924100399,
-0.0008036607760004699,
0.03675520420074463,
-0.028342517092823982,
-0.039188943803310394,
-0.030163031071424484,
0.003049359656870365,
-0.039553046226501465,
-0.03581620380282402,
0.018933337181806564,
-0.029396498575806618,
0.019853176549077034,
-0.020313095301389694,
-0.00896363239735365,
0.022306079044938087,
0.015570179559290409,
0.02828502655029297,
-0.05817976966500282,
-0.06848962604999542,
-0.019853176549077034,
-0.09336358308792114,
-0.012465724721550941,
0.024797307327389717,
0.03148529678583145,
0.026177063584327698,
-0.026483677327632904,
-0.02146289311349392,
0.009730163961648941,
-0.004021896980702877,
0.058601364493370056,
0.007152700796723366,
-0.020313095301389694,
-0.11122377961874008,
0.03167692944407463,
-0.0015139004681259394,
-0.005998112261295319,
-0.07078921794891357,
0.06952444463968277,
-0.013529287651181221,
-0.03131282702088356,
0.06189744919538498,
0.0006425693281926215,
0.008829489350318909,
0.00044225298915989697,
0.027001086622476578,
0.0233983863145113,
-0.01242739800363779,
0.019517818465828896,
-0.019642379134893417,
-0.04353901371359825,
-0.0412394143640995,
-0.04338570684194565,
0.024720653891563416,
0.04541701450943947,
-0.005859178025275469,
0.004191971383988857,
-0.023360060527920723,
-0.06205075606703758,
0.024375714361667633,
-0.033554933965206146,
0.015445617958903313,
-0.02853414975106716,
0.0057777343317866325,
0.05001620575785637,
-0.0017294875578954816,
-0.0048507098108530045,
0.05867801606655121,
0.0234750397503376,
0.02015978842973709,
-0.008978004567325115,
0.038000818341970444,
-0.009619975462555885,
0.09114064276218414,
0.004007524810731411,
-0.016681650653481483,
-0.0320410318672657,
0.013586778193712234,
-0.025372205302119255,
-0.019853176549077034,
0.020044809207320213,
-0.09060406684875488,
0.025180572643876076,
0.05756654590368271,
0.030872073024511337,
-0.009452296420931816,
-0.0672631710767746,
0.011574631556868553,
0.0006419704877771437,
0.04051120951771736,
-0.0038470320869237185,
-0.017361948266625404,
0.037521734833717346,
-0.0013246629387140274,
0.04652848467230797,
-0.017582325264811516,
-0.0022397104185074568,
0.046451833099126816,
0.07500514388084412,
0.0013677803799510002,
0.022248588502407074,
-0.04208260029554367,
0.016566671431064606,
-0.010616466403007507,
0.018808776512742043,
-0.08746129274368286,
0.08086911588907242,
-0.027499331161379814,
-0.023321732878684998,
0.06664995104074478,
-0.08600487560033798,
0.0216545257717371,
-0.04675844684243202,
-0.005279488395899534,
-0.010645211674273014,
0.04641350731253624,
0.04407558590173721,
0.012139949016273022,
-0.004110527224838734,
-0.05691499263048172,
0.06925615668296814,
-0.013644267804920673,
0.04192929342389107,
-0.002714002039283514,
0.02579379826784134,
-0.019124971702694893,
0.033554933965206146,
-0.009878680109977722,
0.004450676031410694,
0.010194874368607998,
0.07029097527265549,
-0.023321732878684998,
-0.005705871619284153,
-0.027786782011389732,
-0.013720921240746975,
0.02761431224644184,
0.006323887966573238,
0.0023331313859671354,
0.04384562373161316,
0.03846073895692825,
-0.052507434040308,
0.06975439935922623,
-0.06718651950359344,
-0.04511040076613426,
0.049211349338293076,
0.01040567085146904,
-0.028783272951841354,
-0.0377516970038414,
0.020102299749851227,
0.03211768716573715,
0.03309501335024834,
-0.012379489839076996,
-0.03959137201309204,
0.009964914992451668,
0.03959137201309204,
-0.006122673396021128,
-0.012034551240503788,
0.07266722619533539,
0.0037775649689137936,
-0.006510730367153883,
-0.02698192372918129,
0.012858572416007519,
-0.029818091541528702,
0.0732804462313652,
0.007013767026364803,
-0.05496033653616905,
0.005087855271995068,
0.041124437004327774,
-0.026023758575320244,
-0.03708098083734512,
-0.003545209998264909,
0.0025175781920552254,
0.016921192407608032,
-0.05059110373258591,
-0.023609181866049767,
-0.005686708725988865,
-0.03395736217498779,
0.027844270691275597,
0.0279975775629282,
0.01132550835609436,
0.014995280653238297,
-0.015206076204776764,
0.02301512099802494,
-0.018981246277689934,
-0.011651284992694855,
0.023685835301876068,
-0.0010551790473982692,
-0.005907086655497551,
-0.020198116078972816,
0.010923079214990139,
0.015033606439828873,
0.032462626695632935,
-0.007756344508379698,
0.006520311813801527,
-0.024835633113980293,
0.04407558590173721,
0.005811269860714674,
-0.05108935013413429,
0.019661543890833855,
-0.08155899494886398,
0.022152772173285484,
0.05396384745836258,
-0.03959137201309204,
0.03342078998684883,
-0.043040767312049866,
0.024624837562441826,
0.008561203256249428,
0.028955742716789246,
0.005389677360653877,
0.05676168575882912,
-0.022976793348789215,
0.012101622298359871,
0.02219109795987606,
0.011689611710608006,
-0.05745156481862068,
-0.02964562177658081,
-0.0456853024661541,
-0.021712016314268112,
-0.001271963817998767,
0.016078006476163864,
-0.020485565066337585,
-0.005643591284751892,
-0.005274697672575712,
0.07117248326539993,
-0.006707154214382172,
-0.04748665168881416,
0.03579704090952873,
0.05978948995471001,
-0.028035903349518776,
-0.03460891544818878,
0.10064563900232315,
0.014822810888290405,
0.007004185114055872,
0.012312418781220913,
0.0958164855837822,
0.03424481302499771,
-0.019134553149342537,
0.05415548011660576,
-0.020044809207320213,
-0.015311474911868572,
0.03801998123526573,
-0.019000409170985222,
0.00021319168445188552,
0.015570179559290409,
-0.03307585045695305,
-0.016825376078486443,
-0.0387098602950573,
-0.009481041692197323,
-0.03970635309815407,
-0.011382998898625374,
-0.01123927440494299,
0.017361948266625404,
0.003942848648875952,
0.010348180308938026,
0.032194338738918304,
0.022880977019667625,
-0.027786782011389732,
-0.0355287529528141,
0.025372205302119255,
0.011986642144620419,
0.0027044203598052263,
-0.07316546887159348,
-0.0801025852560997,
0.022344404831528664,
0.036985162645578384,
-0.0515492707490921,
-0.012619031593203545,
-0.0171319879591465,
-0.04798489809036255,
-0.007526385132223368,
-0.07634657621383667,
0.019268695265054703,
-0.011181783862411976,
-0.014698249287903309,
-0.04656681418418884,
0.007440150249749422,
0.0004329707589931786,
-0.0021726388949900866,
-0.017438599839806557,
0.0022037792950868607,
0.06346884369850159,
-0.00011355750757502392,
-0.02383914217352867,
0.03756006434559822,
0.03685102239251137,
-0.014583269134163857,
0.016279220581054688,
-0.0086043206974864,
0.004572841804474592,
0.05135763809084892,
-0.02882159873843193,
0.03481971099972725,
0.03470472991466522,
0.03148529678583145,
-0.04595358669757843,
0.02751849591732025,
-0.008819907903671265,
0.013950880616903305,
-0.011076386086642742,
0.02153954654932022,
-0.007023348473012447,
-0.024701490998268127,
0.036410264670848846,
0.04008961841464043,
0.020140625536441803,
-0.010808099992573261,
-0.014008370228111744,
0.010051149874925613,
0.005404049996286631,
-0.052354127168655396,
-0.051702577620744705,
0.008259381167590618,
0.01925911381840706,
-0.007545548491179943,
-0.012695685029029846,
-0.006434076931327581,
-0.013021460734307766,
-0.040741171687841415,
0.00094978092238307,
-0.012791501358151436,
-0.01923995092511177,
-0.002457692986354232,
0.015052770264446735,
-0.01851174607872963,
-0.02238273061811924,
0.00669757230207324,
-0.056493401527404785,
-0.07799462229013443,
0.048483144491910934,
0.06032606214284897,
0.024605674669146538,
-0.06714819371700287,
0.015014443546533585,
-0.022210262715816498,
0.0017989545594900846,
0.0377516970038414,
0.043040767312049866,
-0.024739816784858704,
-0.001323465257883072,
-0.01960405334830284,
-0.011066804639995098,
0.024069102481007576,
0.03418732434511185,
0.03010554052889347,
0.01766856014728546,
-0.04292578622698784,
-0.00722935376688838,
-0.04970959201455116,
-0.04997787997126579,
-0.009792445227503777,
0.008886978961527348,
0.00004188228558632545,
0.06182079762220383,
-0.022785160690546036,
0.016317548230290413,
0.04426721855998039,
0.028419170528650284,
-0.02937733568251133,
0.018789613619446754,
0.0019929830450564623,
-0.02864912897348404,
-0.07688315212726593,
-0.022440221160650253,
0.032270994037389755,
-0.044612158089876175,
0.004706984851509333,
0.042312562465667725,
0.04767828434705734,
-0.01519649475812912,
-0.05672335997223854,
-0.07546506822109222,
0.03556707873940468,
0.03248178958892822,
0.0019678310491144657,
-0.0015354591887444258,
0.05515196919441223,
0.016739141196012497,
-0.003648212645202875,
-0.06316222995519638,
0.025353042408823967,
0.0034877201542258263,
-0.03656357154250145,
-0.0017438600771129131,
-0.027116065844893456,
-0.06381378322839737,
-0.038000818341970444,
-0.05396384745836258,
-0.04503374919295311,
0.018597980961203575,
0.0233983863145113,
0.04721836373209953,
-0.03545210137963295,
0.01979568600654602,
0.01827220432460308,
0.051051024347543716,
-0.025353042408823967,
-0.0061610001139342785,
-0.025659656152129173,
-0.025755472481250763,
0.015742648392915726,
-0.0032529698219150305,
0.01667206920683384,
-0.05791148543357849,
0.02920486591756344,
-0.0018947710050269961,
0.0245865099132061,
-0.02383914217352867,
0.051625922322273254,
0.007957559078931808,
0.002050472889095545,
0.08776789903640747,
-0.06664995104074478,
0.010798518545925617,
-0.06339218467473984,
-0.003724865848198533,
-0.03784751147031784,
0.005739407613873482,
-0.020198116078972816,
0.019230369478464127,
0.010970987379550934,
-0.02598543092608452,
-0.022306079044938087,
0.050706084817647934,
0.008125238120555878,
-0.0031140358187258244,
-0.032730910927057266,
-0.0024361342657357454,
0.01778353936970234,
-0.005748989060521126,
-0.003013428533449769,
-0.03409150615334511,
0.06588342040777206,
0.004618354607373476,
0.029032396152615547,
0.04411391168832779,
0.007809043861925602,
0.05814144387841225,
0.022612690925598145,
-0.039744678884744644,
-0.0366402231156826,
0.007852161303162575,
-0.02809339389204979,
-0.027422679588198662,
-0.006242444273084402,
-0.06511688232421875,
-0.048023223876953125,
0.029875580221414566,
-0.021290423348546028,
-0.004845918621867895,
0.01150756049901247,
0.01202496886253357,
0.07730474323034286,
-0.002874494530260563,
-0.002951147733256221,
-0.0053465599194169044,
0.0016432527918368578,
0.05066775903105736,
-0.014698249287903309,
0.018205132335424423,
-0.057221606373786926,
-0.0022492920979857445,
0.021520383656024933,
-0.025180572643876076,
0.023455876857042313,
0.050322819501161575,
0.038633208721876144,
0.0639287605881691,
-0.02579379826784134,
-0.017342783510684967,
-0.0537722110748291,
-0.04752497747540474,
0.02117544412612915,
-0.038901492953300476,
-0.036065325140953064,
0.058256424963474274,
-0.07596331089735031,
0.03539460897445679,
-0.05116600543260574,
0.00904028583317995,
-0.03248178958892822,
0.010214037261903286,
-0.01805182546377182,
-0.04530203342437744,
0.04924967512488365,
-0.008594739250838757,
0.004342882428318262,
-0.04016626998782158,
-0.005614846013486385,
0.031638603657484055,
-0.054462090134620667,
0.001561808749102056,
-0.06189744919538498,
-0.013740084134042263,
0.036141980439424515,
0.007306007202714682,
0.023781651630997658,
-0.008364778943359852,
0.03160027787089348,
-0.053733885288238525,
-0.012139949016273022,
-0.03608448803424835,
0.014180839993059635,
0.03280756622552872,
0.0013869436224922538,
0.01506235171109438,
-0.0038949402514845133,
-0.03397652506828308,
0.010990151204168797,
0.009222337044775486,
0.02359001897275448,
0.008508504368364811,
0.01657625287771225,
0.003418253269046545,
-0.05220082402229309,
0.0445738285779953,
-0.006141836754977703,
0.035950347781181335,
-0.030258847400546074,
0.008115656673908234,
0.008383942767977715,
0.0003287703148089349,
0.05453874543309212,
-0.0179272647947073,
-0.01865546964108944,
0.054922010749578476,
0.027690965682268143,
0.004934549331665039,
0.04798489809036255,
-0.029262354597449303,
-0.032079361379146576,
-0.07339543104171753,
-0.0163367111235857,
0.01367301307618618,
0.06189744919538498,
-0.04070284217596054,
-0.002252885140478611,
0.020658034831285477,
0.015905536711215973,
0.047103386372327805
]
|
30,514 | networkx.classes.function | create_empty_copy | Returns a copy of the graph G with all of the edges removed.
Parameters
----------
G : graph
A NetworkX graph
with_data : bool (default=True)
Propagate Graph and Nodes data to the new graph.
See Also
--------
empty_graph
| def create_empty_copy(G, with_data=True):
"""Returns a copy of the graph G with all of the edges removed.
Parameters
----------
G : graph
A NetworkX graph
with_data : bool (default=True)
Propagate Graph and Nodes data to the new graph.
See Also
--------
empty_graph
"""
H = G.__class__()
H.add_nodes_from(G.nodes(data=with_data))
if with_data:
H.graph.update(G.graph)
return H
| (G, with_data=True) | [
0.028552457690238953,
-0.00813495833426714,
-0.025277113541960716,
-0.03298485279083252,
-0.048418134450912476,
-0.00026756804436445236,
-0.05578765645623207,
-0.021004924550652504,
0.12346623837947845,
-0.033572278916835785,
-0.009968439117074013,
-0.014285129494965076,
-0.02383524924516678,
0.021788159385323524,
-0.028356648981571198,
0.020239491015672684,
-0.02424466796219349,
-0.044573161751031876,
0.06764297932386398,
-0.03688322380185127,
-0.002107167849317193,
-0.04464436694979668,
-0.028641462326049805,
0.024760890752077103,
0.0019035713048651814,
0.00720931775867939,
-0.04047898203134537,
0.019456256181001663,
0.0492369681596756,
-0.007400676142424345,
0.04097740352153778,
-0.051052648574113846,
-0.020310694351792336,
-0.0009417727123945951,
0.013519695028662682,
0.04133342206478119,
-0.0151840690523386,
0.023390229791402817,
-0.052903931587934494,
0.015789294615387917,
0.04735008627176285,
-0.06109229102730751,
-0.019064640626311302,
0.008846989832818508,
0.06707335263490677,
0.01159721054136753,
0.05236990749835968,
0.04848933592438698,
-0.01798769272863865,
-0.006955656222999096,
0.021770358085632324,
0.044929180294275284,
-0.03309165686368942,
0.05208509415388107,
-0.049557384103536606,
-0.007507480680942535,
0.04635324329137802,
0.049272570759058,
0.02161015197634697,
0.02233998477458954,
-0.011677314527332783,
-0.01136580016463995,
0.006951206363737583,
-0.042686279863119125,
0.006488385610282421,
-0.003951773978769779,
-0.07618735730648041,
-0.02127193659543991,
-0.00208714185282588,
-0.02086251974105835,
-0.0417606383562088,
0.01778298243880272,
0.020720113068819046,
0.04058578610420227,
0.019616464152932167,
-0.001288331695832312,
0.034284308552742004,
0.00835746806114912,
-0.014080420136451721,
-0.01439193356782198,
0.022589195519685745,
-0.0034355514217168093,
-0.0720219686627388,
0.06102108955383301,
0.04667365550994873,
-0.00914070289582014,
0.03535235673189163,
0.0029015277978032827,
0.01966986618936062,
-0.06621892005205154,
0.0380580760538578,
0.02315882034599781,
-0.007574233692139387,
-0.01608300767838955,
0.0568913072347641,
-0.017693979665637016,
-0.054790813475847244,
-0.006466134916990995,
0.034284308552742004,
0.006897803861647844,
-0.047243282198905945,
0.05642848461866379,
-0.08081556111574173,
0.006047816481441259,
0.040443383157253265,
-0.01557568646967411,
0.0012293666368350387,
-0.05995304137468338,
-0.0028147490229457617,
-0.012202437035739422,
-0.01556678581982851,
0.03561937063932419,
0.05539603903889656,
0.00890929251909256,
0.045000381767749786,
-0.006132370326668024,
-0.005006470717489719,
0.0026055898051708937,
-0.03186340257525444,
-0.050696633756160736,
-0.04745689034461975,
0.03455132246017456,
-0.04667365550994873,
0.005816406104713678,
0.03480053320527077,
0.02009708434343338,
0.0284634530544281,
-0.049450576305389404,
0.00013976397167425603,
-0.06358440220355988,
0.04706527292728424,
0.029762910678982735,
-0.031649794429540634,
0.0017478144727647305,
-0.07775382697582245,
-0.0340350978076458,
-0.006986807566136122,
0.0001976165222004056,
0.03706123307347298,
0.02538391761481762,
-0.02693258598446846,
-0.054434798657894135,
0.008989395573735237,
0.10331574827432632,
0.012068931944668293,
-0.02691478468477726,
0.010671569965779781,
0.0030572847463190556,
0.01938505470752716,
-0.01005744282156229,
0.03289584815502167,
0.02207297272980213,
0.05500442162156105,
-0.019527459517121315,
-0.038164880126714706,
0.007956950925290585,
-0.05945461988449097,
-0.011294597759842873,
-0.03731044381856918,
-0.01308357622474432,
-0.027591215446591377,
0.046068429946899414,
0.05343795195221901,
-0.01863742060959339,
-0.033981695771217346,
-0.02121853455901146,
0.1135689988732338,
-0.024760890752077103,
-0.013492994010448456,
-0.0025677632074803114,
0.0030884360894560814,
-0.05625047907233238,
-0.03184560313820839,
0.00900274608284235,
-0.05924100801348686,
0.05098144710063934,
0.010377856902778149,
0.00432336563244462,
-0.008717933669686317,
-0.004009626805782318,
0.00016201494145207107,
-0.016688235104084015,
-0.026006946340203285,
0.03652720898389816,
0.026736777275800705,
-0.0756177306175232,
-0.030225731432437897,
-0.02921108715236187,
0.004521399270743132,
-0.025597527623176575,
-0.0532243438065052,
-0.015958402305841446,
0.013136978261172771,
0.06272996217012405,
0.04578361660242081,
-0.02355043776333332,
-0.060843080282211304,
0.024867694824934006,
-0.08537255972623825,
0.09170963615179062,
0.0001661870046518743,
-0.05041182041168213,
0.051408663392066956,
-0.03556596487760544,
-0.028178641572594643,
0.020008081570267677,
-0.04375432804226875,
-0.02963830530643463,
-0.023301227018237114,
-0.00010854306310648099,
0.016207613050937653,
-0.0059721628203988075,
0.04375432804226875,
0.018014393746852875,
-0.018797628581523895,
0.037417247891426086,
-0.030599547550082207,
0.0016143085667863488,
0.009398814290761948,
-0.033625680953264236,
-0.09598182886838913,
-0.030118927359580994,
-0.0417962409555912,
-0.0030417090747505426,
0.017044249922037125,
-0.01589610055088997,
-0.005277932621538639,
-0.03862770274281502,
0.02308761700987816,
-0.06561368703842163,
0.0949137806892395,
0.012487250380218029,
0.01023545116186142,
-0.08686782419681549,
0.01931385137140751,
-0.00951451901346445,
-0.011623911559581757,
-0.0011253432603552938,
0.057460930198431015,
0.01384900975972414,
-0.0361177921295166,
-0.07269839942455292,
-0.012264740653336048,
0.02353263646364212,
0.05379397049546242,
0.02693258598446846,
-0.03302045539021492,
-0.0023096518125385046,
0.0531531423330307,
0.00681770034134388,
-0.07761141657829285,
-0.020737912505865097,
-0.02768022008240223,
0.014356331899762154,
0.02082691714167595,
0.009719228371977806,
-0.0606294721364975,
-0.035850778222084045,
-0.02506350353360176,
0.0027235199231654406,
0.005291283130645752,
-0.004143132362514734,
-0.038876913487911224,
0.046460047364234924,
0.03766645863652229,
-0.011632812209427357,
0.024369273334741592,
0.025704331696033478,
-0.008428671397268772,
0.015673590824007988,
0.06867542117834091,
0.01423172652721405,
0.05625047907233238,
-0.014267328195273876,
0.05236990749835968,
0.030261332169175148,
-0.007071361411362886,
0.01362650003284216,
0.04008736461400986,
-0.03371468558907509,
-0.004125331528484821,
0.03859210014343262,
0.0341063030064106,
-0.02009708434343338,
-0.033162862062454224,
0.019420655444264412,
-0.02013268694281578,
-0.012789863161742687,
0.010012941434979439,
-0.04325590655207634,
0.02127193659543991,
0.019545260816812515,
0.022233178839087486,
0.022108573466539383,
0.05247671157121658,
0.07348163425922394,
0.006995708215981722,
-0.0008221737225539982,
-0.01929605007171631,
0.04880974814295769,
0.10103724896907806,
-0.04770610108971596,
0.0031752148643136024,
0.03191680461168289,
0.02050650306046009,
0.009594622999429703,
0.009336511604487896,
0.027929430827498436,
0.014650044962763786,
-0.001582044642418623,
-0.06525767594575882,
-0.010546964593231678,
0.0359753854572773,
0.04254387319087982,
-0.031275976449251175,
-0.04097740352153778,
0.04322030395269394,
-0.05051862448453903,
0.03157858923077583,
-0.02549072355031967,
-0.023230023682117462,
-0.003740389831364155,
-0.003533455543220043,
0.016554730013012886,
-0.06718015670776367,
0.03232622519135475,
0.002805848605930805,
0.05724732205271721,
-0.021432144567370415,
0.009754830040037632,
-0.027822624891996384,
0.022464590147137642,
0.0013027949025854468,
0.02963830530643463,
-0.03955334052443504,
0.04400353878736496,
0.033554479479789734,
-0.024725288152694702,
-0.036598410457372665,
-0.03841409087181091,
-0.007645436562597752,
0.03328746557235718,
0.01608300767838955,
-0.015807095915079117,
0.021182933822274208,
-0.00616352166980505,
-0.06180432066321373,
-0.022874007001519203,
-0.030207930132746696,
-0.005126625765115023,
0.03731044381856918,
0.0642964318394661,
0.006252525374293327,
0.025917941704392433,
0.07362404465675354,
-0.023230023682117462,
0.011890923604369164,
0.031685397028923035,
-0.029745109379291534,
0.041938647627830505,
0.03581517934799194,
0.029104281216859818,
0.0008661194005981088,
-0.025188108906149864,
0.02573993429541588,
-0.011294597759842873,
0.01215793564915657,
0.02161015197634697,
-0.0646880492568016,
-0.043469514697790146,
-0.0022918509785085917,
-0.0683906152844429,
-0.041475825011730194,
0.0035201050341129303,
0.02881946973502636,
0.006937855388969183,
-0.03369688242673874,
-0.02161015197634697,
0.013217082247138023,
0.04467996954917908,
-0.02007928490638733,
-0.010360056534409523,
-0.008709033951163292,
0.01023545116186142,
0.038520894944667816,
-0.006777648348361254,
0.019527459517121315,
0.05810175836086273,
0.055218033492565155,
-0.004432395100593567,
-0.04012296721339226,
-0.051017045974731445,
0.02086251974105835,
0.04820452257990837,
-0.018370408564805984,
0.019171444699168205,
0.01899343729019165,
0.016608132049441338,
-0.019865674898028374,
-0.02883727103471756,
0.0020637784618884325,
-0.01819240115582943,
-0.005291283130645752,
-0.003718138672411442,
0.002054878044873476,
-0.03609998896718025,
-0.00834856741130352,
0.008397519588470459,
0.08117157220840454,
0.003555706702172756,
0.06486605852842331,
0.026273956522345543,
-0.00012078110012225807,
0.029139883816242218,
0.08814948052167892,
-0.01425842847675085,
0.0874374508857727,
0.03880570828914642,
0.03869890421628952,
0.005589446052908897,
0.021147331222891808,
0.018334807828068733,
0.0264875665307045,
-0.02766241878271103,
0.014970459043979645,
0.042757485061883926,
-0.05927661061286926,
-0.006523987278342247,
-0.03969574719667435,
0.035921983420848846,
-0.01477465033531189,
-0.04325590655207634,
-0.004152033012360334,
0.01254955306649208,
-0.024369273334741592,
0.030172329396009445,
0.020702311769127846,
-0.032023608684539795,
-0.027555612847208977,
0.09904356300830841,
0.002592239063233137,
-0.0456056073307991,
0.01731126196682453,
-0.018459413200616837,
0.0007504143286496401,
-0.007084711920469999,
-0.005647298879921436,
0.012424947693943977,
0.04240146651864052,
0.010279952548444271,
0.028623661026358604,
0.016812840476632118,
0.019919076934456825,
0.00615907134488225,
-0.06981467455625534,
-0.003615784225985408,
0.002138319192454219,
-0.009229706600308418,
-0.05568085238337517,
0.05614367127418518,
0.0016243215650320053,
0.010733872652053833,
-0.027573414146900177,
0.012193537317216396,
0.02687918394804001,
-0.042365867644548416,
0.05151546746492386,
-0.014943758025765419,
-0.052547913044691086,
0.009781531058251858,
0.00834856741130352,
-0.03494293987751007,
-0.01589610055088997,
-0.0416182316839695,
0.05279712378978729,
-0.007899098098278046,
-0.026398561894893646,
-0.009327610954642296,
-0.011801919899880886,
-0.05041182041168213,
0.015308674424886703,
-0.00006842176662757993,
0.006626341957598925,
0.043077897280454636,
-0.031685397028923035,
0.05133746191859245,
0.024921096861362457,
-0.01594950258731842,
-0.017337962985038757,
-0.0006575164734385908,
-0.008139408193528652,
-0.046495646238327026,
-0.06593410670757294,
-0.04738568887114525,
0.015201869420707226,
0.01768507808446884,
-0.037844467908144,
0.0060522668063640594,
0.04489357769489288,
-0.049877796322107315,
-0.004703857004642487,
-0.019812272861599922,
-0.03253983333706856,
0.003302045399323106,
0.006884453352540731,
-0.019847873598337173,
-0.00627032620832324,
0.015041662380099297,
0.0341775044798851,
-0.007102512754499912,
-0.005900959949940443,
0.037346046417951584,
-0.01137470081448555,
0.03369688242673874,
0.055218033492565155,
0.010511362925171852,
0.006288127042353153,
0.01574479416012764,
0.008984945714473724,
-0.04866734519600868,
-0.010778374969959259,
0.062017932534217834,
-0.010885179042816162,
-0.014872554689645767,
-0.060700673609972,
0.03426650911569595,
-0.011232295073568821,
0.0014040368841961026,
0.022286580875515938,
-0.022606994956731796,
0.0265231691300869,
0.008953794836997986,
0.0070936125703155994,
0.0949137806892395,
-0.0189044326543808,
-0.028908472508192062,
0.03163199499249458,
-0.035797376185655594,
0.006986807566136122,
-0.006105668842792511,
0.00052289804443717,
0.01815680041909218,
0.036598410457372665,
0.014694547280669212,
-0.048026517033576965,
0.04514278843998909,
0.04467996954917908,
0.0645812451839447,
-0.040407780557870865,
-0.04503598436713219,
-0.042294662445783615,
-0.015308674424886703,
0.018103396520018578,
-0.028605859726667404,
0.07469209283590317,
-0.007738891057670116,
-0.00929200928658247,
0.021449944004416466,
0.03955334052443504,
-0.010342255234718323,
-0.03731044381856918,
-0.06312157958745956,
-0.0025032353587448597,
-0.00550489267334342,
0.009176304563879967,
-0.015976203605532646,
-0.030973363667726517,
0.03948213905096054,
-0.03642040491104126,
0.032023608684539795,
0.023728445172309875,
-0.006777648348361254,
0.03218381851911545,
-0.04471556842327118,
0.024832094088196754,
-0.0005584995960816741,
-0.04126221686601639,
0.05169347673654556,
0.011312398128211498,
-0.037702061235904694,
-0.010956382378935814,
-0.01826360449194908,
-0.05372276529669762,
0.003219716716557741,
-0.025259312242269516,
-0.0094522163271904,
-0.026736777275800705,
0.01461444329470396,
0.0027858226094394922,
-0.014667846262454987,
0.10182048380374908,
0.0684618130326271,
0.053651563823223114,
-0.0012204662198200822,
-0.007427377160638571,
-0.04218785837292671,
0.008624480105936527,
-0.02958490327000618,
-0.03898371756076813,
-0.01462334394454956,
0.021129529923200607,
0.07088272273540497,
0.04667365550994873,
0.013777806423604488,
-0.028321048244833946,
0.024404874071478844,
-0.030848758295178413,
-0.033198460936546326,
0.04478677362203598,
-0.09562581032514572,
-0.016554730013012886,
0.041191015392541885,
-0.0568557046353817,
-0.05763893947005272,
0.0006241399678401649,
-0.022179776802659035,
-0.05201389268040657,
0.00616352166980505,
-0.0378088653087616,
0.008962694555521011,
0.0011375813046470284,
-0.06871102750301361,
-0.02887287177145481,
0.012175736017525196,
-0.009737028740346432,
-0.039197325706481934,
0.01684844121336937,
0.0066174413077533245,
-0.05418558791279793,
0.062017932534217834,
-0.006790999323129654,
-0.10730312764644623,
-0.028267644345760345,
0.05269031971693039,
0.025668730959296227,
-0.05895619839429855,
-0.011401401832699776,
0.017533771693706512,
0.042686279863119125,
0.017364664003252983,
-0.009211905300617218,
-0.029673907905817032,
-0.012122333981096745,
-0.016768338158726692,
-0.044217146933078766,
-0.04820452257990837,
0.00664859265089035,
-0.05500442162156105,
-0.02426246926188469,
-0.06746497005224228,
-0.0009350974578410387,
0.018673023208975792,
0.05340235307812691,
-0.011997728608548641,
-0.03930412977933884,
0.050305016338825226,
0.020631108433008194,
-0.018130099400877953,
0.019100241363048553,
-0.013448492623865604,
0.0006152396090328693,
0.04895215481519699,
0.03298485279083252,
0.08223962038755417,
0.04400353878736496,
0.045000381767749786,
0.017008649185299873,
-0.009523419663310051,
0.03307385742664337,
0.01712435483932495,
-0.08907512575387955,
0.02431587129831314,
-0.050661031156778336,
0.012611855752766132,
-0.041938647627830505,
-0.02506350353360176,
0.02159235067665577,
0.030225731432437897,
-0.025722132995724678,
-0.007062461227178574,
0.045320797711610794,
0.036242395639419556,
0.00020276205032132566,
-0.0681414008140564,
-0.02844565361738205,
0.0532243438065052,
-0.03841409087181091,
-0.05233430489897728,
0.031293779611587524,
-0.015958402305841446,
-0.01731126196682453,
-0.03855649754405022,
0.09598182886838913,
0.005731852259486914,
0.010733872652053833,
0.007565333042293787,
-0.009318710304796696,
-0.04101300612092018,
-0.00034155254252254963,
-0.017702879384160042,
0.02807183563709259,
0.012950070202350616,
-0.043469514697790146,
0.01666153408586979,
0.00393619854003191,
-0.007827894762158394,
-0.036954429000616074,
0.05390077456831932,
-0.04282868653535843,
0.020381897687911987,
0.006937855388969183,
0.039980560541152954,
-0.0284990556538105,
0.020987125113606453,
0.07120313495397568,
0.005291283130645752,
-0.023603839799761772,
-0.048738546669483185,
-0.08537255972623825,
-0.007142564747482538,
0.02082691714167595,
0.005629498045891523,
0.013528595678508282,
0.04211665689945221,
-0.0323440246284008,
0.02054210565984249,
0.014062619768083096,
-0.1249615028500557,
0.029317891225218773,
-0.007138114422559738,
0.03652720898389816,
0.06493726372718811,
0.018352609127759933,
0.029406895861029625,
0.018744224682450294,
-0.027591215446591377,
-0.01790758967399597,
0.024031057953834534,
0.038876913487911224,
-0.0060166651383042336,
-0.03104456700384617,
-0.019100241363048553,
0.02921108715236187,
0.034658126533031464,
-0.059739429503679276,
-0.06038025766611099,
0.010422359220683575,
0.023016413673758507,
-0.037025630474090576,
0.03181000053882599,
-0.007609835360199213,
-0.003511204617097974,
0.0170175489038229,
0.012122333981096745,
0.025971343740820885,
0.055502843111753464,
-0.04108421131968498,
-0.004007401410490274,
-0.007111413404345512,
-0.05949021875858307,
-0.021823761984705925,
-0.006906704045832157,
0.00889149121940136,
-0.021716956049203873,
-0.03837849199771881,
-0.00013879049220122397,
0.04144022613763809,
0.024814292788505554
]
|
30,515 | networkx.generators.small | cubical_graph |
Returns the 3-regular Platonic Cubical Graph
The skeleton of the cube (the nodes and edges) form a graph, with 8
nodes, and 12 edges. It is a special case of the hypercube graph.
It is one of 5 Platonic graphs, each a skeleton of its
Platonic solid [1]_.
Such graphs arise in parallel processing in computers.
Parameters
----------
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : networkx Graph
A cubical graph with 8 nodes and 12 edges
References
----------
.. [1] https://en.wikipedia.org/wiki/Cube#Cubical_graph
| def _raise_on_directed(func):
"""
A decorator which inspects the `create_using` argument and raises a
NetworkX exception when `create_using` is a DiGraph (class or instance) for
graph generators that do not support directed outputs.
"""
@wraps(func)
def wrapper(*args, **kwargs):
if kwargs.get("create_using") is not None:
G = nx.empty_graph(create_using=kwargs["create_using"])
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
return func(*args, **kwargs)
return wrapper
| (create_using=None, *, backend=None, **backend_kwargs) | [
0.02052106149494648,
-0.003826453583315015,
0.036479901522397995,
0.005174993071705103,
0.0002132951485691592,
0.039002541452646255,
-0.060078226029872894,
-0.017846345901489258,
0.08022357523441315,
-0.0368913933634758,
0.019215013831853867,
0.010833045467734337,
0.04422673583030701,
-0.02680082991719246,
0.011011956259608269,
0.04515707120299339,
-0.048806849867105484,
0.09403548389673233,
0.02332996018230915,
0.04737556353211403,
-0.009178120642900467,
-0.03184611350297928,
-0.0025740782730281353,
-0.019894873723387718,
0.0007603706326335669,
0.04347531124949455,
-0.025244304910302162,
0.0010136411292478442,
0.0061903116293251514,
0.023687781766057014,
-0.034297190606594086,
-0.04676726832985878,
0.0009113266132771969,
0.06562446057796478,
0.04633788391947746,
0.06276188790798187,
-0.046624138951301575,
0.08093921840190887,
-0.10212225466966629,
-0.07342496514320374,
-0.031255707144737244,
0.0077378894202411175,
0.03207869455218315,
0.011396613903343678,
-0.0013496578903868794,
-0.020002221688628197,
0.009822200052440166,
0.00007624672434758395,
-0.08931224048137665,
-0.0420440249145031,
0.022363843396306038,
0.005568597000092268,
0.05514029040932655,
0.06147373095154762,
0.012344840914011002,
0.04036226496100426,
-0.0097327446565032,
0.028965650126338005,
0.03943192586302757,
-0.016307713463902473,
0.0049737184308469296,
0.05102534219622612,
0.012487969361245632,
-0.024188732728362083,
-0.03299114108085632,
0.000811248377431184,
-0.07821977883577347,
-0.026621919125318527,
-0.021916566416621208,
0.05456777662038803,
0.011664980091154575,
-0.005783289670944214,
0.01718437671661377,
0.009500160813331604,
0.07224415987730026,
-0.030629519373178482,
0.019876983016729355,
-0.010251585394144058,
0.04827011749148369,
-0.023634109646081924,
-0.03599684312939644,
-0.018767736852169037,
-0.022399624809622765,
0.00704908324405551,
0.06197468191385269,
-0.021898675709962845,
-0.051275819540023804,
0.02640722505748272,
0.030182242393493652,
-0.044441428035497665,
-0.0055909608490765095,
-0.03537065535783768,
-0.017408015206456184,
0.005219720769673586,
-0.03220393508672714,
0.059684623032808304,
0.02960972860455513,
-0.05263553932309151,
0.06397847831249237,
-0.011781272478401661,
0.0017879892839118838,
0.00821200292557478,
-0.019107667729258537,
0.033456310629844666,
-0.016254041343927383,
-0.09739901125431061,
0.00984009075909853,
-0.028071096166968346,
-0.01962650753557682,
-0.02338363416492939,
-0.08279988914728165,
-0.01825784146785736,
0.049987662583589554,
0.000976181763689965,
0.0173632875084877,
-0.001127696828916669,
-0.010063729248940945,
-0.018588826060295105,
0.001818180433474481,
-0.03640833497047424,
-0.021719764918088913,
0.02898354083299637,
-0.05653579533100128,
-0.05109690874814987,
0.05646422877907753,
-0.023974038660526276,
-0.0005283457576297224,
-0.016611862927675247,
0.042258717119693756,
0.015198467299342155,
0.018660390749573708,
0.047304000705480576,
-0.029878094792366028,
0.03699874132871628,
0.0043810768984258175,
0.03644411638379097,
-0.05395948141813278,
0.052742887288331985,
-0.014169731177389622,
0.0027954804245382547,
-0.00294308178126812,
-0.018910866230726242,
0.027945857495069504,
0.04261653870344162,
0.013874527998268604,
0.041686203330755234,
-0.05564124137163162,
-0.0227216649800539,
0.02433186024427414,
-0.02842891775071621,
0.05921945720911026,
0.005613324698060751,
0.009039465337991714,
0.01686233840882778,
-0.043153271079063416,
0.03426140546798706,
-0.03318794444203377,
0.025494780391454697,
0.02136194333434105,
0.014357587322592735,
-0.03152407333254814,
-0.022864792495965958,
0.04233027994632721,
0.02332996018230915,
0.015609961934387684,
-0.022274388000369072,
0.01001005619764328,
-0.020038003101944923,
0.007903382182121277,
-0.004305039532482624,
-0.04537176340818405,
-0.022292278707027435,
-0.0057564531452953815,
-0.039288800209760666,
-0.028804630041122437,
0.03023591637611389,
0.03746391087770462,
0.04261653870344162,
-0.03352787345647812,
0.01607513055205345,
0.054424647241830826,
-0.044047825038433075,
-0.01951916143298149,
-0.02832156978547573,
0.04132838174700737,
0.01867828145623207,
0.009884818457067013,
-0.025280088186264038,
0.0032472300808876753,
0.0003916467831004411,
0.017560089007019997,
0.017381178215146065,
0.03250808268785477,
0.04973718523979187,
0.03796485811471939,
-0.09267576783895493,
-0.009374923072755337,
-0.0015274505130946636,
-0.016924956813454628,
0.07457000017166138,
0.05270710587501526,
0.0321502611041069,
0.03605051338672638,
0.014035548083484173,
-0.004799280781298876,
0.047304000705480576,
-0.025136958807706833,
-0.05188411474227905,
-0.05217037349939346,
-0.010349986143410206,
-0.03885941207408905,
-0.034297190606594086,
0.034959159791469574,
0.05152629315853119,
-0.03444031625986099,
0.02315104939043522,
0.02154085412621498,
0.05399526283144951,
-0.010349986143410206,
-0.027212323620915413,
-0.012112257070839405,
-0.01820416748523712,
-0.008082292973995209,
-0.02041371539235115,
0.0626545399427414,
-0.0413641631603241,
0.008122547529637814,
-0.05252819508314133,
0.025637909770011902,
-0.017846345901489258,
0.04104212298989296,
-0.01584254577755928,
0.01684444583952427,
0.02277533710002899,
0.0389309786260128,
-0.047697603702545166,
0.01968018151819706,
-0.045121289789676666,
0.010224749334156513,
0.013606161810457706,
-0.061831552535295486,
-0.0011215467238798738,
0.004445931874215603,
-0.0005487527814693749,
0.08279988914728165,
0.029538163915276527,
-0.009705907665193081,
0.048806849867105484,
0.005948781967163086,
-0.04161464050412178,
-0.04211558774113655,
-0.011459233239293098,
-0.0037660710513591766,
-0.023652000352740288,
0.008435641415417194,
-0.028697283938527107,
-0.059970881789922714,
-0.058790069073438644,
0.03925301507115364,
0.006990937050431967,
-0.03628309816122055,
0.05825333669781685,
-0.05667892470955849,
0.020342150703072548,
0.004568933043628931,
-0.033456310629844666,
-0.025315869599580765,
0.02214914932847023,
-0.03408249467611313,
0.025047503411769867,
-0.022453298792243004,
0.04086321219801903,
0.0739259198307991,
-0.02411716803908348,
0.006566024385392666,
0.020109567791223526,
-0.020038003101944923,
0.011584470979869366,
-0.01340041495859623,
0.034959159791469574,
-0.046230535954236984,
-0.01668342761695385,
-0.052063025534152985,
0.03644411638379097,
-0.07492782175540924,
0.03184611350297928,
0.009768527001142502,
0.012792117893695831,
0.0114950155839324,
-0.01191545557230711,
0.030540063977241516,
0.012022801674902439,
0.0347265750169754,
0.03202502429485321,
-0.04776916652917862,
0.0033366852439939976,
0.026943957433104515,
-0.042079806327819824,
0.033849913626909256,
0.03229339048266411,
0.029305579140782356,
-0.03760703653097153,
-0.008435641415417194,
0.01833835057914257,
0.008672698400914669,
0.003736998187378049,
0.03465501219034195,
-0.027963748201727867,
0.004723243415355682,
-0.01530581433326006,
-0.0655171126127243,
0.03517385199666023,
-0.01555628888309002,
0.0191255584359169,
0.03572847694158554,
0.024689681828022003,
-0.011870727874338627,
-0.037929076701402664,
0.033778347074985504,
0.06938158720731735,
-0.035692691802978516,
0.10555733740329742,
-0.06744935363531113,
0.0013709035702049732,
-0.08308614790439606,
0.048198554664850235,
0.06108012795448303,
0.03857315704226494,
0.056500013917684555,
0.09002788364887238,
0.0021156196016818285,
-0.02842891775071621,
-0.007567924447357655,
-0.01825784146785736,
-0.08716531097888947,
0.027802729979157448,
0.06938158720731735,
-0.04884263128042221,
0.05535498261451721,
-0.017622707411646843,
0.008650334551930428,
0.003819744335487485,
-0.008784517645835876,
0.0018002893775701523,
-0.006673370487987995,
0.032669100910425186,
0.00895895529538393,
-0.023634109646081924,
0.023616217076778412,
0.04490659758448601,
-0.010197912342846394,
0.1102805808186531,
-0.021326160058379173,
0.00981325376778841,
0.04061273857951164,
0.014625953510403633,
-0.024653900414705276,
0.03374256566166878,
-0.027265997603535652,
-0.005233139265328646,
-0.03656935691833496,
-0.040970560163259506,
0.05743034929037094,
0.01393714640289545,
0.06175998970866203,
-0.012112257070839405,
0.032096587121486664,
0.013078375719487667,
0.045729584991931915,
-0.05338696390390396,
-0.03279433771967888,
-0.0698467567563057,
-0.0356748029589653,
-0.00005566500112763606,
0.018275732174515724,
0.009911655448377132,
-0.012273277156054974,
-0.01424129493534565,
0.03739234432578087,
0.06891641765832901,
-0.03651568293571472,
0.01163814403116703,
0.04587271437048912,
-0.0051079015247523785,
0.05714409053325653,
-0.04279544949531555,
0.05367322266101837,
0.08451743423938751,
-0.01752430759370327,
-0.03739234432578087,
-0.009061829186975956,
-0.04032647982239723,
0.029180342331528664,
0.0317387655377388,
-0.03324161469936371,
-0.03342052549123764,
0.014608061872422695,
0.0001255869574379176,
-0.02764170989394188,
0.0037638347130268812,
-0.033849913626909256,
-0.008033092133700848,
-0.016585025936365128,
0.028572045266628265,
0.027069196105003357,
0.022006021812558174,
-0.008471423760056496,
0.015860436484217644,
0.039217233657836914,
-0.007397959008812904,
0.04193667694926262,
-0.013257285580039024,
-0.04111368954181671,
0.007715525571256876,
0.04973718523979187,
0.02994965761899948,
0.009008156135678291,
0.03660513833165169,
0.024045603349804878,
-0.034798137843608856,
0.07185055315494537,
-0.04104212298989296,
0.07700318098068237,
0.03885941207408905,
0.04240184649825096,
-0.039610836654901505,
-0.03139883652329445,
0.007433741353452206,
-0.046230535954236984,
0.02932346984744072,
0.018642500042915344,
-0.04970140382647514,
0.03089788556098938,
-0.052241936326026917,
0.02567369118332863,
-0.01323044952005148,
-0.015359487384557724,
0.0144112603738904,
0.0032539390958845615,
0.05796708166599274,
0.02209547720849514,
-0.007813926786184311,
-0.004875317681580782,
-0.017202267423272133,
-0.01978752762079239,
-0.0363546647131443,
0.02091466635465622,
0.023133158683776855,
0.0012356023071333766,
-0.022328060120344162,
0.06873750686645508,
-0.00034076906740665436,
0.08129703998565674,
0.02338363416492939,
-0.14048071205615997,
-0.010859882459044456,
-0.009093138389289379,
-0.030146460980176926,
-0.024600226432085037,
0.05567702278494835,
0.011834945529699326,
-0.008422222919762135,
-0.10412605106830597,
-0.02417084202170372,
-0.032096587121486664,
0.04043382778763771,
-0.010045838542282581,
0.014608061872422695,
-0.02411716803908348,
0.0016392696416005492,
0.06848703324794769,
-0.041578855365514755,
-0.0054567777551710606,
-0.028500480577349663,
0.005309176165610552,
-0.013391468673944473,
-0.01578887365758419,
-0.0025584236718714237,
0.03544221818447113,
0.01368667185306549,
0.0020887828432023525,
-0.017479579895734787,
0.026049403473734856,
0.0111550847068429,
-0.029341362416744232,
0.004870845004916191,
-0.015091121196746826,
-0.01382085494697094,
0.0029028267599642277,
0.06508772820234299,
-0.05052439495921135,
-0.04004022479057312,
0.017220158129930496,
-0.06540976464748383,
0.03585371375083923,
0.02871517464518547,
-0.04390469565987587,
-0.018928756937384605,
-0.01645084284245968,
-0.07643067091703415,
0.01592305675148964,
-0.02322261407971382,
-0.04036226496100426,
-0.0047724442556500435,
0.041185252368450165,
-0.03170298412442207,
-0.017229104414582253,
0.01413394883275032,
0.006812026724219322,
-0.015609961934387684,
0.006803080905228853,
0.06444364786148071,
0.049200452864170074,
0.08122547715902328,
0.02595994807779789,
0.011146139353513718,
-0.02782062068581581,
-0.018275732174515724,
0.016406115144491196,
-0.039682403206825256,
0.05231350287795067,
0.034243516623973846,
0.00048249991959892213,
-0.010394713841378689,
-0.004097056109458208,
0.013534598052501678,
0.04261653870344162,
-0.002706025028601289,
0.0320071317255497,
0.017640599980950356,
0.010716753080487251,
0.04458455741405487,
0.01676393672823906,
0.05217037349939346,
-0.011700762435793877,
-0.005085537675768137,
-0.0060114008374512196,
0.04894997924566269,
-0.08351553231477737,
-0.015833601355552673,
0.011342940852046013,
-0.012112257070839405,
-0.04322483390569687,
-0.028679391369223595,
0.018374133855104446,
-0.026836611330509186,
0.017560089007019997,
0.008909755386412144,
0.0038465808611363173,
-0.04934358224272728,
-0.03651568293571472,
0.004211111459881067,
-0.0005071001360192895,
-0.005045283120125532,
0.06641166657209396,
0.008744262158870697,
-0.015431051142513752,
0.06179577112197876,
0.01867828145623207,
0.014670681208372116,
-0.061259038746356964,
0.0028357352130115032,
-0.003799616824835539,
-0.039396144449710846,
0.039789747446775436,
-0.017703218385577202,
0.04759025573730469,
-0.021737655624747276,
-0.023508870974183083,
-0.009119975380599499,
-0.04555067420005798,
-0.0492362380027771,
0.010027946904301643,
-0.02579892985522747,
-0.01996643841266632,
0.024743355810642242,
-0.0030057004187256098,
-0.03433297201991081,
0.012997865676879883,
-0.06530242413282394,
-0.05159785971045494,
-0.020199023187160492,
-0.03095155768096447,
0.018588826060295105,
0.013436196371912956,
-0.02451077103614807,
0.0010186730651184916,
-0.011450287885963917,
-0.027069196105003357,
-0.026049403473734856,
-0.054639339447021484,
-0.06254719197750092,
0.021898675709962845,
-0.055605459958314896,
0.013561434112489223,
0.011826000176370144,
0.0008956718957051635,
-0.01671026274561882,
0.049987662583589554,
-0.022417515516281128,
-0.0706697404384613,
0.06337018311023712,
0.018660390749573708,
0.023705672472715378,
0.05149051174521446,
-0.0024533134419471025,
-0.029126668348908424,
-0.061437949538230896,
-0.01705019362270832,
-0.07363966107368469,
-0.06859438121318817,
0.05023813620209694,
-0.017900019884109497,
-0.016021456569433212,
0.00843116920441389,
-0.043940477073192596,
-0.05349431186914444,
0.032669100910425186,
0.005573069676756859,
0.02180922031402588,
0.03157774731516838,
-0.04175776615738869,
-0.05020235478878021,
-0.02114724926650524,
-0.02007378451526165,
0.057788170874118805,
0.009822200052440166,
-0.04021913558244705,
-0.007787090260535479,
0.04569380357861519,
-0.018928756937384605,
-0.010913555510342121,
0.02372356504201889,
0.0028737538959831,
-0.032114479690790176,
-0.06730622053146362,
0.0340467132627964,
0.025727365165948868,
0.024349752813577652,
-0.004065746441483498,
-0.07192211598157883,
0.004651679191738367,
-0.038215335458517075,
-0.0129531379789114,
-0.008650334551930428,
-0.03134516254067421,
0.028911976143717766,
-0.03488759323954582,
0.04759025573730469,
-0.023061593994498253,
0.01379401795566082,
0.0480196438729763,
-0.0006591742858290672,
-0.05170520395040512,
0.055426549166440964,
0.047912295907735825,
-0.032275497913360596,
-0.021165139973163605,
0.0043721310794353485,
-0.021845001727342606,
0.023813020437955856,
-0.0027216796297580004,
0.037929076701402664,
0.003479813924059272,
0.0004858544853050262,
0.03843002766370773,
-0.016093021258711815,
-0.05310070887207985,
-0.025101177394390106,
-0.051848333328962326,
-0.04165042191743851,
-0.018588826060295105,
0.011199812404811382,
-0.010001110844314098,
-0.01786423847079277,
-0.03195345774292946,
0.02114724926650524,
0.011137194000184536,
-0.038501590490341187,
-0.02282901108264923,
-0.03585371375083923,
0.030522173270583153,
-0.05288601666688919,
-0.017640599980950356,
-0.032830122858285904,
-0.03410038724541664,
-0.018141549080610275,
-0.03225760534405708,
0.02697974070906639,
-0.015431051142513752,
-0.0069641005247831345,
-0.01578887365758419,
0.036032624542713165,
0.019501270726323128,
-0.023419415578246117,
-0.06641166657209396,
-0.06820077449083328,
0.014679626561701298,
-0.003153301775455475,
-0.0114950155839324,
0.048699505627155304,
0.01726488582789898,
0.008149384520947933,
0.034851811826229095,
0.030969450250267982,
-0.0713496059179306,
-0.052349284291267395,
0.019089777022600174,
0.0039449818432331085,
0.01642400585114956,
-0.03365311026573181,
-0.02366989105939865,
0.03746391087770462,
0.001657160697504878,
-0.01031420473009348,
-0.05231350287795067,
0.011933346278965473,
0.014402315020561218,
-0.03263331949710846,
-0.03039693459868431,
-0.015225304290652275,
-0.013436196371912956,
-0.017542198300361633,
0.001302693854086101,
-0.0046829888597130775,
-0.03549589216709137,
-0.010269477032124996,
-0.02826789766550064,
0.0363546647131443,
-0.017166486009955406,
0.02359832637012005,
0.03767860308289528,
0.001203174702823162,
0.0633344054222107,
-0.024761246517300606,
0.03644411638379097,
-0.010627297684550285,
0.07442686706781387,
-0.02816055156290531,
0.032275497913360596,
-0.0064094774425029755,
0.007545560598373413,
-0.06451521068811417,
-0.012326950207352638,
0.057000961154699326,
-0.026550354436039925,
0.0184456966817379,
0.08931224048137665,
-0.00048082260764203966,
-0.024045603349804878,
0.04490659758448601,
-0.008243312127888203,
0.02579892985522747,
0.0329553596675396,
0.024206623435020447,
-0.03596105799078941,
0.04075586795806885,
-0.01320361252874136,
0.011199812404811382,
-0.06841547042131424,
-0.015520506538450718,
0.003951691091060638,
0.034690793603658676,
-0.024743355810642242,
-0.04673148691654205,
0.019662290811538696,
0.04422673583030701,
0.0569651797413826
]
|
30,524 | networkx.algorithms.cycles | cycle_basis | Returns a list of cycles which form a basis for cycles of G.
A basis for cycles of a network is a minimal collection of
cycles such that any cycle in the network can be written
as a sum of cycles in the basis. Here summation of cycles
is defined as "exclusive or" of the edges. Cycle bases are
useful, e.g. when deriving equations for electric circuits
using Kirchhoff's Laws.
Parameters
----------
G : NetworkX Graph
root : node, optional
Specify starting node for basis.
Returns
-------
A list of cycle lists. Each cycle list is a list of nodes
which forms a cycle (loop) in G.
Examples
--------
>>> G = nx.Graph()
>>> nx.add_cycle(G, [0, 1, 2, 3])
>>> nx.add_cycle(G, [0, 3, 4, 5])
>>> nx.cycle_basis(G, 0)
[[3, 4, 5, 0], [1, 2, 3, 0]]
Notes
-----
This is adapted from algorithm CACM 491 [1]_.
References
----------
.. [1] Paton, K. An algorithm for finding a fundamental set of
cycles of a graph. Comm. ACM 12, 9 (Sept 1969), 514-518.
See Also
--------
simple_cycles
minimum_cycle_basis
| def recursive_simple_cycles(G):
"""Find simple cycles (elementary circuits) of a directed graph.
A `simple cycle`, or `elementary circuit`, is a closed path where
no node appears twice. Two elementary circuits are distinct if they
are not cyclic permutations of each other.
This version uses a recursive algorithm to build a list of cycles.
You should probably use the iterator version called simple_cycles().
Warning: This recursive version uses lots of RAM!
It appears in NetworkX for pedagogical value.
Parameters
----------
G : NetworkX DiGraph
A directed graph
Returns
-------
A list of cycles, where each cycle is represented by a list of nodes
along the cycle.
Example:
>>> edges = [(0, 0), (0, 1), (0, 2), (1, 2), (2, 0), (2, 1), (2, 2)]
>>> G = nx.DiGraph(edges)
>>> nx.recursive_simple_cycles(G)
[[0], [2], [0, 1, 2], [0, 2], [1, 2]]
Notes
-----
The implementation follows pp. 79-80 in [1]_.
The time complexity is $O((n+e)(c+1))$ for $n$ nodes, $e$ edges and $c$
elementary circuits.
References
----------
.. [1] Finding all the elementary circuits of a directed graph.
D. B. Johnson, SIAM Journal on Computing 4, no. 1, 77-84, 1975.
https://doi.org/10.1137/0204007
See Also
--------
simple_cycles, cycle_basis
"""
# Jon Olav Vik, 2010-08-09
def _unblock(thisnode):
"""Recursively unblock and remove nodes from B[thisnode]."""
if blocked[thisnode]:
blocked[thisnode] = False
while B[thisnode]:
_unblock(B[thisnode].pop())
def circuit(thisnode, startnode, component):
closed = False # set to True if elementary path is closed
path.append(thisnode)
blocked[thisnode] = True
for nextnode in component[thisnode]: # direct successors of thisnode
if nextnode == startnode:
result.append(path[:])
closed = True
elif not blocked[nextnode]:
if circuit(nextnode, startnode, component):
closed = True
if closed:
_unblock(thisnode)
else:
for nextnode in component[thisnode]:
if thisnode not in B[nextnode]: # TODO: use set for speedup?
B[nextnode].append(thisnode)
path.pop() # remove thisnode from path
return closed
path = [] # stack of nodes in current path
blocked = defaultdict(bool) # vertex: blocked from search?
B = defaultdict(list) # graph portions that yield no elementary circuit
result = [] # list to accumulate the circuits found
# Johnson's algorithm exclude self cycle edges like (v, v)
# To be backward compatible, we record those cycles in advance
# and then remove from subG
for v in G:
if G.has_edge(v, v):
result.append([v])
G.remove_edge(v, v)
# Johnson's algorithm requires some ordering of the nodes.
# They might not be sortable so we assign an arbitrary ordering.
ordering = dict(zip(G, range(len(G))))
for s in ordering:
# Build the subgraph induced by s and following nodes in the ordering
subgraph = G.subgraph(node for node in G if ordering[node] >= ordering[s])
# Find the strongly connected component in the subgraph
# that contains the least node according to the ordering
strongcomp = nx.strongly_connected_components(subgraph)
mincomp = min(strongcomp, key=lambda ns: min(ordering[n] for n in ns))
component = G.subgraph(mincomp)
if len(component) > 1:
# smallest node in the component according to the ordering
startnode = min(component, key=ordering.__getitem__)
for node in component:
blocked[node] = False
B[node][:] = []
dummy = circuit(startnode, startnode, component)
return result
| (G, root=None, *, backend=None, **backend_kwargs) | [
0.021105309948325157,
-0.03184344246983528,
-0.04127347469329834,
0.02903200499713421,
-0.03898918256163597,
-0.0010597804794088006,
-0.03861822932958603,
-0.01459409762173891,
0.07567454874515533,
-0.05911829695105553,
-0.025049133226275444,
0.039106324315071106,
0.00016198716184590012,
0.002402657177299261,
-0.029969150200486183,
-0.02836819365620613,
0.0031164989341050386,
0.0029114980716258287,
-0.03613869473338127,
0.0388525128364563,
-0.015980293974280357,
-0.042171575129032135,
0.04107823595404625,
0.04759921133518219,
-0.018860064446926117,
0.059157345443964005,
-0.0024685501120984554,
0.024229131639003754,
-0.09785366803407669,
-0.02063673734664917,
0.012973615899682045,
0.001964590046554804,
-0.07961837202310562,
-0.049942076206207275,
0.02434627339243889,
0.06618594378232956,
0.015052909031510353,
0.05232398957014084,
-0.0784078910946846,
0.009117650799453259,
0.031980108469724655,
-0.009986463002860546,
0.011294562369585037,
-0.050332553684711456,
0.0433039590716362,
-0.014662431553006172,
0.029773911461234093,
0.085905060172081,
-0.014340287074446678,
-0.0543544739484787,
0.05154303461313248,
-0.005730257835239172,
-0.04146871343255043,
0.0011384860845282674,
0.0445534884929657,
0.011118847876787186,
0.01023051142692566,
0.04353824630379677,
0.07258976995944977,
-0.024971038103103638,
-0.013959571719169617,
-0.021808169782161713,
0.02452198974788189,
0.052167799323797226,
-0.058688774704933167,
-0.014916242100298405,
-0.013403140939772129,
-0.04736492410302162,
-0.008326933719217777,
0.0022769721690565348,
0.0037192984018474817,
-0.004824838135391474,
0.017698394134640694,
-0.0477554015815258,
-0.014828383922576904,
-0.052206847816705704,
-0.00848312396556139,
-0.008034075610339642,
-0.0051591843366622925,
-0.02225722000002861,
0.02452198974788189,
-0.011167657561600208,
0.002412419067695737,
-0.047286830842494965,
0.029090575873851776,
-0.00037217390490695834,
0.015316481702029705,
0.03650964796543121,
-0.04018013924360275,
-0.023799605667591095,
-0.007238477468490601,
-0.02469770424067974,
0.006667403969913721,
0.09004411846399307,
0.027470095083117485,
0.003384952200576663,
-0.03567012399435043,
-0.05533066764473915,
0.030769629403948784,
0.0015240826178342104,
0.007092048414051533,
0.003916977904736996,
-0.1169089749455452,
-0.013373855501413345,
-0.024190083146095276,
-0.026259614154696465,
-0.033600591123104095,
0.023370079696178436,
0.008214671164751053,
-0.08645172417163849,
-0.051777321845293045,
0.056502100080251694,
0.015980293974280357,
-0.03469393029808998,
-0.01082598976790905,
0.05946972966194153,
0.028329145163297653,
-0.02719675935804844,
0.0071213338524103165,
-0.01428171619772911,
-0.014535525813698769,
-0.021593406796455383,
-0.041546810418367386,
0.04447539150714874,
0.020792929455637932,
-0.0016229222528636456,
0.009010269306600094,
0.021339597180485725,
0.008761339820921421,
-0.008253718726336956,
0.06189068779349327,
0.038110606372356415,
0.02346769906580448,
0.07032500207424164,
-0.0006790648330934346,
-0.02284293621778488,
-0.0518554151058197,
-0.019728876650333405,
-0.019094351679086685,
0.016497675329446793,
-0.01611695997416973,
-0.10503845661878586,
0.012212185189127922,
0.06649832427501678,
0.039535850286483765,
-0.015492196194827557,
0.03572869300842285,
-0.024600084871053696,
0.0028797718696296215,
0.03022296167910099,
0.014428145252168179,
0.0024258417543023825,
0.025791041553020477,
0.0019865543581545353,
0.021905789151787758,
-0.0033434638753533363,
-0.04049251973628998,
0.04549063369631767,
-0.0461544431746006,
0.024385321885347366,
-0.031980108469724655,
-0.006335497833788395,
-0.024639131501317024,
0.006950499955564737,
-0.02799723856151104,
0.019094351679086685,
0.023526271805167198,
-0.008561220020055771,
-0.052167799323797226,
0.025459134951233864,
0.007297048810869455,
0.006428236607462168,
-0.07161357998847961,
0.011157895438373089,
0.0037241794634610415,
0.03574821725487709,
0.013227426446974277,
0.03719298541545868,
0.010689322836697102,
-0.018850302323698997,
-0.02167150378227234,
-0.00929824635386467,
-0.026318185031414032,
-0.01541410107165575,
0.014369573444128036,
0.028758671134710312,
0.06829451769590378,
-0.051191605627536774,
0.058142103254795074,
0.009185983799397945,
-0.06314022094011307,
0.010318368673324585,
0.04494396597146988,
0.05763448402285576,
0.06993452459573746,
-0.03779822587966919,
-0.020343879237771034,
0.0298520065844059,
-0.058688774704933167,
0.08145361393690109,
0.014174334704875946,
0.030691534280776978,
0.053651612251996994,
-0.0022269422188401222,
0.04517824947834015,
0.0327024944126606,
0.014681954868137836,
-0.005539900157600641,
0.0163512472063303,
0.013559332117438316,
-0.05618971586227417,
-0.05103541538119316,
0.031902015209198,
-0.01654648594558239,
-0.04123442620038986,
0.02637675777077675,
-0.003289773128926754,
0.019299352541565895,
0.01775696501135826,
-0.06876309216022491,
-0.033210113644599915,
0.010171939618885517,
-0.008941935375332832,
-0.022784363478422165,
-0.009971819818019867,
-0.0251272302120924,
0.039145372807979584,
0.012485519051551819,
0.026864854618906975,
-0.02167150378227234,
0.027860572561621666,
0.004688170738518238,
0.04357729107141495,
-0.011362896300852299,
0.010455035604536533,
-0.053456373512744904,
-0.03676345944404602,
0.004683290142565966,
0.020304832607507706,
-0.00237825233489275,
-0.048731595277786255,
-0.06973928958177567,
-0.0008865060517564416,
-0.01275885384529829,
0.014516002498567104,
-0.01571672037243843,
0.04049251973628998,
-0.00016930862329900265,
-0.013842429034411907,
-0.0013227426679804921,
-0.08106313645839691,
-0.0518554151058197,
-0.0007126214914023876,
-0.06548308581113815,
0.008458719588816166,
-0.04025823250412941,
-0.04533444344997406,
-0.02694294974207878,
-0.0005219586309976876,
0.01143123023211956,
0.01142146810889244,
0.01677100919187069,
-0.047286830842494965,
0.021925313398241997,
-0.0024307225830852985,
0.008644196204841137,
0.01122622936964035,
0.01733720302581787,
-0.03358106687664986,
0.02696247398853302,
0.0759088322520256,
-0.058688774704933167,
0.01142146810889244,
0.008629553951323032,
-0.04720873385667801,
0.027060093358159065,
-0.005603352561593056,
0.03123820200562477,
-0.02270626835525036,
-0.052636370062828064,
-0.07872027158737183,
0.027431046590209007,
0.0006827255710959435,
-0.004497813060879707,
-0.04701349511742592,
-0.014740526676177979,
0.004785790108144283,
-0.04248395562171936,
0.0006238488713279366,
-0.00567656708881259,
0.07442501932382584,
-0.03371773660182953,
0.05123065412044525,
0.028543908149003983,
0.04470967873930931,
0.006403831765055656,
-0.020949119701981544,
-0.07836884260177612,
0.0023196805268526077,
0.026279138401150703,
0.010952894575893879,
-0.050176363438367844,
0.0018047383055090904,
-0.026220565661787987,
0.007370263338088989,
-0.04470967873930931,
0.009356818161904812,
-0.02372151054441929,
-0.00007348146755248308,
-0.011685039848089218,
-0.04908302426338196,
0.024053415283560753,
0.011499563232064247,
0.02208150364458561,
-0.004758944734930992,
-0.060172587633132935,
-0.028329145163297653,
-0.02163245528936386,
0.06794308871030807,
0.052363038063049316,
0.015677673742175102,
0.04349919781088829,
-0.04310872033238411,
0.04084394872188568,
-0.05950877442955971,
0.044865868985652924,
0.06372593343257904,
0.052597325295209885,
0.037036795169115067,
0.0053739468567073345,
-0.0056082336232066154,
0.02284293621778488,
-0.0140767153352499,
0.04310872033238411,
0.0036826911382377148,
0.011509325355291367,
0.06271069496870041,
-0.054666854441165924,
-0.022120552137494087,
-0.07993075251579285,
0.076104074716568,
0.054042089730501175,
-0.013940048404037952,
-0.018752682954072952,
0.002628401853144169,
-0.009142055176198483,
0.04939540848135948,
0.011665516532957554,
-0.02061721310019493,
0.02594723179936409,
0.03291725739836693,
0.06817737966775894,
-0.036021552979946136,
0.019465304911136627,
-0.025029610842466354,
0.029891055077314377,
0.010679560713469982,
-0.005344661418348551,
-0.010650274343788624,
-0.005168946459889412,
0.026220565661787987,
0.03691964969038963,
-0.008107289671897888,
-0.013930286280810833,
0.04849730804562569,
-0.006003592163324356,
-0.017610536888241768,
0.04346014931797981,
0.0019963164813816547,
-0.05497923865914345,
-0.03414725884795189,
-0.00016335993132088333,
0.006062163505703211,
-0.003211677772924304,
0.002198876580223441,
0.0352015495300293,
0.02493199147284031,
-0.016282912343740463,
0.0527535155415535,
0.02698199823498726,
-0.0010732030496001244,
-0.006755261216312647,
0.0011049293680116534,
0.01155813504010439,
0.03024248592555523,
-0.0028163192328065634,
0.04459253326058388,
0.027021044865250587,
0.08278124034404755,
-0.011372658424079418,
-0.04611539840698242,
-0.050762079656124115,
0.023819129914045334,
0.009107888676226139,
-0.0458030141890049,
-0.012592900544404984,
0.14377382397651672,
0.03553345426917076,
-0.007995027117431164,
-0.013940048404037952,
-0.0002827911521308124,
0.013764332979917526,
0.030281532555818558,
0.028856290504336357,
0.0055057331919670105,
-0.028329145163297653,
0.047911591827869415,
0.00018303634715266526,
0.002726021222770214,
-0.007458121050149202,
-0.03123820200562477,
0.009840033948421478,
0.004680849611759186,
-0.01695648767054081,
0.01328599825501442,
-0.05579923838376999,
-0.03783727437257767,
-0.0008425773121416569,
0.07344882190227509,
0.02469770424067974,
0.04287443310022354,
-0.008448957465589046,
0.04576396569609642,
-0.008219552226364613,
0.009581342339515686,
0.020968643948435783,
0.026923425495624542,
0.03346392512321472,
-0.046466827392578125,
0.0682554766535759,
-0.003201915882527828,
-0.029071051627397537,
-0.028953909873962402,
-0.049161121249198914,
-0.019758163020014763,
-0.024619609117507935,
0.0436553880572319,
-0.020578166469931602,
0.05736114829778671,
0.026318185031414032,
-0.021612931042909622,
0.06478022038936615,
-0.009371460415422916,
-0.035552978515625,
0.05162113159894943,
-0.018450062721967697,
0.00414638314396143,
0.03317106515169144,
0.011977897956967354,
-0.017024820670485497,
0.021320072934031487,
-0.02881724201142788,
0.030984392389655113,
-0.05146493762731552,
-0.12284423410892487,
0.031355347484350204,
0.018010776489973068,
0.018635541200637817,
-0.05044969916343689,
0.025244371965527534,
0.06681070476770401,
0.02223769575357437,
0.016907677054405212,
0.013754570856690407,
-0.05349542200565338,
-0.042796336114406586,
0.01142146810889244,
0.014916242100298405,
-0.02188626490533352,
0.0040463232435286045,
0.03447916731238365,
-0.022784363478422165,
-0.08051646500825882,
-0.03266344591975212,
0.030398676171898842,
-0.021163882687687874,
-0.07165262848138809,
-0.013159092515707016,
-0.0017620298312976956,
-0.08121933043003082,
-0.07536216080188751,
-0.014623383991420269,
0.022179123014211655,
-0.01760077476501465,
-0.0037851915694773197,
-0.030886773020029068,
0.03916489705443382,
-0.005437399726361036,
-0.02290150709450245,
-0.0597040131688118,
-0.052206847816705704,
-0.02044149860739708,
-0.021593406796455383,
0.01023051142692566,
0.02553723007440567,
0.06891928613185883,
-0.044241104274988174,
-0.018479349091649055,
0.08871649205684662,
-0.024424370378255844,
0.012456233613193035,
-0.004514896310865879,
-0.0006918773869983852,
0.00868324376642704,
0.04537348821759224,
0.03104296326637268,
0.015257909893989563,
-0.007218953222036362,
0.025459134951233864,
0.006769904401153326,
0.028114382177591324,
-0.006052401848137379,
0.019318876788020134,
0.04498301073908806,
0.01094313245266676,
0.0017034582560881972,
-0.013764332979917526,
-0.004173228517174721,
0.03637298196554184,
-0.027079617604613304,
0.012973615899682045,
0.02018768899142742,
0.004876088351011276,
0.053612563759088516,
-0.008478243835270405,
0.019855782389640808,
-0.0006037148996256292,
-0.050566840916872025,
-0.026806281879544258,
-0.008405028842389584,
0.00607192562893033,
0.020324354991316795,
-0.025693422183394432,
0.0960574746131897,
0.010152416303753853,
-0.01692720130085945,
0.04720873385667801,
0.018479349091649055,
-0.058688774704933167,
0.000943857419770211,
0.022960079833865166,
0.03904775157570839,
0.07071547955274582,
0.009205508045852184,
0.006725975312292576,
0.020500071346759796,
0.056463051587343216,
0.016800295561552048,
-0.03303439915180206,
-0.03678298369050026,
-0.004056085366755724,
0.006672285031527281,
-0.007463001646101475,
-0.02797771617770195,
0.06282783299684525,
-0.08504600822925568,
-0.020695310086011887,
0.014525764621794224,
0.0028797718696296215,
0.02448294125497341,
-0.03307344764471054,
0.0034874523989856243,
-0.0657564178109169,
-0.08246885240077972,
0.04107823595404625,
-0.022354839369654655,
0.07532311975955963,
-0.029539626091718674,
0.018508635461330414,
0.03332725912332535,
0.012973615899682045,
-0.00209271558560431,
0.03295630216598511,
-0.02676723524928093,
-0.0010060897329822183,
0.037114888429641724,
-0.020480547100305557,
-0.021515311673283577,
0.000978634343482554,
-0.06946595013141632,
-0.007594787981361151,
-0.04435824602842331,
-0.007111572194844484,
0.012495281174778938,
0.05939163267612457,
-0.008107289671897888,
-0.022608648985624313,
0.004092692863196135,
-0.030496295541524887,
-0.007326334714889526,
0.030125342309474945,
-0.05919639393687248,
0.03067201003432274,
-0.005725376773625612,
-0.020539117977023125,
0.03221439570188522,
-0.0027772714383900166,
0.027313902974128723,
-0.0035240596625953913,
-0.014106000773608685,
-0.03201915696263313,
0.015804577618837357,
0.04049251973628998,
0.049942076206207275,
-0.0346548818051815,
0.02350674755871296,
0.019767925143241882,
-0.06306212395429611,
0.04416300728917122,
-0.018869826570153236,
0.001953607890754938,
0.052636370062828064,
-0.003362987656146288,
0.006472165230661631,
-0.06692785024642944,
0.011802183464169502,
-0.04338205233216286,
0.01521886233240366,
-0.024190083146095276,
-0.008034075610339642,
0.0069358572363853455,
0.0013044390361756086,
0.013256711885333061,
-0.02801676280796528,
-0.07091072201728821,
0.025595802813768387,
0.023409128189086914,
0.00948372296988964,
0.02940295822918415,
0.07001262158155441,
0.0136764757335186,
-0.0047711473889648914,
-0.012231708504259586,
0.05822020024061203,
0.007297048810869455,
-0.06946595013141632,
0.0019438460003584623,
-0.002621080493554473,
-0.013188378885388374,
0.08738887310028076,
-0.06649832427501678,
-0.015501958318054676,
-0.052441131323575974,
0.018245061859488487,
-0.07821264863014221,
-0.04552968218922615,
0.031179631128907204,
-0.04474872723221779,
0.019113875925540924,
0.04123442620038986,
-0.030984392389655113,
0.02329198457300663,
0.029910579323768616,
-0.014496478252112865,
-0.005901091732084751,
0.053417325019836426,
0.03980918601155281,
-0.031902015209198,
0.017727680504322052,
-0.0404534712433815,
0.05642400309443474,
0.0053202565759420395,
0.015355529263615608,
-0.012895520776510239,
-0.02106626331806183,
-0.0030164390336722136,
0.07348787039518356,
-0.021320072934031487,
-0.03459630906581879,
0.015375052578747272,
-0.02227674424648285,
-0.06782595068216324,
0.002301377011463046,
-0.02413151226937771,
-0.0777050256729126,
-0.004026799462735653,
-0.03797394037246704,
0.040765855461359024,
-0.007541097234934568,
-0.0171517264097929,
0.016692914068698883,
0.012280518189072609,
-0.02979343570768833,
-0.033405352383852005,
-0.0006394069641828537,
-0.0025234611239284277,
-0.002167150378227234,
-0.053456373512744904,
0.037485841661691666,
-0.07856407761573792,
0.001818160992115736,
0.013168854638934135,
0.03365916386246681,
0.018225539475679398,
-0.014437906444072723,
0.02475627511739731,
0.016624581068754196,
0.010005987249314785,
0.04439729452133179,
-0.053183041512966156,
0.05419827997684479,
-0.013149331323802471,
0.020480547100305557,
0.028875812888145447,
-0.0025673897471278906,
0.00011874482879647985,
-0.05146493762731552,
0.0050029936246573925,
0.03004724718630314,
0.043811578303575516,
-0.001637565204873681,
0.009517889469861984,
-0.0033703092485666275,
-0.003802275052294135,
0.01778625138103962,
-0.06739642471075058,
-0.014564812183380127,
-0.023760557174682617,
-0.0461544431746006,
0.029285814613103867,
-0.0051591843366622925,
0.009146936237812042,
-0.02676723524928093,
0.03080867789685726,
-0.02249150536954403,
0.0903564989566803,
0.051152557134628296,
-0.023233413696289062,
0.014984575100243092,
-0.02061721310019493,
-0.04119538143277168,
0.06282783299684525,
-0.011040751822292805,
0.03127725049853325,
0.02532246895134449,
-0.04447539150714874,
-0.020714832469820976,
0.003382511669769883,
-0.010123129934072495,
0.029754387214779854,
-0.006125616375356913,
-0.03594345599412918,
-0.06282783299684525,
0.02963724546134472,
-0.018293872475624084,
-0.022003408521413803,
0.010972418822348118,
0.06212497502565384,
0.018020538613200188,
-0.09746319055557251,
-0.005696090869605541,
-0.031726300716400146,
-0.027899619191884995,
-0.039516326040029526,
-0.0087759830057621,
0.010191463865339756,
-0.059782110154628754,
-0.01001574844121933,
-0.05142589285969734,
-0.05357351899147034,
-0.013930286280810833,
0.007794907782226801,
0.022120552137494087,
0.023331033065915108,
-0.0343034528195858,
0.029324863106012344,
0.00031543264049105346,
0.05599447712302208
]
|
30,525 | networkx.generators.classic | cycle_graph | Returns the cycle graph $C_n$ of cyclically connected nodes.
$C_n$ is a path with its two end-nodes connected.
.. plot::
>>> nx.draw(nx.cycle_graph(5))
Parameters
----------
n : int or iterable container of nodes
If n is an integer, nodes are from `range(n)`.
If n is a container of nodes, those nodes appear in the graph.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
If create_using is directed, the direction is in increasing order.
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (n, create_using=None, *, backend=None, **backend_kwargs) | [
0.02225247211754322,
-0.006895069498568773,
0.02168417163193226,
-0.0502234548330307,
-0.012653540819883347,
0.06673965603113174,
-0.047559551894664764,
0.007436729967594147,
-0.0006354519282467663,
0.0049814991652965546,
0.004182328004390001,
0.06244189292192459,
0.016960183158516884,
0.07608107477426529,
0.02701197937130928,
-0.007583244703710079,
0.014793542213737965,
0.011836609803140163,
-0.02283853106200695,
0.03800502046942711,
-0.019801679998636246,
0.015130970627069473,
0.03425779566168785,
0.013941093347966671,
-0.020849483087658882,
0.012058601714670658,
0.022216953337192535,
0.03244633972644806,
-0.03736568242311478,
0.027260608971118927,
0.03315671533346176,
-0.01215627882629633,
0.0011676775757223368,
0.018363172188401222,
0.020671889185905457,
0.04237382113933563,
-0.02145330049097538,
0.05313599109649658,
-0.1044960469007492,
-0.01573478803038597,
0.046387434005737305,
-0.005953823681920767,
0.014837941154837608,
-0.03299688175320625,
0.012174038216471672,
0.028450487181544304,
0.0834689661860466,
0.004541954956948757,
-0.06876422464847565,
-0.017555123195052147,
0.04290660098195076,
0.004220066592097282,
-0.04329730570316315,
-0.058321721851825714,
-0.0019435393624007702,
0.010087313130497932,
-0.007561045233160257,
-0.01233387179672718,
0.059493839740753174,
-0.03995854780077934,
0.03365397825837135,
0.032108914107084274,
0.006206894759088755,
-0.023548904806375504,
-0.05622611939907074,
-0.02180848829448223,
-0.03885746747255325,
-0.06141185015439987,
-0.014305160380899906,
-0.018931472674012184,
0.0540594756603241,
0.041485853493213654,
0.030190903693437576,
-0.009634450078010559,
0.012893292121589184,
0.026337122544646263,
0.0364777147769928,
0.01084208581596613,
-0.01046913955360651,
-0.009052830748260021,
-0.02283853106200695,
-0.036211322993040085,
0.022003840655088425,
-0.048056814819574356,
0.046316396445035934,
0.09824474900960922,
-0.019677365198731422,
0.021027076989412308,
-0.04457598179578781,
-0.023992888629436493,
-0.024401353672146797,
-0.027793390676379204,
-0.026106251403689384,
0.0055098398588597775,
-0.0127068180590868,
0.01596565917134285,
0.050330013036727905,
-0.09249071776866913,
0.012351631186902523,
-0.0009695497574284673,
-0.03754327446222305,
-0.03336982801556587,
-0.08865469694137573,
-0.021844007074832916,
-0.05665234103798866,
-0.031434059143066406,
-0.02534259855747223,
0.05682993680238724,
-0.013115284033119678,
0.028539283201098442,
-0.019055787473917007,
0.01742192730307579,
0.06613583862781525,
-0.01362142525613308,
0.029782438650727272,
0.04269348829984665,
-0.018185580149292946,
0.03864435479044914,
0.06521235406398773,
-0.023051641881465912,
-0.058463796973228455,
0.044185273349285126,
-0.040384773164987564,
0.029746919870376587,
0.02686990424990654,
-0.0003812711511272937,
0.04457598179578781,
-0.05313599109649658,
0.030208662152290344,
0.021062595769762993,
-0.0015495037660002708,
0.01896699145436287,
-0.0010544616961851716,
0.06819592416286469,
-0.03530559688806534,
0.01322183944284916,
-0.07885153591632843,
-0.02834393084049225,
-0.0012775636278092861,
-0.014287400990724564,
0.03392036631703377,
-0.03413347899913788,
0.03875091299414635,
0.0495130829513073,
-0.06070147454738617,
0.015477278269827366,
0.01873612031340599,
0.019144585356116295,
0.01331951655447483,
-0.014482754282653332,
0.023690979927778244,
0.002009026939049363,
0.09533222019672394,
0.030723683536052704,
-0.02211039699614048,
-0.018398690968751907,
0.02710077539086342,
-0.02234126813709736,
-0.012147398665547371,
0.029853476211428642,
-0.007463369052857161,
0.011845489963889122,
0.03988751024007797,
-0.016596117988228798,
-0.07615211606025696,
-0.0033232192508876324,
-0.006291251629590988,
-0.004397660028189421,
0.0065665217116475105,
-0.02717181295156479,
-0.04166344553232193,
-0.0009062821045517921,
0.0012575843138620257,
-0.05601300671696663,
-0.004568594042211771,
-0.0020434358157217503,
-0.030865758657455444,
-0.01119727361947298,
-0.017191056162118912,
-0.02591089904308319,
0.029675882309675217,
-0.07064671069383621,
0.029107581824064255,
-0.041770003736019135,
-0.01208524126559496,
0.017697196453809738,
0.00995411816984415,
0.014109807088971138,
0.029125342145562172,
0.03354742005467415,
0.04670710489153862,
0.025093968957662582,
-0.012884411960840225,
0.05601300671696663,
0.022891808301210403,
-0.05842827633023262,
0.06986530125141144,
0.036211322993040085,
-0.0722450539469719,
0.05526711419224739,
0.07743078470230103,
0.07132156938314438,
0.020458776503801346,
-0.010362583212554455,
0.04848304018378258,
-0.0005799539503641427,
-0.051217980682849884,
-0.048127852380275726,
-0.05182179808616638,
0.028716877102851868,
-0.008044987916946411,
0.019677365198731422,
0.037969499826431274,
0.04454046115279198,
-0.06485716253519058,
0.06968770921230316,
0.038999542593955994,
0.03177148476243019,
0.01002515573054552,
-0.061092179268598557,
-0.035181280225515366,
-0.015672631561756134,
0.0032344225328415632,
0.034222278743982315,
-0.008373536169528961,
-0.005767350550740957,
-0.008373536169528961,
-0.016826989129185677,
-0.004586353432387114,
-0.06269052624702454,
0.026550235226750374,
-0.02656799554824829,
0.04422079399228096,
-0.015273044817149639,
0.012609141878783703,
-0.01522864680737257,
0.03345862403512001,
-0.011694535613059998,
-0.04237382113933563,
0.032322026789188385,
-0.05512503907084465,
-0.019499771296977997,
0.007396771106868982,
-0.009394698776304722,
-0.01383453793823719,
0.07970398664474487,
-0.01039810199290514,
0.031434059143066406,
0.0024907495826482773,
-0.011694535613059998,
-0.0044820173643529415,
-0.019055787473917007,
0.01284889318048954,
-0.030919037759304047,
0.0188959538936615,
0.030546089634299278,
-0.05697201192378998,
-0.0074678086675703526,
0.015166489407420158,
0.04269348829984665,
-0.02759803831577301,
-0.008773121051490307,
-0.0580020546913147,
-0.02834393084049225,
0.06176703795790672,
0.01807902380824089,
-0.06869318336248398,
0.05288735777139664,
-0.05952935665845871,
-0.028663598001003265,
0.05704304948449135,
0.08140888065099716,
0.10527745634317398,
0.004477577283978462,
0.012760096229612827,
-0.056119561195373535,
0.0025018490850925446,
0.039851993322372437,
-0.04290660098195076,
-0.03162940964102745,
-0.053917400538921356,
-0.03711705282330513,
-0.01175669301301241,
0.04283556342124939,
0.02532484009861946,
0.032322026789188385,
0.049974825233221054,
-0.004082431551069021,
0.025680027902126312,
-0.028805673122406006,
0.019677365198731422,
-0.014837941154837608,
-0.03683290258049965,
-0.0030990075320005417,
0.030475053936243057,
0.020245663821697235,
-0.026479197666049004,
0.015273044817149639,
0.002346454653888941,
0.052532173693180084,
0.09412457793951035,
-0.05310047045350075,
0.036655306816101074,
0.0224833432585001,
0.045357391238212585,
0.02701197937130928,
0.0004706229083240032,
0.01039810199290514,
0.012760096229612827,
0.014695866033434868,
-0.05448570102453232,
0.014349558390676975,
0.005061415955424309,
0.009323661215603352,
-0.010513538494706154,
-0.05864138901233673,
-0.020441018044948578,
-0.02145330049097538,
0.038040537387132645,
0.038253650069236755,
0.019144585356116295,
0.005256769247353077,
-0.052603207528591156,
0.02129346691071987,
-0.052461136132478714,
0.05334910377860069,
-0.01003403589129448,
0.057149603962898254,
-0.04912237450480461,
0.02100931666791439,
0.019002510234713554,
-0.0195530503988266,
-0.031132148578763008,
0.035394392907619476,
-0.07213850319385529,
0.03551870957016945,
0.013905574567615986,
-0.032552897930145264,
-0.01548615749925375,
-0.051075905561447144,
0.029782438650727272,
0.010531297884881496,
-0.015548314899206161,
0.007050463929772377,
-0.03010210581123829,
0.03864435479044914,
0.04695573449134827,
-0.09348524361848831,
-0.03786294534802437,
-0.0267278291285038,
0.03155837208032608,
0.07870946079492569,
-0.02628384530544281,
-0.029782438650727272,
0.040242698043584824,
0.06641998887062073,
0.005345565732568502,
0.012360511347651482,
-0.06404023617506027,
-0.01058457512408495,
-0.003749443916603923,
0.0035385515075176954,
0.062193259596824646,
-0.009856441989541054,
-0.005758470855653286,
0.02108035422861576,
-0.013568147085607052,
0.08702083677053452,
0.011667896062135696,
-0.006539882626384497,
-0.024152722209692,
-0.0736658051609993,
-0.07679145038127899,
0.05043656751513481,
-0.0057851099409163,
0.05423707142472267,
-0.01544175948947668,
-0.031807005405426025,
0.02717181295156479,
-0.0018902613082900643,
-0.041912078857421875,
-0.019730642437934875,
0.04251589626073837,
0.006917268969118595,
0.02644367888569832,
-0.00003877921699313447,
0.0411306656897068,
0.019304418936371803,
-0.04269348829984665,
-0.027562519535422325,
-0.053633250296115875,
-0.046458471566438675,
0.06240637227892876,
-0.004857183434069157,
-0.029338454827666283,
0.002228799043223262,
0.09561637043952942,
0.049015820026397705,
-0.05288735777139664,
0.017359768971800804,
0.05178627744317055,
-0.04571257904171944,
0.025537952780723572,
0.002623944776132703,
-0.0047195483930408955,
-0.03697497770190239,
0.010593455284833908,
-0.009936358779668808,
-0.02614177018404007,
-0.026603514328598976,
0.01997927390038967,
-0.07870946079492569,
-0.03038625605404377,
-0.0004234496154822409,
0.07153467833995819,
0.006215773988515139,
0.010406982153654099,
0.0009756545769050717,
0.02949828840792179,
0.004621872212737799,
0.023904092609882355,
-0.09384042769670486,
-0.015122090466320515,
0.09682400524616241,
0.05310047045350075,
-0.05072071775794029,
0.027988743036985397,
-0.0163208469748497,
-0.01200532354414463,
0.07267127931118011,
0.03413347899913788,
-0.023850813508033752,
0.035980451852083206,
0.006730795372277498,
0.007356812711805105,
-0.06155392527580261,
0.025378117337822914,
0.006158056203275919,
-0.0017437466885894537,
0.0013275117380544543,
0.031025592237710953,
-0.005301167257130146,
0.01868284121155739,
-0.021062595769762993,
-0.0026461437810212374,
-0.015770306810736656,
0.03814709559082985,
0.03475505858659744,
-0.002339794998988509,
-0.0339558869600296,
-0.006695276591926813,
-0.031434059143066406,
0.05221250280737877,
0.00030412894557230175,
-0.03878642991185188,
-0.007751958444714546,
0.019020268693566322,
-0.04578361660242081,
-0.059706952422857285,
0.04713332653045654,
-0.010930882766842842,
0.026852143928408623,
-0.020831722766160965,
0.02189728431403637,
-0.01672043278813362,
-0.042444858700037,
0.028095299378037453,
-0.005829508416354656,
-0.04116618633270264,
-0.0705401599407196,
0.024472391232848167,
0.013124163262546062,
-0.038999542593955994,
-0.031007833778858185,
0.038182612508535385,
-0.03477281704545021,
-0.026408160105347633,
-0.04656502977013588,
-0.000288034527329728,
-0.03088351897895336,
-0.060736995190382004,
0.015335203148424625,
-0.010176110081374645,
0.039567843079566956,
-0.04716884717345238,
-0.023708738386631012,
0.023175958544015884,
-0.047559551894664764,
0.0018491927767172456,
-0.03542991355061531,
-0.0031189867295324802,
-0.022607658058404922,
-0.015237526968121529,
0.01596565917134285,
-0.030634887516498566,
0.07089534401893616,
-0.01746632531285286,
-0.038395725190639496,
-0.0020012573804706335,
-0.009297022596001625,
0.019304418936371803,
-0.002124462742358446,
-0.022021600976586342,
0.014873459935188293,
0.006979426369071007,
0.05803757160902023,
-0.006655318196862936,
-0.012884411960840225,
0.00828917883336544,
0.042800046503543854,
0.0391061007976532,
0.03857331722974777,
0.024632224813103676,
0.041983116418123245,
-0.022643176838755608,
0.008013908751308918,
-0.021719690412282944,
-0.0076942406594753265,
0.04329730570316315,
-0.057362716645002365,
0.04123722389340401,
0.03821813315153122,
0.00988308060914278,
0.041841041296720505,
-0.025271562859416008,
-0.005936064291745424,
0.03843124583363533,
-0.02665679156780243,
0.016214290633797646,
-0.0005477651138789952,
0.022359028458595276,
0.06169600039720535,
-0.03946128487586975,
0.010779928416013718,
-0.04134377837181091,
-0.0808405801653862,
0.03471953794360161,
0.046742621809244156,
0.008151544257998466,
-0.020316701382398605,
0.002672782866284251,
-0.0022709774784743786,
-0.011099596507847309,
0.0019113505259156227,
0.0011987565085291862,
0.02964036352932453,
0.006140296813100576,
-0.06748554855585098,
0.026337122544646263,
-0.059635914862155914,
0.034222278743982315,
-0.0038981784600764513,
0.007436729967594147,
0.006588720716536045,
0.08368208259344101,
-0.006118097808212042,
0.007996149361133575,
-0.026834385469555855,
0.004186768084764481,
0.03242858126759529,
-0.062193259596824646,
0.006584280636161566,
-0.0017615059623494744,
-0.029604844748973846,
0.01866508275270462,
-0.0000034859672268794384,
0.008679884485900402,
-0.023016123101115227,
0.02466774359345436,
0.007569924928247929,
-0.005603076424449682,
0.06421782821416855,
0.08972026407718658,
-0.009279263205826283,
-0.016054457053542137,
-0.0072591365315020084,
-0.04269348829984665,
-0.004741747863590717,
-0.039709918200969696,
-0.01793694868683815,
-0.020334461703896523,
-0.019641846418380737,
0.002570666605606675,
0.0005610845983028412,
-0.002583986148238182,
0.06393367797136307,
-0.09433769434690475,
-0.004639631602913141,
-0.01786591112613678,
0.015610473230481148,
0.04503772407770157,
-0.05690097436308861,
0.06435990333557129,
0.03354742005467415,
-0.04372353106737137,
0.01072665024548769,
-0.020174626260995865,
-0.045641541481018066,
0.02651471644639969,
0.005931624677032232,
-0.046813659369945526,
0.08865469694137573,
-0.02086724154651165,
0.032908085733652115,
0.062264297157526016,
0.042942121624946594,
0.03155837208032608,
-0.016045577824115753,
-0.016303088515996933,
-0.08453452587127686,
-0.0060692597180604935,
0.05373980849981308,
-0.02093827910721302,
-0.04869615286588669,
-0.050187937915325165,
0.012724577449262142,
-0.028716877102851868,
0.05189283564686775,
-0.06531890481710434,
-0.029995551332831383,
-0.015832465142011642,
0.03542991355061531,
-0.01522864680737257,
-0.007743078749626875,
-0.02900102734565735,
0.0012187357060611248,
0.018469728529453278,
-0.029107581824064255,
0.0012997627491131425,
0.004060232546180487,
0.010673372074961662,
-0.05491192638874054,
-0.022962845861911774,
-0.03463074192404747,
-0.0115702198818326,
-0.007547725923359394,
0.009439096786081791,
-0.027544759213924408,
0.0038826388772577047,
0.09625570476055145,
-0.0430486761033535,
0.008329137228429317,
-0.029089823365211487,
-0.026301603764295578,
-0.0038182612042874098,
-0.031149908900260925,
0.018700601533055305,
-0.03654875233769417,
-0.006531002931296825,
-0.028130818158388138,
-0.0391061007976532,
-0.002901434665545821,
0.01772383600473404,
0.01880715601146221,
0.04276452586054802,
0.037294644862413406,
-0.034808333963155746,
-0.06240637227892876,
0.0054476819932460785,
-0.06173151731491089,
0.05381084606051445,
-0.015610473230481148,
0.029817957431077957,
0.06162496283650398,
0.0011965365847572684,
0.06105666235089302,
-0.003685066243633628,
-0.06148288771510124,
0.006033740937709808,
-0.0004462038050405681,
0.0046485112980008125,
0.008098266087472439,
0.038253650069236755,
-0.016942424699664116,
-0.055089518427848816,
-0.01501553412526846,
-0.014882339164614677,
0.028166336938738823,
-0.04461149871349335,
-0.009856441989541054,
0.009483495727181435,
-0.0091194286942482,
0.03281928971409798,
-0.024436872452497482,
-0.0199082363396883,
-0.01786591112613678,
-0.04098859056830406,
-0.05199939012527466,
0.018718359991908073,
0.011117355898022652,
-0.01749296486377716,
0.028219614177942276,
0.010771049186587334,
0.016303088515996933,
-0.0195530503988266,
0.014873459935188293,
-0.01599229872226715,
0.027189573273062706,
0.004233386367559433,
-0.05079175531864166,
0.03669082745909691,
-0.0014362878864631057,
-0.009341420605778694,
0.03768534958362579,
0.01746632531285286,
0.022820770740509033,
-0.03420451655983925,
0.012111879885196686,
-0.04141481593251228,
0.035696301609277725,
-0.07132156938314438,
-0.023193717002868652,
0.0042555853724479675,
0.02175520919263363,
-0.08716291189193726,
0.0052123707719147205,
0.029693640768527985,
0.005265648942440748,
-0.05192835256457329,
-0.0014917858643457294,
0.03361845761537552,
-0.04727540165185928,
-0.025822101160883904,
0.05111142247915268,
-0.035980451852083206,
0.009070590138435364,
-0.032108914107084274,
-0.037152569741010666,
-0.042196229100227356,
-0.029480529949069023,
-0.021027076989412308,
0.030439535155892372,
0.011792211793363094,
-0.016054457053542137,
0.018931472674012184,
-0.0016316407127305865,
0.020973797887563705,
0.02759803831577301,
-0.016560599207878113,
-0.016640515998005867,
0.002959152450785041,
-0.02145330049097538,
-0.06656206399202347,
-0.020902760326862335,
-0.016658274456858635,
-0.014473874121904373,
0.008329137228429317,
-0.01845197007060051,
0.0011621278245002031,
0.02928517572581768,
0.04134377837181091,
-0.00279265851713717,
0.008964034728705883,
0.02649695798754692,
-0.04471805691719055,
-0.024063926190137863,
0.015281924977898598,
-0.0055142794735729694,
-0.01786591112613678,
-0.04354593902826309,
-0.02283853106200695,
0.02834393084049225,
0.06404023617506027,
-0.010966401547193527,
-0.045144278556108475,
0.003292140318080783,
0.0456770621240139,
-0.003096787491813302
]
|
30,528 | networkx.readwrite.json_graph.cytoscape | cytoscape_data | Returns data in Cytoscape JSON format (cyjs).
Parameters
----------
G : NetworkX Graph
The graph to convert to cytoscape format
name : string
A string which is mapped to the 'name' node element in cyjs format.
Must not have the same value as `ident`.
ident : string
A string which is mapped to the 'id' node element in cyjs format.
Must not have the same value as `name`.
Returns
-------
data: dict
A dictionary with cyjs formatted data.
Raises
------
NetworkXError
If the values for `name` and `ident` are identical.
See Also
--------
cytoscape_graph: convert a dictionary in cyjs format to a graph
References
----------
.. [1] Cytoscape user's manual:
http://manual.cytoscape.org/en/stable/index.html
Examples
--------
>>> G = nx.path_graph(2)
>>> nx.cytoscape_data(G) # doctest: +SKIP
{'data': [],
'directed': False,
'multigraph': False,
'elements': {'nodes': [{'data': {'id': '0', 'value': 0, 'name': '0'}},
{'data': {'id': '1', 'value': 1, 'name': '1'}}],
'edges': [{'data': {'source': 0, 'target': 1}}]}}
| def cytoscape_data(G, name="name", ident="id"):
"""Returns data in Cytoscape JSON format (cyjs).
Parameters
----------
G : NetworkX Graph
The graph to convert to cytoscape format
name : string
A string which is mapped to the 'name' node element in cyjs format.
Must not have the same value as `ident`.
ident : string
A string which is mapped to the 'id' node element in cyjs format.
Must not have the same value as `name`.
Returns
-------
data: dict
A dictionary with cyjs formatted data.
Raises
------
NetworkXError
If the values for `name` and `ident` are identical.
See Also
--------
cytoscape_graph: convert a dictionary in cyjs format to a graph
References
----------
.. [1] Cytoscape user's manual:
http://manual.cytoscape.org/en/stable/index.html
Examples
--------
>>> G = nx.path_graph(2)
>>> nx.cytoscape_data(G) # doctest: +SKIP
{'data': [],
'directed': False,
'multigraph': False,
'elements': {'nodes': [{'data': {'id': '0', 'value': 0, 'name': '0'}},
{'data': {'id': '1', 'value': 1, 'name': '1'}}],
'edges': [{'data': {'source': 0, 'target': 1}}]}}
"""
if name == ident:
raise nx.NetworkXError("name and ident must be different.")
jsondata = {"data": list(G.graph.items())}
jsondata["directed"] = G.is_directed()
jsondata["multigraph"] = G.is_multigraph()
jsondata["elements"] = {"nodes": [], "edges": []}
nodes = jsondata["elements"]["nodes"]
edges = jsondata["elements"]["edges"]
for i, j in G.nodes.items():
n = {"data": j.copy()}
n["data"]["id"] = j.get(ident) or str(i)
n["data"]["value"] = i
n["data"]["name"] = j.get(name) or str(i)
nodes.append(n)
if G.is_multigraph():
for e in G.edges(keys=True):
n = {"data": G.adj[e[0]][e[1]][e[2]].copy()}
n["data"]["source"] = e[0]
n["data"]["target"] = e[1]
n["data"]["key"] = e[2]
edges.append(n)
else:
for e in G.edges():
n = {"data": G.adj[e[0]][e[1]].copy()}
n["data"]["source"] = e[0]
n["data"]["target"] = e[1]
edges.append(n)
return jsondata
| (G, name='name', ident='id') | [
0.0046446677297353745,
0.004635429009795189,
0.021414896473288536,
-0.02736450545489788,
-0.0338129960000515,
0.05070101469755173,
-0.06308063864707947,
-0.015668535605072975,
0.10701905190944672,
-0.027863387018442154,
0.01889277994632721,
0.00059242028510198,
0.0026653138920664787,
0.037305157631635666,
-0.017331469804048538,
-0.0594591349363327,
0.011270998977124691,
0.02810358814895153,
0.02102687954902649,
0.030043678358197212,
0.0028801097068935633,
-0.06064166873693466,
0.039356108754873276,
-0.02017693594098091,
-0.021451851353049278,
-0.025424417108297348,
0.034940093755722046,
0.05062710866332054,
-0.019973687827587128,
0.007972845807671547,
-0.05956999957561493,
-0.06348713487386703,
-0.027715569362044334,
0.034348830580711365,
0.025405939668416977,
0.0355498380959034,
-0.005067329853773117,
-0.008310051634907722,
-0.05938522890210152,
-0.03412710502743721,
-0.031226208433508873,
0.0022160906810313463,
-0.02939698100090027,
-0.024944012984633446,
0.006767218466848135,
0.0365106426179409,
-0.019807394593954086,
0.04105599969625473,
-0.01958566904067993,
-0.05166182294487953,
0.009589587338268757,
-0.055800680071115494,
-0.01895744912326336,
0.07124749571084976,
0.039060477167367935,
-0.012592107057571411,
0.022837629541754723,
0.06529788672924042,
0.05369429662823677,
0.03791489824652672,
-0.011003081686794758,
-0.0275123231112957,
0.017100507393479347,
-0.012943170964717865,
-0.08920717984437943,
0.03588242456316948,
-0.001703352783806622,
-0.05853528529405594,
-0.050811879336833954,
-0.009645018726587296,
0.000992563902400434,
-0.023890821263194084,
0.016296755522489548,
-0.0035083291586488485,
0.05591154471039772,
0.00540453614667058,
-0.03795185312628746,
0.03364670276641846,
-0.015031077899038792,
0.03673236817121506,
-0.05280739814043045,
-0.05639194697141647,
-0.004161954857409,
0.007072089705616236,
0.01836618408560753,
0.003836296731606126,
0.025091828778386116,
0.06134379655122757,
-0.02178443782031536,
-0.017830349504947662,
-0.0012575939763337374,
0.0017992024077102542,
-0.02250504307448864,
0.04512094706296921,
0.0034990906715393066,
-0.015631580725312233,
-0.0016617793589830399,
-0.008693450130522251,
0.03763774409890175,
0.07716014981269836,
0.0006137844175100327,
0.03423796594142914,
-0.04475140571594238,
-0.008688830770552158,
-0.029082871973514557,
-0.06611087173223495,
-0.010273237712681293,
0.04057559370994568,
-0.02867637574672699,
-0.06818030029535294,
-0.06489139050245285,
0.06252632290124893,
0.05387906730175018,
-0.03902352228760719,
0.09016799181699753,
0.004690860398113728,
0.01484630722552538,
-0.03488466516137123,
-0.03372060880064964,
-0.044788360595703125,
-0.04423404857516289,
0.06182419881224632,
0.004612332675606012,
0.059791721403598785,
-0.008674973621964455,
0.01484630722552538,
0.013746922835707664,
-0.011141658760607243,
-0.0212116502225399,
-0.022117024287581444,
0.06263718754053116,
0.008231524378061295,
0.012850785627961159,
0.033166300505399704,
0.07121054083108902,
-0.016296755522489548,
-0.029082871973514557,
-0.02721668966114521,
0.03780403733253479,
0.05720493569970131,
-0.000043991251004626974,
-0.06422621756792068,
-0.01479087583720684,
0.01925308257341385,
0.015770159661769867,
-0.04035387188196182,
-0.012213327921926975,
-0.07612543553113937,
-0.04659911245107651,
-0.02808511070907116,
0.03057951293885708,
0.06718254089355469,
0.05387906730175018,
-0.017229845747351646,
0.008735023438930511,
-0.04249720647931099,
-0.059643905609846115,
0.006933511700481176,
-0.018865065649151802,
0.04016910120844841,
0.01022704504430294,
0.0053491052240133286,
0.005344485864043236,
0.041240766644477844,
0.013201849535107613,
0.009021418169140816,
0.03137402608990669,
-0.07464727014303207,
-0.022856106981635094,
0.024740764871239662,
-0.021747484803199768,
-0.006748741492629051,
-0.052290040999650955,
0.0026514562778174877,
0.027161259204149246,
0.008494822308421135,
0.03401624411344528,
0.02616349793970585,
0.032427217811346054,
-0.015483764931559563,
-0.022985445335507393,
-0.021581189706921577,
-0.02440817840397358,
0.1026584729552269,
0.007432391867041588,
-0.05557895824313164,
0.029951293021440506,
-0.03353583812713623,
0.07886003702878952,
-0.02719821222126484,
-0.021655099466443062,
0.017063552513718605,
-0.011123182252049446,
0.08070774376392365,
0.06540874391794205,
-0.07039754837751389,
-0.00854563433676958,
0.017719488590955734,
-0.06644345819950104,
0.09741099178791046,
-0.009903697296977043,
-0.03957783430814743,
0.042755886912345886,
-0.015548435039818287,
0.002522116992622614,
0.02939698100090027,
0.04733819514513016,
-0.03518029674887657,
-0.05775924772024155,
-0.005173573270440102,
0.017756441608071327,
-0.0053306277841329575,
0.03475532308220863,
0.01228723581880331,
-0.021100787445902824,
-0.019678054377436638,
0.015881022438406944,
0.01810750551521778,
0.0038617027457803488,
-0.05864614620804787,
-0.01470772922039032,
0.028288358822464943,
0.014652297832071781,
0.024740764871239662,
-0.01191769540309906,
-0.09164614975452423,
0.026699332520365715,
-0.015770159661769867,
0.01781187392771244,
-0.048594631254673004,
0.05402688309550285,
0.010310191661119461,
0.03767469897866249,
-0.005898796953260899,
-0.021692052483558655,
-0.04682083800435066,
-0.009049133397638798,
-0.013968647457659245,
-0.0015462978044524789,
0.015631580725312233,
-0.02634826861321926,
-0.05151400715112686,
-0.032741326838731766,
-0.0030972149688750505,
0.014735444448888302,
-0.0030764283146709204,
0.035069435834884644,
0.02808511070907116,
0.019641101360321045,
-0.014097986742854118,
-0.03809966892004013,
-0.021581189706921577,
0.030099108815193176,
0.010116183198988438,
-0.04985107108950615,
-0.04497313126921654,
-0.026274360716342926,
-0.008296193554997444,
0.003154955804347992,
-0.03880179673433304,
-0.01823684573173523,
0.016832590103149414,
-0.10110639780759811,
0.09681972861289978,
0.04877940192818642,
-0.03264894336462021,
0.005617022048681974,
0.01499412301927805,
-0.09164614975452423,
0.008799693547189236,
0.0028708712197840214,
0.0004887756076641381,
0.03499552607536316,
-0.04748601093888283,
0.03237178549170494,
-0.01309098768979311,
-0.006051233038306236,
-0.004457587376236916,
-0.005880319979041815,
-0.0146245826035738,
-0.03414558246731758,
0.020417137071490288,
-0.035826992243528366,
-0.014024078845977783,
-0.04327324405312538,
-0.06134379655122757,
-0.004780936054885387,
-0.006670213770121336,
-0.004443729761987925,
-0.014171894639730453,
0.009432532824575901,
-0.015899498015642166,
-0.04556439816951752,
0.014495243318378925,
0.006143617909401655,
0.011270998977124691,
-0.027918817475438118,
-0.04367974027991295,
0.030376264825463295,
0.04264502227306366,
0.04619261622428894,
-0.00887360144406557,
0.0838857889175415,
-0.021396420896053314,
0.012416575103998184,
-0.009848265908658504,
-0.010106944479048252,
-0.012998602353036404,
-0.03894961625337601,
0.025073353201150894,
-0.03146640956401825,
-0.010199329815804958,
-0.01162206195294857,
0.026514561846852303,
-0.08107727766036987,
-0.028583990409970284,
-0.012268759310245514,
-0.03658455237746239,
0.08765511214733124,
0.021433373913168907,
-0.022763721644878387,
-0.019678054377436638,
-0.0259048193693161,
0.0033743707463145256,
0.02396472916007042,
0.04519485682249069,
0.06167638301849365,
0.07856440544128418,
0.07228220999240875,
0.008628780953586102,
-0.04770773649215698,
0.022560473531484604,
-0.005617022048681974,
0.039060477167367935,
-0.011825310066342354,
0.05262262746691704,
0.00742315361276269,
-0.051994409412145615,
-0.007048993371427059,
0.006078948266804218,
0.0015289756702259183,
-0.023428894579410553,
-0.03344345465302467,
-0.01200084201991558,
-0.03384995087981224,
0.00812528096139431,
0.01442133542150259,
-0.009007560089230537,
0.021359466016292572,
-0.015188132412731647,
-0.038617026060819626,
0.07257784157991409,
0.0020428684074431658,
0.03460750728845596,
-0.03778555989265442,
0.017931973561644554,
0.07143226265907288,
-0.06223069503903389,
-0.05265958234667778,
-0.0008233833941631019,
0.0520683191716671,
0.01515117846429348,
0.01574244350194931,
0.0036353589966893196,
-0.012102466076612473,
0.01103079691529274,
0.04312542825937271,
0.04770773649215698,
0.06064166873693466,
-0.049961935728788376,
-0.011381860822439194,
-0.011178613640367985,
0.0012344976421445608,
-0.008721166290342808,
-0.017590148374438286,
0.024167977273464203,
0.034662939608097076,
-0.04356887564063072,
-0.006637879181653261,
-0.00971892662346363,
-0.02795577235519886,
-0.02472228929400444,
0.014171894639730453,
0.028713330626487732,
0.057426661252975464,
-0.024241885170340538,
0.07272565364837646,
-0.004279745742678642,
-0.011908456683158875,
-0.023558234795928,
-0.0397256501019001,
-0.007631020154803991,
0.0567614883184433,
0.07782532274723053,
-0.058904826641082764,
-0.02442665584385395,
0.0379888080060482,
-0.01912374421954155,
-0.033295638859272,
0.026292838156223297,
-0.01764557883143425,
-0.004464516416192055,
0.019345467910170555,
-0.0035152581986039877,
0.01176063995808363,
-0.03165118023753166,
0.057426661252975464,
-0.05469205975532532,
0.0550246462225914,
0.020232366397976875,
0.013867023400962353,
0.01895744912326336,
0.0035891663283109665,
0.02572004869580269,
0.07767750322818756,
0.010467247106134892,
-0.014818591065704823,
0.007381580304354429,
0.03737906739115715,
0.0006715251947753131,
0.01876344159245491,
0.012379621155560017,
0.011501961387693882,
0.0007546718697994947,
0.04870549589395523,
0.005108903627842665,
-0.03444121405482292,
0.0054414900951087475,
-0.012767639011144638,
0.08647257834672928,
-0.019493283703923225,
-0.0550246462225914,
0.03264894336462021,
-0.06707167625427246,
0.008638019673526287,
0.027734046801924706,
0.03142945468425751,
-0.015132701024413109,
0.03835834935307503,
0.03835834935307503,
-0.012823070399463177,
0.05458119511604309,
-0.043014563620090485,
-0.03987346589565277,
-0.032852187752723694,
-0.034644462168216705,
0.016065791249275208,
0.035402022302150726,
0.02267133630812168,
-0.014393619261682034,
0.059643905609846115,
0.043642785400152206,
0.03344345465302467,
-0.08839419484138489,
-0.07187571376562119,
0.05472901090979576,
0.07967302203178406,
-0.020620383322238922,
-0.010725925676524639,
0.02869485318660736,
0.021562714129686356,
-0.03543897718191147,
0.03032083436846733,
-0.0020313202403485775,
-0.0027299837674945593,
-0.018754202872514725,
-0.027549276128411293,
0.012555153109133244,
-0.010023797862231731,
-0.008933652192354202,
0.01686030440032482,
0.037730131298303604,
-0.06633260101079941,
-0.0259048193693161,
0.030376264825463295,
0.017802635207772255,
-0.06208287551999092,
0.014356665313243866,
-0.03928220272064209,
-0.03176204487681389,
-0.028454652056097984,
-0.0550246462225914,
0.05646585300564766,
-0.023632142692804337,
0.047116469591856,
0.03854312002658844,
0.04482531547546387,
-0.051107510924339294,
0.005418393760919571,
0.010836787521839142,
-0.05044233798980713,
0.013876262120902538,
-0.04216462001204491,
0.004677002318203449,
-0.00808370765298605,
0.0668499544262886,
0.008965986780822277,
-0.035826992243528366,
-0.029821952804923058,
-0.025184214115142822,
-0.022117024287581444,
0.024962490424513817,
0.003074118634685874,
-0.027881864458322525,
0.01133566815406084,
0.00540453614667058,
-0.006725645158439875,
0.052733492106199265,
0.05439642444252968,
0.018052075058221817,
-0.010485723614692688,
0.02293001487851143,
0.04752296581864357,
0.0073122913017869,
0.005104284267872572,
0.00788046047091484,
-0.039319153875112534,
0.05062710866332054,
-0.04149944707751274,
-0.05487683042883873,
0.003316629910841584,
0.02322564832866192,
0.043014563620090485,
0.03784099221229553,
-0.04504704102873802,
0.08698993921279907,
-0.004365202505141497,
-0.02045409008860588,
-0.02222788706421852,
0.039356108754873276,
-0.04090818017721176,
0.021950731053948402,
-0.014763160608708858,
0.098223976790905,
-0.029304595664143562,
-0.03322172909975052,
0.05055319890379906,
0.043458014726638794,
-0.025350507348775864,
-0.021396420896053314,
0.034348830580711365,
0.014449050650000572,
0.050516244024038315,
-0.012795355170965195,
0.024962490424513817,
0.011040035635232925,
0.056428901851177216,
-0.0160380769520998,
0.01442133542150259,
-0.02895353175699711,
-0.04279284179210663,
-0.010910696350038052,
0.0005078300600871444,
-0.03492162004113197,
0.017322231084108353,
-0.04164726287126541,
-0.0046446677297353745,
-0.011123182252049446,
-0.010698210448026657,
-0.02823292650282383,
-0.03142945468425751,
0.04138858616352081,
-0.0035452833399176598,
-0.03806271776556969,
0.022117024287581444,
0.021396420896053314,
0.033591270446777344,
0.0009296264033764601,
-0.041092950850725174,
-0.03704647719860077,
0.027567753568291664,
0.0013291925424709916,
0.09608064591884613,
0.005857223644852638,
-0.018818872049450874,
0.01198236458003521,
-0.03939306363463402,
0.02043561451137066,
0.059052642434835434,
-0.0532878041267395,
-0.007815790362656116,
0.03750840574502945,
0.001220639911480248,
0.03647369146347046,
0.04264502227306366,
-0.0008251155959442258,
-0.01759938709437847,
0.05247481167316437,
0.06075252965092659,
-0.027438415214419365,
0.013109465129673481,
-0.0355498380959034,
0.02839922159910202,
0.0052382429130375385,
0.021562714129686356,
0.0017945831641554832,
-0.020361704751849174,
0.047559916973114014,
-0.002676862059161067,
-0.07324301451444626,
-0.08573349565267563,
0.027327552437782288,
0.010467247106134892,
-0.023318033665418625,
-0.02326260134577751,
0.01929003745317459,
-0.0015012600924819708,
0.001477008918300271,
0.0032842950895428658,
-0.057722292840480804,
0.01637990213930607,
0.007058231625705957,
-0.022246364504098892,
-0.06976933032274246,
-0.00611128332093358,
0.0002819193177856505,
-0.03364670276641846,
-0.021655099466443062,
-0.07582979649305344,
-0.03839530423283577,
0.043605830520391464,
-0.05454424023628235,
-0.012028557248413563,
-0.002496710978448391,
-0.029895860701799393,
0.0030718089547008276,
-0.007210667710751295,
0.04246025159955025,
-0.04767078161239624,
-0.00021263038797769696,
-0.015400618314743042,
-0.08004256337881088,
0.027549276128411293,
0.027013441547751427,
-0.0021133122500032187,
-0.05047929286956787,
-0.040243007242679596,
0.018393900245428085,
0.015077270567417145,
0.024463610723614693,
-0.03534658998250961,
0.01764557883143425,
-0.030209971591830254,
-0.0001312880776822567,
-0.08669430017471313,
-0.03455207869410515,
0.04574916884303093,
-0.02472228929400444,
0.00283391703851521,
-0.042903702706098557,
-0.0007229144684970379,
-0.0077234054915606976,
0.05724189057946205,
0.007561731152236462,
0.042755886912345886,
0.04305151849985123,
-0.0024204931687563658,
-0.003616881789639592,
0.01125252153724432,
-0.05203136429190636,
0.025553755462169647,
0.03577156364917755,
-0.0019966759718954563,
0.007922033779323101,
0.07342778146266937,
-0.005044233985245228,
-0.021876823157072067,
-0.00804213434457779,
0.030265402048826218,
-0.007972845807671547,
-0.017359185963869095,
0.033757563680410385,
0.024648379534482956,
-0.01545604970306158,
-0.030062155798077583,
-0.062008969485759735,
0.02161814458668232,
-0.006245241966098547,
0.01969653181731701,
0.0013395858695730567,
-0.02267133630812168,
0.04970325529575348,
0.0199921652674675,
-0.005372201558202505,
-0.04334715008735657,
0.01264753844588995,
0.005769457668066025,
-0.02895353175699711,
-0.014947930350899696,
-0.030376264825463295,
0.0426819771528244,
-0.021507281810045242,
0.02267133630812168,
-0.0003626120451372117,
0.019326990470290184,
-0.02058343030512333,
-0.0017495453357696533,
0.01228723581880331,
0.0017264490015804768,
-0.011640539392828941,
0.0030025201849639416,
0.0028408458456397057,
0.035087913274765015,
0.027752524241805077,
0.025221168994903564,
-0.04456663504242897,
-0.010615062899887562,
0.01914221979677677,
0.003658455330878496,
-0.04408623278141022,
-0.045823074877262115,
0.027456890791654587,
-0.0027807955630123615,
0.04914894327521324,
0.02398320659995079,
-0.0016767920460551977,
-0.05646585300564766,
0.01309098768979311,
-0.021414896473288536,
0.039799559861421585,
-0.0010670494521036744,
0.02488858252763748,
0.010846026241779327,
0.06452184915542603,
-0.012961648404598236,
0.05439642444252968,
0.019493283703923225,
-0.03105991519987583,
0.029951293021440506,
-0.044344913214445114,
-0.045970890671014786,
0.08691602945327759,
-0.005367582198232412,
0.01521584764122963,
-0.031115347519516945,
-0.0412038154900074,
-0.053805161267519,
-0.014338187873363495,
-0.039060477167367935,
0.024685334414243698,
-0.06160247325897217,
0.009183092042803764,
-0.043901462107896805,
0.016324471682310104,
-0.030043678358197212,
-0.03545745089650154,
0.025664618238806725,
0.06211983039975166,
-0.011095467023551464,
-0.0019169936422258615,
0.007219905965030193,
0.06485443562269211,
-0.050220612436532974,
-0.04637738689780235,
0.04050168767571449,
-0.015188132412731647,
-0.02189530059695244,
0.005409155506640673,
-0.003651526290923357,
-0.04135163128376007,
-0.06636954843997955,
0.014051794074475765,
-0.00010552125604590401,
-0.0017541645793244243,
-0.04556439816951752,
-0.009326289407908916,
0.04116686061024666,
0.06792162358760834
]
|
30,530 | networkx.algorithms.d_separation | d_separated | Return whether nodes sets ``x`` and ``y`` are d-separated by ``z``.
.. deprecated:: 3.3
This function is deprecated and will be removed in NetworkX v3.5.
Please use `is_d_separator(G, x, y, z)`.
| def d_separated(G, x, y, z):
"""Return whether nodes sets ``x`` and ``y`` are d-separated by ``z``.
.. deprecated:: 3.3
This function is deprecated and will be removed in NetworkX v3.5.
Please use `is_d_separator(G, x, y, z)`.
"""
import warnings
warnings.warn(
"d_separated is deprecated and will be removed in NetworkX v3.5."
"Please use `is_d_separator(G, x, y, z)`.",
category=DeprecationWarning,
stacklevel=2,
)
return nx.is_d_separator(G, x, y, z)
| (G, x, y, z) | [
0.00877203606069088,
0.0756981298327446,
-0.008348288014531136,
0.04232245311141014,
0.034808557480573654,
-0.019081801176071167,
-0.009855435229837894,
0.05920250713825226,
-0.004578234162181616,
-0.0026145735755562782,
0.011961073614656925,
-0.011393162421882153,
0.012826045043766499,
-0.013105631805956364,
0.014896735548973083,
-0.021842719987034798,
-0.01547338254749775,
0.011349477805197239,
0.05172356218099594,
0.00756631838157773,
-0.04326606169342995,
-0.04085462540388107,
0.031366147100925446,
0.003044875105842948,
-0.01209213025867939,
0.002025912282988429,
0.029007133096456528,
0.01625972054898739,
0.011594115756452084,
0.039736274629831314,
-0.028081001713871956,
-0.007151306606829166,
-0.059132613241672516,
0.018714843317866325,
0.02615884132683277,
0.05864333361387253,
0.009270050562918186,
0.06427001953125,
-0.03589195758104324,
-0.0290420800447464,
-0.036066699773073196,
-0.021318495273590088,
0.022297048941254616,
-0.00030197561136446893,
0.03210006281733513,
0.021895142272114754,
0.0026604433078318834,
0.0069721960462629795,
-0.05780457332730293,
-0.027032550424337387,
0.08024141937494278,
-0.03830339387059212,
0.013070683926343918,
0.029985686764121056,
0.006692609284073114,
-0.022698955610394478,
0.08548367023468018,
0.045957084745168686,
0.01455598883330822,
0.004364175256341696,
0.0008644256740808487,
0.014355035498738289,
0.012301820330321789,
0.021965039893984795,
0.0015803207643330097,
-0.011541693471372128,
-0.030352644622325897,
-0.04452420026063919,
-0.020182672888040543,
0.024795856326818466,
-0.02250673808157444,
-0.0044821263290941715,
-0.0004660690319724381,
0.0042374879121780396,
0.010073862969875336,
-0.02661317028105259,
0.06143920496106148,
0.02355518937110901,
0.021877668797969818,
-0.034913402050733566,
-0.02191261760890484,
-0.06402537971735,
0.004093325696885586,
0.034319281578063965,
0.060041267424821854,
0.001770352479070425,
0.000958349322900176,
0.03286892548203468,
-0.0402255542576313,
0.006295071914792061,
0.019081801176071167,
0.00933120958507061,
-0.023799827322363853,
-0.01722080074250698,
-0.044314511120319366,
0.01127084344625473,
-0.03732483834028244,
0.009680693969130516,
0.011594115756452084,
-0.007644952274858952,
0.05340108275413513,
0.04452420026063919,
-0.012432876043021679,
-0.000005277235231915256,
-0.03148846700787544,
-0.10603330284357071,
-0.02806352637708187,
-0.0036368127912282944,
-0.06077518314123154,
-0.0789133757352829,
-0.054100047796964645,
0.007828431203961372,
0.06475929915904999,
-0.022629057988524437,
0.021825246512889862,
-0.04246224835515022,
0.025355029851198196,
-0.01836535893380642,
-0.050290677696466446,
-0.030806971713900566,
-0.049242228269577026,
0.040400296449661255,
-0.06643681973218918,
0.0335678905248642,
0.009051622822880745,
-0.020392363891005516,
0.06475929915904999,
0.0446290448307991,
-0.017404278740286827,
0.00938363280147314,
0.058503542095422745,
0.02638600580394268,
-0.02490070089697838,
0.009602059610188007,
0.023974569514393806,
0.0245162695646286,
-0.006941616535186768,
0.0768863782286644,
0.01813819445669651,
0.013988077640533447,
-0.012756148353219032,
-0.03788401558995247,
-0.006028590723872185,
0.05483396351337433,
-0.009138993918895721,
0.045223169028759,
-0.03337567672133446,
-0.004368544090539217,
0.015604439191520214,
0.0264209546148777,
0.00019016818259842694,
0.022646531462669373,
0.051898304373025894,
-0.08066079765558243,
-0.037115149199962616,
-0.025547245517373085,
-0.053610771894454956,
0.02717234380543232,
0.06825413554906845,
0.014625885523855686,
-0.02027004398405552,
-0.04232245311141014,
-0.010405872017145157,
0.07118979096412659,
0.03938679397106171,
0.004696184769272804,
0.014337561093270779,
-0.0049582975916564465,
-0.019134223461151123,
0.014206505380570889,
0.04448925331234932,
0.07471957802772522,
-0.039212051779031754,
0.0124678248539567,
-0.03746463358402252,
0.01265130378305912,
-0.030772024765610695,
0.048543259501457214,
0.00921762827783823,
-0.040400296449661255,
0.06112466752529144,
0.017343120649456978,
0.0378490649163723,
-0.009095308370888233,
0.013411429710686207,
-0.010423346422612667,
0.004840346984565258,
-0.023258129134774208,
-0.005617947783321142,
0.03942174091935158,
-0.030702127143740654,
-0.00977680180221796,
0.009750590659677982,
0.0033157248981297016,
0.015822866931557655,
-0.015307378023862839,
-0.010807777754962444,
-0.008326444774866104,
-0.03426685929298401,
0.04012070968747139,
-0.01843525655567646,
0.0019767661578953266,
0.009899120777845383,
-0.04211276397109032,
-0.007907064631581306,
0.033340729773044586,
-0.0372549444437027,
-0.02336297370493412,
0.016644151881337166,
0.010764092206954956,
0.03056233376264572,
-0.01915169693529606,
0.030212851241230965,
0.07199360430240631,
0.010580613277852535,
0.03348052129149437,
0.0007120726513676345,
0.07457978278398514,
0.046865738928318024,
-0.06150909885764122,
0.03935184329748154,
-0.02470848523080349,
0.07213339954614639,
0.06797454506158829,
-0.0004849083779845387,
-0.035367731004953384,
0.02138839103281498,
0.012336768209934235,
-0.02142333984375,
-0.06311672180891037,
0.012887204997241497,
-0.0364161841571331,
0.01342016737908125,
-0.005976168438792229,
0.05231768265366554,
-0.049766454845666885,
0.011183472350239754,
-0.004940823186188936,
0.10225887596607208,
0.028168370947241783,
-0.04655120521783829,
-0.006967827677726746,
-0.025372503325343132,
-0.037604428827762604,
0.056791070848703384,
-0.024201733991503716,
-0.028535328805446625,
0.009829224087297916,
0.03265923634171486,
0.0478442944586277,
-0.05997137352824211,
-0.015517068095505238,
-0.046865738928318024,
-0.0484384149312973,
-0.020741846412420273,
0.04994119703769684,
-0.05951704457402229,
0.01813819445669651,
0.0217204000800848,
-0.040330398827791214,
-0.03854803368449211,
-0.020969010889530182,
-0.04026050120592117,
0.04179823026061058,
0.01724701188504696,
0.015429697930812836,
0.07409050315618515,
-0.013018261641263962,
0.002087072003632784,
-0.021930091083049774,
-0.00659650145098567,
0.06206827238202095,
-0.07056072354316711,
-0.019868137314915657,
0.020462259650230408,
0.03173310309648514,
-0.011279581114649773,
-0.07786493003368378,
0.03942174091935158,
0.01888958364725113,
-0.010370923206210136,
0.012319293804466724,
-0.08744077384471893,
0.02014772593975067,
-0.053016651421785355,
0.03250196576118469,
-0.002518465742468834,
-0.04120410606265068,
-0.025215236470103264,
0.013725965283811092,
-0.021895142272114754,
0.017963452264666557,
0.04228750616312027,
-0.02533755451440811,
0.02563461661338806,
0.010283553041517735,
0.023223180323839188,
-0.015980133786797523,
-0.002507544355466962,
0.0454678051173687,
0.026787912473082542,
-0.039177101105451584,
0.05004604160785675,
0.026438428089022636,
-0.009934068657457829,
0.037045251578092575,
0.027189817279577255,
-0.0245162695646286,
0.049102433025836945,
-0.0005485253059305251,
-0.03302619233727455,
0.013332796283066273,
-0.008509923703968525,
-0.02914692647755146,
0.04393007978796959,
0.02243684232234955,
-0.029286719858646393,
0.016093716025352478,
-0.02086416631937027,
0.04777439683675766,
0.01169896125793457,
0.04078472778201103,
-0.06863856315612793,
0.06297693401575089,
-0.06196342781186104,
0.04270688816905022,
0.033200934529304504,
0.03421443700790405,
0.006343125831335783,
0.05930735543370247,
-0.012441613711416721,
-0.05609210580587387,
-0.03339315205812454,
0.030632231384515762,
0.08170925080776215,
-0.0017736288718879223,
0.04497852921485901,
-0.0035559949465095997,
0.04218266159296036,
0.014206505380570889,
-0.007295468356460333,
0.028465433046221733,
-0.03585701063275337,
-0.006413022521883249,
0.023502767086029053,
-0.0018358806846663356,
0.025931676849722862,
0.03669577091932297,
0.03279902786016464,
0.12322788685560226,
-0.02000793255865574,
0.062417756766080856,
-0.016277195885777473,
-0.008715244941413403,
0.03257186338305473,
-0.04896264150738716,
0.01128831785172224,
0.009374895133078098,
0.05158376693725586,
0.04759965464472771,
0.053575824946165085,
-0.021021433174610138,
0.059132613241672516,
0.030772024765610695,
-0.01643446274101734,
-0.06776485592126846,
-0.03246701881289482,
-0.028238268569111824,
-0.03085939586162567,
-0.028745019808411598,
-0.04683079198002815,
0.0007863379432819784,
0.0016709681367501616,
-0.03019537590444088,
0.03559489548206329,
0.0002298946346854791,
0.01711595617234707,
-0.013516275212168694,
0.016189824789762497,
0.05500870570540428,
-0.05057026445865631,
0.016714049503207207,
0.0648641437292099,
0.05259726941585541,
0.012826045043766499,
0.060041267424821854,
0.031628258526325226,
0.032187432050704956,
-0.03311356529593468,
-0.042077817022800446,
0.027853837236762047,
-0.005032562650740147,
0.02724224142730236,
0.07276246696710587,
-0.07863379269838333,
-0.04354564845561981,
-0.0027456299867480993,
-0.033899903297424316,
0.00010962314991047606,
-0.006089750211685896,
-0.007806587964296341,
0.020986486226320267,
-0.03781411796808243,
0.03519298881292343,
-0.008811353705823421,
-0.002400514902547002,
0.03168068081140518,
0.0004461375647224486,
-0.00661397585645318,
-0.018907058984041214,
-0.017343120649456978,
-0.023258129134774208,
0.004761713091284037,
0.01918664574623108,
0.04358059540390968,
-0.0157092846930027,
0.0025031757541000843,
0.08142966032028198,
0.0390373095870018,
0.01455598883330822,
-0.00008812172745820135,
-0.11085617542266846,
-0.0010069493437185884,
-0.004174144007265568,
-0.00285921199247241,
-0.036486078053712845,
-0.06255754828453064,
-0.013324059545993805,
0.002819895278662443,
-0.003713262500241399,
-0.02947893552482128,
-0.04179823026061058,
0.028570277616381645,
-0.049766454845666885,
0.03634628653526306,
-0.0028177108615636826,
0.03196026757359505,
-0.009706905111670494,
0.017657654359936714,
0.06269734352827072,
-0.01862747222185135,
0.009261312894523144,
-0.022559162229299545,
-0.027067499235272408,
-0.01128831785172224,
0.025110391899943352,
0.023310551419854164,
0.006854245439171791,
0.04123905673623085,
-0.04176327958703041,
0.0025512296706438065,
0.00024395587388426065,
-0.015910238027572632,
-0.02329307608306408,
-0.050849851220846176,
-0.011524219065904617,
-0.002577441046014428,
-0.010475768707692623,
-0.02500554546713829,
0.0997425988316536,
0.004503969103097916,
-0.018522625789046288,
-0.06273229420185089,
0.0498712994158268,
-0.07751544564962387,
0.031628258526325226,
0.006998407654464245,
-0.02060205303132534,
0.018854636698961258,
0.0326068140566349,
-0.00862350594252348,
-0.04211276397109032,
-0.04239235073328018,
-0.02526765875518322,
0.003949163947254419,
0.037709273397922516,
-0.010370923206210136,
0.0498712994158268,
-0.010021439753472805,
-0.014381246641278267,
-0.048683054745197296,
-0.024009518325328827,
-0.013594908639788628,
-0.0448736846446991,
0.008322075940668583,
-0.0034598868805915117,
-0.05147892236709595,
0.025215236470103264,
0.034546446055173874,
-0.014992843382060528,
0.059027768671512604,
-0.03620649129152298,
0.01509768795222044,
-0.10149001330137253,
0.05881807580590248,
0.03325335681438446,
0.001746325520798564,
-0.06612228602170944,
0.04885779693722725,
-0.05057026445865631,
0.0023284340277314186,
0.035699740052223206,
0.016023820266127586,
-0.03019537590444088,
0.03292134776711464,
-0.0176139697432518,
0.039876069873571396,
0.009505951777100563,
-0.03171563148498535,
-0.023415395990014076,
-0.037604428827762604,
-0.02645590342581272,
0.06633197516202927,
0.06741537153720856,
-0.0012788912281394005,
0.0004778095171786845,
-0.046411409974098206,
0.0023524609860032797,
0.02470848523080349,
-0.0001864822261268273,
0.0366608202457428,
-0.006766874808818102,
-0.0015715836780145764,
0.0016567703569307923,
-0.048683054745197296,
0.04955676198005676,
-0.019658448174595833,
-0.023258129134774208,
-0.03075454942882061,
-0.018644945695996284,
-0.015027791261672974,
0.06252260506153107,
0.04179823026061058,
0.0384431891143322,
-0.011751383543014526,
0.05375056713819504,
0.013795861974358559,
0.0384431891143322,
-0.010589350946247578,
0.0032698551658540964,
0.035367731004953384,
-0.05951704457402229,
0.026892757043242455,
-0.01190865132957697,
-0.019833190366625786,
0.04955676198005676,
0.052422527223825455,
0.036451131105422974,
0.045223169028759,
0.0021394945215433836,
-0.014433669857680798,
0.002688838867470622,
-0.01967592164874077,
-0.03788401558995247,
0.0789133757352829,
0.015630651265382767,
-0.058468591421842575,
0.0366608202457428,
-0.020951537415385246,
0.021038908511400223,
-0.057420141994953156,
-0.009130257181823254,
0.0179110299795866,
-0.006002379581332207,
-0.011812543496489525,
-0.03914215415716171,
-0.026333583518862724,
-0.06989670544862747,
-0.00632565189152956,
0.047494810074567795,
-0.016906265169382095,
0.004949560388922691,
0.013455115258693695,
0.02283874899148941,
-0.01000396627932787,
0.011384425684809685,
0.02067195065319538,
0.03075454942882061,
-0.039212051779031754,
-0.06402537971735,
-0.04386018216609955,
0.03777916729450226,
-0.04340585321187973,
0.05920250713825226,
0.030352644622325897,
-0.0578395240008831,
-0.026700541377067566,
-0.010781566612422466,
0.03314851224422455,
-0.0299332644790411,
0.0305273849517107,
0.039806172251701355,
0.05619695037603378,
-0.04634151607751846,
0.012957101687788963,
-0.01685384288430214,
0.013778387568891048,
0.0195186547935009,
0.04337090626358986,
-0.02601904794573784,
-0.02135344408452511,
0.005722792819142342,
0.023205704987049103,
-0.020165199413895607,
0.04763460531830788,
-0.0498712994158268,
-0.010440819896757603,
-0.07590781897306442,
-0.03370768576860428,
-0.08932799100875854,
-0.00010354814730817452,
0.041483692824840546,
-0.05707065761089325,
-0.050849851220846176,
-0.009698167443275452,
-0.026193790137767792,
0.003090744838118553,
-0.0037307366728782654,
0.010449557565152645,
-0.017299434170126915,
-0.02769656851887703,
-0.0066489242017269135,
-0.0006230635917745531,
-0.01149800792336464,
0.007400313392281532,
-0.022908644750714302,
-0.000641629914753139,
-0.01470451895147562,
0.02822079509496689,
-0.0408196747303009,
-0.03108655847609043,
-0.008129860274493694,
0.03847813606262207,
0.00009426498581888154,
-0.07171402126550674,
-0.07255277782678604,
-0.0052160415798425674,
-0.03496582806110382,
0.002824263647198677,
-0.024131836369633675,
-0.03358536586165428,
0.027888784185051918,
-0.05231768265366554,
-0.011410636827349663,
-0.017334382981061935,
-0.03466876596212387,
0.05119933560490608,
0.022978542372584343,
0.04455914720892906,
-0.030772024765610695,
-0.016810158267617226,
0.08052100241184235,
-0.051304180175065994,
-0.040470190346241,
-0.020095301792025566,
0.0126163549721241,
-0.024551216512918472,
0.030841920524835587,
0.007129463832825422,
-0.07227319478988647,
0.03610164672136307,
0.021248597651720047,
-0.009147731587290764,
0.016897527500987053,
0.0006438141572289169,
0.02407941408455372,
0.025215236470103264,
0.020095301792025566,
-0.0002576075785327703,
-0.06975691020488739,
-0.024656062945723534,
-0.016277195885777473,
0.019378861412405968,
-0.06273229420185089,
-0.038617927581071854,
-0.08380614966154099,
0.0252327099442482,
0.009995228610932827,
0.007693006191402674,
-0.017666392028331757,
0.009505951777100563,
0.004019060637801886,
-0.001216639531776309,
-0.004731133114546537,
0.02836058847606182,
0.030806971713900566,
0.0028373694512993097,
-0.07318185269832611,
0.02753930166363716,
0.02769656851887703,
-0.026211263611912727,
0.004278989043086767,
0.04938202351331711,
0.024131836369633675,
-0.014407457783818245,
-0.027382034808397293,
0.029513884335756302,
0.06643681973218918,
-0.05584746599197388,
-0.02549482323229313,
-0.030894342809915543,
-0.003564731916412711,
-0.06786970049142838,
0.04162348806858063,
0.01030102651566267,
-0.059656836092472076,
-0.01738680526614189,
0.005814532283693552,
0.0384431891143322,
0.001229745103046298,
-0.0346338152885437,
-0.008151703514158726,
-0.02392214722931385,
-0.0654582604765892,
-0.01806829869747162,
-0.0396314300596714,
0.027416981756687164,
-0.05207304656505585,
0.0192215945571661,
0.035472579300403595,
-0.03300871700048447,
-0.02220967784523964,
-0.001687350100837648,
0.02933914214372635,
-0.06954722106456757,
0.008038121275603771,
-0.03749958053231239,
-0.043685439974069595,
-0.031925320625305176,
-0.025477347895503044,
-0.055218394845724106,
0.08744077384471893,
0.009471003897488117,
0.08730098605155945,
-0.025127865374088287,
-0.0028548436239361763,
0.01836535893380642,
0.01317552849650383,
-0.046376463025808334,
0.004185065161436796,
-0.0023306182119995356,
-0.009872909635305405,
0.05396025627851486,
-0.059586942195892334,
-0.018854636698961258,
0.01013502199202776,
-0.021965039893984795,
0.031628258526325226,
-0.04190307483077049,
-0.026805385947227478,
0.07905317097902298,
-0.02701507695019245,
0.02145828865468502,
-0.06643681973218918,
0.03426685929298401,
0.03187289834022522,
-0.014031763188540936,
-0.03907225653529167,
-0.003031769534572959,
-0.04683079198002815,
-0.05448448285460472,
0.003287329338490963,
0.01813819445669651,
-0.016469411551952362,
0.006517867557704449,
0.013236688449978828,
0.009462266229093075,
0.03791896253824234
]
|
30,533 | networkx.algorithms.dag | dag_longest_path | Returns the longest path in a directed acyclic graph (DAG).
If `G` has edges with `weight` attribute the edge data are used as
weight values.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
weight : str, optional
Edge data key to use for weight
default_weight : int, optional
The weight of edges that do not have a weight attribute
topo_order: list or tuple, optional
A topological order for `G` (if None, the function will compute one)
Returns
-------
list
Longest path
Raises
------
NetworkXNotImplemented
If `G` is not directed
Examples
--------
>>> DG = nx.DiGraph([(0, 1, {"cost": 1}), (1, 2, {"cost": 1}), (0, 2, {"cost": 42})])
>>> list(nx.all_simple_paths(DG, 0, 2))
[[0, 1, 2], [0, 2]]
>>> nx.dag_longest_path(DG)
[0, 1, 2]
>>> nx.dag_longest_path(DG, weight="cost")
[0, 2]
In the case where multiple valid topological orderings exist, `topo_order`
can be used to specify a specific ordering:
>>> DG = nx.DiGraph([(0, 1), (0, 2)])
>>> sorted(nx.all_topological_sorts(DG)) # Valid topological orderings
[[0, 1, 2], [0, 2, 1]]
>>> nx.dag_longest_path(DG, topo_order=[0, 1, 2])
[0, 1]
>>> nx.dag_longest_path(DG, topo_order=[0, 2, 1])
[0, 2]
See also
--------
dag_longest_path_length
| def transitive_closure_dag(G, topo_order=None):
"""Returns the transitive closure of a directed acyclic graph.
This function is faster than the function `transitive_closure`, but fails
if the graph has a cycle.
The transitive closure of G = (V,E) is a graph G+ = (V,E+) such that
for all v, w in V there is an edge (v, w) in E+ if and only if there
is a non-null path from v to w in G.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
topo_order: list or tuple, optional
A topological order for G (if None, the function will compute one)
Returns
-------
NetworkX DiGraph
The transitive closure of `G`
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` has a cycle
Examples
--------
>>> DG = nx.DiGraph([(1, 2), (2, 3)])
>>> TC = nx.transitive_closure_dag(DG)
>>> TC.edges()
OutEdgeView([(1, 2), (1, 3), (2, 3)])
Notes
-----
This algorithm is probably simple enough to be well-known but I didn't find
a mention in the literature.
"""
if topo_order is None:
topo_order = list(topological_sort(G))
TC = G.copy()
# idea: traverse vertices following a reverse topological order, connecting
# each vertex to its descendants at distance 2 as we go
for v in reversed(topo_order):
TC.add_edges_from((v, u) for u in nx.descendants_at_distance(TC, v, 2))
return TC
| (G, weight='weight', default_weight=1, topo_order=None, *, backend=None, **backend_kwargs) | [
-0.03266729414463043,
0.021180087700486183,
-0.02476874180138111,
0.007968920283019543,
-0.0362735390663147,
-0.030996110290288925,
-0.01892838440835476,
-0.012648242525756359,
0.09302350878715515,
-0.07761341333389282,
0.012155681848526001,
0.028199071064591408,
0.0005280179320834577,
-0.01179505791515112,
-0.03152385354042053,
0.022429080680012703,
-0.013993986882269382,
-0.017257198691368103,
0.0031994422897696495,
0.02943047136068344,
0.0009411417995579541,
-0.06410319358110428,
0.013510222546756268,
-0.023853987455368042,
-0.015709152445197105,
0.01653594896197319,
-0.047074683010578156,
0.032069187611341476,
-0.06069045141339302,
-0.03133034706115723,
0.031154433265328407,
-0.04542108625173569,
-0.09049034118652344,
0.013501427136361599,
0.05266875773668289,
0.08092060685157776,
-0.000371893955161795,
0.018171953037381172,
-0.01715165004134178,
-0.06040899083018303,
0.012199660763144493,
-0.01841823384165764,
-0.011487207375466824,
-0.0325089730322361,
0.04591364786028862,
0.013475039973855019,
-0.009129955433309078,
0.03806786611676216,
-0.03739939257502556,
-0.04953748360276222,
0.08640912920236588,
-0.03722347691655159,
-0.005787582136690617,
-0.010598840191960335,
0.0153133450075984,
0.03905298560857773,
0.019508901983499527,
0.059459052979946136,
0.06821958720684052,
-0.01778494194149971,
-0.009947956539690495,
-0.05516674369573593,
-0.009059589356184006,
0.035481926053762436,
-0.05097997933626175,
0.021268045529723167,
-0.03683646768331528,
-0.06002197787165642,
-0.021162496879696846,
0.007291649933904409,
-0.013615771196782589,
0.020247742533683777,
0.0055720871314406395,
-0.07606536895036697,
-0.027354681864380836,
-0.07641719281673431,
0.027987973764538765,
-0.045209988951683044,
-0.02853330783545971,
-0.03511250391602516,
-0.034408848732709885,
-0.06839550286531448,
0.023449383676052094,
-0.00835153367370367,
0.06135892868041992,
-0.02795279026031494,
0.03368759900331497,
-0.0014183095190674067,
-0.0676918476819992,
-0.04074176400899887,
0.007828189060091972,
-0.03437366336584091,
-0.031224798411130905,
0.032772842794656754,
0.037469759583473206,
-0.008830900304019451,
-0.000948288303334266,
-0.04851717874407768,
0.01008868869394064,
0.009983140043914318,
0.03894743695855141,
0.007489553652703762,
-0.0854240134358406,
-0.006231766194105148,
0.023203102871775627,
-0.04535071924328804,
-0.01750347763299942,
0.016852594912052155,
-0.01738033816218376,
-0.08753498643636703,
-0.0025023818016052246,
-0.0012940700398758054,
0.09787874668836594,
-0.03891225531697273,
0.03155903518199921,
0.013132006861269474,
0.007766618859022856,
0.000716850976459682,
-0.00036419768002815545,
-0.005690829362720251,
0.014143514446914196,
0.022182799875736237,
0.0010791246313601732,
0.012709812261164188,
-0.007265262771397829,
0.00804368406534195,
0.00934984814375639,
0.0276713278144598,
0.03439125791192055,
-0.010862711817026138,
0.060936734080314636,
-0.013738911598920822,
0.03324781358242035,
0.08169462531805038,
0.051718819886446,
0.003834933042526245,
-0.032350651919841766,
0.015392506495118141,
-0.02033570036292076,
0.022763317450881004,
-0.010097484104335308,
-0.061394110321998596,
-0.02153191715478897,
0.04932638630270958,
0.04978376254439354,
0.00397786358371377,
-0.005827162880450487,
-0.013316716998815536,
0.011926993727684021,
0.019297804683446884,
0.008527448400855064,
0.003876712638884783,
-0.014847171492874622,
0.032579340040683746,
0.00015502452151849866,
-0.007841382175683975,
-0.04362675920128822,
0.0724063515663147,
-0.053724244236946106,
0.01210290752351284,
-0.03127757087349892,
0.047250594943761826,
-0.040038108825683594,
0.024733558297157288,
0.016659090295433998,
-0.001907571335323155,
0.11406286805868149,
0.006236163899302483,
-0.031506262719631195,
0.03141830489039421,
-0.056855518370866776,
-0.030714645981788635,
-0.007291649933904409,
-0.004886021371930838,
-0.006174593698233366,
0.029870256781578064,
0.003823938313871622,
0.030538732185959816,
-0.016069777309894562,
0.021778197959065437,
-0.01654474437236786,
0.0005359890637919307,
-0.04573773220181465,
0.02119768038392067,
0.03243860602378845,
0.03108406625688076,
0.041234325617551804,
-0.040038108825683594,
0.0769801214337349,
-0.020951399579644203,
-0.05495564639568329,
0.012665833346545696,
0.03789195045828819,
0.023273469880223274,
0.07529134303331375,
-0.056011129170656204,
-0.029923031106591225,
0.03715311363339424,
-0.047707974910736084,
0.07152678072452545,
0.06396245956420898,
0.015049473382532597,
0.07198415696620941,
0.033318180590867996,
0.023713255301117897,
0.08155389875173569,
0.03433848172426224,
-0.033036716282367706,
-0.023713255301117897,
0.008641792461276054,
-0.01300886645913124,
-0.025525173172354698,
0.010642818175256252,
-0.03996774181723595,
-0.051718819886446,
0.032245103269815445,
-0.038278963416814804,
0.013475039973855019,
0.0480949841439724,
0.0019152675522491336,
-0.026299195364117622,
0.03715311363339424,
0.02568349614739418,
-0.01687898300588131,
0.07043610513210297,
-0.07754305005073547,
-0.00044555807835422456,
0.01127611007541418,
0.020300516858696938,
-0.05956460162997246,
0.011029830202460289,
-0.007181703578680754,
0.032808028161525726,
-0.01971999928355217,
0.06199222058057785,
-0.04436559975147247,
-0.0351300984621048,
0.0032126358710229397,
0.0188756100833416,
0.017925672233104706,
-0.05073370039463043,
-0.006007475312799215,
-0.024592826142907143,
0.010546065866947174,
-0.01703730598092079,
-0.00518507556989789,
0.026633433997631073,
0.005959098692983389,
0.0325089730322361,
0.026387153193354607,
-0.051226262003183365,
-0.03567543253302574,
-0.04865790903568268,
-0.029641568660736084,
-0.03097851760685444,
-0.012604263611137867,
-0.004096605349332094,
-0.056855518370866776,
-0.005330204963684082,
0.01733635924756527,
0.0003204939712304622,
0.017239606007933617,
-0.057594358921051025,
0.06923989206552505,
0.008874879218637943,
-0.029518429189920425,
0.03414497524499893,
-0.08183535933494568,
-0.06681226938962936,
-0.0055720871314406395,
-0.016659090295433998,
0.0038591211196035147,
0.04408413916826248,
0.0054357536137104034,
0.003689803648740053,
-0.04091767966747284,
0.015498055145144463,
0.016043389216065407,
-0.0029795493464916945,
-0.029905440285801888,
-0.04183243215084076,
0.029236966744065285,
-0.031242389231920242,
-0.023167921230196953,
-0.06269587576389313,
-0.00639008916914463,
-0.011346476152539253,
-0.026897305622696877,
0.02211243472993374,
0.018541373312473297,
0.07648756355047226,
0.0026431132573634386,
0.07296927273273468,
0.02478633262217045,
0.06301252543926239,
0.035376377403736115,
0.02647511102259159,
-0.0254548080265522,
-0.002396833151578903,
0.033036716282367706,
0.07353220134973526,
0.00951696652919054,
-0.016386421397328377,
-0.05185955390334129,
0.001837205607444048,
0.004586966708302498,
0.009886386804282665,
-0.007986512035131454,
-0.02943047136068344,
0.040143657475709915,
-0.05164845660328865,
-0.049924492835998535,
-0.07040092349052429,
0.04506925866007805,
-0.06916952133178711,
-0.03416256979107857,
-0.03268488869071007,
-0.049361567944288254,
0.05442790314555168,
0.011768670752644539,
0.0023418599739670753,
0.015621194615960121,
-0.00858462043106556,
-0.006566003430634737,
-0.07648756355047226,
0.04682840034365654,
0.009719268418848515,
0.05784064158797264,
0.05857948213815689,
0.010238215327262878,
-0.005646850913763046,
0.03859560936689377,
0.005242247600108385,
0.057136982679367065,
-0.003085097996518016,
0.07068239152431488,
0.09661216288805008,
-0.029958214610815048,
0.015295753255486488,
-0.028199071064591408,
0.04563218355178833,
0.04186761751770973,
-0.02876199781894684,
0.009675289504230022,
-0.012349187396466732,
0.010018322616815567,
0.003030124818906188,
-0.00140621536411345,
0.037082746624946594,
-0.02285127528011799,
0.04313420131802559,
0.03817341476678848,
-0.01818954385817051,
0.027319500222802162,
-0.03919371962547302,
0.06575678288936615,
0.04911528900265694,
-0.008654986508190632,
0.014979107305407524,
0.02784724347293377,
0.0034369267523288727,
-0.0221652090549469,
0.019420944154262543,
-0.0362735390663147,
0.05516674369573593,
0.0032676090486347675,
-0.009041997604072094,
0.03743457421660423,
-0.02091621607542038,
-0.04450633376836777,
0.01698453165590763,
-0.011346476152539253,
0.0407065823674202,
0.00928827840834856,
-0.051296625286340714,
0.030468367040157318,
0.04777833819389343,
-0.05404089018702507,
0.05302058532834053,
0.036062441766262054,
-0.02000146172940731,
0.017635414376854897,
-0.008114049211144447,
0.03127757087349892,
0.020388474687933922,
0.015295753255486488,
0.043556395918130875,
0.008606609888374805,
0.02351974882185459,
-0.027829650789499283,
-0.0056028724648058414,
-0.027020445093512535,
0.04542108625173569,
-0.004026239737868309,
0.000395807292079553,
-0.034232933074235916,
0.06614379584789276,
0.04461188241839409,
0.025753861293196678,
0.002953162183985114,
-0.014512934722006321,
0.007625887170433998,
0.022006886079907417,
0.008967234753072262,
0.023678071796894073,
-0.03342372924089432,
0.012173273600637913,
0.036801282316446304,
0.061745937913656235,
0.04886900633573532,
-0.003621636889874935,
0.006319723092019558,
0.032069187611341476,
-0.01716044545173645,
-0.020212559029459953,
-0.01977277360856533,
-0.07113976776599884,
0.0029311729595065117,
0.05872021242976189,
0.0023330640979111195,
0.04897455498576164,
0.02897309511899948,
0.028427759185433388,
-0.03898262232542038,
0.0046485369093716145,
-0.03407461196184158,
0.03143589571118355,
0.0392289012670517,
-0.010299785993993282,
0.09196802228689194,
0.010704388841986656,
-0.032069187611341476,
0.013246350921690464,
-0.03330058604478836,
0.00008575824904255569,
0.020986583083868027,
0.014187492430210114,
0.008193210698664188,
0.04007329046726227,
0.06614379584789276,
-0.007696253247559071,
0.04024920612573624,
-0.025243710726499557,
-0.06090154871344566,
-0.011979768052697182,
-0.029465654864907265,
0.008998019620776176,
0.03289598599076271,
0.04911528900265694,
-0.02227075770497322,
0.04626547545194626,
0.0464765727519989,
-0.006715530529618263,
-0.011610347777605057,
-0.08514254540205002,
0.05003004148602486,
0.024680783972144127,
-0.005317011382430792,
-0.11863664537668228,
0.0101414630189538,
0.008593415841460228,
-0.03215714544057846,
0.05959978327155113,
-0.04528035596013069,
-0.016298465430736542,
-0.02221798337996006,
0.0026189249474555254,
0.000970827357377857,
-0.040882498025894165,
-0.032596930861473083,
0.05136699229478836,
-0.032755251973867416,
-0.05921277403831482,
-0.04397859051823616,
0.04489334300160408,
0.015216591767966747,
-0.05312613397836685,
0.033318180590867996,
0.057312898337841034,
-0.03335336223244667,
0.020705120638012886,
-0.02960638701915741,
0.003511690301820636,
0.01113537885248661,
0.0026299196761101484,
0.0008718755561858416,
0.015295753255486488,
-0.02045883983373642,
0.011205744929611683,
-0.0004617751983460039,
0.0015909255016595125,
-0.022974414750933647,
-0.005928313825279474,
-0.011513594537973404,
0.006222970318049192,
0.039017803966999054,
-0.015841087326407433,
-0.035992078483104706,
0.009481783956289291,
0.006165798287838697,
-0.0015722345560789108,
0.04211389645934105,
-0.01813676953315735,
0.021056948229670525,
-0.0009680786752142012,
-0.03620317578315735,
0.009569740854203701,
0.026334378868341446,
0.0127274040132761,
0.013993986882269382,
0.04109359532594681,
0.022816091775894165,
0.008830900304019451,
0.0339866541326046,
0.010150258429348469,
0.014811988919973373,
-0.023343835026025772,
0.004881623201072216,
0.02432895451784134,
-0.029483245685696602,
0.004186761565506458,
0.013167189434170723,
0.020705120638012886,
0.08056877553462982,
-0.011293701827526093,
-0.013017662800848484,
0.021391185000538826,
-0.03416256979107857,
-0.006966208573430777,
-0.0029839472845196724,
0.000460400857264176,
0.032368242740631104,
-0.013906029984354973,
0.05724253132939339,
-0.0036370293237268925,
-0.05280948802828789,
-0.008030490018427372,
-0.024416912347078323,
-0.11610347777605057,
0.0005799676291644573,
0.014064352959394455,
0.048270899802446365,
0.015929045155644417,
0.013228759169578552,
0.03915853425860405,
-0.010801141150295734,
0.04626547545194626,
-0.04091767966747284,
-0.02812870591878891,
-0.010809937492012978,
-0.07895036041736603,
0.031172024086117744,
-0.012692220509052277,
0.025331666693091393,
0.03630872443318367,
-0.03425052389502525,
-0.027002854272723198,
0.049748580902814865,
-0.02142636850476265,
0.01048449520021677,
-0.057312898337841034,
-0.009736859239637852,
-0.06589751690626144,
-0.05302058532834053,
0.01463607419282198,
0.006895842961966991,
0.05115589499473572,
-0.009077181108295918,
0.0321747362613678,
-0.02290404960513115,
0.013914825394749641,
-0.08148352801799774,
0.012041337788105011,
-0.0020878834184259176,
-0.02091621607542038,
0.05073370039463043,
-0.012472327798604965,
0.01179505791515112,
0.03722347691655159,
-0.06178112328052521,
-0.01989591307938099,
-0.035763390362262726,
0.018330276012420654,
0.03887707367539406,
0.007581908721476793,
-0.011381658725440502,
-0.0007525836117565632,
0.03425052389502525,
0.0020944802090525627,
-0.03936963155865669,
0.018224727362394333,
-0.04042511805891991,
0.01959685981273651,
0.006843068636953831,
-0.0017976248636841774,
-0.015665173530578613,
-0.010862711817026138,
0.06741037964820862,
-0.01716044545173645,
-0.023431792855262756,
-0.03863079100847244,
0.005400570575147867,
0.02825184538960457,
0.016799820587038994,
-0.06938061863183975,
0.0019592461176216602,
0.008034888654947281,
-0.03739939257502556,
0.06948617100715637,
-0.03982701152563095,
-0.0021736416965723038,
0.01744190789759159,
-0.036625370383262634,
-0.04436559975147247,
-0.04911528900265694,
-0.010616431012749672,
-0.07508024573326111,
0.028937911614775658,
-0.07916145771741867,
0.004325294401496649,
0.018453415483236313,
-0.02568349614739418,
0.014855967834591866,
-0.03388110548257828,
-0.039123352617025375,
0.08085023611783981,
0.033670008182525635,
-0.04689876735210419,
0.0020988781470805407,
0.0531965009868145,
-0.03233305737376213,
-0.020881034433841705,
-0.006319723092019558,
0.03595689311623573,
0.015761926770210266,
-0.07958365231752396,
0.00137433095369488,
0.024293772876262665,
-0.018365459516644478,
-0.02784724347293377,
-0.10695593059062958,
0.04496371001005173,
-0.039475180208683014,
0.00080975575838238,
-0.0509096160531044,
-0.02074030227959156,
0.009780838154256344,
-0.04644139111042023,
-0.005163086578249931,
-0.0428527370095253,
-0.013061640784144402,
0.0188756100833416,
0.037082746624946594,
0.004243934061378241,
0.013431061059236526,
0.06684745848178864,
0.04176206886768341,
-0.04471743106842041,
0.03456716984510422,
0.011496002785861492,
0.0783170685172081,
0.013686137273907661,
0.01852378249168396,
-0.01994868740439415,
-0.001963644055649638,
0.02573627047240734,
0.05013559013605118,
-0.06646044552326202,
-0.0048728277906775475,
-0.04257127270102501,
-0.024469686672091484,
0.02313273772597313,
0.012665833346545696,
-0.027759285643696785,
-0.0224994458258152,
-0.0050971186719834805,
0.03697719797492027,
0.02920178323984146,
0.012322800233960152,
-0.029923031106591225,
0.02744263969361782,
0.06445501744747162,
0.007084950804710388,
-0.04573773220181465,
-0.014987902715802193,
-0.01457450445741415,
-0.014011578634381294,
-0.039123352617025375,
0.06389209628105164,
-0.05330204963684082,
0.03849006071686745,
-0.002238510176539421,
0.007274058647453785,
-0.016447992995381355,
0.05784064158797264,
0.00563805503770709,
-0.001755845150910318,
0.014618483372032642,
0.015981819480657578,
-0.019051523879170418,
-0.005180677864700556,
0.0022604994010180235,
0.03403942659497261,
0.0369420163333416,
-0.025665905326604843,
-0.005558893550187349,
-0.0343208909034729,
-0.03143589571118355,
0.002088983077555895,
0.01709887571632862,
-0.03461994603276253,
-0.032368242740631104,
-0.006095432210713625,
0.015955431386828423,
0.017705779522657394,
-0.04904492199420929,
-0.04130469262599945,
0.006508831400424242,
-0.04426005110144615,
-0.0021901337895542383,
0.01903393305838108,
0.03249138221144676,
-0.05745362862944603,
0.021461552008986473,
0.024223407730460167,
0.05192991718649864,
0.022816091775894165,
-0.03595689311623573,
-0.03143589571118355,
-0.029289741069078445,
-0.011970971710979939,
0.04858754575252533,
0.021795788779854774,
0.008052479475736618,
-0.019983870908617973,
-0.0037755619268864393,
-0.04777833819389343,
0.03358205035328865,
-0.041339874267578125,
0.032755251973867416,
-0.0351300984621048,
0.015445280820131302,
-0.05506119504570961,
0.02176060527563095,
-0.010194237343966961,
-0.01796085573732853,
-0.025595538318157196,
-0.0008449386223219335,
0.015295753255486488,
-0.0188052449375391,
0.004564977716654539,
0.006412078160792589,
0.004802461713552475,
-0.08401669561862946,
-0.01862933114171028,
-0.01022941991686821,
-0.057136982679367065,
-0.020423656329512596,
-0.06227368116378784,
-0.06104228273034096,
-0.04422486945986748,
-0.013000071048736572,
0.015436484478414059,
-0.026228830218315125,
0.05618704482913017,
0.014363407157361507,
0.03419775143265724,
0.04960784688591957
]
|
30,534 | networkx.algorithms.dag | dag_longest_path_length | Returns the longest path length in a DAG
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
weight : string, optional
Edge data key to use for weight
default_weight : int, optional
The weight of edges that do not have a weight attribute
Returns
-------
int
Longest path length
Raises
------
NetworkXNotImplemented
If `G` is not directed
Examples
--------
>>> DG = nx.DiGraph([(0, 1, {"cost": 1}), (1, 2, {"cost": 1}), (0, 2, {"cost": 42})])
>>> list(nx.all_simple_paths(DG, 0, 2))
[[0, 1, 2], [0, 2]]
>>> nx.dag_longest_path_length(DG)
2
>>> nx.dag_longest_path_length(DG, weight="cost")
42
See also
--------
dag_longest_path
| def transitive_closure_dag(G, topo_order=None):
"""Returns the transitive closure of a directed acyclic graph.
This function is faster than the function `transitive_closure`, but fails
if the graph has a cycle.
The transitive closure of G = (V,E) is a graph G+ = (V,E+) such that
for all v, w in V there is an edge (v, w) in E+ if and only if there
is a non-null path from v to w in G.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
topo_order: list or tuple, optional
A topological order for G (if None, the function will compute one)
Returns
-------
NetworkX DiGraph
The transitive closure of `G`
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` has a cycle
Examples
--------
>>> DG = nx.DiGraph([(1, 2), (2, 3)])
>>> TC = nx.transitive_closure_dag(DG)
>>> TC.edges()
OutEdgeView([(1, 2), (1, 3), (2, 3)])
Notes
-----
This algorithm is probably simple enough to be well-known but I didn't find
a mention in the literature.
"""
if topo_order is None:
topo_order = list(topological_sort(G))
TC = G.copy()
# idea: traverse vertices following a reverse topological order, connecting
# each vertex to its descendants at distance 2 as we go
for v in reversed(topo_order):
TC.add_edges_from((v, u) for u in nx.descendants_at_distance(TC, v, 2))
return TC
| (G, weight='weight', default_weight=1, *, backend=None, **backend_kwargs) | [
-0.032722052186727524,
0.021163780242204666,
-0.02473505772650242,
0.007943014614284039,
-0.036240555346012115,
-0.03105076588690281,
-0.018982309848070145,
-0.012622619979083538,
0.09309951961040497,
-0.07768848538398743,
0.012130030430853367,
0.02825355716049671,
0.0004870923876296729,
-0.011769384145736694,
-0.03159613162279129,
0.022412847727537155,
-0.0140036316588521,
-0.017328614369034767,
0.0031908401288092136,
0.029432255774736404,
0.0009450471843592823,
-0.06410707533359528,
0.013493448495864868,
-0.02392580173909664,
-0.01571889966726303,
0.016536951065063477,
-0.047042351216077805,
0.032123908400535583,
-0.06058857589960098,
-0.031314652413129807,
0.031156320124864578,
-0.04542383924126625,
-0.09056620299816132,
0.01345826406031847,
0.052671950310468674,
0.08099588006734848,
-0.0004252437502145767,
0.01810268498957157,
-0.017143893986940384,
-0.06041265279054642,
0.012200400233268738,
-0.018436942249536514,
-0.01149670034646988,
-0.03244057297706604,
0.0458812452852726,
0.01345826406031847,
-0.009192082099616528,
0.03807017579674721,
-0.037331290543079376,
-0.04947011545300484,
0.08634399622678757,
-0.03715536370873451,
-0.005783535074442625,
-0.010634667240083218,
0.015261495485901833,
0.03905535489320755,
0.019527677446603775,
0.059427469968795776,
0.06815335154533386,
-0.017803611233830452,
-0.009974948130548,
-0.0552404560148716,
-0.009068934246897697,
0.035501670092344284,
-0.0509478859603405,
0.02125174179673195,
-0.03680351376533508,
-0.06006080284714699,
-0.02114618755877018,
0.007336073089390993,
-0.013695762492716312,
0.02019619196653366,
0.005590017419308424,
-0.07606998085975647,
-0.027356339618563652,
-0.07635145634412766,
0.027936892583966255,
-0.04521273076534271,
-0.028570223599672318,
-0.03513222560286522,
-0.03439334034919739,
-0.06843483448028564,
0.023450804874300957,
-0.008272874169051647,
0.06129227578639984,
-0.027989670634269714,
0.03368964046239853,
-0.0014414855977520347,
-0.06769594550132751,
-0.04070904850959778,
0.00783306173980236,
-0.03432296961545944,
-0.03119150549173355,
0.032722052186727524,
0.037436842918395996,
-0.008875417523086071,
-0.0009587913518771529,
-0.04852012172341347,
0.01012448500841856,
0.009992540813982487,
0.03894979879260063,
0.007503202185034752,
-0.08535882085561752,
-0.006254134234040976,
0.023222101852297783,
-0.045353468507528305,
-0.017478151246905327,
0.016809634864330292,
-0.017337409779429436,
-0.0874699205160141,
-0.0024475567042827606,
-0.001305143698118627,
0.09788467735052109,
-0.03894979879260063,
0.03154335543513298,
0.013167987577617168,
0.007797876372933388,
0.0007004014914855361,
-0.00035075051710009575,
-0.005682378076016903,
0.014170760288834572,
0.02218414470553398,
0.001111076446250081,
0.01265780534595251,
-0.007274499628692865,
0.008057366125285625,
0.009315229952335358,
0.027637820690870285,
0.03437574952840805,
-0.010854573920369148,
0.06101079657673836,
-0.013722151517868042,
0.03332019969820976,
0.08169957995414734,
0.05168677121400833,
0.003749402007088065,
-0.032370202243328094,
0.015402235090732574,
-0.020284155383706093,
0.022764697670936584,
-0.010133281350135803,
-0.06139783188700676,
-0.021550815552473068,
0.04936455935239792,
0.049786780029535294,
0.003953914623707533,
-0.005801127292215824,
-0.013255950063467026,
0.011927716434001923,
0.01926378905773163,
0.00851037260144949,
0.0038505587726831436,
-0.014848071150481701,
0.032616499811410904,
0.00014486325380858034,
-0.007828663103282452,
-0.043664589524269104,
0.07241073995828629,
-0.053657129406929016,
0.012059659697115421,
-0.0312618762254715,
0.04725345969200134,
-0.04004053398966789,
0.024752650409936905,
0.016633709892630577,
-0.0018450135830789804,
0.11414015293121338,
0.006320106331259012,
-0.0314553938806057,
0.03140261396765709,
-0.056788597255945206,
-0.030769284814596176,
-0.007309684529900551,
-0.0049039097502827644,
-0.006152977701276541,
0.029924845322966576,
0.0038505587726831436,
0.030610952526330948,
-0.016079546883702278,
0.021867480129003525,
-0.016545748338103294,
0.0005662586772814393,
-0.045705318450927734,
0.02119896560907364,
0.0324229821562767,
0.031015580520033836,
0.0412016399204731,
-0.04011090472340584,
0.07698478549718857,
-0.020970262587070465,
-0.05506452918052673,
0.012701786123216152,
0.03785906359553337,
0.023310065269470215,
0.07522553950548172,
-0.05597934126853943,
-0.02996003068983555,
0.03715536370873451,
-0.04771086573600769,
0.07153110951185226,
0.06396633386611938,
0.015076774172484875,
0.07188296318054199,
0.03332019969820976,
0.023697100579738617,
0.08155883848667145,
0.03434056416153908,
-0.033056311309337616,
-0.023714693263173103,
0.008615927770733833,
-0.012974469922482967,
-0.025561904534697533,
0.010661056265234947,
-0.03997016325592995,
-0.05175714194774628,
0.03224705532193184,
-0.03824609890580177,
0.013502244837582111,
0.04809790104627609,
0.0018900943687185645,
-0.02637116052210331,
0.03712017834186554,
0.025614682585000992,
-0.016888801008462906,
0.070440374314785,
-0.07754775136709213,
-0.00043513954733498394,
0.011250404641032219,
0.020284155383706093,
-0.05949784070253372,
0.010977720841765404,
-0.007142555899918079,
0.03284519910812378,
-0.019721195101737976,
0.06196079030632973,
-0.04436828941106796,
-0.035149820148944855,
0.0032238259445875883,
0.01885916106402874,
0.01790916733443737,
-0.050666406750679016,
-0.006034228019416332,
-0.024611910805106163,
0.010590686462819576,
-0.017055930569767952,
-0.005202982574701309,
0.026599863544106483,
0.0060122376307845116,
0.032510943710803986,
0.026406345888972282,
-0.051229365170001984,
-0.035607222467660904,
-0.04862567409873009,
-0.029572995379567146,
-0.031015580520033836,
-0.01246428769081831,
-0.004105649888515472,
-0.056788597255945206,
-0.005409694276750088,
0.01731102168560028,
0.0003754899662453681,
0.017231855541467667,
-0.05766822025179863,
0.06931445747613907,
0.008849028497934341,
-0.029520217329263687,
0.03423500806093216,
-0.08184032142162323,
-0.06681632250547409,
-0.005568027030676603,
-0.016589729115366936,
0.003883544821292162,
0.04401643946766853,
0.0053613148629665375,
0.0037713926285505295,
-0.040920160710811615,
0.015525382943451405,
0.01602676883339882,
-0.0030325076077133417,
-0.029924845322966576,
-0.04183496907353401,
0.029273923486471176,
-0.03124428354203701,
-0.0231341402977705,
-0.06273486465215683,
-0.006421263329684734,
-0.011294386349618435,
-0.026898935437202454,
0.022078590467572212,
0.018524903804063797,
0.07656256854534149,
0.0026586668100208044,
0.07297369837760925,
0.024840611964464188,
0.06305152922868729,
0.035343337804079056,
0.02642393857240677,
-0.02547394298017025,
-0.0024365615099668503,
0.03298594057559967,
0.07360702753067017,
0.009543932043015957,
-0.01631704531610012,
-0.0518626943230629,
0.0017900370294228196,
0.004587244708091021,
0.009869393892586231,
-0.007995791733264923,
-0.02939707040786743,
0.04014609009027481,
-0.05168677121400833,
-0.049927521497011185,
-0.07040519267320633,
0.04507198929786682,
-0.06924408674240112,
-0.034164637327194214,
-0.032669275999069214,
-0.049329373985528946,
0.05446638539433479,
0.011742995120584965,
0.0023859830107539892,
0.015639733523130417,
-0.00848398357629776,
-0.006579595617949963,
-0.07656256854534149,
0.04683123901486397,
0.009658283554017544,
0.057844147086143494,
0.05854784697294235,
0.010194854810833931,
-0.005691174417734146,
0.0385979488492012,
0.005255760159343481,
0.05710526183247566,
-0.003030308522284031,
0.07079222798347473,
0.09661801904439926,
-0.029977623373270035,
0.015279088169336319,
-0.028183188289403915,
0.04556458070874214,
0.041870154440402985,
-0.02881651744246483,
0.009746246039867401,
-0.012349936179816723,
0.010036522522568703,
0.0030325076077133417,
-0.0014019025256857276,
0.037049807608127594,
-0.02288784459233284,
0.043171998113393784,
0.03810535743832588,
-0.01820823922753334,
0.02726837806403637,
-0.039231278002262115,
0.06572558730840683,
0.04911826550960541,
-0.00865551084280014,
0.014909645542502403,
0.027901707217097282,
0.0033777602948248386,
-0.0220961831510067,
0.01940452866256237,
-0.03627573698759079,
0.0552404560148716,
0.0032722053583711386,
-0.009024953469634056,
0.037436842918395996,
-0.02095266990363598,
-0.044509030878543854,
0.01701194979250431,
-0.011320775374770164,
0.04070904850959778,
0.009262451902031898,
-0.05129973590373993,
0.030470212921500206,
0.047781236469745636,
-0.05407935008406639,
0.0530238002538681,
0.03602944314479828,
-0.019985081627964973,
0.01761009357869625,
-0.008066162467002869,
0.03124428354203701,
0.020424894988536835,
0.015270291827619076,
0.04359421879053116,
0.00858074240386486,
0.023503582924604416,
-0.02781374566257,
-0.005638396833091974,
-0.02702208235859871,
0.04542383924126625,
-0.003953914623707533,
0.0003326082369312644,
-0.034305378794670105,
0.06611262261867523,
0.044614583253860474,
0.025790607556700706,
0.0029071609023958445,
-0.014584183692932129,
0.007670330815017223,
0.02199062705039978,
0.008941388688981533,
0.02367950789630413,
-0.03349612280726433,
0.012174011208117008,
0.036838699132204056,
0.06178486719727516,
0.048836786299943924,
-0.0037032216787338257,
0.006342096719890833,
0.032071132212877274,
-0.017152689397335052,
-0.020161006599664688,
-0.01970360241830349,
-0.07110889256000519,
0.0029599384870380163,
0.058688584715127945,
0.0023002196103334427,
0.0488719716668129,
0.029027627781033516,
0.0284646674990654,
-0.03902016952633858,
0.004644420463591814,
-0.034059084951877594,
0.031420208513736725,
0.039231278002262115,
-0.010397168807685375,
0.09197360277175903,
0.010705037042498589,
-0.032071132212877274,
0.013203172944486141,
-0.03330260515213013,
0.00006892687088111416,
0.02098785527050495,
0.014188352972269058,
0.00813213363289833,
0.04000534862279892,
0.0661478042602539,
-0.0076571363024413586,
0.0402868278324604,
-0.02528042532503605,
-0.060870055109262466,
-0.011971697211265564,
-0.029432255774736404,
0.009016157127916813,
0.0329507552087307,
0.04918863624334335,
-0.022272108122706413,
0.046268280595541,
0.04651457443833351,
-0.006702743005007505,
-0.011619847267866135,
-0.08507733792066574,
0.050033073872327805,
0.024611910805106163,
-0.005387703888118267,
-0.11864383518695831,
0.010168465785682201,
0.00858074240386486,
-0.03214149922132492,
0.05963858217000961,
-0.04528310149908066,
-0.01631704531610012,
-0.022166552022099495,
0.002638875273987651,
0.0009549430105835199,
-0.040920160710811615,
-0.03254612907767296,
0.05140529200434685,
-0.03277483209967613,
-0.05921636149287224,
-0.04398125410079956,
0.045001618564128876,
0.015191125683486462,
-0.05312935635447502,
0.03330260515213013,
0.05735155567526817,
-0.0333377905189991,
0.020688781514763832,
-0.029572995379567146,
0.0035053060855716467,
0.011136054061353207,
0.0026564677245914936,
0.0009477960411459208,
0.01532306894659996,
-0.020424894988536835,
0.011224016547203064,
-0.0004618031671270728,
0.001651496160775423,
-0.0229406226426363,
-0.005941867362707853,
-0.01147031132131815,
0.006192560773342848,
0.03894979879260063,
-0.015806863084435463,
-0.03601185232400894,
0.0094559695571661,
0.0062365420162677765,
-0.001593220978975296,
0.042116448283195496,
-0.018173053860664368,
0.021111002191901207,
-0.0009796824306249619,
-0.03620536997914314,
0.009508747607469559,
0.026300789788365364,
0.012728175148367882,
0.013994835317134857,
0.04109608381986618,
0.022817475721240044,
0.008809445425868034,
0.03404149040579796,
0.01012448500841856,
0.014786497689783573,
-0.023310065269470215,
0.004947890993207693,
0.024348022416234016,
-0.029520217329263687,
0.004156228620558977,
0.013132802210748196,
0.020688781514763832,
0.08043292164802551,
-0.011294386349618435,
-0.013000858947634697,
0.021410074084997177,
-0.03412945196032524,
-0.0069578345865011215,
-0.00297973002307117,
0.00040710149914957583,
0.03240538761019707,
-0.013924465514719486,
0.05728118494153023,
-0.0036680365446954966,
-0.052812691777944565,
-0.008000190369784832,
-0.02443598583340645,
-0.11611051112413406,
0.000672363443300128,
0.014047612436115742,
0.04827382415533066,
0.015947602689266205,
0.01323835738003254,
0.03916090726852417,
-0.010757815092802048,
0.04623309522867203,
-0.04088497534394264,
-0.02816559560596943,
-0.010889758355915546,
-0.07895515114068985,
0.031138727441430092,
-0.012710582464933395,
0.025333203375339508,
0.03631092235445976,
-0.03428778797388077,
-0.027004489675164223,
0.049786780029535294,
-0.021480444818735123,
0.010432353243231773,
-0.05728118494153023,
-0.009667079895734787,
-0.0659015104174614,
-0.05309417098760605,
0.014619369059801102,
0.006891862489283085,
0.05119417980313301,
-0.009060138836503029,
0.032123908400535583,
-0.0229406226426363,
0.013906872831285,
-0.0814884677529335,
0.01204206794500351,
-0.002123194979503751,
-0.020935077220201492,
0.050771959125995636,
-0.01243789866566658,
0.011857346631586552,
0.03722573444247246,
-0.06167931109666824,
-0.019826749339699745,
-0.03578314930200577,
0.0182610172778368,
0.03894979879260063,
0.007595562841743231,
-0.011391145177185535,
-0.0007410841644741595,
0.03434056416153908,
0.0021275931503623724,
-0.03940720483660698,
0.0182610172778368,
-0.04039238393306732,
0.019580453634262085,
0.006817094516009092,
-0.0017944352002814412,
-0.01563093811273575,
-0.010836981236934662,
0.06741447001695633,
-0.017231855541467667,
-0.023415619507431984,
-0.03866831958293915,
0.0054228887893259525,
0.028200780972838402,
0.016800839453935623,
-0.06942000985145569,
0.0019406728679314256,
0.008057366125285625,
-0.03740165755152702,
0.06942000985145569,
-0.03979424014687538,
-0.0021781716495752335,
0.017434168606996536,
-0.03662759065628052,
-0.044403474777936935,
-0.04904789477586746,
-0.01059948280453682,
-0.07508479803800583,
0.028922073543071747,
-0.07916625589132309,
0.00427937600761652,
0.018436942249536514,
-0.025685053318738937,
0.01487446017563343,
-0.033953528851270676,
-0.039125725626945496,
0.08078476786613464,
0.03367204964160919,
-0.04690160974860191,
0.002126493724063039,
0.05319972708821297,
-0.03235261142253876,
-0.020917484536767006,
-0.006280523259192705,
0.035941481590270996,
0.01582445576786995,
-0.07958848029375076,
0.0013590208254754543,
0.024295244365930557,
-0.018348978832364082,
-0.02786652371287346,
-0.10689204186201096,
0.0449664331972599,
-0.039477575570344925,
0.0008081555715762079,
-0.05084232985973358,
-0.02070637419819832,
0.00977263506501913,
-0.04640901833772659,
-0.005172195378690958,
-0.0428905189037323,
-0.013088821433484554,
0.01880638487637043,
0.03708499297499657,
0.004274977836757898,
0.01340548601001501,
0.06695706397294998,
0.04179978370666504,
-0.04472013935446739,
0.03458685800433159,
0.011514292098581791,
0.07825145125389099,
0.013607800006866455,
0.01850731112062931,
-0.019932305440306664,
-0.001981355482712388,
0.025702646002173424,
0.05010344460606575,
-0.06642928719520569,
-0.004846734460443258,
-0.04253866896033287,
-0.024471169337630272,
0.023116547614336014,
0.012728175148367882,
-0.027778560295701027,
-0.02248321659862995,
-0.005075437016785145,
0.037049807608127594,
0.029168367385864258,
0.012376325204968452,
-0.02990725263953209,
0.027356339618563652,
0.06449411064386368,
0.007129361387342215,
-0.045705318450927734,
-0.015041588805615902,
-0.014540202915668488,
-0.014021224342286587,
-0.03905535489320755,
0.06389596313238144,
-0.05319972708821297,
0.038492392748594284,
-0.002324409317225218,
0.007296490017324686,
-0.016440192237496376,
0.057879332453012466,
0.005651591345667839,
-0.0016613919287919998,
0.014601776376366615,
0.015947602689266205,
-0.019035087898373604,
-0.005172195378690958,
0.0023002196103334427,
0.03398871421813965,
0.036944255232810974,
-0.025702646002173424,
-0.005629600491374731,
-0.034305378794670105,
-0.0314553938806057,
0.00208251248113811,
0.01710870862007141,
-0.03458685800433159,
-0.03244057297706604,
-0.0060430243611335754,
0.01597399078309536,
0.01775963045656681,
-0.04911826550960541,
-0.04130719602108002,
0.006469642743468285,
-0.04429791867733002,
-0.0021968637593090534,
0.019017495214939117,
0.03249334916472435,
-0.05742192640900612,
0.02149803750216961,
0.024260060861706734,
0.05200343579053879,
0.022817475721240044,
-0.03595907241106033,
-0.031420208513736725,
-0.02925633080303669,
-0.011945309117436409,
0.048590488731861115,
0.02179710939526558,
0.007995791733264923,
-0.019985081627964973,
-0.003815373871475458,
-0.047781236469745636,
0.033619269728660583,
-0.04130719602108002,
0.032722052186727524,
-0.035061854869127274,
0.015498993918299675,
-0.054994162172079086,
0.021726740524172783,
-0.010203651152551174,
-0.01801472157239914,
-0.025614682585000992,
-0.0008636818965896964,
0.015270291827619076,
-0.018823977559804916,
0.004543263465166092,
0.006399272475391626,
0.004780762363225222,
-0.08402179181575775,
-0.018595274537801743,
-0.010168465785682201,
-0.057140447199344635,
-0.020460080355405807,
-0.062312640249729156,
-0.06104598194360733,
-0.0441923663020134,
-0.01300965528935194,
0.015367050655186176,
-0.02626560442149639,
0.05619044974446297,
0.014399462379515171,
0.034164637327194214,
0.04961085692048073
]
|
30,535 | networkx.algorithms.dag | dag_to_branching | Returns a branching representing all (overlapping) paths from
root nodes to leaf nodes in the given directed acyclic graph.
As described in :mod:`networkx.algorithms.tree.recognition`, a
*branching* is a directed forest in which each node has at most one
parent. In other words, a branching is a disjoint union of
*arborescences*. For this function, each node of in-degree zero in
`G` becomes a root of one of the arborescences, and there will be
one leaf node for each distinct path from that root to a leaf node
in `G`.
Each node `v` in `G` with *k* parents becomes *k* distinct nodes in
the returned branching, one for each parent, and the sub-DAG rooted
at `v` is duplicated for each copy. The algorithm then recurses on
the children of each copy of `v`.
Parameters
----------
G : NetworkX graph
A directed acyclic graph.
Returns
-------
DiGraph
The branching in which there is a bijection between root-to-leaf
paths in `G` (in which multiple paths may share the same leaf)
and root-to-leaf paths in the branching (in which there is a
unique path from a root to a leaf).
Each node has an attribute 'source' whose value is the original
node to which this node corresponds. No other graph, node, or
edge attributes are copied into this new graph.
Raises
------
NetworkXNotImplemented
If `G` is not directed, or if `G` is a multigraph.
HasACycle
If `G` is not acyclic.
Examples
--------
To examine which nodes in the returned branching were produced by
which original node in the directed acyclic graph, we can collect
the mapping from source node to new nodes into a dictionary. For
example, consider the directed diamond graph::
>>> from collections import defaultdict
>>> from operator import itemgetter
>>>
>>> G = nx.DiGraph(nx.utils.pairwise("abd"))
>>> G.add_edges_from(nx.utils.pairwise("acd"))
>>> B = nx.dag_to_branching(G)
>>>
>>> sources = defaultdict(set)
>>> for v, source in B.nodes(data="source"):
... sources[source].add(v)
>>> len(sources["a"])
1
>>> len(sources["d"])
2
To copy node attributes from the original graph to the new graph,
you can use a dictionary like the one constructed in the above
example::
>>> for source, nodes in sources.items():
... for v in nodes:
... B.nodes[v].update(G.nodes[source])
Notes
-----
This function is not idempotent in the sense that the node labels in
the returned branching may be uniquely generated each time the
function is invoked. In fact, the node labels may not be integers;
in order to relabel the nodes to be more readable, you can use the
:func:`networkx.convert_node_labels_to_integers` function.
The current implementation of this function uses
:func:`networkx.prefix_tree`, so it is subject to the limitations of
that function.
| def transitive_closure_dag(G, topo_order=None):
"""Returns the transitive closure of a directed acyclic graph.
This function is faster than the function `transitive_closure`, but fails
if the graph has a cycle.
The transitive closure of G = (V,E) is a graph G+ = (V,E+) such that
for all v, w in V there is an edge (v, w) in E+ if and only if there
is a non-null path from v to w in G.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
topo_order: list or tuple, optional
A topological order for G (if None, the function will compute one)
Returns
-------
NetworkX DiGraph
The transitive closure of `G`
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` has a cycle
Examples
--------
>>> DG = nx.DiGraph([(1, 2), (2, 3)])
>>> TC = nx.transitive_closure_dag(DG)
>>> TC.edges()
OutEdgeView([(1, 2), (1, 3), (2, 3)])
Notes
-----
This algorithm is probably simple enough to be well-known but I didn't find
a mention in the literature.
"""
if topo_order is None:
topo_order = list(topological_sort(G))
TC = G.copy()
# idea: traverse vertices following a reverse topological order, connecting
# each vertex to its descendants at distance 2 as we go
for v in reversed(topo_order):
TC.add_edges_from((v, u) for u in nx.descendants_at_distance(TC, v, 2))
return TC
| (G, *, backend=None, **backend_kwargs) | [
-0.032722052186727524,
0.021163780242204666,
-0.02473505772650242,
0.007943014614284039,
-0.036240555346012115,
-0.03105076588690281,
-0.018982309848070145,
-0.012622619979083538,
0.09309951961040497,
-0.07768848538398743,
0.012130030430853367,
0.02825355716049671,
0.0004870923876296729,
-0.011769384145736694,
-0.03159613162279129,
0.022412847727537155,
-0.0140036316588521,
-0.017328614369034767,
0.0031908401288092136,
0.029432255774736404,
0.0009450471843592823,
-0.06410707533359528,
0.013493448495864868,
-0.02392580173909664,
-0.01571889966726303,
0.016536951065063477,
-0.047042351216077805,
0.032123908400535583,
-0.06058857589960098,
-0.031314652413129807,
0.031156320124864578,
-0.04542383924126625,
-0.09056620299816132,
0.01345826406031847,
0.052671950310468674,
0.08099588006734848,
-0.0004252437502145767,
0.01810268498957157,
-0.017143893986940384,
-0.06041265279054642,
0.012200400233268738,
-0.018436942249536514,
-0.01149670034646988,
-0.03244057297706604,
0.0458812452852726,
0.01345826406031847,
-0.009192082099616528,
0.03807017579674721,
-0.037331290543079376,
-0.04947011545300484,
0.08634399622678757,
-0.03715536370873451,
-0.005783535074442625,
-0.010634667240083218,
0.015261495485901833,
0.03905535489320755,
0.019527677446603775,
0.059427469968795776,
0.06815335154533386,
-0.017803611233830452,
-0.009974948130548,
-0.0552404560148716,
-0.009068934246897697,
0.035501670092344284,
-0.0509478859603405,
0.02125174179673195,
-0.03680351376533508,
-0.06006080284714699,
-0.02114618755877018,
0.007336073089390993,
-0.013695762492716312,
0.02019619196653366,
0.005590017419308424,
-0.07606998085975647,
-0.027356339618563652,
-0.07635145634412766,
0.027936892583966255,
-0.04521273076534271,
-0.028570223599672318,
-0.03513222560286522,
-0.03439334034919739,
-0.06843483448028564,
0.023450804874300957,
-0.008272874169051647,
0.06129227578639984,
-0.027989670634269714,
0.03368964046239853,
-0.0014414855977520347,
-0.06769594550132751,
-0.04070904850959778,
0.00783306173980236,
-0.03432296961545944,
-0.03119150549173355,
0.032722052186727524,
0.037436842918395996,
-0.008875417523086071,
-0.0009587913518771529,
-0.04852012172341347,
0.01012448500841856,
0.009992540813982487,
0.03894979879260063,
0.007503202185034752,
-0.08535882085561752,
-0.006254134234040976,
0.023222101852297783,
-0.045353468507528305,
-0.017478151246905327,
0.016809634864330292,
-0.017337409779429436,
-0.0874699205160141,
-0.0024475567042827606,
-0.001305143698118627,
0.09788467735052109,
-0.03894979879260063,
0.03154335543513298,
0.013167987577617168,
0.007797876372933388,
0.0007004014914855361,
-0.00035075051710009575,
-0.005682378076016903,
0.014170760288834572,
0.02218414470553398,
0.001111076446250081,
0.01265780534595251,
-0.007274499628692865,
0.008057366125285625,
0.009315229952335358,
0.027637820690870285,
0.03437574952840805,
-0.010854573920369148,
0.06101079657673836,
-0.013722151517868042,
0.03332019969820976,
0.08169957995414734,
0.05168677121400833,
0.003749402007088065,
-0.032370202243328094,
0.015402235090732574,
-0.020284155383706093,
0.022764697670936584,
-0.010133281350135803,
-0.06139783188700676,
-0.021550815552473068,
0.04936455935239792,
0.049786780029535294,
0.003953914623707533,
-0.005801127292215824,
-0.013255950063467026,
0.011927716434001923,
0.01926378905773163,
0.00851037260144949,
0.0038505587726831436,
-0.014848071150481701,
0.032616499811410904,
0.00014486325380858034,
-0.007828663103282452,
-0.043664589524269104,
0.07241073995828629,
-0.053657129406929016,
0.012059659697115421,
-0.0312618762254715,
0.04725345969200134,
-0.04004053398966789,
0.024752650409936905,
0.016633709892630577,
-0.0018450135830789804,
0.11414015293121338,
0.006320106331259012,
-0.0314553938806057,
0.03140261396765709,
-0.056788597255945206,
-0.030769284814596176,
-0.007309684529900551,
-0.0049039097502827644,
-0.006152977701276541,
0.029924845322966576,
0.0038505587726831436,
0.030610952526330948,
-0.016079546883702278,
0.021867480129003525,
-0.016545748338103294,
0.0005662586772814393,
-0.045705318450927734,
0.02119896560907364,
0.0324229821562767,
0.031015580520033836,
0.0412016399204731,
-0.04011090472340584,
0.07698478549718857,
-0.020970262587070465,
-0.05506452918052673,
0.012701786123216152,
0.03785906359553337,
0.023310065269470215,
0.07522553950548172,
-0.05597934126853943,
-0.02996003068983555,
0.03715536370873451,
-0.04771086573600769,
0.07153110951185226,
0.06396633386611938,
0.015076774172484875,
0.07188296318054199,
0.03332019969820976,
0.023697100579738617,
0.08155883848667145,
0.03434056416153908,
-0.033056311309337616,
-0.023714693263173103,
0.008615927770733833,
-0.012974469922482967,
-0.025561904534697533,
0.010661056265234947,
-0.03997016325592995,
-0.05175714194774628,
0.03224705532193184,
-0.03824609890580177,
0.013502244837582111,
0.04809790104627609,
0.0018900943687185645,
-0.02637116052210331,
0.03712017834186554,
0.025614682585000992,
-0.016888801008462906,
0.070440374314785,
-0.07754775136709213,
-0.00043513954733498394,
0.011250404641032219,
0.020284155383706093,
-0.05949784070253372,
0.010977720841765404,
-0.007142555899918079,
0.03284519910812378,
-0.019721195101737976,
0.06196079030632973,
-0.04436828941106796,
-0.035149820148944855,
0.0032238259445875883,
0.01885916106402874,
0.01790916733443737,
-0.050666406750679016,
-0.006034228019416332,
-0.024611910805106163,
0.010590686462819576,
-0.017055930569767952,
-0.005202982574701309,
0.026599863544106483,
0.0060122376307845116,
0.032510943710803986,
0.026406345888972282,
-0.051229365170001984,
-0.035607222467660904,
-0.04862567409873009,
-0.029572995379567146,
-0.031015580520033836,
-0.01246428769081831,
-0.004105649888515472,
-0.056788597255945206,
-0.005409694276750088,
0.01731102168560028,
0.0003754899662453681,
0.017231855541467667,
-0.05766822025179863,
0.06931445747613907,
0.008849028497934341,
-0.029520217329263687,
0.03423500806093216,
-0.08184032142162323,
-0.06681632250547409,
-0.005568027030676603,
-0.016589729115366936,
0.003883544821292162,
0.04401643946766853,
0.0053613148629665375,
0.0037713926285505295,
-0.040920160710811615,
0.015525382943451405,
0.01602676883339882,
-0.0030325076077133417,
-0.029924845322966576,
-0.04183496907353401,
0.029273923486471176,
-0.03124428354203701,
-0.0231341402977705,
-0.06273486465215683,
-0.006421263329684734,
-0.011294386349618435,
-0.026898935437202454,
0.022078590467572212,
0.018524903804063797,
0.07656256854534149,
0.0026586668100208044,
0.07297369837760925,
0.024840611964464188,
0.06305152922868729,
0.035343337804079056,
0.02642393857240677,
-0.02547394298017025,
-0.0024365615099668503,
0.03298594057559967,
0.07360702753067017,
0.009543932043015957,
-0.01631704531610012,
-0.0518626943230629,
0.0017900370294228196,
0.004587244708091021,
0.009869393892586231,
-0.007995791733264923,
-0.02939707040786743,
0.04014609009027481,
-0.05168677121400833,
-0.049927521497011185,
-0.07040519267320633,
0.04507198929786682,
-0.06924408674240112,
-0.034164637327194214,
-0.032669275999069214,
-0.049329373985528946,
0.05446638539433479,
0.011742995120584965,
0.0023859830107539892,
0.015639733523130417,
-0.00848398357629776,
-0.006579595617949963,
-0.07656256854534149,
0.04683123901486397,
0.009658283554017544,
0.057844147086143494,
0.05854784697294235,
0.010194854810833931,
-0.005691174417734146,
0.0385979488492012,
0.005255760159343481,
0.05710526183247566,
-0.003030308522284031,
0.07079222798347473,
0.09661801904439926,
-0.029977623373270035,
0.015279088169336319,
-0.028183188289403915,
0.04556458070874214,
0.041870154440402985,
-0.02881651744246483,
0.009746246039867401,
-0.012349936179816723,
0.010036522522568703,
0.0030325076077133417,
-0.0014019025256857276,
0.037049807608127594,
-0.02288784459233284,
0.043171998113393784,
0.03810535743832588,
-0.01820823922753334,
0.02726837806403637,
-0.039231278002262115,
0.06572558730840683,
0.04911826550960541,
-0.00865551084280014,
0.014909645542502403,
0.027901707217097282,
0.0033777602948248386,
-0.0220961831510067,
0.01940452866256237,
-0.03627573698759079,
0.0552404560148716,
0.0032722053583711386,
-0.009024953469634056,
0.037436842918395996,
-0.02095266990363598,
-0.044509030878543854,
0.01701194979250431,
-0.011320775374770164,
0.04070904850959778,
0.009262451902031898,
-0.05129973590373993,
0.030470212921500206,
0.047781236469745636,
-0.05407935008406639,
0.0530238002538681,
0.03602944314479828,
-0.019985081627964973,
0.01761009357869625,
-0.008066162467002869,
0.03124428354203701,
0.020424894988536835,
0.015270291827619076,
0.04359421879053116,
0.00858074240386486,
0.023503582924604416,
-0.02781374566257,
-0.005638396833091974,
-0.02702208235859871,
0.04542383924126625,
-0.003953914623707533,
0.0003326082369312644,
-0.034305378794670105,
0.06611262261867523,
0.044614583253860474,
0.025790607556700706,
0.0029071609023958445,
-0.014584183692932129,
0.007670330815017223,
0.02199062705039978,
0.008941388688981533,
0.02367950789630413,
-0.03349612280726433,
0.012174011208117008,
0.036838699132204056,
0.06178486719727516,
0.048836786299943924,
-0.0037032216787338257,
0.006342096719890833,
0.032071132212877274,
-0.017152689397335052,
-0.020161006599664688,
-0.01970360241830349,
-0.07110889256000519,
0.0029599384870380163,
0.058688584715127945,
0.0023002196103334427,
0.0488719716668129,
0.029027627781033516,
0.0284646674990654,
-0.03902016952633858,
0.004644420463591814,
-0.034059084951877594,
0.031420208513736725,
0.039231278002262115,
-0.010397168807685375,
0.09197360277175903,
0.010705037042498589,
-0.032071132212877274,
0.013203172944486141,
-0.03330260515213013,
0.00006892687088111416,
0.02098785527050495,
0.014188352972269058,
0.00813213363289833,
0.04000534862279892,
0.0661478042602539,
-0.0076571363024413586,
0.0402868278324604,
-0.02528042532503605,
-0.060870055109262466,
-0.011971697211265564,
-0.029432255774736404,
0.009016157127916813,
0.0329507552087307,
0.04918863624334335,
-0.022272108122706413,
0.046268280595541,
0.04651457443833351,
-0.006702743005007505,
-0.011619847267866135,
-0.08507733792066574,
0.050033073872327805,
0.024611910805106163,
-0.005387703888118267,
-0.11864383518695831,
0.010168465785682201,
0.00858074240386486,
-0.03214149922132492,
0.05963858217000961,
-0.04528310149908066,
-0.01631704531610012,
-0.022166552022099495,
0.002638875273987651,
0.0009549430105835199,
-0.040920160710811615,
-0.03254612907767296,
0.05140529200434685,
-0.03277483209967613,
-0.05921636149287224,
-0.04398125410079956,
0.045001618564128876,
0.015191125683486462,
-0.05312935635447502,
0.03330260515213013,
0.05735155567526817,
-0.0333377905189991,
0.020688781514763832,
-0.029572995379567146,
0.0035053060855716467,
0.011136054061353207,
0.0026564677245914936,
0.0009477960411459208,
0.01532306894659996,
-0.020424894988536835,
0.011224016547203064,
-0.0004618031671270728,
0.001651496160775423,
-0.0229406226426363,
-0.005941867362707853,
-0.01147031132131815,
0.006192560773342848,
0.03894979879260063,
-0.015806863084435463,
-0.03601185232400894,
0.0094559695571661,
0.0062365420162677765,
-0.001593220978975296,
0.042116448283195496,
-0.018173053860664368,
0.021111002191901207,
-0.0009796824306249619,
-0.03620536997914314,
0.009508747607469559,
0.026300789788365364,
0.012728175148367882,
0.013994835317134857,
0.04109608381986618,
0.022817475721240044,
0.008809445425868034,
0.03404149040579796,
0.01012448500841856,
0.014786497689783573,
-0.023310065269470215,
0.004947890993207693,
0.024348022416234016,
-0.029520217329263687,
0.004156228620558977,
0.013132802210748196,
0.020688781514763832,
0.08043292164802551,
-0.011294386349618435,
-0.013000858947634697,
0.021410074084997177,
-0.03412945196032524,
-0.0069578345865011215,
-0.00297973002307117,
0.00040710149914957583,
0.03240538761019707,
-0.013924465514719486,
0.05728118494153023,
-0.0036680365446954966,
-0.052812691777944565,
-0.008000190369784832,
-0.02443598583340645,
-0.11611051112413406,
0.000672363443300128,
0.014047612436115742,
0.04827382415533066,
0.015947602689266205,
0.01323835738003254,
0.03916090726852417,
-0.010757815092802048,
0.04623309522867203,
-0.04088497534394264,
-0.02816559560596943,
-0.010889758355915546,
-0.07895515114068985,
0.031138727441430092,
-0.012710582464933395,
0.025333203375339508,
0.03631092235445976,
-0.03428778797388077,
-0.027004489675164223,
0.049786780029535294,
-0.021480444818735123,
0.010432353243231773,
-0.05728118494153023,
-0.009667079895734787,
-0.0659015104174614,
-0.05309417098760605,
0.014619369059801102,
0.006891862489283085,
0.05119417980313301,
-0.009060138836503029,
0.032123908400535583,
-0.0229406226426363,
0.013906872831285,
-0.0814884677529335,
0.01204206794500351,
-0.002123194979503751,
-0.020935077220201492,
0.050771959125995636,
-0.01243789866566658,
0.011857346631586552,
0.03722573444247246,
-0.06167931109666824,
-0.019826749339699745,
-0.03578314930200577,
0.0182610172778368,
0.03894979879260063,
0.007595562841743231,
-0.011391145177185535,
-0.0007410841644741595,
0.03434056416153908,
0.0021275931503623724,
-0.03940720483660698,
0.0182610172778368,
-0.04039238393306732,
0.019580453634262085,
0.006817094516009092,
-0.0017944352002814412,
-0.01563093811273575,
-0.010836981236934662,
0.06741447001695633,
-0.017231855541467667,
-0.023415619507431984,
-0.03866831958293915,
0.0054228887893259525,
0.028200780972838402,
0.016800839453935623,
-0.06942000985145569,
0.0019406728679314256,
0.008057366125285625,
-0.03740165755152702,
0.06942000985145569,
-0.03979424014687538,
-0.0021781716495752335,
0.017434168606996536,
-0.03662759065628052,
-0.044403474777936935,
-0.04904789477586746,
-0.01059948280453682,
-0.07508479803800583,
0.028922073543071747,
-0.07916625589132309,
0.00427937600761652,
0.018436942249536514,
-0.025685053318738937,
0.01487446017563343,
-0.033953528851270676,
-0.039125725626945496,
0.08078476786613464,
0.03367204964160919,
-0.04690160974860191,
0.002126493724063039,
0.05319972708821297,
-0.03235261142253876,
-0.020917484536767006,
-0.006280523259192705,
0.035941481590270996,
0.01582445576786995,
-0.07958848029375076,
0.0013590208254754543,
0.024295244365930557,
-0.018348978832364082,
-0.02786652371287346,
-0.10689204186201096,
0.0449664331972599,
-0.039477575570344925,
0.0008081555715762079,
-0.05084232985973358,
-0.02070637419819832,
0.00977263506501913,
-0.04640901833772659,
-0.005172195378690958,
-0.0428905189037323,
-0.013088821433484554,
0.01880638487637043,
0.03708499297499657,
0.004274977836757898,
0.01340548601001501,
0.06695706397294998,
0.04179978370666504,
-0.04472013935446739,
0.03458685800433159,
0.011514292098581791,
0.07825145125389099,
0.013607800006866455,
0.01850731112062931,
-0.019932305440306664,
-0.001981355482712388,
0.025702646002173424,
0.05010344460606575,
-0.06642928719520569,
-0.004846734460443258,
-0.04253866896033287,
-0.024471169337630272,
0.023116547614336014,
0.012728175148367882,
-0.027778560295701027,
-0.02248321659862995,
-0.005075437016785145,
0.037049807608127594,
0.029168367385864258,
0.012376325204968452,
-0.02990725263953209,
0.027356339618563652,
0.06449411064386368,
0.007129361387342215,
-0.045705318450927734,
-0.015041588805615902,
-0.014540202915668488,
-0.014021224342286587,
-0.03905535489320755,
0.06389596313238144,
-0.05319972708821297,
0.038492392748594284,
-0.002324409317225218,
0.007296490017324686,
-0.016440192237496376,
0.057879332453012466,
0.005651591345667839,
-0.0016613919287919998,
0.014601776376366615,
0.015947602689266205,
-0.019035087898373604,
-0.005172195378690958,
0.0023002196103334427,
0.03398871421813965,
0.036944255232810974,
-0.025702646002173424,
-0.005629600491374731,
-0.034305378794670105,
-0.0314553938806057,
0.00208251248113811,
0.01710870862007141,
-0.03458685800433159,
-0.03244057297706604,
-0.0060430243611335754,
0.01597399078309536,
0.01775963045656681,
-0.04911826550960541,
-0.04130719602108002,
0.006469642743468285,
-0.04429791867733002,
-0.0021968637593090534,
0.019017495214939117,
0.03249334916472435,
-0.05742192640900612,
0.02149803750216961,
0.024260060861706734,
0.05200343579053879,
0.022817475721240044,
-0.03595907241106033,
-0.031420208513736725,
-0.02925633080303669,
-0.011945309117436409,
0.048590488731861115,
0.02179710939526558,
0.007995791733264923,
-0.019985081627964973,
-0.003815373871475458,
-0.047781236469745636,
0.033619269728660583,
-0.04130719602108002,
0.032722052186727524,
-0.035061854869127274,
0.015498993918299675,
-0.054994162172079086,
0.021726740524172783,
-0.010203651152551174,
-0.01801472157239914,
-0.025614682585000992,
-0.0008636818965896964,
0.015270291827619076,
-0.018823977559804916,
0.004543263465166092,
0.006399272475391626,
0.004780762363225222,
-0.08402179181575775,
-0.018595274537801743,
-0.010168465785682201,
-0.057140447199344635,
-0.020460080355405807,
-0.062312640249729156,
-0.06104598194360733,
-0.0441923663020134,
-0.01300965528935194,
0.015367050655186176,
-0.02626560442149639,
0.05619044974446297,
0.014399462379515171,
0.034164637327194214,
0.04961085692048073
]
|
30,538 | networkx.classes.function | degree | Returns a degree view of single node or of nbunch of nodes.
If nbunch is omitted, then return degrees of *all* nodes.
This function wraps the :func:`G.degree <networkx.Graph.degree>` property.
| def degree(G, nbunch=None, weight=None):
"""Returns a degree view of single node or of nbunch of nodes.
If nbunch is omitted, then return degrees of *all* nodes.
This function wraps the :func:`G.degree <networkx.Graph.degree>` property.
"""
return G.degree(nbunch, weight)
| (G, nbunch=None, weight=None) | [
0.0204286091029644,
0.005291232373565435,
0.0401722677052021,
0.05253560096025467,
0.02053135074675083,
-0.0027740439400076866,
-0.026147933676838875,
0.01938406005501747,
0.05068623647093773,
-0.01813402771949768,
0.045446377247571945,
-0.010180057026445866,
0.020839577540755272,
0.026747263967990875,
0.006322936620563269,
-0.0008813369204290211,
0.007744206115603447,
-0.04089146479964256,
-0.022603321820497513,
0.03296317905187607,
-0.00016053495346568525,
-0.06907711923122406,
0.03935032710433006,
-0.012611625716090202,
-0.0943174958229065,
-0.012149285525083542,
0.0724676176905632,
0.012885605916380882,
-0.00958072580397129,
0.0031935754232108593,
-0.04048049449920654,
-0.04572035372257233,
-0.08644058555364609,
-0.0006646147230640054,
0.01577095314860344,
0.060823485255241394,
-0.00933243241161108,
0.04013802111148834,
-0.03904210031032562,
-0.012440389022231102,
0.0158908199518919,
0.012200656346976757,
-0.013502060435712337,
0.0024722383823245764,
-0.029110338538885117,
0.01705523394048214,
0.05907686427235603,
-0.004109695088118315,
0.01970941200852394,
-0.030052144080400467,
0.031028196215629578,
-0.02032586559653282,
-0.03320290893316269,
-0.023236900568008423,
0.009880391880869865,
0.0017637440469115973,
0.03387073427438736,
0.0045292261056602,
0.0002076252130791545,
0.05678228288888931,
-0.045617613941431046,
-0.041096948087215424,
0.04763821139931679,
0.017440518364310265,
-0.061439938843250275,
0.04048049449920654,
-0.01936693675816059,
0.03287756070494652,
0.021849878132343292,
0.005167085211724043,
0.016515836119651794,
-0.007478788495063782,
0.0028853481635451317,
0.011823934502899647,
0.05763847008347511,
0.006143137812614441,
-0.04839165881276131,
0.007658587768673897,
0.003876384114846587,
0.0026156494859606028,
-0.028151409700512886,
-0.03376799449324608,
-0.006352903321385384,
0.022877302020788193,
0.06863190233707428,
0.005291232373565435,
0.027295224368572235,
-0.022688940167427063,
-0.00040561830974183977,
0.021336166188120842,
-0.024863654747605324,
-0.01952105015516281,
-0.012765740044414997,
-0.01988064870238304,
0.03330565243959427,
-0.03138779476284981,
-0.060960475355386734,
0.04753547161817551,
-0.0052270181477069855,
0.0029195956885814667,
-0.002968826564028859,
0.03736397624015808,
-0.030308999121189117,
0.02030874229967594,
0.0037179896607995033,
-0.08445423096418381,
-0.045754604041576385,
0.0071020666509866714,
0.022534826770424843,
-0.03496665507555008,
-0.06349478662014008,
0.021969743072986603,
0.06462495028972626,
-0.03354538604617119,
0.016704197973012924,
0.09123522788286209,
0.047056008130311966,
-0.026935625821352005,
-0.00957216415554285,
0.029692545533180237,
0.008578987792134285,
0.06880313903093338,
-0.0030779901426285505,
0.03388785943388939,
-0.000013377913091972005,
-0.004317319951951504,
-0.000961604411713779,
0.012620188295841217,
0.0338364876806736,
-0.03458993136882782,
0.13041432201862335,
0.011481460183858871,
0.023921849206089973,
0.007658587768673897,
-0.029726792126893997,
0.04715874791145325,
-0.013596240431070328,
0.0052955131977796555,
0.009751963429152966,
0.08294734358787537,
-0.045754604041576385,
-0.04962456598877907,
0.021730011329054832,
0.07390601187944412,
0.03181588649749756,
0.022620445117354393,
-0.046919018030166626,
0.045103900134563446,
0.0017241453751921654,
-0.010847882367670536,
0.008138052187860012,
0.006691096816211939,
0.0779472142457962,
-0.045309387147426605,
0.0014769216068089008,
0.006010428536683321,
-0.027723316103219986,
0.03907634690403938,
-0.016909681260585785,
-0.0007657517562620342,
-0.013236641883850098,
0.030548732727766037,
-0.0170894805341959,
0.08089249581098557,
0.017149414867162704,
0.007149156648665667,
0.06736474484205246,
-0.025959571823477745,
-0.03291180729866028,
-0.027963049709796906,
0.008471964858472347,
-0.03308304399251938,
-0.0169182438403368,
0.0029880907386541367,
0.060138534754514694,
0.021079309284687042,
0.03426457941532135,
0.03392210602760315,
0.0006474909605458379,
0.008506212383508682,
-0.014914767816662788,
0.014050018973648548,
0.0008561864378862083,
-0.006429960019886494,
0.03277481719851494,
0.010180057026445866,
0.025514354929327965,
-0.011798248626291752,
0.023356765508651733,
-0.05301506444811821,
-0.03976129740476608,
0.021113557741045952,
-0.0037158490158617496,
0.060515258461236954,
0.027260975912213326,
0.01878472976386547,
-0.003912772051990032,
0.03320290893316269,
-0.10692056268453598,
0.03832290321588516,
0.009597850032150745,
-0.01799703948199749,
0.025240376591682434,
-0.0035146453883498907,
-0.022003991529345512,
0.026182180270552635,
-0.0009348485618829727,
0.00921256560832262,
0.0016160518862307072,
-0.024675292894244194,
0.07774172723293304,
0.003244946477934718,
0.03630230575799942,
0.06804969906806946,
-0.015556907281279564,
-0.010702330619096756,
-0.01864773966372013,
-0.016104867681860924,
0.045788850635290146,
-0.00010548484715400264,
-0.022569075226783752,
-0.008193704299628735,
0.08424874395132065,
-0.04191888868808746,
0.03344264253973961,
-0.09959160536527634,
-0.03210699185729027,
-0.07678280025720596,
-0.07096073031425476,
-0.022808806970715523,
0.0188018549233675,
-0.05948783457279205,
0.00196922873146832,
0.008707416243851185,
0.0007753838435746729,
-0.0035724379122257233,
-0.061439938843250275,
0.005809225142002106,
-0.005689358804374933,
0.011284537613391876,
-0.03551461175084114,
-0.023391013965010643,
-0.027432212606072426,
0.08705703914165497,
0.01953817345201969,
0.04191888868808746,
0.025052014738321304,
-0.044864170253276825,
-0.010239989496767521,
0.024384189397096634,
-0.06602909415960312,
-0.017012424767017365,
0.006143137812614441,
-0.029880907386541367,
-0.045240890234708786,
0.003985547926276922,
-0.03541187196969986,
0.046816274523735046,
-0.03989828750491142,
0.007350360509008169,
-0.004253106191754341,
-0.0331515371799469,
-0.04873413220047951,
0.01818539947271347,
0.05678228288888931,
0.002679863478988409,
0.05191914364695549,
-0.043631259351968765,
-0.05024101957678795,
-0.0012746475404128432,
-0.01857924647629261,
0.005852034315466881,
-0.021404661238193512,
-0.026319170370697975,
0.03274057060480118,
-0.008626078255474567,
0.008566144853830338,
0.08575563132762909,
0.00868173036724329,
0.009015643037855625,
-0.05024101957678795,
-0.00994032435119152,
-0.05479593202471733,
0.021336166188120842,
-0.11377005279064178,
0.060515258461236954,
0.03162752836942673,
0.010702330619096756,
0.006995043251663446,
-0.02080533094704151,
0.0724676176905632,
-0.01821964792907238,
-0.004559192806482315,
0.04075447469949722,
0.06328929960727692,
0.043391529470682144,
-0.014272627420723438,
-0.013544869609177113,
0.0200005155056715,
0.05174790695309639,
0.07411149889230728,
-0.05024101957678795,
-0.004300196189433336,
-0.04948757588863373,
0.0044350456446409225,
0.014443865045905113,
0.03244946524500847,
-0.012097914703190327,
-0.007992500439286232,
0.04825466871261597,
-0.08596111834049225,
-0.05452195182442665,
-0.016224732622504234,
0.0201717521995306,
-0.06928260624408722,
-0.026216428726911545,
-0.011430088430643082,
-0.0025086263194680214,
0.05633706599473953,
0.006691096816211939,
0.0035681568551808596,
0.03633655235171318,
-0.00963209755718708,
0.006485612131655216,
-0.03388785943388939,
0.06763872504234314,
-0.014897643588483334,
0.059556327760219574,
0.012928415089845657,
0.029452813789248466,
-0.0741799920797348,
0.0024658169131726027,
0.01938406005501747,
0.03613106906414032,
-0.1001395657658577,
0.042672332376241684,
0.09561890363693237,
-0.023870477452874184,
-0.04585734382271767,
0.011198918335139751,
0.023356765508651733,
-0.002049496164545417,
-0.03756945952773094,
0.05726175010204315,
0.015026072040200233,
0.027774687856435776,
0.017389146611094475,
0.021832754835486412,
0.05277533084154129,
0.027432212606072426,
0.0034654145129024982,
0.05661104619503021,
-0.024504056200385094,
-0.040001031011343,
-0.007221932522952557,
0.04890536889433861,
0.043460022658109665,
-0.041953135281801224,
-0.025599975138902664,
0.010034505277872086,
-0.04876837879419327,
-0.025805458426475525,
0.011164670810103416,
0.025839706882834435,
0.014717844314873219,
-0.01945255510509014,
-0.005000128876417875,
0.029915153980255127,
0.10897541046142578,
-0.017132289707660675,
-0.009914638474583626,
-0.012594502419233322,
-0.05140543356537819,
0.03339127078652382,
-0.029435688629746437,
0.01565108820796013,
0.03226110339164734,
0.026439037173986435,
0.005929091013967991,
-0.04869988560676575,
-0.016635702922940254,
-0.001174045610241592,
0.012868481688201427,
0.05092597007751465,
-0.0355488620698452,
0.00481604877859354,
0.0022346465848386288,
-0.0045763165690004826,
0.008454840630292892,
-0.024298571050167084,
-0.045754604041576385,
-0.01613055169582367,
-0.002117991214618087,
0.008861529640853405,
-0.03869962692260742,
0.02001763880252838,
0.013604802079498768,
-0.022243723273277283,
-0.06308381259441376,
-0.05606308579444885,
0.0018172557465732098,
-0.03750096634030342,
-0.02036011405289173,
0.03287756070494652,
-0.01736346073448658,
-0.007277584634721279,
0.043151795864105225,
-0.013913029804825783,
0.05335753783583641,
-0.05832342058420181,
-0.027243852615356445,
0.01902446337044239,
0.0096577825024724,
0.012431827373802662,
0.025052014738321304,
-0.023493755608797073,
-0.023682117462158203,
0.01638740859925747,
0.05068623647093773,
0.000809631310403347,
0.03979554399847984,
-0.007397450972348452,
0.03952156752347946,
-0.0022025397047400475,
0.047364234924316406,
-0.023425260558724403,
0.006733906455338001,
-0.0071448758244514465,
-0.021610146388411522,
0.06592635810375214,
-0.03527488186955452,
-0.0044650123454630375,
0.05058349296450615,
-0.03647354245185852,
0.029880907386541367,
0.00021712352463509887,
0.013621926307678223,
-0.0052612656727433205,
-0.006665411405265331,
-0.0185449980199337,
0.0370899960398674,
0.03431595116853714,
-0.02015462890267372,
-0.01933269016444683,
0.029298700392246246,
-0.027106862515211105,
0.00481176795437932,
-0.008921463042497635,
0.0044307648204267025,
-0.029778163880109787,
0.05606308579444885,
-0.012560254894196987,
0.0360625721514225,
-0.028921978548169136,
-0.04726149141788483,
0.05157667025923729,
-0.011027681641280651,
-0.01672988198697567,
-0.021575897932052612,
0.027980173006653786,
0.028065791353583336,
0.002076252130791545,
0.013399317860603333,
-0.0008208687650039792,
-0.061371441930532455,
0.0189730916172266,
0.03849414363503456,
-0.02020600065588951,
-0.01681550219655037,
0.01809978112578392,
0.06585785746574402,
-0.012962662614881992,
-0.03354538604617119,
-0.062398865818977356,
0.008112366311252117,
0.062227629125118256,
-0.03472692146897316,
-0.0037950463593006134,
0.007731363642960787,
-0.05534389242529869,
-0.043665509670972824,
-0.028305523097515106,
0.07781022042036057,
0.0021351149771362543,
-0.028784988448023796,
0.06394000351428986,
-0.0688716396689415,
-0.010693768970668316,
-0.01929844170808792,
-0.044384703040122986,
0.0011098316172137856,
0.01904158666729927,
0.02008613385260105,
0.0009530425304546952,
0.022860176861286163,
0.05253560096025467,
0.011858182027935982,
-0.07096073031425476,
-0.030771341174840927,
0.061439938843250275,
-0.03719273954629898,
0.0758923664689064,
0.08685155212879181,
-0.03976129740476608,
0.01979503035545349,
-0.059248100966215134,
0.005804943852126598,
0.01994914375245571,
0.003022338030859828,
0.0341789610683918,
0.007709958590567112,
0.05000128597021103,
0.045617613941431046,
0.029863782227039337,
0.001018861890770495,
0.045172397047281265,
0.04075447469949722,
0.026267800480127335,
0.013416441157460213,
-0.025206128135323524,
0.030017895624041557,
0.008493369445204735,
0.029795287176966667,
0.04760396480560303,
-0.024384189397096634,
0.04832316190004349,
-0.013604802079498768,
-0.026096561923623085,
-0.014871958643198013,
0.044281963258981705,
0.007457383908331394,
0.04048049449920654,
-0.021918373182415962,
0.05393974483013153,
-0.03952156752347946,
-0.031199432909488678,
-0.022192351520061493,
0.011335908435285091,
0.007243337109684944,
0.045823097229003906,
-0.025052014738321304,
-0.03291180729866028,
0.05935084447264671,
0.0393160805106163,
-0.00009424739982932806,
0.025154758244752884,
0.03378511592745781,
-0.012577379122376442,
0.022928671911358833,
-0.027192480862140656,
-0.013356508687138557,
-0.013082528486847878,
-0.04037775099277496,
-0.030308999121189117,
0.05688502639532089,
0.0204286091029644,
-0.05126844346523285,
-0.00934955570846796,
0.0007839457248337567,
-0.04685052111744881,
-0.0369187593460083,
-0.04003527760505676,
-0.021712888032197952,
0.00459344033151865,
0.05554937571287155,
-0.059008367359638214,
-0.00882728211581707,
-0.06534414738416672,
0.014914767816662788,
-0.002010967815294862,
-0.010967748239636421,
0.0027804654091596603,
0.0175175741314888,
0.011746877804398537,
-0.005894843488931656,
-0.029487060382962227,
-0.03267207369208336,
0.06537839770317078,
0.00204200460575521,
-0.05691927298903465,
-0.021832754835486412,
-0.004092571325600147,
-0.01642165519297123,
0.012303398922085762,
-0.0185449980199337,
0.028356894850730896,
0.014289751648902893,
0.007551564369350672,
-0.03477829322218895,
-0.03301454707980156,
0.007692835293710232,
-0.0724676176905632,
0.04726149141788483,
-0.01921282336115837,
-0.003632370848208666,
-0.013279451988637447,
-0.09123522788286209,
0.01835663802921772,
0.0317816399037838,
-0.030103515833616257,
-0.01993202045559883,
0.006870896089822054,
0.04219286888837814,
-0.03416183963418007,
-0.006053238175809383,
0.04030925780534744,
-0.05801519379019737,
0.00393845746293664,
0.007431698031723499,
-0.06644006818532944,
-0.0013067545369267464,
0.003461133688688278,
-0.06757023185491562,
-0.01741483248770237,
-0.043220292776823044,
0.0006169893313199282,
0.013082528486847878,
-0.014846272766590118,
-0.08774198591709137,
0.023459509015083313,
-0.05181640386581421,
-0.016721321269869804,
-0.046919018030166626,
-0.005094309337437153,
-0.014015771448612213,
0.00504721887409687,
0.0006255512125790119,
0.003018057206645608,
0.04027501121163368,
-0.01941830851137638,
-0.010111561976373196,
0.0045292261056602,
-0.00105524982791394,
0.0044692931696772575,
0.0015068880748003721,
-0.09287910163402557,
-0.023921849206089973,
-0.04890536889433861,
-0.011584202758967876,
-0.016789816319942474,
-0.07150869071483612,
0.07308407127857208,
-0.026319170370697975,
-0.059967298060655594,
-0.03928183391690254,
-0.004073306918144226,
0.017440518364310265,
0.029298700392246246,
0.01909295655786991,
-0.03876812011003494,
-0.04787794500589371,
0.03702150285243988,
0.04914510250091553,
-0.026815759018063545,
-0.03498377650976181,
0.00867316871881485,
0.027740441262722015,
0.013151023536920547,
-0.01583944819867611,
-0.030874082818627357,
-0.00970059260725975,
-0.004837453365325928,
0.026267800480127335,
0.012234903872013092,
0.045343633741140366,
0.03818591311573982,
-0.00979477260261774,
-0.03678176924586296,
-0.011455774307250977,
-0.03986404091119766,
-0.07198815792798996,
0.011918115429580212,
0.11356456577777863,
-0.03883661702275276,
-0.07335805147886276,
-0.011207479983568192,
0.05948783457279205,
0.03815166652202606,
0.030685720965266228,
0.0029902311507612467,
0.012799987569451332,
0.025360241532325745,
-0.003289896296337247,
-0.00248294067569077,
-0.04880262538790703,
0.05010402947664261,
-0.04859714210033417,
-0.024110209196805954,
0.021387537941336632,
-0.013527745380997658,
0.013895905576646328,
-0.04787794500589371,
0.031011072918772697,
0.03464130312204361,
0.024504056200385094,
-0.01655864529311657,
-0.03729547932744026,
0.08144045621156693,
-0.010616711340844631,
-0.011601326055824757,
0.006036114413291216,
-0.013596240431070328,
-0.015394232235848904,
0.008870091289281845,
0.01774018257856369,
-0.04037775099277496,
-0.0033434079959988594,
0.03479541838169098,
-0.00824507512152195,
0.0062415990978479385,
-0.03928183391690254,
0.0016342458548024297,
-0.006673973053693771,
0.01739770919084549,
0.03443581983447075,
0.005590897519141436,
-0.008715977892279625,
0.002007757080718875,
-0.05691927298903465,
0.01984640210866928,
-0.042912062257528305,
-0.05435071513056755,
0.0420558787882328,
0.027774687856435776,
0.004854577127844095,
-0.005650830455124378,
0.044829919934272766,
-0.029983649030327797,
-0.05671378970146179,
0.002985950093716383,
-0.028219904750585556,
0.024675292894244194,
0.04989854618906975,
0.006661130581051111,
-0.005471031181514263,
0.001999195432290435,
0.01804840937256813,
0.04753547161817551,
-0.029504183679819107,
0.0161476768553257,
-0.03791193664073944,
0.03149053826928139,
-0.021695764735341072,
0.009760525077581406,
0.0398297943174839,
-0.03150765970349312,
-0.05753572657704353,
0.0014940453693270683,
0.013022596016526222,
-0.029966525733470917,
0.01756894588470459,
0.03818591311573982,
0.04106270149350166,
-0.03780919313430786,
0.012680120766162872,
-0.05013827607035637,
-0.028887730091810226,
-0.01928131841123104,
-0.029487060382962227,
-0.07644032686948776,
-0.05791245028376579,
-0.030874082818627357,
-0.05013827607035637,
-0.05582335591316223,
-0.01876760646700859,
-0.00950366910547018,
0.04986429959535599,
0.022432085126638412
]
|
30,542 | networkx.classes.function | degree_histogram | Returns a list of the frequency of each degree value.
Parameters
----------
G : Networkx graph
A graph
Returns
-------
hist : list
A list of frequencies of degrees.
The degree values are the index in the list.
Notes
-----
Note: the bins are width one, hence len(list) can be large
(Order(number_of_edges))
| def degree_histogram(G):
"""Returns a list of the frequency of each degree value.
Parameters
----------
G : Networkx graph
A graph
Returns
-------
hist : list
A list of frequencies of degrees.
The degree values are the index in the list.
Notes
-----
Note: the bins are width one, hence len(list) can be large
(Order(number_of_edges))
"""
counts = Counter(d for n, d in G.degree())
return [counts.get(i, 0) for i in range(max(counts) + 1 if counts else 0)]
| (G) | [
-0.012196668423712254,
0.028789907693862915,
-0.03064020350575447,
-0.008979870937764645,
0.08446850627660751,
0.041317593306303024,
-0.008279644884169102,
0.02264489233493805,
0.07523400336503983,
-0.020726697519421577,
0.036496639251708984,
-0.0027393698692321777,
-0.03381456062197685,
-0.037888605147600174,
-0.021796133369207382,
-0.005058604292571545,
-0.0017728455131873488,
-0.010541588068008423,
-0.0021176538430154324,
0.015455902554094791,
-0.019283806905150414,
-0.0733327865600586,
-0.03011397272348404,
-0.017204346135258675,
-0.055882297456264496,
-0.01960633508861065,
0.012638023123145103,
-0.005432058125734329,
0.00859792996197939,
0.02328994870185852,
-0.043965719640254974,
-0.03782070428133011,
-0.06039769574999809,
0.014437392354011536,
0.012638023123145103,
0.03608923777937889,
0.012009941041469574,
0.037515152245759964,
-0.04668175056576729,
0.05832672491669655,
0.03989167883992195,
-0.049533579498529434,
-0.061178553849458694,
0.023188097402453423,
0.03836391121149063,
0.02291649580001831,
0.013002988882362843,
0.020777622237801552,
0.024223584681749344,
-0.06443779170513153,
-0.03795650601387024,
-0.03541022911667824,
-0.02149057947099209,
0.006717928219586611,
-0.006577882915735245,
0.030181873589754105,
0.04603669419884682,
-0.014267640188336372,
0.03428986668586731,
0.07000564783811569,
-0.02846737951040268,
-0.030300699174404144,
0.03415406495332718,
-0.027397943660616875,
-0.006467544473707676,
0.004472960252314806,
-0.03198124095797539,
-0.007761901710182428,
0.00569941708818078,
-0.024783765897154808,
0.0028539523482322693,
-0.031200384721159935,
0.04104598984122276,
0.012986013665795326,
0.018248319625854492,
0.007358741480857134,
0.04552743583917618,
0.04009537771344185,
0.0025420335587114096,
0.017789989709854126,
0.03240562230348587,
-0.019674235954880714,
0.016830893233418465,
0.0307760052382946,
0.039552174508571625,
0.004290477372705936,
0.058802030980587006,
-0.014547730796039104,
-0.03440869227051735,
0.03289790078997612,
-0.004833682905882597,
-0.05279281362891197,
0.036394789814949036,
-0.012799287214875221,
-0.036632440984249115,
-0.061585959047079086,
-0.09492521733045578,
-0.0022555773612111807,
-0.0051392363384366035,
0.002161152893677354,
-0.014895722270011902,
0.045493487268686295,
-0.05075579509139061,
0.0698019489645958,
0.013249129056930542,
-0.0523514598608017,
-0.022118661552667618,
-0.07686362415552139,
0.004144066013395786,
0.011942040175199509,
-0.03619108721613884,
0.08344999700784683,
0.1248694360256195,
-0.05669710785150528,
0.032473523169755936,
0.04787001386284828,
0.04427127540111542,
-0.020692747086286545,
-0.0014036353677511215,
-0.022203538566827774,
-0.005843706429004669,
0.054116878658533096,
0.02115107700228691,
0.04457682743668556,
0.007002262398600578,
0.04416942223906517,
-0.029027560725808144,
-0.008207499980926514,
-0.01677996665239334,
0.03951822221279144,
0.1007646769285202,
-0.0022852837573736906,
0.049805182963609695,
0.018536899238824844,
0.04885457456111908,
-0.04641014710068703,
-0.007846777327358723,
-0.03863551467657089,
0.05252121388912201,
0.020438117906451225,
-0.028433429077267647,
-0.039280571043491364,
-0.01683937944471836,
0.03534232825040817,
0.06966614723205566,
0.023951981216669083,
0.007587906438857317,
0.030572302639484406,
0.024630988016724586,
-0.06908898800611496,
0.020675770938396454,
-0.018044618889689445,
0.03741329908370972,
-0.04165709763765335,
-0.006293548736721277,
0.006904655136168003,
-0.040434882044792175,
0.01321517862379551,
-0.0496014803647995,
0.012035403400659561,
-0.0058394623920321465,
0.03642873838543892,
-0.02911243587732315,
0.012043891474604607,
-0.022593967616558075,
0.017773015424609184,
0.08480800688266754,
-0.01184018887579441,
-0.045629289001226425,
-0.03520652651786804,
-0.01607549749314785,
-0.05791931971907616,
-0.03581763431429863,
0.004642712417989969,
0.04084228724241257,
0.019436582922935486,
0.02379920519888401,
0.05021258816123009,
0.028450405225157738,
0.051298998296260834,
0.008063211105763912,
-0.039280571043491364,
-0.057410065084695816,
-0.011186644434928894,
0.01858782395720482,
-0.0039446079172194,
0.055508844554424286,
-0.02631153166294098,
0.02048904448747635,
-0.0468515008687973,
-0.05578044801950455,
-0.0435243658721447,
0.007749170530587435,
0.0496014803647995,
0.07204267382621765,
-0.030606253072619438,
-0.0729253813624382,
0.048175565898418427,
-0.09139437973499298,
0.01748443767428398,
0.046749651432037354,
-0.0038151720073074102,
-0.014692019671201706,
-0.017942767590284348,
0.006055896170437336,
0.0349009744822979,
0.04780211299657822,
-0.0038024408277124166,
0.026039928197860718,
-0.04657989740371704,
0.03366178646683693,
-0.04545953497290611,
-0.001814222545363009,
-0.00007499581988668069,
-0.057240311056375504,
0.03530837967991829,
0.003117067739367485,
-0.024087782949209213,
0.016270712018013,
-0.05021258816123009,
-0.026277581229805946,
0.04885457456111908,
-0.0024253290612250566,
-0.01728922314941883,
0.017620239406824112,
-0.045120034366846085,
0.026990538462996483,
-0.0584285743534565,
-0.03301673009991646,
-0.016618702560663223,
0.027754422277212143,
0.019776087254285812,
-0.00477426964789629,
-0.003772734198719263,
0.023103222250938416,
0.014454367570579052,
-0.03403523936867714,
0.01872362568974495,
-0.0063911559991538525,
0.015201275236904621,
-0.00755819957703352,
-0.04040093347430229,
-0.012256081216037273,
0.053471822291612625,
-0.024342410266399384,
0.01619432307779789,
-0.000414831010857597,
-0.008190524764358997,
-0.014547730796039104,
-0.004994947463274002,
-0.11101768910884857,
-0.05595019832253456,
0.018689675256609917,
-0.058530427515506744,
-0.0014556217938661575,
-0.032456547021865845,
-0.08039446175098419,
0.04012933000922203,
-0.020828548818826675,
-0.004528129938989878,
-0.004702125210314989,
0.0008047297014854848,
-0.03700589761137962,
0.03608923777937889,
0.05856437608599663,
-0.009251474402844906,
0.05554279312491417,
0.021931935101747513,
-0.021830083802342415,
0.01674601621925831,
0.05262306332588196,
-0.03707379847764969,
-0.01359712053090334,
-0.047157056629657745,
0.028382504358887672,
-0.01683937944471836,
0.06895318627357483,
0.04325276240706444,
0.004757294896990061,
0.0617557130753994,
-0.0409780889749527,
0.004050702787935734,
-0.00011849472502944991,
0.021847058087587357,
-0.0746907964348793,
0.06688221544027328,
0.006556664127856493,
-0.023442726582288742,
0.005546640604734421,
-0.017806965857744217,
0.07278957962989807,
-0.0012307006400078535,
-0.02707541547715664,
0.04542558640241623,
0.023595502600073814,
0.05045023933053017,
0.028043000027537346,
-0.04579903930425644,
0.007142307702451944,
0.0566631555557251,
0.06756122410297394,
-0.017671164125204086,
-0.017306197434663773,
-0.02822972647845745,
0.008143843151628971,
-0.01494664791971445,
0.023357849568128586,
0.01924985647201538,
0.03432381898164749,
0.03683614358305931,
-0.04484843090176582,
0.011729850433766842,
0.015260688029229641,
0.03731144964694977,
-0.045357685536146164,
0.012688948772847652,
-0.015719018876552582,
-0.04983913525938988,
0.021965885534882545,
0.0009919871808961034,
0.009607953019440174,
0.09071537107229233,
0.03785465657711029,
0.016966694965958595,
-0.06681431829929352,
0.0729253813624382,
0.003038557479158044,
0.039925627410411835,
0.07068465650081635,
-0.06813837587833405,
-0.0937030017375946,
-0.01392813678830862,
0.013036939315497875,
0.02895965985953808,
-0.0531323179602623,
0.059413135051727295,
0.10320910811424255,
-0.005266549997031689,
-0.06032979488372803,
-0.02532697096467018,
-0.030606253072619438,
0.004655443597584963,
-0.029417989775538445,
0.04416942223906517,
0.010040819644927979,
-0.003760002786293626,
-0.026990538462996483,
0.010227547027170658,
0.0006917386781424284,
0.04875272139906883,
0.018180418759584427,
0.004511154722422361,
-0.008406958542764187,
0.05581439658999443,
0.016007596626877785,
0.02520814538002014,
0.05045023933053017,
-0.04389781877398491,
-0.04186079651117325,
0.07183896750211716,
-0.02111712656915188,
0.012553147040307522,
-0.004472960252314806,
-0.0409780889749527,
-0.006879192311316729,
-0.009811654686927795,
0.019674235954880714,
0.055508844554424286,
0.05065394192934036,
-0.02013256587088108,
0.008016529493033886,
-0.028127877041697502,
-0.03174358978867531,
0.04281140863895416,
0.027397943660616875,
-0.01240885816514492,
0.010575538501143456,
0.005385376513004303,
-0.018553873524069786,
-0.030521376058459282,
-0.00967585388571024,
-0.021083176136016846,
-0.00723991496488452,
0.028450405225157738,
-0.022729767486453056,
0.005491471383720636,
-0.007736438885331154,
-0.004258648492395878,
0.04216635227203369,
-0.003125555347651243,
-0.06406433880329132,
-0.008428177796304226,
-0.02722819149494171,
-0.02911243587732315,
0.00415043206885457,
0.039280571043491364,
0.035749733448028564,
-0.012960551306605339,
0.018282270058989525,
-0.014827821403741837,
-0.03717564791440964,
-0.056119952350854874,
-0.0382281094789505,
0.03541022911667824,
-0.001438646693713963,
0.018452022224664688,
0.005932826083153486,
-0.035987384617328644,
0.06161991134285927,
-0.05832672491669655,
-0.03812626004219055,
0.038024406880140305,
0.040706485509872437,
0.0153880026191473,
0.04478053003549576,
-0.006195941474288702,
-0.051570601761341095,
-0.03138710930943489,
0.030945755541324615,
-0.012688948772847652,
0.032235872000455856,
0.011789264157414436,
0.010651926510035992,
-0.013232153840363026,
0.04416942223906517,
0.002365916036069393,
-0.022084711119532585,
0.045391637831926346,
-0.04793791472911835,
0.04871877282857895,
-0.017501411959528923,
0.035885535180568695,
0.0022470897529274225,
-0.06386063247919083,
-0.047530509531497955,
0.026668010279536247,
0.0005601809825748205,
0.012442808598279953,
-0.036530591547489166,
0.021745208650827408,
-0.012171205133199692,
0.0784253403544426,
0.03264327347278595,
0.011237570084631443,
0.10130788385868073,
0.020862499251961708,
-0.022967420518398285,
-0.006658514961600304,
0.037141699343919754,
-0.03153988718986511,
-0.019928863272070885,
-0.04518793523311615,
0.032711174339056015,
-0.028552256524562836,
-0.055101439356803894,
0.03466331958770752,
-0.0503823384642601,
0.0033037946559488773,
-0.050178635865449905,
0.058394625782966614,
0.04698730260133743,
0.04050278291106224,
-0.02493654191493988,
-0.03311857953667641,
-0.015337076969444752,
-0.04379596933722496,
0.02430845983326435,
0.018435047939419746,
0.016907280310988426,
0.06134830787777901,
0.05415083095431328,
0.03362783417105675,
-0.031692665070295334,
-0.05595019832253456,
-0.023137172684073448,
0.027805346995592117,
-0.022627918049693108,
0.016338612884283066,
-0.010414274409413338,
-0.03406918793916702,
0.0007458470645360649,
0.01773906499147415,
0.036157138645648956,
0.001373928738757968,
-0.0000682985846651718,
0.01442890428006649,
-0.01586330682039261,
-0.023748278617858887,
-0.0053089880384504795,
-0.05493168905377388,
0.031947292387485504,
-0.03479912132024765,
-0.02744886837899685,
-0.03036860004067421,
0.07632041722536087,
0.009811654686927795,
0.019555408507585526,
0.01221364364027977,
-0.006276573520153761,
0.07564140856266022,
-0.052215658128261566,
-0.0015977889997884631,
0.03013094700872898,
-0.029570765793323517,
0.009972919709980488,
-0.013563170097768307,
-0.0019075860036537051,
-0.0024168414529412985,
0.017365610226988792,
0.017688140273094177,
-0.01486177183687687,
0.0030067290645092726,
0.011161182075738907,
0.04657989740371704,
0.014904209412634373,
-0.000381941586965695,
-0.005826731212437153,
-0.006365693174302578,
-0.02466493844985962,
0.019419608637690544,
-0.02760164625942707,
0.019131029024720192,
0.0021770671010017395,
0.001002596691250801,
-0.03286395221948624,
0.028433429077267647,
-0.02985934540629387,
-0.04759841039776802,
0.0030406794976443052,
0.008262669667601585,
-0.005640004295855761,
0.04756445810198784,
-0.034001290798187256,
0.03103063255548477,
-0.009506101720035076,
0.005470252130180597,
0.04736075550317764,
-0.039280571043491364,
0.004409303423017263,
0.044984232634305954,
-0.027533745393157005,
-0.01999676413834095,
0.07238217443227768,
0.031947292387485504,
0.038805264979600906,
0.023884080350399017,
0.051061347126960754,
-0.03289790078997612,
0.03832995891571045,
-0.047632358968257904,
-0.013198203407227993,
0.0035265940241515636,
-0.023374825716018677,
-0.10619673877954483,
0.00802926067262888,
0.02417265810072422,
-0.03914476931095123,
-0.01646592654287815,
0.014547730796039104,
-0.03748119994997978,
-0.032354697585105896,
-0.04871877282857895,
-0.07299327850341797,
0.014072425663471222,
0.0007702488801442087,
-0.048039764165878296,
0.006815535482019186,
-0.04481447860598564,
-0.06189151108264923,
0.02403685823082924,
0.00924298632889986,
-0.0046681747771799564,
0.0012391882482916117,
-0.028688056394457817,
0.026158755645155907,
-0.027907198294997215,
0.005966776516288519,
-0.009913505986332893,
0.05774956941604614,
-0.0374472513794899,
-0.06185756251215935,
-0.004163163248449564,
-0.05289466679096222,
0.014929672703146935,
0.027126340195536613,
0.06565999984741211,
0.005304744467139244,
0.02305229753255844,
0.01064343936741352,
-0.002722394885495305,
-0.019928863272070885,
-0.07869694381952286,
0.03378061205148697,
-0.037888605147600174,
0.0015224616508930922,
-0.02960471622645855,
-0.06953034549951553,
-0.02709238976240158,
-0.06552419811487198,
-0.029027560725808144,
-0.011339421384036541,
0.04922802746295929,
0.0017028229776769876,
-0.0009166598320007324,
-0.002953681629151106,
-0.002873049583286047,
-0.007736438885331154,
0.0014269761741161346,
0.011178157292306423,
-0.05771561712026596,
-0.07245007902383804,
0.031217359006404877,
-0.015888771042227745,
-0.015226737596094608,
-0.001139459083788097,
0.010159646160900593,
0.035613931715488434,
-0.018078569322824478,
-0.021948909386992455,
0.07421549409627914,
-0.0354781299829483,
-0.018248319625854492,
0.012595584616065025,
0.005601809825748205,
-0.008886507712304592,
-0.01872362568974495,
-0.02517419494688511,
0.028925709426403046,
-0.007227183785289526,
-0.012043891474604607,
-0.015379514545202255,
-0.018129494041204453,
-0.054490335285663605,
0.015914233401417732,
0.04277745634317398,
-0.07679571956396103,
-0.05961683765053749,
-0.033848512917757034,
0.011313959024846554,
0.002387134823948145,
-0.0729253813624382,
0.06711986660957336,
-0.02670196071267128,
-0.053200218826532364,
-0.029553791508078575,
-0.001341039314866066,
0.03737935051321983,
0.025751350447535515,
0.019572384655475616,
-0.05462613329291344,
0.019894912838935852,
0.01272289827466011,
0.05520329251885414,
0.02227143757045269,
-0.005864925216883421,
0.04484843090176582,
0.02935008890926838,
0.02264489233493805,
-0.01707703247666359,
-0.03527442738413811,
0.011975990608334541,
0.010651926510035992,
0.04522188380360603,
0.009480639360845089,
-0.015735993161797523,
0.032184943556785583,
0.002085825428366661,
0.028382504358887672,
-0.031319212168455124,
-0.01670357957482338,
0.015345564112067223,
-0.006586370524019003,
0.058768078684806824,
-0.007575174793601036,
-0.040061429142951965,
0.036768242716789246,
0.021948909386992455,
0.04912617430090904,
0.03693799674510956,
0.012918113730847836,
-0.0006408130866475403,
0.019928863272070885,
-0.0076812696643173695,
-0.021083176136016846,
-0.015651118010282516,
0.039552174508571625,
-0.027177266776561737,
-0.03734539821743965,
-0.01709400862455368,
-0.002743613673374057,
-0.04919407516717911,
-0.03378061205148697,
0.05445638298988342,
-0.013911161571741104,
0.04630829766392708,
0.04128364101052284,
-0.021320829167962074,
0.05272491276264191,
0.06280817091464996,
-0.038160208612680435,
0.014148813672363758,
0.004625737201422453,
0.02111712656915188,
0.06297792494297028,
-0.014216714538633823,
-0.06012609228491783,
-0.03464634716510773,
-0.02748281881213188,
-0.011347909457981586,
0.05201195552945137,
-0.051944054663181305,
-0.01494664791971445,
-0.022186562418937683,
0.0470552034676075,
0.02583622746169567,
0.025089317932724953,
-0.018519923090934753,
0.0010917163453996181,
-0.05269096419215202,
-0.00538113247603178,
0.010685876943171024,
0.02128687873482704,
0.07265377789735794,
0.09485731273889542,
-0.028297627344727516,
-0.00518591795116663,
0.04569718986749649,
0.029927246272563934,
-0.04691940173506737,
-0.02452913671731949,
-0.007778876926749945,
-0.027279116213321686,
-0.031828466802835464,
0.01938565820455551,
-0.023765254765748978,
0.024393336847424507,
-0.0044474974274635315,
0.028942685574293137,
0.015328588895499706,
0.012926600873470306,
0.045255836099386215,
0.005440545734018087,
-0.022950446233153343,
0.03457844629883766,
0.06111065298318863,
-0.04837926849722862,
-0.033593885600566864,
-0.009327862411737442,
0.0019425973296165466,
-0.030538352206349373,
-0.0038045626133680344,
0.0030491671059280634,
-0.023255998268723488,
-0.03388246148824692,
-0.006815535482019186,
-0.015277663245797157,
-0.04362621530890465,
-0.06742542237043381,
-0.041962649673223495,
-0.03911081701517105,
-0.032473523169755936,
-0.02189798466861248,
-0.02697356417775154,
-0.06742542237043381,
-0.012807774357497692,
0.01011720858514309,
0.00942971371114254,
-0.019181955605745316
]
|
30,547 | networkx.generators.degree_seq | degree_sequence_tree | Make a tree for the given degree sequence.
A tree has #nodes-#edges=1 so
the degree sequence must have
len(deg_sequence)-sum(deg_sequence)/2=1
| def generate(self):
# remaining_degree is mapping from int->remaining degree
self.remaining_degree = dict(enumerate(self.degree))
# add all nodes to make sure we get isolated nodes
self.graph = nx.Graph()
self.graph.add_nodes_from(self.remaining_degree)
# remove zero degree nodes
for n, d in list(self.remaining_degree.items()):
if d == 0:
del self.remaining_degree[n]
if len(self.remaining_degree) > 0:
# build graph in three phases according to how many unmatched edges
self.phase1()
self.phase2()
self.phase3()
return self.graph
| (deg_sequence, create_using=None, *, backend=None, **backend_kwargs) | [
-0.02255886048078537,
0.003668749937787652,
-0.030325323343276978,
-0.0212223082780838,
-0.01601155288517475,
0.04858553782105446,
-0.0715959370136261,
-0.03926578536629677,
0.03426273912191391,
-0.03131870925426483,
0.03233015537261963,
0.08040996640920639,
-0.03393762931227684,
0.04031335189938545,
-0.013699676841497421,
0.005079807713627815,
0.023931538686156273,
0.013654522597789764,
-0.014386015012860298,
0.0017056865617632866,
-0.019199416041374207,
-0.01542455330491066,
-0.0069807847030460835,
0.033522214740514755,
-0.03399181365966797,
-0.005007561296224594,
-0.0168333537876606,
0.0133745688945055,
-0.028970707207918167,
-0.01807056926190853,
-0.0585193857550621,
0.0013083326630294323,
-0.027164554223418236,
0.0043392847292125225,
0.013519061729311943,
0.04645427688956261,
-0.018693692982196808,
0.02680332213640213,
-0.051836613565683365,
0.029530614614486694,
0.09702658653259277,
-0.02931387722492218,
-0.035834092646837234,
0.015569046139717102,
-0.023931538686156273,
-0.03084910660982132,
0.039807628840208054,
0.037567999213933945,
-0.0005875644274055958,
-0.07845932245254517,
0.021294552832841873,
-0.018025415018200874,
0.009455215185880661,
0.015442615374922752,
0.010764677077531815,
0.015135569497942924,
-0.010891107842326164,
0.0168965682387352,
0.08337206393480301,
0.021457107737660408,
-0.020861076191067696,
-0.012706291861832142,
0.0003677216300275177,
-0.0006699701771140099,
-0.029422245919704437,
0.020933322608470917,
-0.04891064763069153,
-0.02441919967532158,
0.009536492638289928,
0.05664098262786865,
0.05093353986740112,
-0.012868845835328102,
0.05129477009177208,
-0.0021211018320173025,
0.053498275578022,
-0.01966901496052742,
0.009563584811985493,
-0.027670277282595634,
0.020535968244075775,
-0.03001827746629715,
-0.0318966768682003,
-0.003429434495046735,
-0.021059753373265266,
-0.0015307153807953,
0.05317316949367523,
0.038471076637506485,
0.0027543846517801285,
-0.04215563088655472,
-0.03807372227311134,
-0.050680678337812424,
-0.019127169623970985,
-0.02718261443078518,
-0.004822430666536093,
0.012652107514441013,
0.03825433924794197,
-0.01696881465613842,
-0.038218215107917786,
-0.05205335468053818,
0.03966313973069191,
-0.023028461262583733,
-0.01735713891685009,
0.025412583723664284,
-0.14376984536647797,
0.03413630649447441,
0.02236018516123295,
-0.06567175686359406,
-0.004133834503591061,
-0.044973231852054596,
0.03561735525727272,
-0.010213799774646759,
-0.049849845468997955,
0.04685163125395775,
0.07199329137802124,
0.040204983204603195,
-0.010638246312737465,
0.02064433880150318,
-0.001000722055323422,
-0.02077076956629753,
0.02584606222808361,
0.021005569025874138,
-0.033648647367954254,
0.023498062044382095,
-0.018729815259575844,
0.057038336992263794,
0.0030659460462629795,
0.02263110689818859,
0.015632260590791702,
-0.030505938455462456,
0.06899507343769073,
-0.05230621621012688,
0.05497932434082031,
0.0054771616123616695,
0.025936368852853775,
-0.0079109538346529,
-0.0660691037774086,
-0.012751446105539799,
-0.016923662275075912,
-0.042011138051748276,
0.022540800273418427,
0.051511507481336594,
-0.01269726175814867,
-0.03959089145064354,
0.009879661723971367,
0.04800757020711899,
0.01015961542725563,
0.044323015958070755,
-0.007305892184376717,
0.008963038213551044,
-0.015776753425598145,
-0.03475039824843407,
0.02860947698354721,
-0.010213799774646759,
0.0092926612123847,
-0.002725034486502409,
-0.0069220843724906445,
0.023877354338765144,
-0.002171899890527129,
0.03299843147397041,
-0.05093353986740112,
-0.0022588211577385664,
-0.03749575465917587,
0.00277244602330029,
0.008877245709300041,
0.01742035336792469,
0.0016864961944520473,
-0.029801538214087486,
0.09659310430288315,
-0.05674935504794121,
-0.02557513862848282,
-0.0084482841193676,
-0.0384349524974823,
-0.04255298525094986,
-0.04461199790239334,
-0.02506941556930542,
-0.033847324550151825,
0.00722913071513176,
0.020283106714487076,
0.006574399769306183,
-0.004510869272053242,
0.05122252181172371,
0.0038313039112836123,
-0.0340459980070591,
-0.03720676898956299,
-0.029801538214087486,
0.039121292531490326,
-0.014223461039364338,
0.06285415589809418,
0.005571984685957432,
0.05497932434082031,
-0.05057230591773987,
-0.039879877120256424,
0.007450384553521872,
0.05266744643449783,
0.08575618267059326,
0.0801209807395935,
-0.01735713891685009,
0.028970707207918167,
0.06567175686359406,
-0.06765852123498917,
0.05111415311694145,
0.03231209143996239,
-0.010529876686632633,
0.02416633814573288,
-0.03810984641313553,
-0.025033291429281235,
0.02062627673149109,
-0.02944030798971653,
-0.009328784421086311,
0.011839338578283787,
0.03375701606273651,
-0.015207814984023571,
-0.002542161615565419,
0.07105409353971481,
0.009816446341574192,
-0.05378726124763489,
0.0012010922655463219,
0.02030116878449917,
0.01400672271847725,
0.013771923258900642,
-0.04125255346298218,
-0.04659876972436905,
0.0033052614890038967,
-0.006583430804312229,
-0.07701440155506134,
-0.01278756931424141,
-0.032564952969551086,
-0.034172430634498596,
-0.0439617857336998,
-0.10555163025856018,
0.0010515202302485704,
0.06913956999778748,
-0.03413630649447441,
-0.03599664568901062,
-0.012345061637461185,
0.02441919967532158,
0.0298918467015028,
-0.01779964566230774,
-0.005404915194958448,
-0.013329415582120419,
0.031986985355615616,
-0.04338381439447403,
-0.056785475462675095,
0.009319753386080265,
0.03361252322793007,
0.046887755393981934,
0.06473255157470703,
0.021583538502454758,
-0.03626756742596626,
0.0071478537283837795,
0.03702615201473236,
-0.04840492457151413,
-0.05161987617611885,
-0.026532400399446487,
-0.022071199491620064,
0.006452484522014856,
-0.05270357057452202,
-0.02217956818640232,
-0.03901292383670807,
0.03541867807507515,
0.013284261338412762,
0.021258430555462837,
0.051583752036094666,
-0.08662313967943192,
0.026279538869857788,
0.03469621390104294,
-0.002618923084810376,
-0.003944188356399536,
0.014729184098541737,
-0.053245414048433304,
-0.007938046008348465,
0.01066533848643303,
0.052739690989255905,
0.016417939215898514,
-0.00970807671546936,
0.036213383078575134,
-0.018025415018200874,
0.0119928615167737,
0.04851329326629639,
-0.04280584678053856,
0.02192670665681362,
-0.04616529121994972,
0.011685815639793873,
-0.0012112519470974803,
-0.0007399586611427367,
-0.06578012555837631,
0.0482243075966835,
0.009843538515269756,
-0.03836270794272423,
0.029476430267095566,
-0.061228614300489426,
0.0012022211449220777,
0.00819993857294321,
-0.014548568986356258,
0.04009661450982094,
0.09435347467660904,
-0.01416927669197321,
-0.003896776819601655,
-0.004876615479588509,
0.0010385384084656835,
0.064046211540699,
0.06245679780840874,
-0.020843015983700752,
0.0017361653735861182,
-0.03523806110024452,
-0.0029349999967962503,
-0.005815815180540085,
0.02584606222808361,
0.0011954481014981866,
0.044648122042417526,
0.011351676657795906,
-0.06303476542234421,
-0.01407896913588047,
0.09290855377912521,
0.02024698443710804,
0.02115006186068058,
-0.04356443136930466,
-0.013546153903007507,
-0.04410627484321594,
0.06729729473590851,
0.05487095192074776,
0.0017903499538078904,
0.05302867665886879,
-0.06451581418514252,
0.014069938100874424,
-0.0869121253490448,
0.04742959886789322,
0.037820860743522644,
0.037062276154756546,
-0.00176438654307276,
-0.04757409170269966,
-0.056207507848739624,
-0.0014291192637756467,
-0.0161379836499691,
0.031210338696837425,
-0.07018713653087616,
0.02049984596669674,
0.09103015065193176,
-0.04854941368103027,
0.0037184192333370447,
-0.015993492677807808,
0.09876049309968948,
0.007287830580025911,
-0.05082516744732857,
0.029548676684498787,
0.0067595308646559715,
-0.009166230447590351,
0.030325323343276978,
-0.04197501391172409,
-0.022161507979035378,
0.010909168981015682,
-0.020427599549293518,
0.09160812199115753,
-0.0060867383144795895,
0.06520215421915054,
0.04735735431313515,
0.0444675087928772,
0.01166775356978178,
0.009726138785481453,
-0.05086129158735275,
0.030162768438458443,
-0.010764677077531815,
0.016417939215898514,
-0.02949449233710766,
0.048043690621852875,
-0.011198153719305992,
-0.047863077372312546,
0.04208338260650635,
0.05895286053419113,
0.03388344496488571,
-0.021944768726825714,
0.00180728267878294,
-0.04273359850049019,
-0.043347690254449844,
0.022902030497789383,
-0.01108978409320116,
0.02597249299287796,
0.007960623130202293,
0.004361861385405064,
0.06780301779508591,
-0.035906337201595306,
-0.026189230382442474,
-0.004835976753383875,
-0.0041880193166434765,
0.024780429899692535,
0.01677916944026947,
-0.03299843147397041,
0.06653870642185211,
0.006271869409829378,
0.060144923627376556,
-0.015993492677807808,
0.0009138009627349675,
-0.03585215285420418,
0.025864122435450554,
-0.015532922931015491,
0.023118769749999046,
0.03079492226243019,
0.06928405910730362,
0.02268529124557972,
-0.040457844734191895,
-0.008583745919167995,
-0.017917046323418617,
-0.06570787727832794,
0.008746299892663956,
0.0555211678147316,
-0.00759939244017005,
-0.08221612125635147,
0.07802584767341614,
0.0391935370862484,
0.0597836934030056,
-0.037315137684345245,
-0.028591414913535118,
0.011658722534775734,
-0.00877339206635952,
0.0022497903555631638,
0.03411824628710747,
-0.05320929363369942,
0.013817076571285725,
-0.018928492441773415,
0.060831259936094284,
0.016445031389594078,
0.0600365549325943,
0.036610737442970276,
0.06538277119398117,
0.010385384783148766,
0.012688230723142624,
0.0270019993185997,
-0.02115006186068058,
0.01359130721539259,
-0.05082516744732857,
0.07246289402246475,
-0.01099044643342495,
-0.014963984489440918,
0.009897722862660885,
-0.050500061362981796,
0.01237215381115675,
-0.02409409172832966,
0.016083799302577972,
-0.018160875886678696,
-0.021294552832841873,
0.00555843859910965,
0.03574378415942192,
0.0028108269907534122,
0.024057969450950623,
-0.01979544572532177,
0.036664921790361404,
-0.011053661815822124,
-0.020337292924523354,
-0.015343276783823967,
-0.02763415314257145,
0.026207292452454567,
0.01665273867547512,
0.007188492454588413,
0.03135482966899872,
-0.020662399008870125,
-0.03760412335395813,
0.0821438729763031,
0.014449230395257473,
-0.04031335189938545,
-0.05519606173038483,
0.005219784565269947,
0.055882398039102554,
0.022414369508624077,
-0.03527418524026871,
0.06437132507562637,
-0.033269353210926056,
-0.014467292465269566,
-0.0007935788598842919,
0.0068453229032456875,
-0.04248073697090149,
0.00352877308614552,
0.004682453814893961,
0.0009657279006205499,
-0.019253600388765335,
-0.08965747803449631,
-0.008583745919167995,
-0.04154153913259506,
-0.02539452351629734,
-0.01916329190135002,
0.008177361451089382,
-0.054545845836400986,
-0.04417852312326431,
-0.007766461465507746,
0.003503938438370824,
0.034551721066236496,
-0.03886843100190163,
0.04024110734462738,
-0.01749259978532791,
-0.026731077581644058,
-0.03552704676985741,
-0.044503629207611084,
-0.060831259936094284,
-0.08171039819717407,
-0.03260107710957527,
0.013799015432596207,
0.01416927669197321,
0.0442146472632885,
-0.009762261062860489,
-0.03556316718459129,
-0.002192219253629446,
-0.02396766096353531,
-0.0016390846576541662,
0.0017768038669601083,
0.0069220843724906445,
0.02250467613339424,
0.017248768359422684,
0.006962723098695278,
-0.030614307150244713,
-0.03760412335395813,
0.011008507572114468,
0.03984375298023224,
0.03489489108324051,
0.007233646232634783,
-0.0013839653693139553,
0.04782695323228836,
0.0035829576663672924,
0.010015122592449188,
0.007314923219382763,
0.00035417548497207463,
-0.024798491969704628,
-0.009428123012185097,
0.010891107842326164,
0.02777864597737789,
0.006678253877907991,
0.03180636838078499,
-0.005048200022429228,
0.03760412335395813,
-0.0437089242041111,
-0.07018713653087616,
0.01407896913588047,
-0.010845953598618507,
0.03915741667151451,
0.0042241420596838,
0.005400400143116713,
0.09225833415985107,
-0.01639987714588642,
-0.0632876306772232,
0.0632876306772232,
-0.044828739017248154,
-0.06585236638784409,
-0.05064455419778824,
-0.002062401967123151,
0.007545207627117634,
-0.009473277255892754,
-0.02017473801970482,
0.0010848211823031306,
0.00938296876847744,
0.0836610421538353,
-0.016092831268906593,
0.03498519957065582,
-0.029982153326272964,
-0.030126646161079407,
0.045804060995578766,
-0.01761903055012226,
-0.05089741572737694,
0.12448012083768845,
-0.013672584667801857,
-0.02178221568465233,
0.0036168231163173914,
0.02873590774834156,
0.019434215500950813,
0.004736638627946377,
-0.038687814027071,
-0.06397397071123123,
-0.02680332213640213,
-0.003779376856982708,
-0.006497638300061226,
-0.01411509234458208,
-0.006181561388075352,
0.0038177575916051865,
0.04782695323228836,
0.008795969188213348,
-0.03431692346930504,
0.011162030510604382,
-0.019560646265745163,
0.006438938435167074,
-0.03984375298023224,
-0.00941909197717905,
0.022540800273418427,
0.01798929274082184,
-0.02564738504588604,
0.003783892374485731,
0.004551507532596588,
-0.014196368865668774,
-0.014431169256567955,
0.004133834503591061,
0.0244914460927248,
-0.04591242969036102,
0.02346193790435791,
0.0816381499171257,
0.002001444110646844,
-0.003926126752048731,
-0.04392566159367561,
0.0020522424019873142,
-0.002372834598645568,
-0.07426904886960983,
0.04685163125395775,
-0.030831046402454376,
-0.005179146304726601,
-0.04435913637280464,
-0.01672498509287834,
-0.050355568528175354,
0.07860381156206131,
0.017917046323418617,
0.09095790982246399,
-0.020734645426273346,
0.042589105665683746,
-0.016490183770656586,
0.010367322713136673,
-0.01734810695052147,
-0.018016384914517403,
0.0005503125139512122,
-0.004944345913827419,
-0.001317363465204835,
-0.04034947603940964,
-0.04074683040380478,
-0.04331156983971596,
-0.014069938100874424,
0.007328469306230545,
-0.03680941462516785,
-0.0037477691657841206,
-0.021041691303253174,
-0.012959153391420841,
-0.06408233940601349,
0.006944661494344473,
-0.004637300036847591,
0.022450491786003113,
0.055448923259973526,
-0.007174945902079344,
0.02487073838710785,
0.024148276075720787,
0.009563584811985493,
-0.05913347750902176,
-0.07499150931835175,
-0.019759323447942734,
-0.00002407617103017401,
-0.015280061401426792,
0.015704507008194923,
0.027399353682994843,
0.02539452351629734,
-0.02732710726559162,
-0.07528049498796463,
0.04034947603940964,
-0.05263132229447365,
-0.04750184714794159,
-0.057435691356658936,
-0.024599814787507057,
0.015090415254235268,
0.03393762931227684,
-0.01787189207971096,
-0.023353569209575653,
-0.01871175318956375,
0.00983450748026371,
0.06242067739367485,
-0.027868954464793205,
0.014936892315745354,
-0.007617453578859568,
0.015018168836832047,
0.00694014597684145,
0.04016886278986931,
-0.04042172431945801,
0.006339599844068289,
0.026694953441619873,
0.08770682662725449,
-0.0059422459453344345,
0.01817893795669079,
0.040204983204603195,
0.044900983572006226,
-0.03149932250380516,
-0.04222787544131279,
-0.013744831085205078,
-0.027941199019551277,
-0.04233624413609505,
0.0675862729549408,
0.013022368773818016,
-0.056532613933086395,
0.016562430188059807,
-0.011866430751979351,
0.0049398308619856834,
0.03614113852381706,
0.030451754108071327,
0.01723070815205574,
0.03231209143996239,
-0.022468553856015205,
-0.07293248921632767,
-0.009951907210052013,
-0.012390214949846268,
-0.042589105665683746,
-0.0384349524974823,
0.003991600126028061,
-0.002186574973165989,
-0.02956673875451088,
0.0022915576118975878,
0.057435691356658936,
0.006118346005678177,
0.0095455227419734,
0.02107781544327736,
-0.03169799968600273,
-0.017086215317249298,
0.02501523122191429,
-0.030162768438458443,
0.03720676898956299,
-0.0185853224247694,
-0.014467292465269566,
0.030162768438458443,
-0.006484092213213444,
-0.008665023371577263,
0.011279430240392685,
0.0061228615231812,
-0.035328369587659836,
0.01734810695052147,
-0.01453050784766674,
0.0023412269074469805,
-0.006944661494344473,
0.0482243075966835,
-0.011812246404588223,
-0.005883546080440283,
0.0033278383780270815,
0.07658091932535172,
-0.03027113899588585,
-0.024780429899692535,
-0.0018806576263159513,
0.016490183770656586,
-0.013166861608624458,
0.04602079838514328,
-0.02557513862848282,
0.04435913637280464,
0.0006750500178895891,
-0.046309784054756165,
-0.01844083145260811,
-0.019831569865345955,
-0.026315661147236824,
0.040710706263780594,
0.0037590577267110348,
-0.029024891555309296,
0.0037771190982311964,
-0.008028353564441204,
0.02017473801970482,
0.05830264464020729,
-0.022035077214241028,
0.033142924308776855,
-0.017898984253406525,
0.008294761180877686,
-0.02539452351629734,
0.03727901354432106,
0.007721307687461376,
-0.010430538095533848,
0.03193280100822449,
0.01734810695052147,
0.0033210653346031904,
0.010385384783148766,
0.028898460790514946,
-0.003591988468542695,
0.03160769119858742,
0.025484830141067505,
-0.04475649073719978,
-0.02301039919257164,
-0.01273338496685028,
-0.025231968611478806,
-0.027110369876027107,
-0.08611741662025452,
-0.03292618319392204,
-0.032745569944381714,
0.04453975334763527,
0.011875461786985397,
-0.01220959983766079,
0.04034947603940964,
0.06942855566740036,
-0.00469148438423872
]
|
30,549 | networkx.generators.random_graphs | dense_gnm_random_graph | Returns a $G_{n,m}$ random graph.
In the $G_{n,m}$ model, a graph is chosen uniformly at random from the set
of all graphs with $n$ nodes and $m$ edges.
This algorithm should be faster than :func:`gnm_random_graph` for dense
graphs.
Parameters
----------
n : int
The number of nodes.
m : int
The number of edges.
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
See Also
--------
gnm_random_graph
Notes
-----
Algorithm by Keith M. Briggs Mar 31, 2006.
Inspired by Knuth's Algorithm S (Selection sampling technique),
in section 3.4.2 of [1]_.
References
----------
.. [1] Donald E. Knuth, The Art of Computer Programming,
Volume 2/Seminumerical algorithms, Third Edition, Addison-Wesley, 1997.
| def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None):
"""Returns a random graph using dual Barabási–Albert preferential attachment
A graph of $n$ nodes is grown by attaching new nodes each with either $m_1$
edges (with probability $p$) or $m_2$ edges (with probability $1-p$) that
are preferentially attached to existing nodes with high degree.
Parameters
----------
n : int
Number of nodes
m1 : int
Number of edges to link each new node to existing nodes with probability $p$
m2 : int
Number of edges to link each new node to existing nodes with probability $1-p$
p : float
The probability of attaching $m_1$ edges (as opposed to $m_2$ edges)
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
initial_graph : Graph or None (default)
Initial network for Barabási–Albert algorithm.
A copy of `initial_graph` is used.
It should be connected for most use cases.
If None, starts from an star graph on max(m1, m2) + 1 nodes.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m1` and `m2` do not satisfy ``1 <= m1,m2 < n``, or
`p` does not satisfy ``0 <= p <= 1``, or
the initial graph number of nodes m0 does not satisfy m1, m2 <= m0 <= n.
References
----------
.. [1] N. Moshiri "The dual-Barabasi-Albert model", arXiv:1810.10538.
"""
if m1 < 1 or m1 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m1 >= 1 and m1 < n, m1 = {m1}, n = {n}"
)
if m2 < 1 or m2 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m2 >= 1 and m2 < n, m2 = {m2}, n = {n}"
)
if p < 0 or p > 1:
raise nx.NetworkXError(
f"Dual Barabási–Albert network must have 0 <= p <= 1, p = {p}"
)
# For simplicity, if p == 0 or 1, just return BA
if p == 1:
return barabasi_albert_graph(n, m1, seed)
elif p == 0:
return barabasi_albert_graph(n, m2, seed)
if initial_graph is None:
# Default initial graph : empty graph on max(m1, m2) nodes
G = star_graph(max(m1, m2))
else:
if len(initial_graph) < max(m1, m2) or len(initial_graph) > n:
raise nx.NetworkXError(
f"Barabási–Albert initial graph must have between "
f"max(m1, m2) = {max(m1, m2)} and n = {n} nodes"
)
G = initial_graph.copy()
# Target nodes for new edges
targets = list(G)
# List of existing nodes, with nodes repeated once for each adjacent edge
repeated_nodes = [n for n, d in G.degree() for _ in range(d)]
# Start adding the remaining nodes.
source = len(G)
while source < n:
# Pick which m to use (m1 or m2)
if seed.random() < p:
m = m1
else:
m = m2
# Now choose m unique nodes from the existing nodes
# Pick uniformly from repeated_nodes (preferential attachment)
targets = _random_subset(repeated_nodes, m, seed)
# Add edges to m nodes from the source.
G.add_edges_from(zip([source] * m, targets))
# Add one node to the list for each new edge just created.
repeated_nodes.extend(targets)
# And the new node "source" has m edges to add to the list.
repeated_nodes.extend([source] * m)
source += 1
return G
| (n, m, seed=None, *, backend=None, **backend_kwargs) | [
0.003564037149772048,
0.0015281288651749492,
0.015348353423178196,
0.004924503155052662,
-0.024948259815573692,
-0.04092894122004509,
-0.06484248489141464,
-0.03631102293729782,
0.012090899981558323,
-0.02998773194849491,
0.006490954663604498,
0.04196366295218468,
-0.036828383803367615,
0.10722769796848297,
-0.04307502880692482,
0.013039394281804562,
0.034663137048482895,
0.04740552604198456,
-0.005954433232545853,
0.027305124327540398,
-0.04004751518368721,
0.002028722781687975,
0.00008188543142750859,
0.071012482047081,
-0.03454816713929176,
0.010749596171081066,
-0.03914692625403404,
0.010749596171081066,
-0.0156357754021883,
0.05928565189242363,
0.039281055331230164,
-0.12355329096317291,
0.021020155400037766,
0.03908944129943848,
-0.00014850155275780708,
0.010146008804440498,
0.02768835425376892,
0.06116347759962082,
-0.10960372537374496,
-0.03677089884877205,
0.07089751213788986,
-0.05541503056883812,
0.08339080214500427,
0.0130585553124547,
0.0246799997985363,
-0.023913539946079254,
0.030945805832743645,
0.01299149077385664,
-0.09657391160726547,
-0.00980589259415865,
0.016114812344312668,
-0.07051428407430649,
0.026232080534100533,
-0.0023951863404363394,
-0.02040698751807213,
0.01846209540963173,
-0.0031185324769467115,
0.04460794851183891,
0.01780102401971817,
0.025293167680501938,
0.06300298124551773,
-0.019583042711019516,
-0.014629798009991646,
-0.035218819975852966,
-0.024430900812149048,
0.0219782292842865,
-0.04855521768331528,
-0.026806924492120743,
-0.0014514828799292445,
0.0620449036359787,
0.050318073481321335,
0.0640760213136673,
-0.008086148649454117,
0.0551084466278553,
0.05472521483898163,
0.044301364570856094,
0.04863186180591583,
0.027056023478507996,
-0.052042607218027115,
0.019698012620210648,
0.004191576037555933,
-0.02582968957722187,
0.01184180099517107,
-0.03433739021420479,
0.005441863089799881,
-0.015482484363019466,
0.006055030971765518,
0.0031257180962711573,
0.0002603268076200038,
-0.10186248272657394,
-0.048593539744615555,
-0.04985819756984711,
0.055644966661930084,
0.01627768576145172,
0.03159729763865471,
-0.033245187252759933,
-0.006284968927502632,
-0.03234459459781647,
0.007453819736838341,
-0.02456502988934517,
-0.04506782442331314,
0.04368819668889046,
-0.038112204521894455,
0.000617958081420511,
0.006476583890616894,
0.0072334627620875835,
-0.052157577127218246,
0.015185480937361717,
0.02082853950560093,
-0.035372111946344376,
-0.11711502820253372,
0.0436115525662899,
0.0797884464263916,
0.01822257786989212,
-0.022936303168535233,
-0.013278912752866745,
0.014984285458922386,
0.011602282524108887,
0.031942203640937805,
0.03226795047521591,
0.016344750300049782,
0.02711350843310356,
-0.032938603311777115,
-0.00018562693730928004,
0.0007455017184838653,
-0.024066831916570663,
0.04824863374233246,
-0.008555605076253414,
-0.012914844788610935,
-0.03874453157186508,
0.010538819245994091,
0.014830993488430977,
-0.047022297978401184,
0.07024602591991425,
-0.012033415958285332,
-0.03441403806209564,
-0.04794204980134964,
0.005729285534471273,
0.0691346600651741,
0.003983194939792156,
-0.0008077765814960003,
-0.06683527678251266,
0.08906260877847672,
0.012895682826638222,
-0.03947266936302185,
-0.021499192342162132,
0.017235759645700455,
-0.05710124224424362,
0.0017664498882368207,
-0.012215450406074524,
0.04004751518368721,
-0.001282622222788632,
0.020886024460196495,
-0.03460565209388733,
-0.039549317210912704,
0.01771479845046997,
-0.04150378704071045,
-0.00041376843000762165,
-0.02324288710951805,
0.014639378525316715,
-0.03058173879981041,
-0.05468689277768135,
0.04878515377640724,
0.05430366471409798,
0.010136428289115429,
-0.030754191800951958,
0.04947496950626373,
0.0017975872615352273,
0.017475279048085213,
-0.035525403916835785,
-0.07434657961130142,
-0.0011413062456995249,
-0.06599216908216476,
-0.0616999976336956,
0.05269409716129303,
-0.0021748291328549385,
-0.026021303609013557,
-0.031041614711284637,
0.029317079111933708,
0.03433739021420479,
0.03832298144698143,
-0.047290556132793427,
0.0677933543920517,
-0.0591706819832325,
-0.030639221891760826,
-0.03541043400764465,
-0.0063664051704108715,
0.04296006262302399,
0.01808844693005085,
0.008565186522901058,
0.021365061402320862,
0.024794967845082283,
0.036100246012210846,
0.06089521571993828,
0.02525484375655651,
0.00524066761136055,
0.02513987571001053,
0.014601055532693863,
-0.012934005819261074,
0.011123244650661945,
0.04568099230527878,
0.0022275231312960386,
0.020464470610022545,
0.023185404017567635,
0.027899129316210747,
0.007645434699952602,
-0.032804470509290695,
-0.04196366295218468,
0.023166241124272346,
-0.02726680040359497,
0.004948454909026623,
-0.010433431714773178,
0.028608104214072227,
-0.027075186371803284,
-0.01536751538515091,
-0.06281136721372604,
0.01921897381544113,
0.01715911366045475,
-0.00011743897630367428,
-0.03491223603487015,
0.032095495611429214,
-0.058787450194358826,
0.010931630618870258,
0.02584885060787201,
0.0057484470307827,
0.04376484453678131,
-0.014591475017368793,
0.004045469686388969,
-0.015137577429413795,
0.028953012079000473,
0.03376254439353943,
-0.0007934054592624307,
0.03677089884877205,
-0.028339844197034836,
-0.03918524831533432,
-0.030198508873581886,
0.003037096234038472,
-0.03958763927221298,
-0.035831987857818604,
0.018979456275701523,
-0.0294128879904747,
0.01983214169740677,
-0.020311180502176285,
-0.008981948718428612,
0.02226565219461918,
0.015549548901617527,
0.02828235924243927,
-0.05813596025109291,
-0.06848316639661789,
-0.01983214169740677,
-0.09335478395223618,
-0.012474129907786846,
0.024775806814432144,
0.031501490622758865,
0.026155434548854828,
-0.02644285559654236,
-0.021499192342162132,
0.009734037332236767,
-0.004007146693766117,
0.058634158223867416,
0.007166397292166948,
-0.020349502563476562,
-0.11121328920125961,
0.031654782593250275,
-0.0014658540021628141,
-0.00599754648283124,
-0.0708208680152893,
0.06951788812875748,
-0.013480108231306076,
-0.031348198652267456,
0.06173831969499588,
0.0006676581688225269,
0.008838237263262272,
0.0004712528898380697,
0.02699854038655758,
0.023357857018709183,
-0.012387903407216072,
0.019496817141771317,
-0.019602203741669655,
-0.043573230504989624,
-0.04123552516102791,
-0.04338161274790764,
0.02471832185983658,
0.04541273042559624,
-0.005882577504962683,
0.004208342172205448,
-0.023338695988059044,
-0.0620449036359787,
0.024373415857553482,
-0.033513445407152176,
0.015463322401046753,
-0.028493136167526245,
0.0057723987847566605,
0.050049811601638794,
-0.0017317197052761912,
-0.004864623304456472,
0.05867248401045799,
0.023491986095905304,
0.020177049562335014,
-0.008957996964454651,
0.03799723461270332,
-0.009623858146369457,
0.09120869636535645,
0.003966428339481354,
-0.0166513342410326,
-0.032076336443424225,
0.013604657724499702,
-0.025350650772452354,
-0.019851304590702057,
0.02010040357708931,
-0.09051887691020966,
0.02513987571001053,
0.05756111815571785,
0.0308499988168478,
-0.009432243183255196,
-0.06725683063268661,
0.011592702008783817,
0.000736519752535969,
0.04046906903386116,
-0.003901758464053273,
-0.017331568524241447,
0.03749903663992882,
-0.001322142779827118,
0.04652410000562668,
-0.017590247094631195,
-0.0022430920507758856,
0.04637080803513527,
0.07499807327985764,
0.0013257355894893408,
0.022303974255919456,
-0.04207863286137581,
0.016622593626379967,
-0.010644207708537579,
0.018807003274559975,
-0.08752968907356262,
0.08086148649454117,
-0.027515899389982224,
-0.023300372064113617,
0.06672030687332153,
-0.08599676936864853,
0.021633323282003403,
-0.046715714037418365,
-0.005231086630374193,
-0.01063462719321251,
0.04633248224854469,
0.04407142847776413,
0.012090899981558323,
-0.004047864582389593,
-0.05694795027375221,
0.06924962252378464,
-0.013662142679095268,
0.04188701882958412,
-0.002752068918198347,
0.025733880698680878,
-0.019161490723490715,
0.033532608300447464,
-0.009858586825430393,
0.0044095381163060665,
0.01018433179706335,
0.07028434425592422,
-0.023338695988059044,
-0.005671801045536995,
-0.027803322300314903,
-0.01370046567171812,
0.027630869299173355,
0.0063232919201254845,
0.002373629482463002,
0.043841488659381866,
0.03845711052417755,
-0.05250248312950134,
0.06970950216054916,
-0.06714186072349548,
-0.04510614648461342,
0.04920670762658119,
0.010404689237475395,
-0.028761396184563637,
-0.03772897273302078,
0.020062079653143883,
0.032095495611429214,
0.03301524743437767,
-0.012387903407216072,
-0.03962596133351326,
0.009992716833949089,
0.03958763927221298,
-0.006222693715244532,
-0.012004673480987549,
0.07258372753858566,
0.0037867894861847162,
-0.006581971887499094,
-0.026960216462612152,
0.01283819880336523,
-0.029834439978003502,
0.07327353954315186,
0.006946040317416191,
-0.05495515465736389,
0.005101746879518032,
0.04115888103842735,
-0.026040464639663696,
-0.037115804851055145,
-0.0035352949053049088,
0.0025029696989804506,
0.016948338598012924,
-0.050586335361003876,
-0.02368360199034214,
-0.005686172284185886,
-0.033954162150621414,
0.027879968285560608,
0.02801409922540188,
0.011286118067800999,
0.01492680050432682,
-0.015195061452686787,
0.023012949153780937,
-0.019027359783649445,
-0.011640605516731739,
0.02370276302099228,
-0.001042504794895649,
-0.005901739001274109,
-0.020177049562335014,
0.010902888141572475,
0.015003446489572525,
0.03242124244570732,
-0.0077795651741325855,
0.006490954663604498,
-0.024890774860978127,
0.04410975053906441,
0.005810721777379513,
-0.051046211272478104,
0.01965968869626522,
-0.08155130594968796,
0.02213152125477791,
0.05399708077311516,
-0.03958763927221298,
0.03341763839125633,
-0.04296006262302399,
0.024641675874590874,
0.008546024560928345,
0.028953012079000473,
0.005374798085540533,
0.05675633251667023,
-0.0229937881231308,
0.012110061943531036,
0.022227328270673752,
0.011726832017302513,
-0.05740782618522644,
-0.029642825946211815,
-0.04568099230527878,
-0.021729130297899246,
-0.0012682511005550623,
0.01605732925236225,
-0.02052195556461811,
-0.005695752799510956,
-0.005250248126685619,
0.07108912616968155,
-0.006749635096639395,
-0.047443848103284836,
0.03579366207122803,
0.059783849865198135,
-0.028033260256052017,
-0.03462481126189232,
0.10063614696264267,
0.014811831526458263,
0.006998734083026648,
0.01235916092991829,
0.09580744802951813,
0.03427990525960922,
-0.019209394231438637,
0.054188694804906845,
-0.020042918622493744,
-0.015281288884580135,
0.0380355566740036,
-0.019008198752999306,
0.00020269263768568635,
0.01558787189424038,
-0.03305356949567795,
-0.016823789104819298,
-0.038706209510564804,
-0.009451405145227909,
-0.039702609181404114,
-0.011391505599021912,
-0.011219052597880363,
0.017331568524241447,
0.0040167272090911865,
0.010280139744281769,
0.03217214345932007,
0.022917142137885094,
-0.027803322300314903,
-0.03556372597813606,
0.02540813572704792,
0.012042996473610401,
0.002689794171601534,
-0.07315856963396072,
-0.08001838624477386,
0.022361459210515022,
0.036962512880563736,
-0.051467761397361755,
-0.012579518370330334,
-0.01715911366045475,
-0.048018693923950195,
-0.007540046237409115,
-0.07633937895298004,
0.019276458770036697,
-0.011219052597880363,
-0.014668121002614498,
-0.046600744128227234,
0.007396335247904062,
0.00042634314741007984,
-0.0021508773788809776,
-0.01744653657078743,
0.002228720812126994,
0.06346285343170166,
-0.00010673548968043178,
-0.02381773293018341,
0.03761400654911995,
0.0368475466966629,
-0.01457231305539608,
0.01629684679210186,
-0.008617879822850227,
0.004558039363473654,
0.05142943933606148,
-0.028742235153913498,
0.034816429018974304,
0.034663137048482895,
0.0314440056681633,
-0.04594925418496132,
0.027515899389982224,
-0.008881350979208946,
0.013968726620078087,
-0.011084921658039093,
0.021499192342162132,
-0.007075380068272352,
-0.02471832185983658,
0.036406829953193665,
0.04008583724498749,
0.02011956460773945,
-0.010854984633624554,
-0.014016630128026009,
0.010098105296492577,
0.005475395824760199,
-0.052310869097709656,
-0.05165937915444374,
0.008234650827944279,
0.01928604021668434,
-0.007554417476058006,
-0.012665744870901108,
-0.006428679917007685,
-0.01299149077385664,
-0.040699005126953125,
0.0008814285392872989,
-0.012751971371471882,
-0.019190233200788498,
-0.0024742274545133114,
0.015032188966870308,
-0.01850999891757965,
-0.022361459210515022,
0.006677779369056225,
-0.05652639642357826,
-0.07798726856708527,
0.04847856983542442,
0.06028204783797264,
0.024584192782640457,
-0.06718018651008606,
0.015013027936220169,
-0.022227328270673752,
0.0017832161393016577,
0.037805620580911636,
0.04307502880692482,
-0.02469916082918644,
-0.001341304276138544,
-0.019515978172421455,
-0.01098911464214325,
0.024028507992625237,
0.03422242030501366,
0.03014102391898632,
0.0176668930798769,
-0.04292173683643341,
-0.007214301265776157,
-0.0497049055993557,
-0.050011489540338516,
-0.00983942486345768,
0.008957996964454651,
0.00008076268568402156,
0.06185328960418701,
-0.022763850167393684,
0.01636391319334507,
0.04426304250955582,
0.028473975136876106,
-0.029393725097179413,
0.018787840381264687,
0.0020095612853765488,
-0.028665589168667793,
-0.0769142210483551,
-0.022457266226410866,
0.03232543542981148,
-0.04460794851183891,
0.004713726695626974,
0.04234689474105835,
0.047750432044267654,
-0.015195061452686787,
-0.05675633251667023,
-0.07549627125263214,
0.035659532994031906,
0.03249788656830788,
0.0019353105453774333,
-0.0015137577429413795,
0.05514676868915558,
0.016766304150223732,
-0.0036646348889917135,
-0.06315626949071884,
0.025293167680501938,
0.003547270782291889,
-0.036521799862384796,
-0.0017221389571204782,
-0.027190154418349266,
-0.06388440728187561,
-0.037978071719408035,
-0.053920432925224304,
-0.044991180300712585,
0.01861538738012314,
0.023319533094763756,
0.04717558994889259,
-0.03544875606894493,
0.019851304590702057,
0.018251318484544754,
0.051046211272478104,
-0.025369813665747643,
-0.0061364672146737576,
-0.0256955586373806,
-0.02571471966803074,
0.01574116386473179,
-0.0032406870741397142,
0.016680076718330383,
-0.057944346219301224,
0.029182950034737587,
-0.0018634549342095852,
0.02456502988934517,
-0.023798570036888123,
0.05165937915444374,
0.007913695648312569,
0.0020406986586749554,
0.08783627301454544,
-0.06656701862812042,
0.010768757201731205,
-0.06334788352251053,
-0.003712538629770279,
-0.037843942642211914,
0.005767608527094126,
-0.020177049562335014,
0.019247716292738914,
0.010969952680170536,
-0.026021303609013557,
-0.022323135286569595,
0.050739627331495285,
0.008110100403428078,
-0.0031185324769467115,
-0.03276614844799042,
-0.002462251577526331,
0.017743539065122604,
-0.005729285534471273,
-0.0029963781125843525,
-0.034107454121112823,
0.06591552495956421,
0.004670613445341587,
0.029029658064246178,
0.04422472044825554,
0.007798726670444012,
0.05813596025109291,
0.022629719227552414,
-0.03977925330400467,
-0.03657928481698036,
0.007856210693717003,
-0.028071582317352295,
-0.02742009237408638,
-0.006217903457581997,
-0.06511074304580688,
-0.048018693923950195,
0.029891924932599068,
-0.021307576447725296,
-0.004833485931158066,
0.011525636538863182,
0.012004673480987549,
0.07733577489852905,
-0.0029149416368454695,
-0.002919732127338648,
-0.0053843786008656025,
0.001637109788134694,
0.05066297948360443,
-0.01470644399523735,
0.018212996423244476,
-0.057216208428144455,
-0.002245487179607153,
0.021556677296757698,
-0.025159036740660667,
0.023453664034605026,
0.050318073481321335,
0.038687050342559814,
0.06392273306846619,
-0.025772204622626305,
-0.01729324460029602,
-0.05380546301603317,
-0.04752049595117569,
0.021211769431829453,
-0.03893614932894707,
-0.03604276478290558,
0.058212608098983765,
-0.07599446922540665,
0.03541043400764465,
-0.05112285539507866,
0.009005900472402573,
-0.032517049461603165,
0.010232235305011272,
-0.01808844693005085,
-0.045297764241695404,
0.04920670762658119,
-0.008565186522901058,
0.0043352870270609856,
-0.04016248509287834,
-0.005590364802628756,
0.03157813474535942,
-0.05453360080718994,
0.0015736373607069254,
-0.06196825951337814,
-0.013796272687613964,
0.0361768938601017,
0.007329269777983427,
0.02383689396083355,
-0.0083256671205163,
0.03159729763865471,
-0.05372881889343262,
-0.012110061943531036,
-0.03604276478290558,
0.01420824509114027,
0.03282363340258598,
0.001371244085021317,
0.015013027936220169,
-0.003853854723274708,
-0.033934999257326126,
0.011017857119441032,
0.009245418943464756,
0.023606956005096436,
0.008517282083630562,
0.01660343073308468,
0.0034466730430722237,
-0.052157577127218246,
0.04460794851183891,
-0.006146048195660114,
0.03602360188961029,
-0.030332639813423157,
0.008076568134129047,
0.008407103829085827,
0.0003224519605282694,
0.05453360080718994,
-0.017906412482261658,
-0.01864412985742092,
0.05495515465736389,
0.027669191360473633,
0.00491971243172884,
0.04798037186264992,
-0.029202111065387726,
-0.03205717355012894,
-0.07335018366575241,
-0.016335170716047287,
0.01371004618704319,
0.06189161166548729,
-0.0407373271882534,
-0.0023041691165417433,
0.020617762580513954,
0.01587529480457306,
0.04713726416230202
]
|
30,550 | networkx.classes.function | density | Returns the density of a graph.
The density for undirected graphs is
.. math::
d = \frac{2m}{n(n-1)},
and for directed graphs is
.. math::
d = \frac{m}{n(n-1)},
where `n` is the number of nodes and `m` is the number of edges in `G`.
Notes
-----
The density is 0 for a graph without edges and 1 for a complete graph.
The density of multigraphs can be higher than 1.
Self loops are counted in the total number of edges so graphs with self
loops can have density higher than 1.
| def density(G):
r"""Returns the density of a graph.
The density for undirected graphs is
.. math::
d = \frac{2m}{n(n-1)},
and for directed graphs is
.. math::
d = \frac{m}{n(n-1)},
where `n` is the number of nodes and `m` is the number of edges in `G`.
Notes
-----
The density is 0 for a graph without edges and 1 for a complete graph.
The density of multigraphs can be higher than 1.
Self loops are counted in the total number of edges so graphs with self
loops can have density higher than 1.
"""
n = number_of_nodes(G)
m = number_of_edges(G)
if m == 0 or n <= 1:
return 0
d = m / (n * (n - 1))
if not G.is_directed():
d *= 2
return d
| (G) | [
0.03312293440103531,
0.05829780176281929,
0.016759268939495087,
-0.0011323071084916592,
0.04851556941866875,
-0.017541488632559776,
0.005178830120712519,
-0.037007056176662445,
0.004621386528015137,
0.034543514251708984,
-0.012074945494532585,
0.01983419992029667,
0.003915591165423393,
0.0299940574914217,
0.0061768339946866035,
0.004540467169135809,
-0.027782265096902847,
0.02990414761006832,
0.01814388670027256,
0.05078130587935448,
-0.002278100699186325,
-0.003495260840281844,
0.003104151226580143,
-0.021794242784380913,
-0.09487328678369522,
-0.05793816223740578,
0.03110894374549389,
0.014394629746675491,
0.010249767452478409,
0.016390638425946236,
0.004643863998353481,
-0.016759268939495087,
-0.005408101249486208,
0.054701391607522964,
0.021326709538698196,
0.0827893540263176,
0.0012227792758494616,
0.017415614798665047,
-0.16039986908435822,
-0.025480562821030617,
-0.013315707445144653,
0.024041999131441116,
-0.020463570952415466,
-0.0027782265096902847,
0.037582483142614365,
-0.016399629414081573,
0.03952454403042793,
-0.00935965683311224,
-0.08760853856801987,
-0.0005537908873520792,
-0.013819204643368721,
-0.007390622049570084,
-0.02657746896147728,
-0.021938100457191467,
0.019888145849108696,
0.059592511504888535,
0.012020999565720558,
-0.014682343229651451,
0.004324682522565126,
-0.009683333337306976,
0.008860654197633266,
-0.02517486922442913,
0.03981225565075874,
-0.039848219603300095,
-0.06354855746030807,
-0.008518995717167854,
0.01143658347427845,
0.01121180783957243,
-0.005902607459574938,
-0.0018926106858998537,
0.0010716177057474852,
-0.0033401655964553356,
-0.02715289406478405,
0.007835677824914455,
0.053334757685661316,
0.03418387472629547,
0.0486234612762928,
-0.026775270700454712,
0.003569436725229025,
-0.02427576668560505,
0.05495314300060272,
-0.05250758305191994,
0.0271888580173254,
-0.02654150500893593,
0.029094954952597618,
-0.005372137296944857,
0.00528672244399786,
0.026091953739523888,
-0.01690312661230564,
0.0257502943277359,
0.036143917590379715,
0.024743299931287766,
0.010942076332867146,
0.01576126553118229,
-0.012218802236020565,
-0.018170859664678574,
-0.01440362073481083,
0.00012854355736635625,
0.056139957159757614,
-0.001742010936141014,
0.017820211127400398,
0.011967053636908531,
0.0005627819336950779,
0.0023511529434472322,
-0.0385175496339798,
-0.06459151953458786,
0.015869157388806343,
0.0023309229873120785,
0.008734780363738537,
-0.003265989711508155,
-0.03279925882816315,
0.020931104198098183,
0.05944865196943283,
-0.0064780330285429955,
0.001833045156672597,
0.0028029519598931074,
-0.0005240081227384508,
-0.0006732029723934829,
0.008132381364703178,
-0.0008726913365535438,
-0.08926288783550262,
0.03409396484494209,
-0.06282927840948105,
-0.014862162992358208,
0.03118087351322174,
-0.006693817675113678,
-0.021416619420051575,
-0.049306776374578476,
0.015725301578640938,
0.07351061701774597,
0.050133951008319855,
0.04448758810758591,
0.09638378024101257,
0.06415995210409164,
0.06394416838884354,
-0.061031073331832886,
-0.0357123501598835,
0.016633395105600357,
0.069950170814991,
0.007161350920796394,
-0.030659392476081848,
-0.07095716148614883,
-0.03393212705850601,
0.03324880823493004,
0.03769037500023842,
0.01662440411746502,
0.032187867909669876,
0.03335670009255409,
0.004711296875029802,
-0.010060956701636314,
0.026091953739523888,
0.021614423021674156,
0.10069947689771652,
-0.009674342349171638,
-0.0029580469708889723,
-0.00543956970795989,
-0.018332699313759804,
0.029922129586338997,
-0.00619032047688961,
0.01300102099776268,
-0.02539065293967724,
-0.03263741731643677,
0.024653388187289238,
0.03808597847819328,
-0.014799226075410843,
-0.009449566714465618,
0.011580439284443855,
0.009773243218660355,
0.0012081689201295376,
0.004203303717076778,
0.017226802185177803,
0.012038981541991234,
-0.03341064602136612,
-0.04808399826288223,
0.04668140038847923,
0.044451624155044556,
0.03733073174953461,
0.01640862040221691,
-0.002034219214692712,
0.022081956267356873,
0.0271169301122427,
-0.05434175208210945,
0.029472578316926956,
0.013702320866286755,
0.024545496329665184,
0.037043020129203796,
0.004039217717945576,
-0.026667378842830658,
0.008375138975679874,
0.023106932640075684,
0.010618399828672409,
-0.026469575241208076,
-0.01888115145266056,
0.03736669570207596,
0.04225781559944153,
-0.005691318307071924,
0.0039021046832203865,
-0.024293748661875725,
0.03362642973661423,
0.009845172055065632,
0.015896130353212357,
0.019726308062672615,
-0.01536566112190485,
0.023592447862029076,
-0.034453604370355606,
0.024491550400853157,
0.0028883665800094604,
-0.004742765333503485,
-0.03040764480829239,
-0.024869173765182495,
-0.057326771318912506,
0.0235744658857584,
0.023844197392463684,
-0.009845172055065632,
-0.0067882235161960125,
-0.009152863174676895,
0.025894150137901306,
-0.013801222667098045,
-0.03341064602136612,
-0.03794212266802788,
-0.047041039913892746,
-0.019780253991484642,
0.0016948081320151687,
0.023466574028134346,
-0.0005776733160018921,
-0.03348257392644882,
-0.00528672244399786,
0.004540467169135809,
0.002881623338907957,
-0.04463144391775131,
0.02967038005590439,
0.014061962254345417,
0.054989106953144073,
0.023358682170510292,
0.042725346982479095,
-0.04081925004720688,
-0.07325886934995651,
0.019150882959365845,
0.01001600082963705,
0.022028010338544846,
-0.031414639204740524,
-0.04718489572405815,
-0.032187867909669876,
0.023017022758722305,
0.021794242784380913,
0.008541473187506199,
-0.047256823629140854,
0.04689718410372734,
0.048479605466127396,
0.01719982922077179,
-0.09314700961112976,
-0.0729711577296257,
-0.026271773502230644,
-0.03657548874616623,
0.02040962502360344,
0.013729294762015343,
-0.04168238863348961,
0.08739275485277176,
-0.015401625074446201,
0.013252769596874714,
-0.0005197935970500112,
-0.038733333349227905,
-0.09070145338773727,
0.06649761646986008,
0.012560460716485977,
0.01499702874571085,
0.004389867652207613,
0.0006406104657799006,
-0.03754651919007301,
0.016345681622624397,
0.07250361889600754,
0.017100928351283073,
0.059304796159267426,
-0.08703311532735825,
0.0349750854074955,
-0.017820211127400398,
0.026217827573418617,
0.05480928346514702,
0.018170859664678574,
0.020463570952415466,
-0.0457463338971138,
-0.0614626444876194,
-0.029886165633797646,
0.06261349469423294,
-0.03733073174953461,
0.049019064754247665,
0.025516526773571968,
-0.00447528250515461,
0.01945657655596733,
0.025534508749842644,
0.0830051377415657,
0.012812210246920586,
0.0024275765754282475,
0.06106703728437424,
-0.015419607050716877,
-0.023268770426511765,
0.024491550400853157,
-0.015131894499063492,
-0.020643392577767372,
0.03468737378716469,
0.05952057987451553,
-0.016363663598895073,
0.006064446177333593,
-0.007975039072334766,
0.0030929124914109707,
0.030191859230399132,
0.03733073174953461,
-0.009458557702600956,
0.04599808156490326,
0.004886621609330177,
-0.06746865063905716,
0.0139091145247221,
-0.007601911202073097,
0.10408009588718414,
-0.05347861349582672,
-0.03110894374549389,
-0.006068941671401262,
-0.03053351864218712,
-0.01776626519858837,
0.01868334785103798,
0.014889136888086796,
0.13767056167125702,
-0.018251780420541763,
0.06398013234138489,
-0.0698782429099083,
0.05477331951260567,
0.03378827124834061,
0.05207601189613342,
0.058729372918605804,
-0.0026658386923372746,
-0.0235744658857584,
-0.018242789432406425,
0.02028375118970871,
0.042725346982479095,
-0.030012039467692375,
0.05916094034910202,
0.07538075000047684,
-0.034417640417814255,
-0.038481585681438446,
-0.09746270626783371,
-0.010825193487107754,
0.0015734293265268207,
-0.002312941011041403,
-0.015015010721981525,
0.010186830535531044,
-0.015095929615199566,
0.045278798788785934,
-0.077178955078125,
0.03472333773970604,
-0.007161350920796394,
-0.009737279266119003,
0.04348059371113777,
0.001347529818303883,
0.012524496763944626,
0.007413099519908428,
-0.02290913090109825,
0.005471038166433573,
-0.02657746896147728,
-0.04135871306061745,
0.03069535829126835,
-0.044451624155044556,
0.07502111047506332,
-0.03916490077972412,
-0.006271239370107651,
-0.004252754617482424,
-0.016552476212382317,
-0.06635376065969467,
0.03148656710982323,
0.019762272015213966,
0.0027220326010137796,
-0.006536474917083979,
-0.029724325984716415,
-0.07861752063035965,
0.009395620785653591,
-0.009251764044165611,
0.005632876884192228,
-0.018314717337489128,
0.00025160820223391056,
0.036755308508872986,
0.0770350992679596,
-0.053586505353450775,
-0.02497706562280655,
0.011967053636908531,
0.015401625074446201,
0.036755308508872986,
-0.017253775149583817,
0.033140916377305984,
0.004070686176419258,
-0.02772831916809082,
-0.018287744373083115,
-0.04035171866416931,
0.004117889329791069,
0.016678350046277046,
0.046465612947940826,
-0.009503512643277645,
0.002405099105089903,
0.069950170814991,
-0.002373630413785577,
-0.024635406211018562,
0.01675027795135975,
-0.025516526773571968,
0.00396953709423542,
-0.02060742862522602,
0.011085933074355125,
-0.007017494644969702,
-0.04693314805626869,
0.027584463357925415,
-0.026217827573418617,
0.06009600684046745,
0.043552521616220474,
0.030929123982787132,
-0.00016422668704763055,
-0.06556255370378494,
0.044739335775375366,
0.06541869044303894,
-0.041610460728406906,
0.014664361253380775,
-0.015707319602370262,
0.07221590727567673,
-0.01909693516790867,
0.003189565846696496,
0.0034323236905038357,
0.032601453363895416,
-0.013108913786709309,
-0.028609439730644226,
-0.04718489572405815,
0.01001600082963705,
0.027530517429113388,
-0.044163912534713745,
0.031540513038635254,
-0.03047957271337509,
-0.00702648563310504,
0.002273605205118656,
-0.024383658543229103,
0.007215297315269709,
0.014331692829728127,
0.022855184972286224,
-0.00016605298151262105,
0.006824187468737364,
-0.03114490769803524,
-0.0019521762151271105,
0.030713340267539024,
0.014079944230616093,
-0.03306898847222328,
-0.0014149624621495605,
-0.02887917123734951,
0.06228981539607048,
-0.05426982417702675,
0.04135871306061745,
-0.07347465306520462,
-0.03920086473226547,
-0.0365215428173542,
0.0385175496339798,
-0.018629401922225952,
-0.12213407456874847,
-0.007336676120758057,
0.0012092927936464548,
-0.02312491461634636,
-0.019780253991484642,
0.05340668559074402,
0.010690327733755112,
0.011796223931014538,
-0.0499541312456131,
0.0032390165142714977,
-0.03127078339457512,
-0.05894515663385391,
0.030065985396504402,
0.02740464173257351,
-0.018170859664678574,
-0.03769037500023842,
0.0671449676156044,
0.054413679987192154,
-0.04078328609466553,
-0.016966063529253006,
-0.02172231487929821,
-0.04966641962528229,
-0.04829978197813034,
-0.004778729286044836,
0.013486536219716072,
0.0015880396822467446,
0.02159644104540348,
0.018791241571307182,
0.040207862854003906,
-0.018449582159519196,
0.011841178871691227,
-0.02715289406478405,
-0.01129272673279047,
0.028447601944208145,
0.04794014245271683,
0.024491550400853157,
0.029490560293197632,
-0.03948858007788658,
0.04031575471162796,
-0.0443437322974205,
0.013621401973068714,
0.017784247174859047,
0.007255756761878729,
-0.027530517429113388,
-0.004574183840304613,
-0.020877158269286156,
-0.03175629675388336,
-0.013702320866286755,
0.027350695803761482,
0.00993508193641901,
-0.019636398181319237,
0.005466542672365904,
0.0092967189848423,
0.04035171866416931,
0.04150256887078285,
0.03641364723443985,
0.0199600737541914,
0.010726291686296463,
-0.006536474917083979,
0.047904178500175476,
0.025210833176970482,
0.019762272015213966,
-0.01559043675661087,
-0.011949071660637856,
0.02389814332127571,
-0.022369667887687683,
-0.012479541823267937,
0.03648557886481285,
-0.030353698879480362,
-0.004787720739841461,
-0.08106307685375214,
0.02702702023088932,
0.012299721129238605,
-0.0013767506461590528,
0.017505524680018425,
0.002973781432956457,
-0.02695509046316147,
0.04369637742638588,
0.026973072439432144,
0.027080966159701347,
-0.019780253991484642,
-0.05426982417702675,
-0.01592310518026352,
-0.03808597847819328,
-0.08077536523342133,
0.013702320866286755,
0.0025646896101534367,
-0.03207997605204582,
0.03920086473226547,
0.0206973385065794,
0.061318784952163696,
-0.030749304220080376,
0.04031575471162796,
-0.0037582481745630503,
0.036971092224121094,
-0.07120891660451889,
-0.03995611146092415,
-0.02776428312063217,
-0.07110102474689484,
-0.08688925951719284,
0.019654380157589912,
0.06545465439558029,
-0.02188415266573429,
0.04952256381511688,
0.018404627218842506,
-0.009746270254254341,
-0.07509303838014603,
-0.06401609629392624,
0.001991512021049857,
0.005686822813004255,
0.021488549187779427,
-0.015122903510928154,
0.0014441832900047302,
-0.04880328103899956,
-0.029184864833950996,
0.024995047599077225,
-0.04276131093502045,
-0.012911111116409302,
0.043876200914382935,
0.019240792840719223,
0.016363663598895073,
-0.012659362517297268,
-0.016696332022547722,
-0.02632571943104267,
-0.005115892738103867,
-0.040099967271089554,
-0.020499534904956818,
-0.01495207380503416,
-0.037870194762945175,
0.07387025654315948,
-0.003306449158117175,
0.009764252230525017,
-0.05599610134959221,
-0.023952089250087738,
0.008658356964588165,
-0.016390638425946236,
-0.035694368183612823,
-0.11630789190530777,
0.009377638809382915,
-0.028339708223938942,
-0.018899133428931236,
-0.027512535452842712,
-0.025804240256547928,
-0.009202313609421253,
0.003326679114252329,
0.003904352430254221,
-0.05207601189613342,
0.0586574450135231,
-0.0007277110125869513,
-0.024833209812641144,
0.05110498145222664,
0.02702702023088932,
0.0206973385065794,
-0.04053153842687607,
0.024095945060253143,
-0.09019795805215836,
-0.0399201475083828,
0.022243794053792953,
-0.0414666049182415,
0.011058960109949112,
-0.025804240256547928,
0.0063027082942426205,
0.02977827377617359,
-0.02533670701086521,
-0.04114292934536934,
0.024815227836370468,
-0.030425626784563065,
0.0013396625872701406,
0.004569688346236944,
-0.07182030379772186,
0.05315493792295456,
0.050133951008319855,
-0.006095914635807276,
-0.06667743623256683,
-0.012047972530126572,
0.016570458188652992,
-0.022405633702874184,
0.03040764480829239,
-0.04948659986257553,
0.06336873769760132,
0.023934107273817062,
-0.034615445882081985,
-0.014286737889051437,
-0.025930114090442657,
0.015653373673558235,
0.041071001440286636,
-0.03479526564478874,
0.07933679968118668,
-0.05204004794359207,
-0.020625410601496696,
-0.007453559432178736,
0.014304719865322113,
0.015536489896476269,
-0.014970055781304836,
0.055025070905685425,
-0.03191813826560974,
-0.027710337191820145,
0.004882126115262508,
0.015131894499063492,
0.028087960556149483,
0.04089117795228958,
0.03296109661459923,
-0.007260252255946398,
-0.013477545231580734,
-0.05117690935730934,
-0.042473599314689636,
0.044163912534713745,
-0.010627390816807747,
-0.004765242803841829,
0.005659849848598242,
-0.016696332022547722,
0.04934274032711983,
-0.019600432366132736,
-0.0684037134051323,
-0.05239969119429588,
-0.10630987584590912,
0.006496015004813671,
0.0485515333712101,
0.06563448160886765,
-0.06646165251731873,
-0.06142668053507805,
-0.016354672610759735,
0.05783027037978172,
0.04509897902607918,
0.009422593750059605,
0.051284804940223694,
0.0007962675881572068,
0.014844181016087532,
-0.02690114453434944,
-0.0016228798776865005,
-0.0012418852420523763,
-0.0059160939417779446,
-0.03011993132531643,
-0.055276818573474884,
-0.01710991933941841,
0.07095716148614883,
-0.04078328609466553,
-0.051320768892765045,
0.03475930169224739,
-0.010051965713500977,
0.03279925882816315,
-0.020337697118520737,
-0.0025444598868489265,
0.07897716015577316,
0.009620396420359612,
-0.04312095418572426,
-0.005282226949930191,
0.02159644104540348,
0.00296703795902431,
0.05196812003850937,
-0.007970543578267097,
-0.04495512321591377,
-0.027548499405384064,
0.04171835258603096,
0.0005627819336950779,
0.03912893682718277,
-0.021452583372592926,
-0.012245775200426579,
0.029184864833950996,
-0.005318190902471542,
-0.013270752504467964,
0.03715091198682785,
0.011346672661602497,
-0.01640862040221691,
-0.023232806473970413,
-0.0058936164714396,
-0.0235744658857584,
-0.031666386872529984,
0.010087929666042328,
0.05772237852215767,
-0.04991816729307175,
0.03465140983462334,
0.02760244533419609,
-0.03303302451968193,
0.012785236351191998,
0.007116395980119705,
-0.028447601944208145,
0.005875634495168924,
-0.017820211127400398,
-0.0037582481745630503,
-0.030191859230399132,
-0.009242773056030273,
-0.0013733790256083012,
0.03801405057311058,
-0.023430610075592995,
-0.006023986265063286,
-0.033878181129693985,
0.025786258280277252,
-0.036629434674978256,
-0.008370643481612206,
0.02127276360988617,
-0.027009038254618645,
-0.02632571943104267,
0.012659362517297268,
0.003630126127973199,
-0.03715091198682785,
0.02245957963168621,
0.0037357707042247057,
-0.010222794488072395,
0.00006925898196641356,
0.012029990553855896,
0.003499756334349513,
0.007228783797472715,
-0.10530287772417068,
0.019402630627155304,
-0.041610460728406906,
-0.013792231678962708,
-0.034165892750024796,
-0.00413362355902791,
-0.00582168810069561,
-0.04491915926337242,
0.025120921432971954,
0.04398409277200699,
0.01790113002061844
]
|
30,552 | networkx.generators.small | desargues_graph |
Returns the Desargues Graph
The Desargues Graph is a non-planar, distance-transitive cubic graph
with 20 nodes and 30 edges [1]_.
It is a symmetric graph. It can be represented in LCF notation
as [5,-5,9,-9]^5 [2]_.
Parameters
----------
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : networkx Graph
Desargues Graph with 20 nodes and 30 edges
References
----------
.. [1] https://en.wikipedia.org/wiki/Desargues_graph
.. [2] https://mathworld.wolfram.com/DesarguesGraph.html
| def sedgewick_maze_graph(create_using=None):
"""
Return a small maze with a cycle.
This is the maze used in Sedgewick, 3rd Edition, Part 5, Graph
Algorithms, Chapter 18, e.g. Figure 18.2 and following [1]_.
Nodes are numbered 0,..,7
Parameters
----------
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : networkx Graph
Small maze with a cycle
References
----------
.. [1] Figure 18.2, Chapter 18, Graph Algorithms (3rd Ed), Sedgewick
"""
G = empty_graph(0, create_using)
G.add_nodes_from(range(8))
G.add_edges_from([[0, 2], [0, 7], [0, 5]])
G.add_edges_from([[1, 7], [2, 6]])
G.add_edges_from([[3, 4], [3, 5]])
G.add_edges_from([[4, 5], [4, 7], [4, 6]])
G.name = "Sedgewick Maze"
return G
| (create_using=None, *, backend=None, **backend_kwargs) | [
0.0845668613910675,
-0.022300876677036285,
-0.01378017757087946,
-0.03377138078212738,
-0.06186806410551071,
0.02337353304028511,
-0.06280231475830078,
0.0550169013440609,
-0.00026897512725554407,
-0.015804383903741837,
-0.006768982391804457,
0.03150496259331703,
-0.006920365151017904,
0.07736968249082565,
0.024048268795013428,
-0.01339090708643198,
0.0429062657058239,
-0.003423418151214719,
-0.024498092010617256,
0.05252557247877121,
-0.010942826978862286,
-0.03999971225857735,
0.04003431275486946,
0.04411732777953148,
-0.02695482224225998,
0.027681460604071617,
-0.014757678844034672,
0.054255664348602295,
-0.008274161256849766,
-0.033131249248981476,
-0.01726631075143814,
-0.04411732777953148,
-0.0583040751516819,
0.018581179901957512,
0.030120888724923134,
0.06394417583942413,
0.0019139135256409645,
0.048096537590026855,
-0.08041464537382126,
-0.05235256254673004,
0.03771599009633064,
-0.00533733144402504,
0.052214156836271286,
-0.004589067306369543,
0.040068913251161575,
-0.012845927849411964,
0.05103769153356552,
0.020968707278370857,
-0.025934068486094475,
-0.03183367848396301,
0.026660706847906113,
-0.023961763828992844,
-0.016418566927313805,
0.03595129773020744,
0.03480943664908409,
-0.01682513765990734,
-0.02243928425014019,
-0.00803194846957922,
0.10262901335954666,
-0.04757751151919365,
0.005285428836941719,
-0.014238650910556316,
0.02728353999555111,
0.04096856340765953,
-0.04581281915307045,
-0.013935885392129421,
-0.03415200114250183,
-0.05487849563360214,
-0.0006028286879882216,
0.004753425717353821,
0.045189984142780304,
0.03581288829445839,
0.04512077942490578,
-0.01017293706536293,
0.0366087332367897,
0.02965376526117325,
-0.014757678844034672,
-0.03591669350862503,
-0.044359542429447174,
-0.04740450158715248,
0.019723040983080864,
0.0170414000749588,
-0.027145132422447205,
-0.053494423627853394,
0.031210847198963165,
0.03212779387831688,
0.03046690858900547,
0.043044671416282654,
-0.011842475272715092,
-0.09653909504413605,
0.01617635414004326,
-0.013070839457213879,
-0.027145132422447205,
-0.011531058698892593,
-0.008624505251646042,
0.004124104976654053,
0.020380474627017975,
-0.0600687712430954,
0.0058087813667953014,
-0.01941162347793579,
-0.04169519990682602,
0.009524152614176273,
-0.08470527082681656,
0.012456657364964485,
-0.052663978189229965,
-0.04283706098794937,
-0.02453269436955452,
0.004078690428286791,
-0.017171155661344528,
-0.040345728397369385,
-0.041729800403118134,
-0.0021323375403881073,
0.02728353999555111,
0.004502562806010246,
0.03140115737915039,
0.036331918090581894,
0.02415207400918007,
0.01660887710750103,
0.034619126468896866,
-0.06557045876979828,
-0.019619235768914223,
0.00973176397383213,
-0.04740450158715248,
-0.037162359803915024,
0.03692014887928963,
-0.029601862654089928,
0.03477483615279198,
-0.01308814063668251,
0.008559626527130604,
-0.012863229028880596,
0.020484281703829765,
0.006228328682482243,
-0.0393768772482872,
0.03216239809989929,
-0.05176433175802231,
0.008256861008703709,
-0.04183360934257507,
-0.04384051263332367,
0.025380440056324005,
0.02903093211352825,
0.011366699822247028,
-0.028684914112091064,
0.0018295715562999249,
0.028286993503570557,
-0.06318293511867523,
-0.0024805183056741953,
-0.018563879653811455,
0.00852935016155243,
0.060864612460136414,
0.027923673391342163,
0.028425399214029312,
-0.009039727039635181,
0.02134932577610016,
0.027093229815363884,
-0.021435830742120743,
-0.031712573021650314,
-0.001302974997088313,
0.05951514095067978,
0.015146949328482151,
0.05878850072622299,
0.011271544732153416,
-0.02569185569882393,
0.012854577973484993,
0.012041435576975346,
-0.03678173944354057,
-0.010449751280248165,
0.008663431741297245,
0.011721368879079819,
-0.012223094701766968,
0.013243848457932472,
-0.027421947568655014,
0.01061411015689373,
-0.05740442872047424,
-0.024982517585158348,
0.06394417583942413,
-0.00002748885344772134,
-0.02557075023651123,
-0.005242176819592714,
0.020120961591601372,
-0.043909717351198196,
-0.019498128443956375,
-0.012387453578412533,
0.014489514753222466,
-0.0058736600913107395,
0.002737869508564472,
0.0039100064896047115,
0.012223094701766968,
-0.00855530146509409,
0.0326814241707325,
0.01666942983865738,
-0.010518955066800117,
0.005371933337301016,
0.033909790217876434,
0.07204100489616394,
0.04051873832941055,
-0.02365034818649292,
0.030345801264047623,
0.02420397661626339,
-0.05615876242518425,
0.07543198019266129,
-0.014117544516921043,
0.03235270828008652,
0.011755970306694508,
-0.026972122490406036,
0.05297539383172989,
0.03503434732556343,
0.0047274744138121605,
-0.08110667765140533,
-0.018771490082144737,
0.03788900002837181,
-0.04775052145123482,
-0.01601199433207512,
0.056297171860933304,
0.026920219883322716,
-0.013408207334578037,
-0.03128005191683769,
0.008187657222151756,
0.06121062859892845,
0.03406549617648125,
-0.026037873700261116,
-0.0507262758910656,
0.007037146482616663,
-0.048926983028650284,
-0.019999856129288673,
0.014255952090024948,
-0.04335608705878258,
-0.04508617892861366,
-0.03910006210207939,
-0.015164250507950783,
-0.07425551861524582,
0.02074379473924637,
-0.028944427147507668,
0.03892705589532852,
-0.012586413882672787,
0.013226548209786415,
-0.011747320182621479,
-0.013313052244484425,
-0.018909897655248642,
0.008023298345506191,
-0.02084759995341301,
-0.05069167539477348,
-0.06380576640367508,
0.010034529492259026,
-0.03406549617648125,
0.04712768644094467,
0.03806200996041298,
-0.007482644636183977,
0.01837356947362423,
0.003094700863584876,
0.00836066622287035,
-0.032871734350919724,
-0.014800931327044964,
0.03278522938489914,
0.00010907684918493032,
-0.004567441064864397,
0.013840730302035809,
-0.05802726373076439,
0.00356182549148798,
-0.016262859106063843,
0.02198946103453636,
-0.02145313285291195,
-0.027404645457863808,
-0.023114020004868507,
-0.017283612862229347,
0.04058794304728508,
0.011141788214445114,
-0.05615876242518425,
0.07494755834341049,
-0.08664297312498093,
-0.045674409717321396,
0.03775059059262276,
0.014550067484378815,
0.01479228027164936,
0.006397012621164322,
0.01720575802028179,
-0.003445044392719865,
-0.025812963023781776,
-0.003817013930529356,
-0.0014403009554371238,
-0.03557067736983299,
-0.09550104290246964,
-0.03546687215566635,
0.012127939611673355,
0.054151859134435654,
-0.05100309103727341,
-0.0021907282061874866,
0.016124451532959938,
0.009446298703551292,
0.04145298898220062,
-0.03013819083571434,
-0.017447970807552338,
-0.042214225977659225,
0.014134845696389675,
0.0007217724341899157,
0.04169519990682602,
-0.004450659733265638,
0.02205866388976574,
-0.008559626527130604,
-0.028788719326257706,
0.047612112015485764,
0.08913430571556091,
-0.06121062859892845,
0.007811362389475107,
0.018494676798582077,
0.023114020004868507,
0.038961656391620636,
0.001902019139379263,
-0.024013666436076164,
0.04982662945985794,
-0.03553607687354088,
-0.0896187275648117,
0.014965289272367954,
-0.004952386487275362,
0.05743902921676636,
-0.02745654806494713,
-0.04207582026720047,
-0.029238542541861534,
-0.0300343856215477,
0.05588194727897644,
0.049030788242816925,
-0.007811362389475107,
0.018079454079270363,
-0.015925491228699684,
0.008499073795974255,
-0.06736975163221359,
0.014446262270212173,
0.018287064507603645,
0.04615883529186249,
0.012612365186214447,
0.018010251224040985,
-0.026816414669156075,
-0.036885544657707214,
0.015925491228699684,
0.018131356686353683,
-0.05131450667977333,
0.01887529529631138,
0.013659071177244186,
-0.007703231647610664,
-0.02228357642889023,
-0.044636353850364685,
0.09058757871389389,
0.02387526072561741,
-0.013174645602703094,
-0.011124487034976482,
0.06166045367717743,
0.016513722017407417,
-0.007897866889834404,
-0.05044946074485779,
-0.012101988308131695,
0.0469546765089035,
0.03650492802262306,
0.0704147145152092,
-0.017076000571250916,
0.006950641982257366,
0.030293898656964302,
0.03392709046602249,
0.01617635414004326,
0.01025944110006094,
-0.03524196147918701,
0.02910013496875763,
-0.06339054554700851,
0.021764548495411873,
0.004926435183733702,
-0.0016241231933236122,
-0.021799150854349136,
-0.02567455545067787,
-0.017015447840094566,
0.03240460902452469,
0.05363282933831215,
-0.0593075305223465,
-0.02122822031378746,
-0.0593075305223465,
-0.021366627886891365,
0.03290633484721184,
-0.008235234767198563,
0.065362848341465,
-0.03442881628870964,
0.009723112918436527,
0.06352895498275757,
0.004312252625823021,
0.01191167812794447,
-0.0017463108524680138,
0.008477447554469109,
-0.002954130992293358,
0.08055304735898972,
-0.028460001572966576,
0.04505157843232155,
0.03503434732556343,
0.017361465841531754,
-0.056297171860933304,
-0.0943937823176384,
-0.024290481582283974,
0.056954603642225266,
0.0681309923529625,
-0.005523316562175751,
0.025311235338449478,
0.08214473724365234,
0.046504855155944824,
-0.03622811287641525,
0.04647025093436241,
0.07750809192657471,
-0.0429062657058239,
0.03205859288573265,
0.04387511685490608,
-0.028235089033842087,
-0.06543204933404922,
-0.02705862745642662,
0.010839021764695644,
0.02655690163373947,
0.018581179901957512,
0.048926983028650284,
-0.048719372600317,
-0.04858096316456795,
0.0180448517203331,
-0.0027767964638769627,
0.010882274247705936,
0.015389162115752697,
0.026089776307344437,
0.05847708508372307,
0.00694199139252305,
0.05134911090135574,
-0.012231745757162571,
0.00036737407208420336,
0.03871944174170494,
0.042491041123867035,
-0.016954895108938217,
-0.024498092010617256,
-0.005713626276701689,
-0.05235256254673004,
0.04788892716169357,
-0.010060480795800686,
-0.06089921295642853,
0.05764664337038994,
-0.021435830742120743,
-0.017733436077833176,
0.005207574926316738,
0.033252354711294174,
-0.018563879653811455,
0.022352779284119606,
0.018615782260894775,
0.03185098245739937,
-0.014143496751785278,
-0.029601862654089928,
-0.030622616410255432,
0.019982554018497467,
-0.030882129445672035,
-0.007257733028382063,
-0.006284556817263365,
0.016375314444303513,
0.009307891130447388,
0.030726421624422073,
0.011608912609517574,
-0.03598589822649956,
0.011781921610236168,
-0.061729658395051956,
0.008127103559672832,
0.02711053006350994,
0.011557010002434254,
-0.03318314999341965,
0.05134911090135574,
0.0383734256029129,
-0.014541417360305786,
-0.020484281703829765,
0.06660851836204529,
-0.03889245167374611,
-0.015363210812211037,
0.021695345640182495,
0.005661723669618368,
0.0009137044544331729,
-0.06792338192462921,
0.03188558295369148,
-0.02965376526117325,
-0.05889230594038963,
-0.04588202014565468,
0.08878828585147858,
-0.04515538364648819,
-0.06342514604330063,
-0.022370079532265663,
0.03934227675199509,
-0.016980845481157303,
-0.06155664846301079,
-0.009550103917717934,
0.004887507762759924,
0.030882129445672035,
-0.010579508729279041,
0.0004625291039701551,
0.04999963939189911,
-0.08518969267606735,
-0.022075964137911797,
-0.04224883019924164,
0.002858975902199745,
-0.034740231931209564,
-0.027975575998425484,
-0.000006158381438581273,
-0.006371061317622662,
0.07806172221899033,
-0.030536111444234848,
-0.031435757875442505,
-0.004502562806010246,
-0.07640083134174347,
0.02882332168519497,
-0.015691928565502167,
-0.03833882138133049,
-0.021141715347766876,
-0.023183222860097885,
0.04397892206907272,
0.02320052497088909,
-0.012422055937349796,
0.018460074439644814,
0.027594955638051033,
0.05615876242518425,
-0.009039727039635181,
0.003326100530102849,
0.07667764276266098,
0.02216246910393238,
0.0300343856215477,
-0.007621052209287882,
0.01499124150723219,
0.05491309612989426,
-0.05923832580447197,
0.015380511991679668,
0.02425587922334671,
0.02809668332338333,
0.03591669350862503,
-0.04397892206907272,
0.05999956652522087,
0.030449606478214264,
0.03375408053398132,
0.04027652367949486,
0.037612184882164,
0.0315568670630455,
0.0714181661605835,
-0.028581108897924423,
0.07937658578157425,
0.03361567482352257,
-0.044463347643613815,
0.04740450158715248,
0.0143251558765769,
-0.019705740734934807,
-0.03851183131337166,
0.005198924336582422,
-0.029601862654089928,
-0.0340828001499176,
-0.02294101007282734,
-0.011392651125788689,
0.0017949696630239487,
0.09480900317430496,
-0.02903093211352825,
-0.02365034818649292,
-0.09813077747821808,
-0.021868353709578514,
0.03228350356221199,
-0.005211899988353252,
-0.0053459820337593555,
0.08636615425348282,
-0.04965361952781677,
-0.0230967178940773,
-0.029498057439923286,
0.016704032197594643,
0.012794025242328644,
-0.06387496739625931,
-0.011167739517986774,
0.014013739302754402,
-0.009065678343176842,
-0.009005125612020493,
0.022456584498286247,
0.0054454621858894825,
0.022318176925182343,
-0.02430778183043003,
0.025709155946969986,
0.02980947308242321,
0.04397892206907272,
0.08622775226831436,
-0.025380440056324005,
-0.02821778878569603,
-0.007815686985850334,
0.00032682507298886776,
0.03145305812358856,
0.04954981431365013,
-0.023684950545430183,
-0.033961690962314606,
-0.014178098179399967,
0.005605496000498533,
0.040345728397369385,
-0.018944500014185905,
0.03934227675199509,
-0.0366087332367897,
0.008373641408979893,
-0.02188565395772457,
0.013191945850849152,
0.051279906183481216,
-0.051279906183481216,
0.041279979050159454,
-0.001974466722458601,
-0.04256024584174156,
-0.002980082295835018,
0.025432342663407326,
0.01991335116326809,
0.023442737758159637,
0.01621960662305355,
-0.05076088011264801,
0.07224861532449722,
0.03536306694149971,
0.034186605364084244,
0.03560527786612511,
0.023338930681347847,
0.018581179901957512,
-0.018581179901957512,
0.001426244038157165,
-0.04394431784749031,
-0.010008578188717365,
0.007499945815652609,
-0.01666942983865738,
-0.053978849202394485,
-0.05913452059030533,
0.008196307346224785,
-0.023252427577972412,
0.00902242586016655,
-0.03157416731119156,
-0.0244807917624712,
0.009299241006374359,
-0.010908225551247597,
0.0016911642160266638,
-0.032871734350919724,
-0.012162541970610619,
0.003992185462266207,
0.02167804352939129,
0.00989612191915512,
-0.013373605906963348,
0.04076094925403595,
-0.021747248247265816,
-0.045397594571113586,
-0.011842475272715092,
-0.03321775421500206,
-0.01996525377035141,
-0.03096863441169262,
0.00021315265621524304,
0.000005926069661654765,
0.010769817978143692,
0.0580618642270565,
-0.041660599410533905,
0.027179734781384468,
0.02745654806494713,
0.017249010503292084,
-0.06754276156425476,
-0.01951543055474758,
0.0635981559753418,
-0.0008693708805367351,
-0.0426640510559082,
0.01133209839463234,
-0.008196307346224785,
0.005320030730217695,
0.023252427577972412,
0.01726631075143814,
0.05494770035147667,
0.03664333373308182,
-0.034895941615104675,
-0.06705833971500397,
0.054151859134435654,
-0.04712768644094467,
0.03892705589532852,
0.008810490369796753,
0.009316541254520416,
0.023633047938346863,
0.021954858675599098,
0.04563980922102928,
0.006141824182122946,
0.028131283819675446,
0.0325603187084198,
-0.02778526581823826,
-0.02579566091299057,
-0.04384051263332367,
-0.008693709038197994,
-0.052110351622104645,
-0.06480921804904938,
-0.045432198792696,
-0.02491331472992897,
0.02288910746574402,
-0.04671246558427811,
-0.037162359803915024,
0.03906546160578728,
0.05186813697218895,
-0.013001635670661926,
-0.0446709580719471,
-0.0056098210625350475,
0.03626271337270737,
-0.05269858241081238,
-0.021418530493974686,
0.030484208837151527,
0.00757779972627759,
-0.0230967178940773,
-0.0403803326189518,
0.02453269436955452,
0.050138045102357864,
-0.01056220754981041,
0.00712365098297596,
-0.016704032197594643,
-0.018217861652374268,
0.002437266055494547,
-0.06345974653959274,
0.03262952342629433,
0.04456715285778046,
0.0023896885104477406,
0.021470433101058006,
0.039965108036994934,
-0.043529096990823746,
-0.039895907044410706,
0.048753973096609116,
-0.0027984227053821087,
0.0063061825931072235,
-0.02072649449110031,
-0.03152226284146309,
0.0419028103351593,
0.028996329754590988,
0.000490913400426507,
-0.05899611487984657,
-0.0037218588404357433,
-0.0009558754391036928,
-0.022525789216160774,
0.006989568937569857,
0.01221444457769394,
0.0012013321975246072,
-0.01865038461983204,
0.02079569734632969,
-0.062352489680051804,
-0.0014976102393120527,
-0.04615883529186249,
-0.05972275137901306,
0.0037845748011022806,
-0.05615876242518425,
-0.04335608705878258,
0.008157380856573582,
-0.004965362139046192,
0.0524909682571888,
0.0069549670442938805,
0.003068749327212572,
0.0003587236278690398,
0.05989576131105423,
-0.018667684867978096,
0.037196964025497437,
-0.03441151604056358,
-0.01830436661839485,
-0.08145269751548767,
0.00615912489593029,
-0.00975771527737379,
0.01270752027630806,
0.030726421624422073,
0.045189984142780304,
-0.04681627079844475,
0.012629666365683079,
0.05968815088272095,
-0.05560513585805893,
0.06698913127183914,
0.028079381212592125,
-0.024947917088866234,
0.02541504055261612,
-0.04017271846532822,
-0.04422113299369812,
-0.036158908158540726,
-0.07100294530391693,
-0.018269764259457588,
0.024169376119971275,
0.014524116180837154,
-0.02294101007282734,
-0.044740159064531326,
0.02233547903597355,
0.022854505106806755,
0.056124161928892136
]
|
30,553 | networkx.algorithms.dag | descendants | Returns all nodes reachable from `source` in `G`.
Parameters
----------
G : NetworkX Graph
source : node in `G`
Returns
-------
set()
The descendants of `source` in `G`
Raises
------
NetworkXError
If node `source` is not in `G`.
Examples
--------
>>> DG = nx.path_graph(5, create_using=nx.DiGraph)
>>> sorted(nx.descendants(DG, 2))
[3, 4]
The `source` node is not a descendant of itself, but can be included manually:
>>> sorted(nx.descendants(DG, 2) | {2})
[2, 3, 4]
See also
--------
ancestors
| def transitive_closure_dag(G, topo_order=None):
"""Returns the transitive closure of a directed acyclic graph.
This function is faster than the function `transitive_closure`, but fails
if the graph has a cycle.
The transitive closure of G = (V,E) is a graph G+ = (V,E+) such that
for all v, w in V there is an edge (v, w) in E+ if and only if there
is a non-null path from v to w in G.
Parameters
----------
G : NetworkX DiGraph
A directed acyclic graph (DAG)
topo_order: list or tuple, optional
A topological order for G (if None, the function will compute one)
Returns
-------
NetworkX DiGraph
The transitive closure of `G`
Raises
------
NetworkXNotImplemented
If `G` is not directed
NetworkXUnfeasible
If `G` has a cycle
Examples
--------
>>> DG = nx.DiGraph([(1, 2), (2, 3)])
>>> TC = nx.transitive_closure_dag(DG)
>>> TC.edges()
OutEdgeView([(1, 2), (1, 3), (2, 3)])
Notes
-----
This algorithm is probably simple enough to be well-known but I didn't find
a mention in the literature.
"""
if topo_order is None:
topo_order = list(topological_sort(G))
TC = G.copy()
# idea: traverse vertices following a reverse topological order, connecting
# each vertex to its descendants at distance 2 as we go
for v in reversed(topo_order):
TC.add_edges_from((v, u) for u in nx.descendants_at_distance(TC, v, 2))
return TC
| (G, source, *, backend=None, **backend_kwargs) | [
-0.032722052186727524,
0.021163780242204666,
-0.02473505772650242,
0.007943014614284039,
-0.036240555346012115,
-0.03105076588690281,
-0.018982309848070145,
-0.012622619979083538,
0.09309951961040497,
-0.07768848538398743,
0.012130030430853367,
0.02825355716049671,
0.0004870923876296729,
-0.011769384145736694,
-0.03159613162279129,
0.022412847727537155,
-0.0140036316588521,
-0.017328614369034767,
0.0031908401288092136,
0.029432255774736404,
0.0009450471843592823,
-0.06410707533359528,
0.013493448495864868,
-0.02392580173909664,
-0.01571889966726303,
0.016536951065063477,
-0.047042351216077805,
0.032123908400535583,
-0.06058857589960098,
-0.031314652413129807,
0.031156320124864578,
-0.04542383924126625,
-0.09056620299816132,
0.01345826406031847,
0.052671950310468674,
0.08099588006734848,
-0.0004252437502145767,
0.01810268498957157,
-0.017143893986940384,
-0.06041265279054642,
0.012200400233268738,
-0.018436942249536514,
-0.01149670034646988,
-0.03244057297706604,
0.0458812452852726,
0.01345826406031847,
-0.009192082099616528,
0.03807017579674721,
-0.037331290543079376,
-0.04947011545300484,
0.08634399622678757,
-0.03715536370873451,
-0.005783535074442625,
-0.010634667240083218,
0.015261495485901833,
0.03905535489320755,
0.019527677446603775,
0.059427469968795776,
0.06815335154533386,
-0.017803611233830452,
-0.009974948130548,
-0.0552404560148716,
-0.009068934246897697,
0.035501670092344284,
-0.0509478859603405,
0.02125174179673195,
-0.03680351376533508,
-0.06006080284714699,
-0.02114618755877018,
0.007336073089390993,
-0.013695762492716312,
0.02019619196653366,
0.005590017419308424,
-0.07606998085975647,
-0.027356339618563652,
-0.07635145634412766,
0.027936892583966255,
-0.04521273076534271,
-0.028570223599672318,
-0.03513222560286522,
-0.03439334034919739,
-0.06843483448028564,
0.023450804874300957,
-0.008272874169051647,
0.06129227578639984,
-0.027989670634269714,
0.03368964046239853,
-0.0014414855977520347,
-0.06769594550132751,
-0.04070904850959778,
0.00783306173980236,
-0.03432296961545944,
-0.03119150549173355,
0.032722052186727524,
0.037436842918395996,
-0.008875417523086071,
-0.0009587913518771529,
-0.04852012172341347,
0.01012448500841856,
0.009992540813982487,
0.03894979879260063,
0.007503202185034752,
-0.08535882085561752,
-0.006254134234040976,
0.023222101852297783,
-0.045353468507528305,
-0.017478151246905327,
0.016809634864330292,
-0.017337409779429436,
-0.0874699205160141,
-0.0024475567042827606,
-0.001305143698118627,
0.09788467735052109,
-0.03894979879260063,
0.03154335543513298,
0.013167987577617168,
0.007797876372933388,
0.0007004014914855361,
-0.00035075051710009575,
-0.005682378076016903,
0.014170760288834572,
0.02218414470553398,
0.001111076446250081,
0.01265780534595251,
-0.007274499628692865,
0.008057366125285625,
0.009315229952335358,
0.027637820690870285,
0.03437574952840805,
-0.010854573920369148,
0.06101079657673836,
-0.013722151517868042,
0.03332019969820976,
0.08169957995414734,
0.05168677121400833,
0.003749402007088065,
-0.032370202243328094,
0.015402235090732574,
-0.020284155383706093,
0.022764697670936584,
-0.010133281350135803,
-0.06139783188700676,
-0.021550815552473068,
0.04936455935239792,
0.049786780029535294,
0.003953914623707533,
-0.005801127292215824,
-0.013255950063467026,
0.011927716434001923,
0.01926378905773163,
0.00851037260144949,
0.0038505587726831436,
-0.014848071150481701,
0.032616499811410904,
0.00014486325380858034,
-0.007828663103282452,
-0.043664589524269104,
0.07241073995828629,
-0.053657129406929016,
0.012059659697115421,
-0.0312618762254715,
0.04725345969200134,
-0.04004053398966789,
0.024752650409936905,
0.016633709892630577,
-0.0018450135830789804,
0.11414015293121338,
0.006320106331259012,
-0.0314553938806057,
0.03140261396765709,
-0.056788597255945206,
-0.030769284814596176,
-0.007309684529900551,
-0.0049039097502827644,
-0.006152977701276541,
0.029924845322966576,
0.0038505587726831436,
0.030610952526330948,
-0.016079546883702278,
0.021867480129003525,
-0.016545748338103294,
0.0005662586772814393,
-0.045705318450927734,
0.02119896560907364,
0.0324229821562767,
0.031015580520033836,
0.0412016399204731,
-0.04011090472340584,
0.07698478549718857,
-0.020970262587070465,
-0.05506452918052673,
0.012701786123216152,
0.03785906359553337,
0.023310065269470215,
0.07522553950548172,
-0.05597934126853943,
-0.02996003068983555,
0.03715536370873451,
-0.04771086573600769,
0.07153110951185226,
0.06396633386611938,
0.015076774172484875,
0.07188296318054199,
0.03332019969820976,
0.023697100579738617,
0.08155883848667145,
0.03434056416153908,
-0.033056311309337616,
-0.023714693263173103,
0.008615927770733833,
-0.012974469922482967,
-0.025561904534697533,
0.010661056265234947,
-0.03997016325592995,
-0.05175714194774628,
0.03224705532193184,
-0.03824609890580177,
0.013502244837582111,
0.04809790104627609,
0.0018900943687185645,
-0.02637116052210331,
0.03712017834186554,
0.025614682585000992,
-0.016888801008462906,
0.070440374314785,
-0.07754775136709213,
-0.00043513954733498394,
0.011250404641032219,
0.020284155383706093,
-0.05949784070253372,
0.010977720841765404,
-0.007142555899918079,
0.03284519910812378,
-0.019721195101737976,
0.06196079030632973,
-0.04436828941106796,
-0.035149820148944855,
0.0032238259445875883,
0.01885916106402874,
0.01790916733443737,
-0.050666406750679016,
-0.006034228019416332,
-0.024611910805106163,
0.010590686462819576,
-0.017055930569767952,
-0.005202982574701309,
0.026599863544106483,
0.0060122376307845116,
0.032510943710803986,
0.026406345888972282,
-0.051229365170001984,
-0.035607222467660904,
-0.04862567409873009,
-0.029572995379567146,
-0.031015580520033836,
-0.01246428769081831,
-0.004105649888515472,
-0.056788597255945206,
-0.005409694276750088,
0.01731102168560028,
0.0003754899662453681,
0.017231855541467667,
-0.05766822025179863,
0.06931445747613907,
0.008849028497934341,
-0.029520217329263687,
0.03423500806093216,
-0.08184032142162323,
-0.06681632250547409,
-0.005568027030676603,
-0.016589729115366936,
0.003883544821292162,
0.04401643946766853,
0.0053613148629665375,
0.0037713926285505295,
-0.040920160710811615,
0.015525382943451405,
0.01602676883339882,
-0.0030325076077133417,
-0.029924845322966576,
-0.04183496907353401,
0.029273923486471176,
-0.03124428354203701,
-0.0231341402977705,
-0.06273486465215683,
-0.006421263329684734,
-0.011294386349618435,
-0.026898935437202454,
0.022078590467572212,
0.018524903804063797,
0.07656256854534149,
0.0026586668100208044,
0.07297369837760925,
0.024840611964464188,
0.06305152922868729,
0.035343337804079056,
0.02642393857240677,
-0.02547394298017025,
-0.0024365615099668503,
0.03298594057559967,
0.07360702753067017,
0.009543932043015957,
-0.01631704531610012,
-0.0518626943230629,
0.0017900370294228196,
0.004587244708091021,
0.009869393892586231,
-0.007995791733264923,
-0.02939707040786743,
0.04014609009027481,
-0.05168677121400833,
-0.049927521497011185,
-0.07040519267320633,
0.04507198929786682,
-0.06924408674240112,
-0.034164637327194214,
-0.032669275999069214,
-0.049329373985528946,
0.05446638539433479,
0.011742995120584965,
0.0023859830107539892,
0.015639733523130417,
-0.00848398357629776,
-0.006579595617949963,
-0.07656256854534149,
0.04683123901486397,
0.009658283554017544,
0.057844147086143494,
0.05854784697294235,
0.010194854810833931,
-0.005691174417734146,
0.0385979488492012,
0.005255760159343481,
0.05710526183247566,
-0.003030308522284031,
0.07079222798347473,
0.09661801904439926,
-0.029977623373270035,
0.015279088169336319,
-0.028183188289403915,
0.04556458070874214,
0.041870154440402985,
-0.02881651744246483,
0.009746246039867401,
-0.012349936179816723,
0.010036522522568703,
0.0030325076077133417,
-0.0014019025256857276,
0.037049807608127594,
-0.02288784459233284,
0.043171998113393784,
0.03810535743832588,
-0.01820823922753334,
0.02726837806403637,
-0.039231278002262115,
0.06572558730840683,
0.04911826550960541,
-0.00865551084280014,
0.014909645542502403,
0.027901707217097282,
0.0033777602948248386,
-0.0220961831510067,
0.01940452866256237,
-0.03627573698759079,
0.0552404560148716,
0.0032722053583711386,
-0.009024953469634056,
0.037436842918395996,
-0.02095266990363598,
-0.044509030878543854,
0.01701194979250431,
-0.011320775374770164,
0.04070904850959778,
0.009262451902031898,
-0.05129973590373993,
0.030470212921500206,
0.047781236469745636,
-0.05407935008406639,
0.0530238002538681,
0.03602944314479828,
-0.019985081627964973,
0.01761009357869625,
-0.008066162467002869,
0.03124428354203701,
0.020424894988536835,
0.015270291827619076,
0.04359421879053116,
0.00858074240386486,
0.023503582924604416,
-0.02781374566257,
-0.005638396833091974,
-0.02702208235859871,
0.04542383924126625,
-0.003953914623707533,
0.0003326082369312644,
-0.034305378794670105,
0.06611262261867523,
0.044614583253860474,
0.025790607556700706,
0.0029071609023958445,
-0.014584183692932129,
0.007670330815017223,
0.02199062705039978,
0.008941388688981533,
0.02367950789630413,
-0.03349612280726433,
0.012174011208117008,
0.036838699132204056,
0.06178486719727516,
0.048836786299943924,
-0.0037032216787338257,
0.006342096719890833,
0.032071132212877274,
-0.017152689397335052,
-0.020161006599664688,
-0.01970360241830349,
-0.07110889256000519,
0.0029599384870380163,
0.058688584715127945,
0.0023002196103334427,
0.0488719716668129,
0.029027627781033516,
0.0284646674990654,
-0.03902016952633858,
0.004644420463591814,
-0.034059084951877594,
0.031420208513736725,
0.039231278002262115,
-0.010397168807685375,
0.09197360277175903,
0.010705037042498589,
-0.032071132212877274,
0.013203172944486141,
-0.03330260515213013,
0.00006892687088111416,
0.02098785527050495,
0.014188352972269058,
0.00813213363289833,
0.04000534862279892,
0.0661478042602539,
-0.0076571363024413586,
0.0402868278324604,
-0.02528042532503605,
-0.060870055109262466,
-0.011971697211265564,
-0.029432255774736404,
0.009016157127916813,
0.0329507552087307,
0.04918863624334335,
-0.022272108122706413,
0.046268280595541,
0.04651457443833351,
-0.006702743005007505,
-0.011619847267866135,
-0.08507733792066574,
0.050033073872327805,
0.024611910805106163,
-0.005387703888118267,
-0.11864383518695831,
0.010168465785682201,
0.00858074240386486,
-0.03214149922132492,
0.05963858217000961,
-0.04528310149908066,
-0.01631704531610012,
-0.022166552022099495,
0.002638875273987651,
0.0009549430105835199,
-0.040920160710811615,
-0.03254612907767296,
0.05140529200434685,
-0.03277483209967613,
-0.05921636149287224,
-0.04398125410079956,
0.045001618564128876,
0.015191125683486462,
-0.05312935635447502,
0.03330260515213013,
0.05735155567526817,
-0.0333377905189991,
0.020688781514763832,
-0.029572995379567146,
0.0035053060855716467,
0.011136054061353207,
0.0026564677245914936,
0.0009477960411459208,
0.01532306894659996,
-0.020424894988536835,
0.011224016547203064,
-0.0004618031671270728,
0.001651496160775423,
-0.0229406226426363,
-0.005941867362707853,
-0.01147031132131815,
0.006192560773342848,
0.03894979879260063,
-0.015806863084435463,
-0.03601185232400894,
0.0094559695571661,
0.0062365420162677765,
-0.001593220978975296,
0.042116448283195496,
-0.018173053860664368,
0.021111002191901207,
-0.0009796824306249619,
-0.03620536997914314,
0.009508747607469559,
0.026300789788365364,
0.012728175148367882,
0.013994835317134857,
0.04109608381986618,
0.022817475721240044,
0.008809445425868034,
0.03404149040579796,
0.01012448500841856,
0.014786497689783573,
-0.023310065269470215,
0.004947890993207693,
0.024348022416234016,
-0.029520217329263687,
0.004156228620558977,
0.013132802210748196,
0.020688781514763832,
0.08043292164802551,
-0.011294386349618435,
-0.013000858947634697,
0.021410074084997177,
-0.03412945196032524,
-0.0069578345865011215,
-0.00297973002307117,
0.00040710149914957583,
0.03240538761019707,
-0.013924465514719486,
0.05728118494153023,
-0.0036680365446954966,
-0.052812691777944565,
-0.008000190369784832,
-0.02443598583340645,
-0.11611051112413406,
0.000672363443300128,
0.014047612436115742,
0.04827382415533066,
0.015947602689266205,
0.01323835738003254,
0.03916090726852417,
-0.010757815092802048,
0.04623309522867203,
-0.04088497534394264,
-0.02816559560596943,
-0.010889758355915546,
-0.07895515114068985,
0.031138727441430092,
-0.012710582464933395,
0.025333203375339508,
0.03631092235445976,
-0.03428778797388077,
-0.027004489675164223,
0.049786780029535294,
-0.021480444818735123,
0.010432353243231773,
-0.05728118494153023,
-0.009667079895734787,
-0.0659015104174614,
-0.05309417098760605,
0.014619369059801102,
0.006891862489283085,
0.05119417980313301,
-0.009060138836503029,
0.032123908400535583,
-0.0229406226426363,
0.013906872831285,
-0.0814884677529335,
0.01204206794500351,
-0.002123194979503751,
-0.020935077220201492,
0.050771959125995636,
-0.01243789866566658,
0.011857346631586552,
0.03722573444247246,
-0.06167931109666824,
-0.019826749339699745,
-0.03578314930200577,
0.0182610172778368,
0.03894979879260063,
0.007595562841743231,
-0.011391145177185535,
-0.0007410841644741595,
0.03434056416153908,
0.0021275931503623724,
-0.03940720483660698,
0.0182610172778368,
-0.04039238393306732,
0.019580453634262085,
0.006817094516009092,
-0.0017944352002814412,
-0.01563093811273575,
-0.010836981236934662,
0.06741447001695633,
-0.017231855541467667,
-0.023415619507431984,
-0.03866831958293915,
0.0054228887893259525,
0.028200780972838402,
0.016800839453935623,
-0.06942000985145569,
0.0019406728679314256,
0.008057366125285625,
-0.03740165755152702,
0.06942000985145569,
-0.03979424014687538,
-0.0021781716495752335,
0.017434168606996536,
-0.03662759065628052,
-0.044403474777936935,
-0.04904789477586746,
-0.01059948280453682,
-0.07508479803800583,
0.028922073543071747,
-0.07916625589132309,
0.00427937600761652,
0.018436942249536514,
-0.025685053318738937,
0.01487446017563343,
-0.033953528851270676,
-0.039125725626945496,
0.08078476786613464,
0.03367204964160919,
-0.04690160974860191,
0.002126493724063039,
0.05319972708821297,
-0.03235261142253876,
-0.020917484536767006,
-0.006280523259192705,
0.035941481590270996,
0.01582445576786995,
-0.07958848029375076,
0.0013590208254754543,
0.024295244365930557,
-0.018348978832364082,
-0.02786652371287346,
-0.10689204186201096,
0.0449664331972599,
-0.039477575570344925,
0.0008081555715762079,
-0.05084232985973358,
-0.02070637419819832,
0.00977263506501913,
-0.04640901833772659,
-0.005172195378690958,
-0.0428905189037323,
-0.013088821433484554,
0.01880638487637043,
0.03708499297499657,
0.004274977836757898,
0.01340548601001501,
0.06695706397294998,
0.04179978370666504,
-0.04472013935446739,
0.03458685800433159,
0.011514292098581791,
0.07825145125389099,
0.013607800006866455,
0.01850731112062931,
-0.019932305440306664,
-0.001981355482712388,
0.025702646002173424,
0.05010344460606575,
-0.06642928719520569,
-0.004846734460443258,
-0.04253866896033287,
-0.024471169337630272,
0.023116547614336014,
0.012728175148367882,
-0.027778560295701027,
-0.02248321659862995,
-0.005075437016785145,
0.037049807608127594,
0.029168367385864258,
0.012376325204968452,
-0.02990725263953209,
0.027356339618563652,
0.06449411064386368,
0.007129361387342215,
-0.045705318450927734,
-0.015041588805615902,
-0.014540202915668488,
-0.014021224342286587,
-0.03905535489320755,
0.06389596313238144,
-0.05319972708821297,
0.038492392748594284,
-0.002324409317225218,
0.007296490017324686,
-0.016440192237496376,
0.057879332453012466,
0.005651591345667839,
-0.0016613919287919998,
0.014601776376366615,
0.015947602689266205,
-0.019035087898373604,
-0.005172195378690958,
0.0023002196103334427,
0.03398871421813965,
0.036944255232810974,
-0.025702646002173424,
-0.005629600491374731,
-0.034305378794670105,
-0.0314553938806057,
0.00208251248113811,
0.01710870862007141,
-0.03458685800433159,
-0.03244057297706604,
-0.0060430243611335754,
0.01597399078309536,
0.01775963045656681,
-0.04911826550960541,
-0.04130719602108002,
0.006469642743468285,
-0.04429791867733002,
-0.0021968637593090534,
0.019017495214939117,
0.03249334916472435,
-0.05742192640900612,
0.02149803750216961,
0.024260060861706734,
0.05200343579053879,
0.022817475721240044,
-0.03595907241106033,
-0.031420208513736725,
-0.02925633080303669,
-0.011945309117436409,
0.048590488731861115,
0.02179710939526558,
0.007995791733264923,
-0.019985081627964973,
-0.003815373871475458,
-0.047781236469745636,
0.033619269728660583,
-0.04130719602108002,
0.032722052186727524,
-0.035061854869127274,
0.015498993918299675,
-0.054994162172079086,
0.021726740524172783,
-0.010203651152551174,
-0.01801472157239914,
-0.025614682585000992,
-0.0008636818965896964,
0.015270291827619076,
-0.018823977559804916,
0.004543263465166092,
0.006399272475391626,
0.004780762363225222,
-0.08402179181575775,
-0.018595274537801743,
-0.010168465785682201,
-0.057140447199344635,
-0.020460080355405807,
-0.062312640249729156,
-0.06104598194360733,
-0.0441923663020134,
-0.01300965528935194,
0.015367050655186176,
-0.02626560442149639,
0.05619044974446297,
0.014399462379515171,
0.034164637327194214,
0.04961085692048073
]
|
30,562 | networkx.algorithms.distance_measures | diameter | Returns the diameter of the graph G.
The diameter is the maximum eccentricity.
Parameters
----------
G : NetworkX graph
A graph
e : eccentricity dictionary, optional
A precomputed dictionary of eccentricities.
weight : string, function, or None
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number.
If this is None, every edge has weight/distance/cost 1.
Weights stored as floating point values can lead to small round-off
errors in distances. Use integer weights to avoid this.
Weights should be positive, since they are distances.
Returns
-------
d : integer
Diameter of graph
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> nx.diameter(G)
3
See Also
--------
eccentricity
| def effective_graph_resistance(G, weight=None, invert_weight=True):
"""Returns the Effective graph resistance of G.
Also known as the Kirchhoff index.
The effective graph resistance is defined as the sum
of the resistance distance of every node pair in G [1]_.
If weight is not provided, then a weight of 1 is used for all edges.
The effective graph resistance of a disconnected graph is infinite.
Parameters
----------
G : NetworkX graph
A graph
weight : string or None, optional (default=None)
The edge data key used to compute the effective graph resistance.
If None, then each edge has weight 1.
invert_weight : boolean (default=True)
Proper calculation of resistance distance requires building the
Laplacian matrix with the reciprocal of the weight. Not required
if the weight is already inverted. Weight cannot be zero.
Returns
-------
RG : float
The effective graph resistance of `G`.
Raises
------
NetworkXNotImplemented
If `G` is a directed graph.
NetworkXError
If `G` does not contain any nodes.
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> round(nx.effective_graph_resistance(G), 10)
10.25
Notes
-----
The implementation is based on Theorem 2.2 in [2]_. Self-loops are ignored.
Multi-edges are contracted in one edge with weight equal to the harmonic sum of the weights.
References
----------
.. [1] Wolfram
"Kirchhoff Index."
https://mathworld.wolfram.com/KirchhoffIndex.html
.. [2] W. Ellens, F. M. Spieksma, P. Van Mieghem, A. Jamakovic, R. E. Kooij.
Effective graph resistance.
Lin. Alg. Appl. 435:2491-2506, 2011.
"""
import numpy as np
if len(G) == 0:
raise nx.NetworkXError("Graph G must contain at least one node.")
# Disconnected graphs have infinite Effective graph resistance
if not nx.is_connected(G):
return float("inf")
# Invert weights
G = G.copy()
if invert_weight and weight is not None:
if G.is_multigraph():
for u, v, k, d in G.edges(keys=True, data=True):
d[weight] = 1 / d[weight]
else:
for u, v, d in G.edges(data=True):
d[weight] = 1 / d[weight]
# Get Laplacian eigenvalues
mu = np.sort(nx.laplacian_spectrum(G, weight=weight))
# Compute Effective graph resistance based on spectrum of the Laplacian
# Self-loops are ignored
return float(np.sum(1 / mu[1:]) * G.number_of_nodes())
| (G, e=None, usebounds=False, weight=None, *, backend=None, **backend_kwargs) | [
0.05050341412425041,
-0.01460190862417221,
0.002688575303182006,
0.05920565873384476,
0.05627957731485367,
-0.009362512268126011,
-0.03188289329409599,
-0.049477383494377136,
0.10077881813049316,
-0.008711744099855423,
0.03178789094090462,
-0.00025027262745425105,
0.015181425027549267,
-0.0045506274327635765,
-0.0597376711666584,
0.04510726407170296,
-0.057001594454050064,
0.0002977739495690912,
-0.005847413558512926,
0.046361297369003296,
0.0052963984198868275,
-0.10412291437387466,
-0.003640976967290044,
0.060573697090148926,
-0.027987783774733543,
0.007414957508444786,
0.020349569618701935,
0.013442876748740673,
-0.0035554745700210333,
0.0004773883556481451,
-0.006654936354607344,
-0.05027540773153305,
-0.02329465188086033,
-0.006521932780742645,
0.022876640781760216,
0.023807667195796967,
0.007091948762536049,
0.007742716930806637,
-0.09257058799266815,
-0.05354350060224533,
-0.011514321900904179,
0.033858947455883026,
0.03212989866733551,
-0.02663874626159668,
0.03323192894458771,
0.017765497788786888,
-0.003809606656432152,
0.018905529752373695,
-0.030400851741433144,
-0.03906509280204773,
0.025840723887085915,
-0.010934806428849697,
-0.046209294348955154,
0.009115505032241344,
0.0019618049263954163,
0.03342193737626076,
0.02604972943663597,
0.054113514721393585,
0.029184816405177116,
-0.07300004363059998,
0.011105811223387718,
-0.08056225627660751,
0.027702774852514267,
0.01686297170817852,
-0.06129571422934532,
0.014962919056415558,
-0.019684551283717155,
-0.00551015418022871,
0.008022974245250225,
0.01382288709282875,
-0.029108814895153046,
-0.0022598758805543184,
0.02608773112297058,
-0.06821191310882568,
0.018744025379419327,
0.026429740712046623,
0.023883668705821037,
-0.013243370689451694,
-0.026885753497481346,
-0.0140983946621418,
0.03176888823509216,
-0.01316736824810505,
0.046323295682668686,
-0.03650002181529999,
0.025441711768507957,
-0.0372980460524559,
0.01105831004679203,
-0.01658746413886547,
0.0259737279266119,
-0.031521882861852646,
-0.006773689761757851,
0.026030728593468666,
0.03380194678902626,
0.037450049072504044,
0.07322805374860764,
0.0010616547660902143,
-0.04989539831876755,
-0.07349405437707901,
0.07071997970342636,
-0.022059617564082146,
-0.013347873464226723,
0.08641441911458969,
-0.018098006024956703,
0.005229896400123835,
0.028690803796052933,
-0.046057287603616714,
-0.01536193024367094,
-0.03435296192765236,
0.05358149856328964,
-0.03119887411594391,
-0.05631757527589798,
0.021717607975006104,
0.016596965491771698,
-0.013699383474886417,
-0.03613901138305664,
0.04514526203274727,
-0.016872473061084747,
0.01526692695915699,
0.0593576617538929,
0.027664775028824806,
0.013148368336260319,
0.03220590204000473,
-0.017698995769023895,
-0.0010082157095894217,
0.010744800791144371,
0.021755609661340714,
0.009562017396092415,
0.0013478501932695508,
-0.011875332333147526,
0.022021615877747536,
0.049249377101659775,
0.00007481459761038423,
0.025213705375790596,
0.04848935827612877,
0.02737976610660553,
0.009842275641858578,
-0.007728466298431158,
0.037488050758838654,
0.06722388416528702,
0.020748581737279892,
-0.010421792045235634,
-0.02329465188086033,
0.023199649527668953,
0.051187433302402496,
0.03176888823509216,
0.008345983922481537,
0.017385486513376236,
0.03955910727381706,
0.039863117039203644,
-0.0028168288990855217,
0.026239734143018723,
-0.014012892730534077,
0.04389122873544693,
-0.010982307605445385,
0.009671270847320557,
0.017280984669923782,
-0.014345401898026466,
0.013860887847840786,
-0.0404331311583519,
-0.03480897471308708,
-0.07429207861423492,
-0.030704859644174576,
0.04016712307929993,
-0.021793609485030174,
0.013860887847840786,
-0.02726576291024685,
0.049515385180711746,
0.015599437057971954,
-0.0649058148264885,
0.028253791853785515,
-0.04510726407170296,
-0.05164344608783722,
-0.03399195149540901,
-0.03872308507561684,
0.03045785240828991,
0.08542639017105103,
0.026619745418429375,
-0.014620909467339516,
0.012160340324044228,
0.0235606599599123,
-0.014962919056415558,
-0.058711644262075424,
-0.0018086131894961,
-0.021508602425456047,
0.028918810188770294,
0.04503126069903374,
0.03461897000670433,
-0.004811884835362434,
0.004662255756556988,
0.00047798213199712336,
0.008203479461371899,
-0.041497163474559784,
0.02538471110165119,
0.0289378110319376,
0.02905181422829628,
-0.014924918301403522,
0.03585400432348251,
0.018354514613747597,
-0.034789975732564926,
0.07056797295808792,
0.029070813208818436,
-0.0009963404154404998,
0.03735504671931267,
0.032034896314144135,
0.005581406410783529,
0.011305316351354122,
-0.00924850907176733,
-0.02901381254196167,
-0.008236730471253395,
0.009984779171645641,
-0.0667678713798523,
0.00509214261546731,
0.0056099072098731995,
-0.03496097773313522,
-0.024244679138064384,
0.02998283877968788,
-0.02648674137890339,
0.008925500325858593,
0.01370888389647007,
-0.06406979262828827,
-0.05475953221321106,
-0.010060781612992287,
-0.009842275641858578,
-0.013072365894913673,
0.044537246227264404,
-0.049287378787994385,
0.022382626309990883,
0.000094705777883064,
0.01421239785850048,
0.007096698507666588,
0.0545315258204937,
0.0031350876670330763,
0.0790422111749649,
-0.051263436675071716,
0.014316900633275509,
-0.021128591150045395,
-0.05981367453932762,
0.07250603288412094,
0.052441466599702835,
0.0411931537091732,
-0.03570200130343437,
-0.06281575560569763,
-0.04282720014452934,
0.058901648968458176,
-0.036310017108917236,
-0.037013035267591476,
0.013851387426257133,
0.001788425026461482,
0.028519798070192337,
0.009001501835882664,
-0.0879344642162323,
-0.06794590502977371,
-0.014050893485546112,
-0.023199649527668953,
0.02760777249932289,
-0.01100130844861269,
-0.08519838750362396,
0.016558963805437088,
-0.018098006024956703,
-0.027322765439748764,
0.014535406604409218,
-0.008360234089195728,
-0.07227802276611328,
-0.004586253315210342,
-0.04829935356974602,
0.010089282877743244,
0.0004114802577532828,
0.010250787250697613,
-0.025517715141177177,
0.05076942220330238,
0.04499325901269913,
0.010345789603888988,
0.013613881543278694,
-0.00948126520961523,
-0.004897387232631445,
0.02014056406915188,
0.02118559367954731,
0.044613249599933624,
-0.005115893203765154,
0.036348018795251846,
-0.08443836122751236,
0.0016031698323786259,
-0.007661964278668165,
0.024472685530781746,
-0.057001594454050064,
0.017394987866282463,
-0.009239008650183678,
-0.0563935786485672,
0.023161647841334343,
-0.00903475284576416,
0.09249459207057953,
0.007742716930806637,
0.0035958506632596254,
0.003405845258384943,
0.07376006245613098,
0.01045979280024767,
-0.013908389024436474,
-0.04829935356974602,
0.016340456902980804,
0.06957995146512985,
0.043169207870960236,
-0.024358682334423065,
0.004624254535883665,
-0.049287378787994385,
0.055557556450366974,
0.04073714092373848,
0.03484697639942169,
-0.0001445821690140292,
0.017261983826756477,
0.05783762037754059,
-0.09614269435405731,
0.004944888409227133,
-0.043093208223581314,
0.022800637409090996,
-0.052555471658706665,
-0.029659830033779144,
0.05004740133881569,
-0.027284763753414154,
0.02010256238281727,
0.025631718337535858,
0.016074450686573982,
0.09705471992492676,
0.014440404251217842,
0.0387800857424736,
-0.07117599248886108,
-0.002365566324442625,
0.019912557676434517,
0.07820618897676468,
0.07942222058773041,
-0.049439385533332825,
-0.04282720014452934,
0.01838301494717598,
-0.010288788005709648,
0.0047335075214505196,
-0.041459161788225174,
0.04225718230009079,
0.10951906442642212,
-0.033858947455883026,
-0.027911782264709473,
-0.029507827013731003,
0.027778778225183487,
0.004241868853569031,
-0.005367650184780359,
-0.0026671995874494314,
-0.00512064341455698,
0.019333040341734886,
0.01705297827720642,
-0.027398766949772835,
-0.03480897471308708,
-0.05308748781681061,
-0.012882360257208347,
0.003909359220415354,
-0.031958892941474915,
0.02682875096797943,
-0.016767969354987144,
0.04556327685713768,
-0.01172332838177681,
-0.047995343804359436,
0.02196461521089077,
0.02375066466629505,
-0.10359089821577072,
0.006384178530424833,
-0.028633801266551018,
-0.019418543204665184,
-0.006906693335622549,
0.012122339569032192,
-0.01643545925617218,
0.017204981297254562,
0.018259510397911072,
-0.04096514731645584,
-0.002365566324442625,
-0.0820062980055809,
-0.07737016677856445,
0.004840385634452105,
0.010915805585682392,
0.037564050406217575,
-0.03399195149540901,
-0.0211475919932127,
-0.01573244109749794,
-0.006379428785294294,
0.009144006296992302,
0.019333040341734886,
-0.044499244540929794,
0.011153312399983406,
0.044765252619981766,
-0.012720855884253979,
0.04894537106156349,
0.004039987921714783,
0.02422567829489708,
-0.0032609663903713226,
-0.04183917120099068,
-0.027550771832466125,
0.06764189153909683,
-0.010830303654074669,
-0.04343521595001221,
0.03477097302675247,
0.061789728701114655,
0.02831079252064228,
-0.04582928121089935,
-0.01421239785850048,
-0.046095289289951324,
-0.007799718528985977,
-0.02141360007226467,
0.008630991913378239,
-0.02667674608528614,
0.015048420988023281,
0.0076667144894599915,
0.04351121932268143,
0.044651251286268234,
0.01441190391778946,
-0.049591388553380966,
0.015675438567996025,
0.013509377837181091,
0.004265619441866875,
-0.01970355212688446,
-0.020121563225984573,
-0.013138867914676666,
0.0023465657141059637,
0.03695603460073471,
0.029925838112831116,
0.02137559838593006,
-0.029659830033779144,
0.07512810081243515,
-0.005980417598038912,
0.022648634389042854,
-0.04670330882072449,
0.00008602193702245131,
-0.020026560872793198,
-0.06646385788917542,
0.054075513035058975,
-0.023826666176319122,
0.0016684841830283403,
0.018924530595541,
-0.031293876469135284,
0.00020692766702268273,
-0.002209999365732074,
0.018003003671765327,
0.01760399341583252,
-0.02010256238281727,
-0.03731704503297806,
0.04016712307929993,
0.01222684234380722,
0.027759777382016182,
-0.04818534851074219,
-0.003346468787640333,
-0.06281575560569763,
-0.006930443923920393,
-0.000914400618057698,
-0.005267897620797157,
-0.03165488690137863,
0.0054911538027226925,
-0.04434724152088165,
0.026695746928453445,
0.028804806992411613,
-0.11704327911138535,
0.029184816405177116,
-0.03714603930711746,
-0.013993891887366772,
-0.06809790432453156,
0.025593716651201248,
0.016216954216361046,
0.03157888352870941,
-0.009096505120396614,
-0.02998283877968788,
-0.01958954893052578,
-0.032927922904491425,
0.007818718440830708,
-0.015570935793220997,
-0.027170760557055473,
-0.021166592836380005,
0.04902137070894241,
-0.020159564912319183,
-0.020007560029625893,
-0.043245211243629456,
0.05650758370757103,
0.012549851089715958,
-0.0912785530090332,
-0.011875332333147526,
0.006227424368262291,
-0.04419523850083351,
-0.020083561539649963,
0.02017856575548649,
0.055633556097745895,
0.023902669548988342,
0.02088158391416073,
-0.0393311008810997,
-0.003954485524445772,
-0.005776161793619394,
0.019855555146932602,
-0.04187717288732529,
-0.015570935793220997,
0.03165488690137863,
0.025631718337535858,
0.012074838392436504,
0.0006828316254541278,
-0.004695506300777197,
0.01228384394198656,
0.0046266294084489346,
0.032775916159152985,
0.014383402653038502,
-0.026410739868879318,
-0.031445879489183426,
-0.015371430665254593,
0.04848935827612877,
0.036937035620212555,
0.03165488690137863,
-0.03860908001661301,
0.007714216131716967,
0.08960650861263275,
0.035340990871191025,
-0.014050893485546112,
0.019143035635352135,
0.07414007931947708,
0.0475013293325901,
0.011846831999719143,
-0.026239734143018723,
-0.036519020795822144,
0.05434152111411095,
0.06524782627820969,
-0.02846279740333557,
-0.01884852722287178,
0.02422567829489708,
0.0005765474052168429,
-0.0018810526235029101,
-0.01678697019815445,
0.008992001414299011,
-0.004419998731464148,
-0.07748416811227798,
-0.0021779360249638557,
-0.015352429822087288,
-0.014383402653038502,
0.019969558343291283,
-0.019447043538093567,
0.0471213199198246,
-0.00040999584598466754,
-0.007799718528985977,
-0.01864902302622795,
-0.04202917590737343,
-0.10222285985946655,
-0.011846831999719143,
-0.015494933351874352,
0.0030353348702192307,
0.014677911065518856,
0.011305316351354122,
0.08246231079101562,
0.020387571305036545,
0.0012374096550047398,
0.002453443594276905,
-0.022496629506349564,
-0.07071997970342636,
-0.044841255992650986,
0.02831079252064228,
-0.020824583247303963,
-0.033858947455883026,
0.061941735446453094,
0.03680403158068657,
-0.05016140267252922,
0.004477000329643488,
0.025422710925340652,
-0.017632493749260902,
-0.016596965491771698,
-0.08732644468545914,
-0.01810750737786293,
-0.06292976438999176,
0.006445930339396,
-0.04039512947201729,
0.032376907765865326,
-0.024985698983073235,
-0.04503126069903374,
0.033934950828552246,
-0.03176888823509216,
0.03245290741324425,
0.07835819572210312,
0.004446124657988548,
-0.0065314327366650105,
-0.01331937313079834,
0.025289708748459816,
-0.06315776705741882,
0.035150982439517975,
-0.06353777647018433,
-0.012711355462670326,
-0.06106770783662796,
0.016368959099054337,
0.04123115539550781,
0.017157480120658875,
0.041649166494607925,
-0.016767969354987144,
0.05346749722957611,
-0.03855207934975624,
-0.01460190862417221,
-0.02433968149125576,
-0.057343605905771255,
0.03828607127070427,
0.0035174735821783543,
-0.0019499296322464943,
-0.03349793702363968,
-0.022059617564082146,
0.008003974333405495,
0.04598128795623779,
0.003222965169698,
-0.05206145718693733,
-0.009357761591672897,
0.01951354555785656,
-0.006944694556295872,
-0.0437772274017334,
0.049477383494377136,
0.005267897620797157,
-0.07033997029066086,
0.036196012049913406,
-0.05323949083685875,
0.0015497308922931552,
-0.02430167980492115,
-0.016188453882932663,
-0.0006103920750319958,
-0.0034319711849093437,
0.012720855884253979,
-0.0022812513634562492,
0.016530463472008705,
-0.04233318567276001,
0.01760399341583252,
-0.004800009541213512,
-0.004712131805717945,
0.03781105950474739,
-0.032775916159152985,
-0.018554018810391426,
0.057001594454050064,
0.040015120059251785,
0.005989917553961277,
-0.03323192894458771,
0.04183917120099068,
-0.00209362106397748,
-0.04214318096637726,
-0.009842275641858578,
0.04225718230009079,
0.0317118875682354,
-0.07128999382257462,
0.04024312645196915,
-0.01748999021947384,
-0.020121563225984573,
0.041687168180942535,
-0.03570200130343437,
0.07596412301063538,
-0.057381607592105865,
-0.0005976260872557759,
-0.06391778588294983,
0.019304540008306503,
0.0489833727478981,
-0.017157480120658875,
-0.005168144591152668,
-0.00566690880805254,
-0.020026560872793198,
0.03184489160776138,
0.03344093635678291,
-0.01790800131857395,
-0.008554989472031593,
0.03594900667667389,
0.026524743065238,
-0.024719692766666412,
0.009571517817676067,
-0.05137743800878525,
0.0011893145274370909,
0.036272015422582626,
0.03332693129777908,
0.011761329136788845,
0.024016672745347023,
0.016986476257443428,
0.033079925924539566,
-0.03625301644206047,
-0.002664824714884162,
-0.06247374787926674,
-0.019760552793741226,
-0.012293344363570213,
0.02293364144861698,
0.031293876469135284,
-0.06874392181634903,
0.0230096448212862,
-0.0032300904858857393,
0.03792506083846092,
-0.0005946572637185454,
-0.02088158391416073,
0.004719256889075041,
0.06726188212633133,
-0.025536714121699333,
-0.004386747721582651,
0.01751849055290222,
-0.02133759669959545,
-0.030704859644174576,
-0.02103358879685402,
0.029260819777846336,
-0.0048878868110477924,
-0.03967311233282089,
-0.04278919845819473,
0.020748581737279892,
-0.0009155881125479937,
0.0578756220638752,
-0.04016712307929993,
-0.04985739663243294,
0.0482233501970768,
0.07030196487903595,
-0.05924366042017937,
0.0790422111749649,
0.025422710925340652,
-0.01662546582520008,
0.02675274945795536,
-0.023959670215845108,
-0.025802722200751305,
-0.07611612975597382,
-0.011248314753174782,
-0.04560127481818199,
0.033972952514886856,
-0.011998835951089859,
-0.023997671902179718,
0.01838301494717598,
-0.004146866034716368,
0.039939116686582565,
0.023845667019486427,
-0.0036481020506471395,
-0.030913865193724632,
-0.04366322234272957,
-0.006303426343947649,
-0.018202509731054306,
-0.00931026041507721,
0.012739856727421284,
0.030400851741433144,
-0.032034896314144135,
0.012122339569032192,
0.07262003421783447,
-0.044651251286268234,
0.006797440350055695,
0.047805339097976685,
-0.02722776308655739,
0.004241868853569031,
0.015599437057971954,
0.03699403628706932,
0.022762637585401535,
0.020786581560969353,
-0.0058426633477211,
0.02831079252064228,
0.03750704973936081,
0.05206145718693733,
0.02593572624027729,
0.041611164808273315,
-0.04753933101892471,
-0.03245290741324425,
0.0013027240056544542,
-0.0070491973310709,
-0.04020512476563454,
0.02329465188086033,
0.019295040518045425,
-0.023028643801808357,
0.05080742388963699,
-0.004740632604807615,
0.03169288858771324,
-0.008863748051226139,
0.05760961398482323,
-0.007851969450712204,
-0.015665939077734947,
-0.05175744742155075,
-0.002624448388814926,
-0.005343899596482515,
-0.0039117345586419106,
-0.06650186330080032,
-0.05175744742155075,
0.014183897525072098,
-0.02924181893467903,
0.008787745609879494,
0.006578934378921986,
0.05460752919316292
]
|
30,563 | networkx.generators.small | diamond_graph |
Returns the Diamond graph
The Diamond Graph is planar undirected graph with 4 nodes and 5 edges.
It is also sometimes known as the double triangle graph or kite graph [1]_.
Parameters
----------
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : networkx Graph
Diamond Graph with 4 nodes and 5 edges
References
----------
.. [1] https://mathworld.wolfram.com/DiamondGraph.html
| def _raise_on_directed(func):
"""
A decorator which inspects the `create_using` argument and raises a
NetworkX exception when `create_using` is a DiGraph (class or instance) for
graph generators that do not support directed outputs.
"""
@wraps(func)
def wrapper(*args, **kwargs):
if kwargs.get("create_using") is not None:
G = nx.empty_graph(create_using=kwargs["create_using"])
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
return func(*args, **kwargs)
return wrapper
| (create_using=None, *, backend=None, **backend_kwargs) | [
0.020483320578932762,
-0.0038506854325532913,
0.036476410925388336,
0.005219221580773592,
0.00022277847165241838,
0.03903459012508392,
-0.060108259320259094,
-0.017835695296525955,
0.08028745651245117,
-0.03695942461490631,
0.019213175401091576,
0.010840953327715397,
0.044186726212501526,
-0.026780376210808754,
0.01099301315844059,
0.04511697217822075,
-0.04880218207836151,
0.09402649104595184,
0.023381397128105164,
0.0473710335791111,
-0.009221966378390789,
-0.03180728852748871,
-0.0026319725438952446,
-0.019892971962690353,
0.000732904823962599,
0.043542709201574326,
-0.025224002078175545,
0.0010124261025339365,
0.006158412899821997,
0.02368551678955555,
-0.03429390862584114,
-0.046798571944236755,
0.0008978223777376115,
0.06558240205049515,
0.046297669410705566,
0.06279166042804718,
-0.046655457466840744,
0.08100303262472153,
-0.10204092413187027,
-0.07348950207233429,
-0.03125271573662758,
0.007714787498116493,
0.032057736068964005,
0.011377634480595589,
-0.0013349936343729496,
-0.02001819759607315,
0.009749703109264374,
0.00016310067439917475,
-0.08937525749206543,
-0.04207577928900719,
0.022379592061042786,
0.005585953593254089,
0.05513501539826393,
0.06146784871816635,
0.01235260535031557,
0.04039417952299118,
-0.009731813333928585,
0.028980767354369164,
0.03942815586924553,
-0.016252486035227776,
0.0049687703140079975,
0.051020462065935135,
0.012477830052375793,
-0.02415063977241516,
-0.03291642665863037,
0.0007239601691253483,
-0.07821229100227356,
-0.026655150577425957,
-0.02198602631688118,
0.054562557488679886,
0.011690698564052582,
-0.005814042873680592,
0.017164843156933784,
0.009490306489169598,
0.07223724573850632,
-0.03060869872570038,
0.019839303568005562,
-0.010223770514130592,
0.04833705723285675,
-0.02359606884419918,
-0.03599339723587036,
-0.01873016357421875,
-0.02239748276770115,
0.007003685459494591,
0.06196875125169754,
-0.02189658023416996,
-0.05127091333270073,
0.026422588154673576,
0.030089907348155975,
-0.04440139979124069,
-0.005670927930623293,
-0.03531360253691673,
-0.017406350001692772,
0.0052147493697702885,
-0.0321829617023468,
0.05967891216278076,
0.029589006677269936,
-0.05266628414392471,
0.06404391676187515,
-0.011833813041448593,
0.0017855820478871465,
0.00827830284833908,
-0.019123729318380356,
0.03345310688018799,
-0.01624354161322117,
-0.097318135201931,
0.009857038967311382,
-0.02805052138864994,
-0.01960674114525318,
-0.023381397128105164,
-0.08286352455615997,
-0.018300818279385567,
0.0499471016228199,
0.0009302468388341367,
0.01737951673567295,
-0.0011315022129565477,
-0.010053821839392185,
-0.01858704723417759,
0.0018660841742530465,
-0.03636907413601875,
-0.021699797362089157,
0.029070213437080383,
-0.05656616389751434,
-0.05109202116727829,
0.05642304942011833,
-0.02391807734966278,
-0.0004969888832420111,
-0.016610274091362953,
0.04229045286774635,
0.015232792124152184,
0.01864071562886238,
0.047299474477767944,
-0.029857346788048744,
0.037066757678985596,
0.004389602225273848,
0.036476410925388336,
-0.053918540477752686,
0.05266628414392471,
-0.014150486327707767,
0.0027012936770915985,
-0.0029204385355114937,
-0.01890905573964119,
0.02796107344329357,
0.042576681822538376,
0.01390897948294878,
0.04171799495816231,
-0.055707477033138275,
-0.022737380117177963,
0.024311643093824387,
-0.028479864820837975,
0.05917801335453987,
0.005702234338968992,
0.009011766873300076,
0.0168607234954834,
-0.04314914345741272,
0.03432968631386757,
-0.03318476676940918,
0.025492342188954353,
0.021324120461940765,
0.01434726919978857,
-0.03159261494874954,
-0.022844716906547546,
0.04232623055577278,
0.02327406033873558,
0.015617413446307182,
-0.02221858873963356,
0.009946485981345177,
-0.02001819759607315,
0.007880263961851597,
-0.004291210789233446,
-0.045331645756959915,
-0.022325925529003143,
-0.0057469578459858894,
-0.039356596767902374,
-0.02878398448228836,
0.03025091253221035,
0.037388768047094345,
0.0426124632358551,
-0.03352466598153114,
0.01606464758515358,
0.054419443011283875,
-0.04407938942313194,
-0.01951729506254196,
-0.028354639187455177,
0.041288647800683975,
0.018712272867560387,
0.009910707361996174,
-0.02529555931687355,
0.0033005874138325453,
0.00040390825597569346,
0.01758524402976036,
0.017406350001692772,
0.03250497207045555,
0.04976820573210716,
0.03796122595667839,
-0.09266690164804459,
-0.009356136433780193,
-0.0014848171267658472,
-0.016950171440839767,
0.07463441789150238,
0.05270206183195114,
0.032147184014320374,
0.03602917492389679,
0.014052093960344791,
-0.004874851554632187,
0.047263696789741516,
-0.02520611137151718,
-0.0518791526556015,
-0.052165381610393524,
-0.010384774766862392,
-0.038855694234371185,
-0.03425813093781471,
0.0350094810128212,
0.051521364599466324,
-0.034454911947250366,
0.023166725412011147,
0.021503014490008354,
0.05399009585380554,
-0.010277438908815384,
-0.027245499193668365,
-0.012012707069516182,
-0.018273983150720596,
-0.00801890715956688,
-0.020447541028261185,
0.0626843273639679,
-0.0413244292140007,
0.00816202163696289,
-0.0525231696665287,
0.025635456666350365,
-0.01788041740655899,
0.04103819653391838,
-0.015867864713072777,
0.0168607234954834,
0.02280893735587597,
0.038998812437057495,
-0.04769304022192955,
0.019678298383951187,
-0.04508119449019432,
0.010223770514130592,
0.013595915399491787,
-0.061897195875644684,
-0.0011410058941692114,
0.004441034514456987,
-0.0005461846012622118,
0.08272041380405426,
0.029589006677269936,
-0.009651310741901398,
0.04883795976638794,
0.0059079620987176895,
-0.041610658168792725,
-0.04207577928900719,
-0.011449191719293594,
-0.0037366405595093966,
-0.023667626082897186,
0.008421417325735092,
-0.028748204931616783,
-0.059929363429546356,
-0.058784447610378265,
0.03921348229050636,
0.006967906840145588,
-0.03635118529200554,
0.058319322764873505,
-0.05674505978822708,
0.02034020610153675,
0.004539425950497389,
-0.03345310688018799,
-0.02533133700489998,
0.022182809188961983,
-0.03409712389111519,
0.025080885738134384,
-0.022343814373016357,
0.04089508205652237,
0.07391884922981262,
-0.024132750928401947,
0.00655197910964489,
0.020089754834771156,
-0.020071864128112793,
0.011681754142045975,
-0.013363353908061981,
0.034955814480781555,
-0.04622611403465271,
-0.01664605177938938,
-0.05209382250905037,
0.036476410925388336,
-0.07499220967292786,
0.031789395958185196,
0.00980337057262659,
0.01276405993849039,
0.011440247297286987,
-0.01191431563347578,
0.030501363798975945,
0.011985872872173786,
0.0347590334713459,
0.032021958380937576,
-0.04772881790995598,
0.0033386023715138435,
0.026959270238876343,
-0.04204000160098076,
0.033846672624349594,
0.0323081873357296,
0.02928488701581955,
-0.037531882524490356,
-0.008475085720419884,
0.01835448667407036,
0.008689758367836475,
0.0037947811651974916,
0.03468747437000275,
-0.028014741837978363,
0.004673596005886793,
-0.015277516096830368,
-0.06547506898641586,
0.03517048805952072,
-0.015510077588260174,
0.01914161816239357,
0.035689279437065125,
0.02465154230594635,
-0.011842758394777775,
-0.037853892892599106,
0.033810894936323166,
0.06944650411605835,
-0.03572505712509155,
0.10561879724264145,
-0.06737133860588074,
0.001358473440632224,
-0.08307819813489914,
0.048265501856803894,
0.061074282974004745,
0.03864102438092232,
0.056387271732091904,
0.09001927077770233,
0.002117653377354145,
-0.02846197597682476,
-0.007634285371750593,
-0.018220316618680954,
-0.08722852915525436,
0.027835847809910774,
0.0693749487400055,
-0.04887373745441437,
0.0553496889770031,
-0.01762102171778679,
0.008653978817164898,
0.003839504439383745,
-0.008770260028541088,
0.0017911724280565977,
-0.006730872672051191,
0.032612308859825134,
0.008989404886960983,
-0.02368551678955555,
0.023578180000185966,
0.04490229859948158,
-0.01014326885342598,
0.11027003079652786,
-0.02130623161792755,
0.009839149191975594,
0.040644630789756775,
0.014642443507909775,
-0.02468731999397278,
0.0337214469909668,
-0.02726338803768158,
-0.0052147493697702885,
-0.036565858870744705,
-0.04100241884589195,
0.05746063217520714,
0.013944758102297783,
0.061718299984931946,
-0.01213793270289898,
0.03207562863826752,
0.013077124021947384,
0.04572521150112152,
-0.0534176379442215,
-0.032826978713274,
-0.06984007358551025,
-0.035689279437065125,
-0.000053912670409772545,
0.018282929435372353,
0.009919651784002781,
-0.012325771152973175,
-0.014239932410418987,
0.03731720894575119,
0.06898137927055359,
-0.03654796630144119,
0.011645975522696972,
0.04586832597851753,
-0.005053745117038488,
0.05713862553238869,
-0.04282713308930397,
0.053632307797670364,
0.08436623215675354,
-0.017477907240390778,
-0.03735299035906792,
-0.009052017703652382,
-0.04035840183496475,
0.029177550226449966,
0.031789395958185196,
-0.033256325870752335,
-0.033488888293504715,
0.01466927770525217,
0.00010020838089985773,
-0.02767484448850155,
0.0036695555318146944,
-0.03388245403766632,
-0.008099408820271492,
-0.01661921851336956,
0.02864087000489235,
0.02708449587225914,
0.022003917023539543,
-0.008461668156087399,
0.015876809135079384,
0.039177704602479935,
-0.007415140978991985,
0.04186110943555832,
-0.013327575288712978,
-0.04103819653391838,
0.007692425977438688,
0.049732428044080734,
0.02992890402674675,
0.009069906547665596,
0.036565858870744705,
0.024043302983045578,
-0.03468747437000275,
0.07184368371963501,
-0.04107397794723511,
0.07699581980705261,
0.038855694234371185,
0.042397789657115936,
-0.039642829447984695,
-0.03136005252599716,
0.007401723880320787,
-0.04619033262133598,
0.029320664703845978,
0.018622826784849167,
-0.04966086894273758,
0.030912818387150764,
-0.05220115929841995,
0.025689125061035156,
-0.013256018050014973,
-0.015366962179541588,
0.014454605057835579,
0.003269281005486846,
0.057997312396764755,
0.022111251950263977,
-0.007777400314807892,
-0.004897213075309992,
-0.017182732000947,
-0.01978563517332077,
-0.03635118529200554,
0.02093055471777916,
0.023166725412011147,
0.0012332479236647487,
-0.022325925529003143,
0.068730928003788,
-0.0003916093264706433,
0.081360824406147,
0.02336350828409195,
-0.14046727120876312,
-0.010814120061695576,
-0.009101212956011295,
-0.03019724413752556,
-0.02459787391126156,
0.055707477033138275,
0.01186959259212017,
-0.008390110917389393,
-0.10411608964204788,
-0.02418641746044159,
-0.03212929517030716,
0.04042996093630791,
-0.010035932064056396,
0.014642443507909775,
-0.024114860221743584,
0.0016704192385077477,
0.0684804767370224,
-0.041574880480766296,
-0.005456255748867989,
-0.028569312766194344,
0.0052952514961361885,
-0.013434911146759987,
-0.01579630747437477,
-0.0025402894243597984,
0.03547460585832596,
0.013667472638189793,
0.0020483320113271475,
-0.0175047405064106,
0.026100579649209976,
0.011225574649870396,
-0.029320664703845978,
0.004821183159947395,
-0.015107566490769386,
-0.013873200863599777,
0.002884659683331847,
0.06511727720499039,
-0.050555337220430374,
-0.0400363951921463,
0.017200622707605362,
-0.065403513610363,
0.03588606044650078,
0.028766095638275146,
-0.043864715844392776,
-0.018926946446299553,
-0.016467157751321793,
-0.07642335444688797,
0.01588575355708599,
-0.02318461425602436,
-0.04035840183496475,
-0.0047630430199205875,
0.04121709242463112,
-0.031646281480789185,
-0.01729901321232319,
0.014123652130365372,
0.006802430376410484,
-0.015599524602293968,
0.00671298336237669,
0.06443748623132706,
0.04919574782252312,
0.0812177062034607,
0.025957465171813965,
0.011082460172474384,
-0.027746401727199554,
-0.018282929435372353,
0.016368767246603966,
-0.039678607136011124,
0.052344273775815964,
0.0342402383685112,
0.0005338856717571616,
-0.010438443161547184,
-0.004060885403305292,
0.013497523963451385,
0.0426124632358551,
-0.002730363979935646,
0.031968291848897934,
0.017656801268458366,
0.010724673047661781,
0.04458029195666313,
0.016780221834778786,
0.052165381610393524,
-0.011681754142045975,
-0.005174498073756695,
-0.005939268507063389,
0.04898107424378395,
-0.08350754529237747,
-0.015841031447052956,
0.011350800283253193,
-0.012128988280892372,
-0.04318492114543915,
-0.02869453839957714,
0.018390264362096786,
-0.026834044605493546,
0.01755840890109539,
0.008908902294933796,
0.0038372683338820934,
-0.0493030846118927,
-0.036476410925388336,
0.004246487282216549,
-0.0004930755821987987,
-0.0050403280183672905,
0.06644109636545181,
0.008698702789843082,
-0.015411686152219772,
0.061718299984931946,
0.018712272867560387,
0.014660332351922989,
-0.06118161976337433,
0.0028667703736573458,
-0.0037634747568517923,
-0.03942815586924553,
0.03978594392538071,
-0.01770152524113655,
0.04754992574453354,
-0.02171768620610237,
-0.02350662276148796,
-0.009168297983705997,
-0.045510537922382355,
-0.04919574782252312,
0.010018043220043182,
-0.02579646185040474,
-0.020000306889414787,
0.024723099544644356,
-0.0030501363798975945,
-0.03425813093781471,
0.012951898388564587,
-0.06529617309570312,
-0.05159292370080948,
-0.020161312073469162,
-0.030966486781835556,
0.01858704723417759,
0.013479635119438171,
-0.024526316672563553,
0.0010101899970322847,
-0.011484971269965172,
-0.027066605165600777,
-0.026082690805196762,
-0.05463411286473274,
-0.06254120916128159,
0.02184291183948517,
-0.05567169561982155,
0.013569081202149391,
0.011842758394777775,
0.000901176652405411,
-0.016744444146752357,
0.0499471016228199,
-0.022379592061042786,
-0.0706629827618599,
0.06336412578821182,
0.018748052418231964,
0.023703405633568764,
0.051485586911439896,
-0.002446370432153344,
-0.029159661382436752,
-0.061396293342113495,
-0.017021728679537773,
-0.0736326202750206,
-0.06858781725168228,
0.05030488967895508,
-0.01794303022325039,
-0.016046758741140366,
0.008345387876033783,
-0.0439004972577095,
-0.05356075242161751,
0.03266597539186478,
0.005536757875233889,
0.021789243444800377,
0.03157472610473633,
-0.041753772646188736,
-0.050197552889585495,
-0.021181005984544754,
-0.020161312073469162,
0.057818420231342316,
0.00982126034796238,
-0.04025106504559517,
-0.007777400314807892,
0.04568943381309509,
-0.018891166895627975,
-0.010957234539091587,
0.023846520110964775,
0.0028377000708132982,
-0.032111406326293945,
-0.06737133860588074,
0.034079235047101974,
0.025724902749061584,
0.024293754249811172,
-0.004065357614308596,
-0.07191523909568787,
0.004628872498869896,
-0.03824745863676071,
-0.012960842810571194,
-0.008680813014507294,
-0.031413719058036804,
0.028855541720986366,
-0.03484847769141197,
0.047621484845876694,
-0.023059388622641563,
0.013783753849565983,
0.0480150505900383,
-0.0006904175970703363,
-0.051664479076862335,
0.055421244353055954,
0.047943491488695145,
-0.0323081873357296,
-0.021181005984544754,
0.0043560597114264965,
-0.021860800683498383,
0.02386440895497799,
-0.002750489627942443,
0.03792544826865196,
0.003519732039421797,
0.000497547909617424,
0.038354795426130295,
-0.01606464758515358,
-0.0531671866774559,
-0.025098776444792747,
-0.05180759355425835,
-0.041610658168792725,
-0.018622826784849167,
0.011189796030521393,
-0.010009098798036575,
-0.017862528562545776,
-0.03198618069291115,
0.02110944874584675,
0.011145072989165783,
-0.038497909903526306,
-0.02280893735587597,
-0.035921841859817505,
0.030537141487002373,
-0.05284517630934715,
-0.017603132873773575,
-0.032844871282577515,
-0.034079235047101974,
-0.018104035407304764,
-0.03221874311566353,
0.027012936770915985,
-0.01542063057422638,
-0.006927655544131994,
-0.015760527923703194,
0.0360470674932003,
0.019570963457226753,
-0.023435065522789955,
-0.06640531122684479,
-0.06819424778223038,
0.01466927770525217,
-0.0031731256749480963,
-0.011529694311320782,
0.04876640439033508,
0.01726323552429676,
0.008157549425959587,
0.034812700003385544,
0.030948597937822342,
-0.07134278118610382,
-0.05238005518913269,
0.019070060923695564,
0.003924478776752949,
0.016422435641288757,
-0.03364989161491394,
-0.023667626082897186,
0.0374603271484375,
0.0017386224353685975,
-0.01030427310615778,
-0.052344273775815964,
0.011905371211469173,
0.014400936663150787,
-0.03259442001581192,
-0.030376138165593147,
-0.015223847702145576,
-0.013434911146759987,
-0.017486851662397385,
0.0013741266448050737,
-0.004655706696212292,
-0.03543882817029953,
-0.010214826092123985,
-0.02828308194875717,
0.03631540760397911,
-0.017164843156933784,
0.023667626082897186,
0.03760344162583351,
0.0012500191805884242,
0.06325678527355194,
-0.024723099544644356,
0.036476410925388336,
-0.01062628161162138,
0.07441975176334381,
-0.028157856315374374,
0.03223663195967674,
-0.006408864166587591,
0.007513532415032387,
-0.06458059698343277,
-0.012316825799643993,
0.05692395195364952,
-0.02658359333872795,
0.018443932756781578,
0.08930370211601257,
-0.0004790994862560183,
-0.024079082533717155,
0.04490229859948158,
-0.00822463445365429,
0.02579646185040474,
0.032987985759973526,
0.024222197011113167,
-0.03595761954784393,
0.04075196757912636,
-0.01314868126064539,
0.011171907186508179,
-0.0684804767370224,
-0.015492187812924385,
0.00399380037561059,
0.03465169668197632,
-0.024723099544644356,
-0.04669123515486717,
0.019624629989266396,
0.044222503900527954,
0.05695972964167595
]
|
30,566 | networkx.algorithms.shortest_paths.weighted | dijkstra_path | Returns the shortest weighted path from source to target in G.
Uses Dijkstra's Method to compute the shortest weighted path
between two nodes in a graph.
Parameters
----------
G : NetworkX graph
source : node
Starting node
target : node
Ending node
weight : string or function
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number or None to indicate a hidden edge.
Returns
-------
path : list
List of nodes in a shortest path.
Raises
------
NodeNotFound
If `source` is not in `G`.
NetworkXNoPath
If no path exists between source and target.
Examples
--------
>>> G = nx.path_graph(5)
>>> print(nx.dijkstra_path(G, 0, 4))
[0, 1, 2, 3, 4]
Find edges of shortest path in Multigraph
>>> G = nx.MultiDiGraph()
>>> G.add_weighted_edges_from([(1, 2, 0.75), (1, 2, 0.5), (2, 3, 0.5), (1, 3, 1.5)])
>>> nodes = nx.dijkstra_path(G, 1, 3)
>>> edges = nx.utils.pairwise(nodes)
>>> list(
... (u, v, min(G[u][v], key=lambda k: G[u][v][k].get("weight", 1)))
... for u, v in edges
... )
[(1, 2, 1), (2, 3, 0)]
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
The weight function can be used to hide edges by returning None.
So ``weight = lambda u, v, d: 1 if d['color']=="red" else None``
will find the shortest red path.
The weight function can be used to include node weights.
>>> def func(u, v, d):
... node_u_wt = G.nodes[u].get("node_weight", 1)
... node_v_wt = G.nodes[v].get("node_weight", 1)
... edge_wt = d.get("weight", 1)
... return node_u_wt / 2 + node_v_wt / 2 + edge_wt
In this example we take the average of start and end node
weights of an edge and add it to the weight of the edge.
The function :func:`single_source_dijkstra` computes both
path and length-of-path if you need both, use that.
See Also
--------
bidirectional_dijkstra
bellman_ford_path
single_source_dijkstra
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, source, target, weight='weight', *, backend=None, **backend_kwargs) | [
0.008667515590786934,
-0.004119985271245241,
-0.03422308340668678,
-0.044231537729501724,
-0.0389455184340477,
-0.021785393357276917,
-0.010727508924901485,
0.0405779667198658,
0.07369332015514374,
-0.010572037659585476,
-0.052860185503959656,
0.029714420437812805,
0.02866499125957489,
0.025536134839057922,
-0.027246316894888878,
0.03587496653199196,
0.00007329462096095085,
0.035991568118333817,
-0.0012595591833814979,
0.013720327988266945,
-0.015012681484222412,
-0.056436024606227875,
0.05550319701433182,
0.049595292657613754,
-0.02100803703069687,
-0.009240815415978432,
0.014857210218906403,
-0.04007268697023392,
-0.025788774713873863,
-0.01634390279650688,
0.01778201200067997,
-0.018782855942845345,
-0.006330590229481459,
-0.0055289422161877155,
0.016538241878151894,
0.058534882962703705,
0.007841575890779495,
-0.00303411646746099,
-0.023320671170949936,
-0.04403720051050186,
-0.030180834233760834,
-0.03045290894806385,
0.005698988679796457,
-0.037837788462638855,
0.08006763458251953,
0.08379894495010376,
-0.017509937286376953,
0.008643223904073238,
-0.019346440210938454,
-0.018821723759174347,
0.01514871884137392,
0.0014842635719105601,
-0.009337984956800938,
0.00955661665648222,
-0.007822141982614994,
0.03948966786265373,
-0.03327082470059395,
0.05418169125914574,
0.027304617688059807,
-0.03822646662592888,
0.03948966786265373,
0.010562320239841938,
0.07085596770048141,
0.04011155292391777,
-0.06378203630447388,
-0.023592745885252953,
-0.04664134234189987,
-0.037526845932006836,
-0.03999495133757591,
0.021396715193986893,
0.001006311271339655,
-0.009512890130281448,
-0.01346768718212843,
-0.03552515432238579,
-0.0019020922482013702,
0.03801269456744194,
-0.000060351343563525006,
-0.034825533628463745,
0.011145337484776974,
-0.0398394800722599,
0.043920595198869705,
-0.05647489055991173,
-0.02584707736968994,
-0.07101143896579742,
0.07303256541490555,
0.025069721043109894,
-0.004134560469537973,
0.0026940233074128628,
-0.009036759845912457,
-0.03406761214137077,
-0.036710623651742935,
0.030841587111353874,
-0.0033159079030156136,
0.00043513698619790375,
0.05678583309054375,
0.02677990309894085,
0.009046477265655994,
-0.05701903998851776,
0.05006170645356178,
0.031035926192998886,
0.06852390617132187,
0.004824463743716478,
-0.01453655119985342,
0.036147039383649826,
0.026449527591466904,
-0.06720239669084549,
-0.011019016616046429,
0.015867773443460464,
-0.013885515742003918,
-0.055619798600673676,
-0.022621050477027893,
0.012369672767817974,
0.025944245979189873,
-0.02677990309894085,
0.02345670759677887,
0.0032697522547096014,
0.006724126636981964,
0.04395946487784386,
-0.0005186420166864991,
-0.021124640479683876,
-0.025225192308425903,
0.05254924297332764,
-0.08309932053089142,
-0.0038770614191889763,
0.040500231087207794,
-0.05635828897356987,
0.024739345535635948,
-0.019900305196642876,
0.06626956909894943,
0.01792776584625244,
0.026196885854005814,
0.004856043960899115,
-0.02790706977248192,
0.06560882180929184,
0.03202705457806587,
-0.02458387427031994,
-0.05663036182522774,
0.046835679560899734,
0.06506466865539551,
0.010406848974525928,
0.04256022348999977,
-0.07548123598098755,
0.007724971976131201,
0.02876215986907482,
0.005893327761441469,
-0.02850951999425888,
0.011135620065033436,
0.014031270518898964,
0.031307999044656754,
0.05973978340625763,
0.01545966137200594,
0.002900508465245366,
0.006850447040051222,
0.011621467769145966,
0.001647022319957614,
-0.0681740939617157,
-0.04201607406139374,
0.02044445462524891,
0.005835026036947966,
-0.0005210712552070618,
0.016645127907395363,
-0.0446590855717659,
0.005713564343750477,
0.0148183424025774,
-0.04982849955558777,
0.03488383814692497,
0.02217407152056694,
0.05212169885635376,
-0.02712971344590187,
0.012359955348074436,
-0.005893327761441469,
-0.06413184106349945,
-0.047807373106479645,
-0.02917027287185192,
-0.024447835981845856,
0.003320766380056739,
0.025050286203622818,
-0.002266477793455124,
0.01182552333921194,
-0.01942417584359646,
0.00988699309527874,
-0.02662443183362484,
0.02314576506614685,
-0.013564856722950935,
0.030083665624260902,
0.02917027287185192,
0.02227124013006687,
-0.02161048725247383,
0.0029685271438211203,
0.03478666767477989,
-0.04827378690242767,
-0.09328268468379974,
-0.06059487536549568,
0.08325479179620743,
-0.009085345081984997,
0.006728985346853733,
-0.03729363903403282,
-0.02217407152056694,
-0.027265751734375954,
0.06374316662549973,
-0.009153363294899464,
-0.029306309297680855,
0.0398394800722599,
-0.008837562054395676,
0.00925053283572197,
-0.028859330341219902,
-0.03245459869503975,
0.0086140725761652,
0.0010421425104141235,
0.018510783091187477,
-0.03511704504489899,
-0.04543644189834595,
0.030005929991602898,
-0.029772723093628883,
0.0011903259437531233,
0.01374947838485241,
-0.031754981726408005,
0.040033817291259766,
0.013963251374661922,
-0.05907903239130974,
-0.004413922782987356,
-0.015284756198525429,
-0.00953232403844595,
0.02116350829601288,
0.061799775809049606,
-0.050256043672561646,
0.047030020505189896,
0.030627815052866936,
0.02584707736968994,
-0.07330463826656342,
0.07719141989946365,
-0.032726675271987915,
0.09639210253953934,
-0.014808625914156437,
0.0738099217414856,
-0.047846242785453796,
0.0034495159052312374,
0.04073343798518181,
0.04559190943837166,
0.027868201956152916,
-0.021707657724618912,
-0.02345670759677887,
-0.014653154648840427,
-0.05814620479941368,
0.0059370542876422405,
-0.00008912261546356604,
0.03148290514945984,
-0.012301653623580933,
0.026099717244505882,
-0.006495778448879719,
0.005057670641690493,
0.027673862874507904,
-0.04236588627099991,
-0.05748545378446579,
-0.01292353868484497,
-0.043143242597579956,
-0.02100803703069687,
-0.03748797997832298,
-0.03653571754693985,
-0.06584202498197556,
-0.03224082663655281,
-0.027829334139823914,
-0.06094468757510185,
0.10152265429496765,
-0.0038892077282071114,
0.032629504799842834,
0.031210830435156822,
-0.014342212118208408,
-0.08022310584783554,
0.006626957096159458,
0.042637959122657776,
0.043104372918605804,
-0.006865022238343954,
-0.003619562368839979,
-0.0251474566757679,
0.005193707533180714,
-0.03220196068286896,
0.03484496846795082,
0.012884670868515968,
-0.023029161617159843,
-0.04372625797986984,
-0.008361431770026684,
-0.04123871773481369,
-0.006461769342422485,
0.01797635108232498,
0.02969498746097088,
0.012117031961679459,
-0.03484496846795082,
0.0164507906883955,
0.00665610795840621,
0.07019522041082382,
-0.012165616266429424,
0.010591471567749977,
-0.037740617990493774,
0.062266189604997635,
0.04769077152013779,
-0.003413077211007476,
-0.07287709414958954,
0.016392488032579422,
0.0536375418305397,
0.015449943952262402,
-0.02571103908121586,
0.025633303448557854,
-0.005698988679796457,
-0.04267682880163193,
0.008269120939075947,
0.031191397458314896,
-0.016781166195869446,
-0.0025847076904028654,
-0.03091932274401188,
-0.02141615003347397,
-0.025205757468938828,
0.0017733427230268717,
0.007326577324420214,
0.0036705764941871166,
-0.037274204194545746,
-0.035136476159095764,
0.0073994542472064495,
-0.006758136209100485,
0.03224082663655281,
-0.038964953273534775,
0.0764140635728836,
-0.06832956522703171,
0.02922857366502285,
-0.030530644580721855,
0.029248008504509926,
0.03183271363377571,
0.025672171264886856,
0.03509761020541191,
0.022465579211711884,
0.037896089255809784,
0.022446146234869957,
0.026177452877163887,
0.030841587111353874,
-0.01987115480005741,
0.08970684558153152,
0.07435407489538193,
-0.00544148962944746,
0.000042245941585861146,
-0.003153149038553238,
0.04741869866847992,
0.021746525540947914,
-0.022057468071579933,
0.02380651794373989,
0.006082808133214712,
-0.0438428595662117,
0.03398987650871277,
-0.0389455184340477,
0.0074480390176177025,
-0.04737982898950577,
0.02186312898993492,
0.06797975301742554,
0.01834559440612793,
0.02646896056830883,
0.050605855882167816,
0.0031312857754528522,
-0.010941280983388424,
-0.04061683639883995,
0.02232954278588295,
-0.004931350238621235,
0.008390583097934723,
0.018160972744226456,
0.009114495478570461,
-0.002917513018473983,
-0.0462915301322937,
0.01364259235560894,
0.019356155768036842,
-0.013331649824976921,
-0.01824842393398285,
-0.050605855882167816,
-0.008463460020720959,
-0.06055600941181183,
-0.025108588859438896,
0.05542546138167381,
0.012010145001113415,
0.000449105107691139,
0.016363337635993958,
-0.0074528977274894714,
-0.003529680659994483,
0.044076066464185715,
-0.02197973243892193,
0.05748545378446579,
0.0052228583954274654,
0.046019457280635834,
0.024875381961464882,
-0.04123871773481369,
0.06638617813587189,
0.007389737293124199,
0.03381497412919998,
0.0063597410917282104,
-0.024661609902977943,
-0.01783059537410736,
0.044425878673791885,
0.028606688603758812,
-0.0026697309222072363,
-0.04170513153076172,
0.07186653465032578,
0.03025856986641884,
-0.050566986203193665,
-0.025069721043109894,
0.01584833860397339,
-0.021241243928670883,
-0.0551922544836998,
0.06910692155361176,
0.009721804410219193,
-0.047651905566453934,
0.04594172164797783,
0.027926502749323845,
0.025944245979189873,
0.04854586347937584,
-0.041782867163419724,
-0.002404944272711873,
-0.014624004252254963,
0.017198994755744934,
-0.04388172924518585,
-0.058884695172309875,
-0.06852390617132187,
0.0422104150056839,
0.05678583309054375,
0.002992819296196103,
0.03659401834011078,
-0.029364611953496933,
0.06405410915613174,
-0.0828661173582077,
0.01213646586984396,
-0.04318210855126381,
-0.013020708225667477,
-0.027965370565652847,
-0.0009692653547972441,
0.05083906278014183,
-0.024894816800951958,
-0.023592745885252953,
0.0393536314368248,
-0.05515338480472565,
-0.00710308738052845,
-0.005208283197134733,
0.016178715974092484,
0.002471748273819685,
0.07206087559461594,
-0.034164782613515854,
-0.009410861879587173,
-0.02775159850716591,
-0.026196885854005814,
-0.027013109996914864,
-0.0520050972700119,
-0.07901820540428162,
0.020502755418419838,
-0.022815389558672905,
0.030899887904524803,
-0.03593326732516289,
0.006942757871001959,
-0.03877061605453491,
0.021182943135499954,
0.023184632882475853,
-0.02615801803767681,
0.024972552433609962,
0.016013527289032936,
0.010241661220788956,
-0.11986824870109558,
0.02703254483640194,
0.05080019310116768,
-0.03187158331274986,
0.028528952971100807,
-0.011942126788198948,
-0.04788510873913765,
0.05923450365662575,
0.03439798951148987,
0.0010269597405567765,
-0.0007287709740921855,
-0.025944245979189873,
0.04531983658671379,
-0.010824677534401417,
-0.08550912886857986,
-0.0059370542876422405,
0.022348975762724876,
-0.004205008503049612,
-0.06350996345281601,
0.014808625914156437,
0.0021668788976967335,
-0.016683995723724365,
0.040694572031497955,
-0.04007268697023392,
0.06693032383918762,
-0.007822141982614994,
0.00544148962944746,
-0.05507564917206764,
0.03908155858516693,
-0.019657382741570473,
0.014478249475359917,
0.0029393762815743685,
0.040694572031497955,
-0.06284920871257782,
0.06937899440526962,
-0.031191397458314896,
-0.0038892077282071114,
0.04275456443428993,
0.03317365422844887,
-0.016577109694480896,
0.08076725900173187,
-0.013419102877378464,
0.002594424644485116,
-0.01042628288269043,
-0.05488131195306778,
0.05954544618725777,
0.03393157571554184,
0.01530419010668993,
0.014487966895103455,
0.048973407596349716,
-0.02574990689754486,
0.026449527591466904,
0.01731559820473194,
0.0029588101897388697,
0.04706888645887375,
0.05507564917206764,
0.04582511633634567,
-0.0078027076087892056,
-0.00665610795840621,
0.0689125806093216,
0.002187527483329177,
-0.022407278418540955,
0.04337644577026367,
0.06218845397233963,
-0.015556830912828445,
0.0276349950581789,
-0.07439293712377548,
0.03531138226389885,
0.004370196722447872,
-0.04753530025482178,
0.023068029433488846,
0.004119985271245241,
0.010892696678638458,
0.0337178036570549,
-0.0004078080819454044,
0.02693537436425686,
0.0184913482517004,
0.014487966895103455,
0.056125082075595856,
-0.018675969913601875,
-0.014653154648840427,
-0.016975505277514458,
0.05946771055459976,
0.00020117114763706923,
-0.004574252292513847,
-0.005635828711092472,
0.06992314755916595,
-0.00513540580868721,
-0.0021608059760183096,
-0.008031056262552738,
-0.00024398644745815545,
-0.05095566436648369,
-0.021999165415763855,
-0.0024061587173491716,
0.007200256921350956,
0.05212169885635376,
0.06957333534955978,
-0.009697511792182922,
0.014138156548142433,
0.009367136284708977,
0.006651249714195728,
0.08504271507263184,
-0.02540009655058384,
-0.08527591824531555,
-0.04617492854595184,
-0.01691720262169838,
-0.0154305100440979,
-0.030569512397050858,
0.015663716942071915,
-0.012797217816114426,
0.0013931671855971217,
-0.006330590229481459,
-0.02979215607047081,
0.0405779667198658,
-0.00573785649612546,
0.026332924142479897,
-0.028392916545271873,
-0.007924169301986694,
-0.026352357119321823,
-0.045242100954055786,
0.023223500698804855,
-0.05099453404545784,
-0.0178403127938509,
0.021241243928670883,
0.06304354965686798,
0.0519273616373539,
0.02534179575741291,
-0.0020964310970157385,
-0.05227717012166977,
0.004153994377702475,
-0.047962844371795654,
0.010523452423512936,
0.010737225413322449,
-0.053326599299907684,
0.014332495629787445,
0.037896089255809784,
0.011291091330349445,
-0.05585300549864769,
-0.01961851492524147,
0.01727673038840294,
0.03152177482843399,
-0.0031288566533476114,
-0.09312721341848373,
-0.009852983057498932,
0.006957333534955978,
-0.006160543765872717,
0.031230265274643898,
-0.01484749373048544,
-0.006277147214859724,
-0.08714157342910767,
-0.015080700628459454,
-0.05099453404545784,
0.019958607852458954,
0.013535706326365471,
0.02596368081867695,
-0.024700477719306946,
-0.029617251828312874,
-0.007613227237015963,
-0.00986270047724247,
0.016120413318276405,
-0.029967062175273895,
-0.03593326732516289,
0.015245888382196426,
-0.03972287476062775,
0.01997804082930088,
-0.012641746550798416,
0.0028640697710216045,
0.038498539477586746,
-0.0024328804574906826,
0.019375590607523918,
-0.060478273779153824,
0.03297931328415871,
-0.02176595851778984,
-0.04901227727532387,
0.044581349939107895,
0.05379301309585571,
-0.022504447028040886,
-0.015916356816887856,
0.06930126249790192,
-0.010513735935091972,
-0.015236171893775463,
-0.011942126788198948,
-0.03488383814692497,
0.04403720051050186,
-0.021280111744999886,
-0.033387426286935806,
-0.03593326732516289,
-0.00440663518384099,
-0.003928075544536114,
-0.02248501405119896,
0.009522607550024986,
0.0007785703055560589,
-0.005752432160079479,
-0.01530419010668993,
-0.030491776764392853,
0.0067678531631827354,
0.020366718992590904,
0.07276049256324768,
-0.018792573362588882,
-0.0341259129345417,
0.012155899778008461,
0.012583444826304913,
0.032532334327697754,
0.053987354040145874,
0.06926239281892776,
-0.0438428595662117,
-0.03744911029934883,
-0.013040142133831978,
0.017616823315620422,
-0.06214958801865578,
-0.01788889802992344,
0.007686104159802198,
-0.0640929788351059,
-0.011485430411994457,
0.008497469127178192,
0.016285602003335953,
-0.032823845744132996,
-0.06055600941181183,
0.02687707357108593,
-0.004073829855769873,
-0.07579217851161957,
-0.06778541952371597,
0.042948901653289795,
0.04609719291329384,
0.024953117594122887,
-0.013088726438581944,
-0.011572882533073425,
0.053676411509513855,
-0.051888491958379745,
-0.08403214812278748,
0.034922704100608826,
0.014215892180800438,
0.01991974003612995,
-0.03459232673048973,
0.04042249545454979,
0.008784119039773941,
-0.0381292961537838,
-0.05142207816243172,
-0.0024802505504339933,
-0.01991974003612995,
0.0308221522718668,
-0.03603043779730797,
0.020425021648406982,
0.053326599299907684,
0.00805049017071724,
-0.03014196641743183,
-0.011145337484776974,
-0.03142460435628891,
-0.08037857711315155,
0.03867344558238983,
0.02295142598450184,
0.009828691370785236,
-0.03622477501630783,
-0.03025856986641884,
-0.01392438355833292,
0.02681877091526985,
0.01152429822832346,
-0.014944663271307945,
0.020716529339551926,
-0.013098442927002907,
-0.01246684230864048,
-0.0026551554910838604,
0.014468532986938953,
-0.023631613701581955,
-0.0032187383621931076,
0.028626123443245888,
-0.08846307545900345,
-0.0008107576868496835,
0.023417839780449867,
-0.08348800241947174,
0.002039344049990177,
-0.01792776584625244,
-0.02631348930299282,
0.08815213292837143,
0.0098578417673707,
0.03198818489909172,
0.004814746789634228,
-0.014604570344090462,
0.025283493101596832,
-0.014983531087636948,
-0.00986270047724247,
0.05993412435054779,
-0.026546696200966835,
0.018316444009542465,
-0.03995608165860176,
-0.017665408551692963,
-0.00125227146781981,
-0.010999582707881927,
0.01019307691603899,
0.01257372833788395,
-0.027576692402362823,
-0.010970432311296463,
0.03107479400932789,
-0.000737880589440465,
0.02411746047437191,
-0.01840389519929886,
0.011689485982060432,
-0.011815806850790977,
-0.04011155292391777,
-0.0519273616373539,
-0.02606084942817688,
-0.048118315637111664,
-0.06125563010573387,
-0.008720959536731243,
-0.018792573362588882,
0.022776521742343903,
0.02207690104842186,
0.04664134234189987,
0.02571103908121586,
0.08496497571468353
]
|
30,567 | networkx.algorithms.shortest_paths.weighted | dijkstra_path_length | Returns the shortest weighted path length in G from source to target.
Uses Dijkstra's Method to compute the shortest weighted path length
between two nodes in a graph.
Parameters
----------
G : NetworkX graph
source : node label
starting node for path
target : node label
ending node for path
weight : string or function
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number or None to indicate a hidden edge.
Returns
-------
length : number
Shortest path length.
Raises
------
NodeNotFound
If `source` is not in `G`.
NetworkXNoPath
If no path exists between source and target.
Examples
--------
>>> G = nx.path_graph(5)
>>> nx.dijkstra_path_length(G, 0, 4)
4
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
The weight function can be used to hide edges by returning None.
So ``weight = lambda u, v, d: 1 if d['color']=="red" else None``
will find the shortest red path.
The function :func:`single_source_dijkstra` computes both
path and length-of-path if you need both, use that.
See Also
--------
bidirectional_dijkstra
bellman_ford_path_length
single_source_dijkstra
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, source, target, weight='weight', *, backend=None, **backend_kwargs) | [
0.008667515590786934,
-0.004119985271245241,
-0.03422308340668678,
-0.044231537729501724,
-0.0389455184340477,
-0.021785393357276917,
-0.010727508924901485,
0.0405779667198658,
0.07369332015514374,
-0.010572037659585476,
-0.052860185503959656,
0.029714420437812805,
0.02866499125957489,
0.025536134839057922,
-0.027246316894888878,
0.03587496653199196,
0.00007329462096095085,
0.035991568118333817,
-0.0012595591833814979,
0.013720327988266945,
-0.015012681484222412,
-0.056436024606227875,
0.05550319701433182,
0.049595292657613754,
-0.02100803703069687,
-0.009240815415978432,
0.014857210218906403,
-0.04007268697023392,
-0.025788774713873863,
-0.01634390279650688,
0.01778201200067997,
-0.018782855942845345,
-0.006330590229481459,
-0.0055289422161877155,
0.016538241878151894,
0.058534882962703705,
0.007841575890779495,
-0.00303411646746099,
-0.023320671170949936,
-0.04403720051050186,
-0.030180834233760834,
-0.03045290894806385,
0.005698988679796457,
-0.037837788462638855,
0.08006763458251953,
0.08379894495010376,
-0.017509937286376953,
0.008643223904073238,
-0.019346440210938454,
-0.018821723759174347,
0.01514871884137392,
0.0014842635719105601,
-0.009337984956800938,
0.00955661665648222,
-0.007822141982614994,
0.03948966786265373,
-0.03327082470059395,
0.05418169125914574,
0.027304617688059807,
-0.03822646662592888,
0.03948966786265373,
0.010562320239841938,
0.07085596770048141,
0.04011155292391777,
-0.06378203630447388,
-0.023592745885252953,
-0.04664134234189987,
-0.037526845932006836,
-0.03999495133757591,
0.021396715193986893,
0.001006311271339655,
-0.009512890130281448,
-0.01346768718212843,
-0.03552515432238579,
-0.0019020922482013702,
0.03801269456744194,
-0.000060351343563525006,
-0.034825533628463745,
0.011145337484776974,
-0.0398394800722599,
0.043920595198869705,
-0.05647489055991173,
-0.02584707736968994,
-0.07101143896579742,
0.07303256541490555,
0.025069721043109894,
-0.004134560469537973,
0.0026940233074128628,
-0.009036759845912457,
-0.03406761214137077,
-0.036710623651742935,
0.030841587111353874,
-0.0033159079030156136,
0.00043513698619790375,
0.05678583309054375,
0.02677990309894085,
0.009046477265655994,
-0.05701903998851776,
0.05006170645356178,
0.031035926192998886,
0.06852390617132187,
0.004824463743716478,
-0.01453655119985342,
0.036147039383649826,
0.026449527591466904,
-0.06720239669084549,
-0.011019016616046429,
0.015867773443460464,
-0.013885515742003918,
-0.055619798600673676,
-0.022621050477027893,
0.012369672767817974,
0.025944245979189873,
-0.02677990309894085,
0.02345670759677887,
0.0032697522547096014,
0.006724126636981964,
0.04395946487784386,
-0.0005186420166864991,
-0.021124640479683876,
-0.025225192308425903,
0.05254924297332764,
-0.08309932053089142,
-0.0038770614191889763,
0.040500231087207794,
-0.05635828897356987,
0.024739345535635948,
-0.019900305196642876,
0.06626956909894943,
0.01792776584625244,
0.026196885854005814,
0.004856043960899115,
-0.02790706977248192,
0.06560882180929184,
0.03202705457806587,
-0.02458387427031994,
-0.05663036182522774,
0.046835679560899734,
0.06506466865539551,
0.010406848974525928,
0.04256022348999977,
-0.07548123598098755,
0.007724971976131201,
0.02876215986907482,
0.005893327761441469,
-0.02850951999425888,
0.011135620065033436,
0.014031270518898964,
0.031307999044656754,
0.05973978340625763,
0.01545966137200594,
0.002900508465245366,
0.006850447040051222,
0.011621467769145966,
0.001647022319957614,
-0.0681740939617157,
-0.04201607406139374,
0.02044445462524891,
0.005835026036947966,
-0.0005210712552070618,
0.016645127907395363,
-0.0446590855717659,
0.005713564343750477,
0.0148183424025774,
-0.04982849955558777,
0.03488383814692497,
0.02217407152056694,
0.05212169885635376,
-0.02712971344590187,
0.012359955348074436,
-0.005893327761441469,
-0.06413184106349945,
-0.047807373106479645,
-0.02917027287185192,
-0.024447835981845856,
0.003320766380056739,
0.025050286203622818,
-0.002266477793455124,
0.01182552333921194,
-0.01942417584359646,
0.00988699309527874,
-0.02662443183362484,
0.02314576506614685,
-0.013564856722950935,
0.030083665624260902,
0.02917027287185192,
0.02227124013006687,
-0.02161048725247383,
0.0029685271438211203,
0.03478666767477989,
-0.04827378690242767,
-0.09328268468379974,
-0.06059487536549568,
0.08325479179620743,
-0.009085345081984997,
0.006728985346853733,
-0.03729363903403282,
-0.02217407152056694,
-0.027265751734375954,
0.06374316662549973,
-0.009153363294899464,
-0.029306309297680855,
0.0398394800722599,
-0.008837562054395676,
0.00925053283572197,
-0.028859330341219902,
-0.03245459869503975,
0.0086140725761652,
0.0010421425104141235,
0.018510783091187477,
-0.03511704504489899,
-0.04543644189834595,
0.030005929991602898,
-0.029772723093628883,
0.0011903259437531233,
0.01374947838485241,
-0.031754981726408005,
0.040033817291259766,
0.013963251374661922,
-0.05907903239130974,
-0.004413922782987356,
-0.015284756198525429,
-0.00953232403844595,
0.02116350829601288,
0.061799775809049606,
-0.050256043672561646,
0.047030020505189896,
0.030627815052866936,
0.02584707736968994,
-0.07330463826656342,
0.07719141989946365,
-0.032726675271987915,
0.09639210253953934,
-0.014808625914156437,
0.0738099217414856,
-0.047846242785453796,
0.0034495159052312374,
0.04073343798518181,
0.04559190943837166,
0.027868201956152916,
-0.021707657724618912,
-0.02345670759677887,
-0.014653154648840427,
-0.05814620479941368,
0.0059370542876422405,
-0.00008912261546356604,
0.03148290514945984,
-0.012301653623580933,
0.026099717244505882,
-0.006495778448879719,
0.005057670641690493,
0.027673862874507904,
-0.04236588627099991,
-0.05748545378446579,
-0.01292353868484497,
-0.043143242597579956,
-0.02100803703069687,
-0.03748797997832298,
-0.03653571754693985,
-0.06584202498197556,
-0.03224082663655281,
-0.027829334139823914,
-0.06094468757510185,
0.10152265429496765,
-0.0038892077282071114,
0.032629504799842834,
0.031210830435156822,
-0.014342212118208408,
-0.08022310584783554,
0.006626957096159458,
0.042637959122657776,
0.043104372918605804,
-0.006865022238343954,
-0.003619562368839979,
-0.0251474566757679,
0.005193707533180714,
-0.03220196068286896,
0.03484496846795082,
0.012884670868515968,
-0.023029161617159843,
-0.04372625797986984,
-0.008361431770026684,
-0.04123871773481369,
-0.006461769342422485,
0.01797635108232498,
0.02969498746097088,
0.012117031961679459,
-0.03484496846795082,
0.0164507906883955,
0.00665610795840621,
0.07019522041082382,
-0.012165616266429424,
0.010591471567749977,
-0.037740617990493774,
0.062266189604997635,
0.04769077152013779,
-0.003413077211007476,
-0.07287709414958954,
0.016392488032579422,
0.0536375418305397,
0.015449943952262402,
-0.02571103908121586,
0.025633303448557854,
-0.005698988679796457,
-0.04267682880163193,
0.008269120939075947,
0.031191397458314896,
-0.016781166195869446,
-0.0025847076904028654,
-0.03091932274401188,
-0.02141615003347397,
-0.025205757468938828,
0.0017733427230268717,
0.007326577324420214,
0.0036705764941871166,
-0.037274204194545746,
-0.035136476159095764,
0.0073994542472064495,
-0.006758136209100485,
0.03224082663655281,
-0.038964953273534775,
0.0764140635728836,
-0.06832956522703171,
0.02922857366502285,
-0.030530644580721855,
0.029248008504509926,
0.03183271363377571,
0.025672171264886856,
0.03509761020541191,
0.022465579211711884,
0.037896089255809784,
0.022446146234869957,
0.026177452877163887,
0.030841587111353874,
-0.01987115480005741,
0.08970684558153152,
0.07435407489538193,
-0.00544148962944746,
0.000042245941585861146,
-0.003153149038553238,
0.04741869866847992,
0.021746525540947914,
-0.022057468071579933,
0.02380651794373989,
0.006082808133214712,
-0.0438428595662117,
0.03398987650871277,
-0.0389455184340477,
0.0074480390176177025,
-0.04737982898950577,
0.02186312898993492,
0.06797975301742554,
0.01834559440612793,
0.02646896056830883,
0.050605855882167816,
0.0031312857754528522,
-0.010941280983388424,
-0.04061683639883995,
0.02232954278588295,
-0.004931350238621235,
0.008390583097934723,
0.018160972744226456,
0.009114495478570461,
-0.002917513018473983,
-0.0462915301322937,
0.01364259235560894,
0.019356155768036842,
-0.013331649824976921,
-0.01824842393398285,
-0.050605855882167816,
-0.008463460020720959,
-0.06055600941181183,
-0.025108588859438896,
0.05542546138167381,
0.012010145001113415,
0.000449105107691139,
0.016363337635993958,
-0.0074528977274894714,
-0.003529680659994483,
0.044076066464185715,
-0.02197973243892193,
0.05748545378446579,
0.0052228583954274654,
0.046019457280635834,
0.024875381961464882,
-0.04123871773481369,
0.06638617813587189,
0.007389737293124199,
0.03381497412919998,
0.0063597410917282104,
-0.024661609902977943,
-0.01783059537410736,
0.044425878673791885,
0.028606688603758812,
-0.0026697309222072363,
-0.04170513153076172,
0.07186653465032578,
0.03025856986641884,
-0.050566986203193665,
-0.025069721043109894,
0.01584833860397339,
-0.021241243928670883,
-0.0551922544836998,
0.06910692155361176,
0.009721804410219193,
-0.047651905566453934,
0.04594172164797783,
0.027926502749323845,
0.025944245979189873,
0.04854586347937584,
-0.041782867163419724,
-0.002404944272711873,
-0.014624004252254963,
0.017198994755744934,
-0.04388172924518585,
-0.058884695172309875,
-0.06852390617132187,
0.0422104150056839,
0.05678583309054375,
0.002992819296196103,
0.03659401834011078,
-0.029364611953496933,
0.06405410915613174,
-0.0828661173582077,
0.01213646586984396,
-0.04318210855126381,
-0.013020708225667477,
-0.027965370565652847,
-0.0009692653547972441,
0.05083906278014183,
-0.024894816800951958,
-0.023592745885252953,
0.0393536314368248,
-0.05515338480472565,
-0.00710308738052845,
-0.005208283197134733,
0.016178715974092484,
0.002471748273819685,
0.07206087559461594,
-0.034164782613515854,
-0.009410861879587173,
-0.02775159850716591,
-0.026196885854005814,
-0.027013109996914864,
-0.0520050972700119,
-0.07901820540428162,
0.020502755418419838,
-0.022815389558672905,
0.030899887904524803,
-0.03593326732516289,
0.006942757871001959,
-0.03877061605453491,
0.021182943135499954,
0.023184632882475853,
-0.02615801803767681,
0.024972552433609962,
0.016013527289032936,
0.010241661220788956,
-0.11986824870109558,
0.02703254483640194,
0.05080019310116768,
-0.03187158331274986,
0.028528952971100807,
-0.011942126788198948,
-0.04788510873913765,
0.05923450365662575,
0.03439798951148987,
0.0010269597405567765,
-0.0007287709740921855,
-0.025944245979189873,
0.04531983658671379,
-0.010824677534401417,
-0.08550912886857986,
-0.0059370542876422405,
0.022348975762724876,
-0.004205008503049612,
-0.06350996345281601,
0.014808625914156437,
0.0021668788976967335,
-0.016683995723724365,
0.040694572031497955,
-0.04007268697023392,
0.06693032383918762,
-0.007822141982614994,
0.00544148962944746,
-0.05507564917206764,
0.03908155858516693,
-0.019657382741570473,
0.014478249475359917,
0.0029393762815743685,
0.040694572031497955,
-0.06284920871257782,
0.06937899440526962,
-0.031191397458314896,
-0.0038892077282071114,
0.04275456443428993,
0.03317365422844887,
-0.016577109694480896,
0.08076725900173187,
-0.013419102877378464,
0.002594424644485116,
-0.01042628288269043,
-0.05488131195306778,
0.05954544618725777,
0.03393157571554184,
0.01530419010668993,
0.014487966895103455,
0.048973407596349716,
-0.02574990689754486,
0.026449527591466904,
0.01731559820473194,
0.0029588101897388697,
0.04706888645887375,
0.05507564917206764,
0.04582511633634567,
-0.0078027076087892056,
-0.00665610795840621,
0.0689125806093216,
0.002187527483329177,
-0.022407278418540955,
0.04337644577026367,
0.06218845397233963,
-0.015556830912828445,
0.0276349950581789,
-0.07439293712377548,
0.03531138226389885,
0.004370196722447872,
-0.04753530025482178,
0.023068029433488846,
0.004119985271245241,
0.010892696678638458,
0.0337178036570549,
-0.0004078080819454044,
0.02693537436425686,
0.0184913482517004,
0.014487966895103455,
0.056125082075595856,
-0.018675969913601875,
-0.014653154648840427,
-0.016975505277514458,
0.05946771055459976,
0.00020117114763706923,
-0.004574252292513847,
-0.005635828711092472,
0.06992314755916595,
-0.00513540580868721,
-0.0021608059760183096,
-0.008031056262552738,
-0.00024398644745815545,
-0.05095566436648369,
-0.021999165415763855,
-0.0024061587173491716,
0.007200256921350956,
0.05212169885635376,
0.06957333534955978,
-0.009697511792182922,
0.014138156548142433,
0.009367136284708977,
0.006651249714195728,
0.08504271507263184,
-0.02540009655058384,
-0.08527591824531555,
-0.04617492854595184,
-0.01691720262169838,
-0.0154305100440979,
-0.030569512397050858,
0.015663716942071915,
-0.012797217816114426,
0.0013931671855971217,
-0.006330590229481459,
-0.02979215607047081,
0.0405779667198658,
-0.00573785649612546,
0.026332924142479897,
-0.028392916545271873,
-0.007924169301986694,
-0.026352357119321823,
-0.045242100954055786,
0.023223500698804855,
-0.05099453404545784,
-0.0178403127938509,
0.021241243928670883,
0.06304354965686798,
0.0519273616373539,
0.02534179575741291,
-0.0020964310970157385,
-0.05227717012166977,
0.004153994377702475,
-0.047962844371795654,
0.010523452423512936,
0.010737225413322449,
-0.053326599299907684,
0.014332495629787445,
0.037896089255809784,
0.011291091330349445,
-0.05585300549864769,
-0.01961851492524147,
0.01727673038840294,
0.03152177482843399,
-0.0031288566533476114,
-0.09312721341848373,
-0.009852983057498932,
0.006957333534955978,
-0.006160543765872717,
0.031230265274643898,
-0.01484749373048544,
-0.006277147214859724,
-0.08714157342910767,
-0.015080700628459454,
-0.05099453404545784,
0.019958607852458954,
0.013535706326365471,
0.02596368081867695,
-0.024700477719306946,
-0.029617251828312874,
-0.007613227237015963,
-0.00986270047724247,
0.016120413318276405,
-0.029967062175273895,
-0.03593326732516289,
0.015245888382196426,
-0.03972287476062775,
0.01997804082930088,
-0.012641746550798416,
0.0028640697710216045,
0.038498539477586746,
-0.0024328804574906826,
0.019375590607523918,
-0.060478273779153824,
0.03297931328415871,
-0.02176595851778984,
-0.04901227727532387,
0.044581349939107895,
0.05379301309585571,
-0.022504447028040886,
-0.015916356816887856,
0.06930126249790192,
-0.010513735935091972,
-0.015236171893775463,
-0.011942126788198948,
-0.03488383814692497,
0.04403720051050186,
-0.021280111744999886,
-0.033387426286935806,
-0.03593326732516289,
-0.00440663518384099,
-0.003928075544536114,
-0.02248501405119896,
0.009522607550024986,
0.0007785703055560589,
-0.005752432160079479,
-0.01530419010668993,
-0.030491776764392853,
0.0067678531631827354,
0.020366718992590904,
0.07276049256324768,
-0.018792573362588882,
-0.0341259129345417,
0.012155899778008461,
0.012583444826304913,
0.032532334327697754,
0.053987354040145874,
0.06926239281892776,
-0.0438428595662117,
-0.03744911029934883,
-0.013040142133831978,
0.017616823315620422,
-0.06214958801865578,
-0.01788889802992344,
0.007686104159802198,
-0.0640929788351059,
-0.011485430411994457,
0.008497469127178192,
0.016285602003335953,
-0.032823845744132996,
-0.06055600941181183,
0.02687707357108593,
-0.004073829855769873,
-0.07579217851161957,
-0.06778541952371597,
0.042948901653289795,
0.04609719291329384,
0.024953117594122887,
-0.013088726438581944,
-0.011572882533073425,
0.053676411509513855,
-0.051888491958379745,
-0.08403214812278748,
0.034922704100608826,
0.014215892180800438,
0.01991974003612995,
-0.03459232673048973,
0.04042249545454979,
0.008784119039773941,
-0.0381292961537838,
-0.05142207816243172,
-0.0024802505504339933,
-0.01991974003612995,
0.0308221522718668,
-0.03603043779730797,
0.020425021648406982,
0.053326599299907684,
0.00805049017071724,
-0.03014196641743183,
-0.011145337484776974,
-0.03142460435628891,
-0.08037857711315155,
0.03867344558238983,
0.02295142598450184,
0.009828691370785236,
-0.03622477501630783,
-0.03025856986641884,
-0.01392438355833292,
0.02681877091526985,
0.01152429822832346,
-0.014944663271307945,
0.020716529339551926,
-0.013098442927002907,
-0.01246684230864048,
-0.0026551554910838604,
0.014468532986938953,
-0.023631613701581955,
-0.0032187383621931076,
0.028626123443245888,
-0.08846307545900345,
-0.0008107576868496835,
0.023417839780449867,
-0.08348800241947174,
0.002039344049990177,
-0.01792776584625244,
-0.02631348930299282,
0.08815213292837143,
0.0098578417673707,
0.03198818489909172,
0.004814746789634228,
-0.014604570344090462,
0.025283493101596832,
-0.014983531087636948,
-0.00986270047724247,
0.05993412435054779,
-0.026546696200966835,
0.018316444009542465,
-0.03995608165860176,
-0.017665408551692963,
-0.00125227146781981,
-0.010999582707881927,
0.01019307691603899,
0.01257372833788395,
-0.027576692402362823,
-0.010970432311296463,
0.03107479400932789,
-0.000737880589440465,
0.02411746047437191,
-0.01840389519929886,
0.011689485982060432,
-0.011815806850790977,
-0.04011155292391777,
-0.0519273616373539,
-0.02606084942817688,
-0.048118315637111664,
-0.06125563010573387,
-0.008720959536731243,
-0.018792573362588882,
0.022776521742343903,
0.02207690104842186,
0.04664134234189987,
0.02571103908121586,
0.08496497571468353
]
|
30,568 | networkx.algorithms.shortest_paths.weighted | dijkstra_predecessor_and_distance | Compute weighted shortest path length and predecessors.
Uses Dijkstra's Method to obtain the shortest weighted paths
and return dictionaries of predecessors for each node and
distance for each node from the `source`.
Parameters
----------
G : NetworkX graph
source : node label
Starting node for path
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
weight : string or function
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number or None to indicate a hidden edge.
Returns
-------
pred, distance : dictionaries
Returns two dictionaries representing a list of predecessors
of a node and the distance to each node.
Raises
------
NodeNotFound
If `source` is not in `G`.
Notes
-----
Edge weight attributes must be numerical.
Distances are calculated as sums of weighted edges traversed.
The list of predecessors contains more than one element only when
there are more than one shortest paths to the key node.
Examples
--------
>>> G = nx.path_graph(5, create_using=nx.DiGraph())
>>> pred, dist = nx.dijkstra_predecessor_and_distance(G, 0)
>>> sorted(pred.items())
[(0, []), (1, [0]), (2, [1]), (3, [2]), (4, [3])]
>>> sorted(dist.items())
[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
>>> pred, dist = nx.dijkstra_predecessor_and_distance(G, 0, 1)
>>> sorted(pred.items())
[(0, []), (1, [0])]
>>> sorted(dist.items())
[(0, 0), (1, 1)]
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, source, cutoff=None, weight='weight', *, backend=None, **backend_kwargs) | [
0.008711859583854675,
-0.0040741185657680035,
-0.03422551229596138,
-0.044156935065984726,
-0.03894828259944916,
-0.02178693749010563,
-0.01075742207467556,
0.04050310328602791,
0.07358193397521973,
-0.01058250479400158,
-0.05282506346702576,
0.02973596379160881,
0.0286670234054327,
0.025537945330142975,
-0.027306554839015007,
0.03587750717997551,
0.00003505561107886024,
0.03599411994218826,
-0.0012754396302625537,
0.013740736059844494,
-0.015033181756734848,
-0.056478895246982574,
0.055546000599861145,
0.04955993965268135,
-0.020990092307329178,
-0.009226894937455654,
0.014858264476060867,
-0.040075525641441345,
-0.025712862610816956,
-0.01636449806392193,
0.017754118889570236,
-0.01871616579592228,
-0.006243580486625433,
-0.005539052188396454,
0.01652969792485237,
0.05861677601933479,
0.007871284149587154,
-0.003014896297827363,
-0.023361194878816605,
-0.04404032230377197,
-0.030163539573550224,
-0.030435632914304733,
0.005786851514130831,
-0.03778216615319252,
0.08007331192493439,
0.08380488306283951,
-0.01747230812907219,
0.008658412843942642,
-0.019396400079131126,
-0.018832776695489883,
0.01519838161766529,
0.0014904423151165247,
-0.009290059097111225,
0.009557293727993965,
-0.007856708019971848,
0.039453599601984024,
-0.033273182809352875,
0.0542244054377079,
0.027306554839015007,
-0.038248613476753235,
0.039492469280958176,
0.010572787374258041,
0.07086099684238434,
0.040036655962467194,
-0.06378655880689621,
-0.02365272305905819,
-0.046566907316446304,
-0.03752950578927994,
-0.040036655962467194,
0.021417668089270592,
0.0010452531278133392,
-0.009528141468763351,
-0.013468642719089985,
-0.03552767261862755,
-0.0019204476848244667,
0.03801538795232773,
-0.000011606121006479952,
-0.034828003495931625,
0.011116974987089634,
-0.03984230384230614,
0.043845970183610916,
-0.056478895246982574,
-0.025810038670897484,
-0.07101647555828094,
0.07299887388944626,
0.025129804387688637,
-0.004052253905683756,
0.002684496808797121,
-0.00906655378639698,
-0.03410889953374863,
-0.036693789064884186,
0.03080490417778492,
-0.0033380077220499516,
0.0004321310843806714,
0.056789860129356384,
0.026781802996993065,
0.009090847335755825,
-0.05706195533275604,
0.049948643893003464,
0.03111586719751358,
0.06841215491294861,
0.004851529374718666,
-0.014518147334456444,
0.03613016754388809,
0.02645140327513218,
-0.06720716506242752,
-0.010990645736455917,
0.015849463641643524,
-0.013925370760262012,
-0.05562374368309975,
-0.022680960595607758,
0.012389984913170338,
0.025946086272597313,
-0.026742931455373764,
0.023458370938897133,
0.003231113776564598,
0.0067343213595449924,
0.04400145262479782,
-0.0005332552245818079,
-0.021126138046383858,
-0.025226980447769165,
0.0525529719889164,
-0.08310521394014359,
-0.003957506734877825,
0.040386490523815155,
-0.05636228248476982,
0.024741098284721375,
-0.01996002346277237,
0.06627427041530609,
0.017929036170244217,
0.026101568713784218,
0.004807800054550171,
-0.02787017822265625,
0.06561347097158432,
0.03197101876139641,
-0.024605052545666695,
-0.05667324736714363,
0.04683900251984596,
0.06503041088581085,
0.010427022352814674,
0.042524371296167374,
-0.07544771581888199,
0.007730378769338131,
0.028783636167645454,
0.005869451444596052,
-0.028511540964245796,
0.011107256636023521,
0.014090570621192455,
0.031232479959726334,
0.05974401906132698,
0.015421886928379536,
0.0028958553448319435,
0.006860650610178709,
0.011651444248855114,
0.001658071530982852,
-0.0681789293885231,
-0.041980184614658356,
0.02044590376317501,
0.00581114599481225,
-0.0005238412413746119,
0.016646308824419975,
-0.04458450898528099,
0.005738263484090567,
0.014887416735291481,
-0.04987090453505516,
0.0349251814186573,
0.022156208753585815,
0.052125394344329834,
-0.02711220271885395,
0.012399702332913876,
-0.005937475245445967,
-0.06409752368927002,
-0.047771893441677094,
-0.02915290556848049,
-0.02444957010447979,
0.003333148779347539,
0.025149239227175713,
-0.0023419500794261694,
0.011874950490891933,
-0.019435269758105278,
0.00988769344985485,
-0.02666519023478031,
0.0232057124376297,
-0.013556101359426975,
0.030066363513469696,
0.02915290556848049,
0.022253384813666344,
-0.021612020209431648,
0.003002749290317297,
0.034828003495931625,
-0.048160601407289505,
-0.09336704015731812,
-0.06067691370844841,
0.08310521394014359,
-0.009090847335755825,
0.006705168168991804,
-0.037276849150657654,
-0.022214513272047043,
-0.027267683297395706,
0.06378655880689621,
-0.009163729846477509,
-0.029327822849154472,
0.03988117352128029,
-0.008852765895426273,
0.009294917806982994,
-0.028841940686106682,
-0.0324569009244442,
0.00858067162334919,
0.000982088502496481,
0.0185412485152483,
-0.03506122902035713,
-0.04540079087018967,
0.029969187453389168,
-0.02969709224998951,
0.001222599996253848,
0.013769889250397682,
-0.031757231801748276,
0.040036655962467194,
0.014061418361961842,
-0.05908322334289551,
-0.004470112267881632,
-0.01526640448719263,
-0.00951356440782547,
0.021223315969109535,
0.06184303015470505,
-0.050259608775377274,
0.04707222431898117,
0.03066885657608509,
0.02586834505200386,
-0.07327096909284592,
0.07723576575517654,
-0.032787300646305084,
0.09632120281457901,
-0.014848546124994755,
0.07381515949964523,
-0.04788850620388985,
0.003493489930406213,
0.040775198489427567,
0.04555627331137657,
0.0279090479016304,
-0.021670326590538025,
-0.023438936099410057,
-0.014654194004833698,
-0.05815032869577408,
0.005777134094387293,
-0.00010864012438105419,
0.03152401000261307,
-0.012312243692576885,
0.02614043839275837,
-0.006520533002912998,
0.005082323215901852,
0.02773413062095642,
-0.04233001917600632,
-0.05748952925205231,
-0.012943889945745468,
-0.043224040418863297,
-0.021048396825790405,
-0.03756837919354439,
-0.036557745188474655,
-0.06592443585395813,
-0.03226254880428314,
-0.02783130668103695,
-0.06091013550758362,
0.10152985155582428,
-0.0039405012503266335,
0.03259294852614403,
0.03111586719751358,
-0.014304358512163162,
-0.08022879809141159,
0.00665658013895154,
0.04267985373735428,
0.04310742765665054,
-0.00683635612949729,
-0.00356151326559484,
-0.025129804387688637,
0.005164923146367073,
-0.032204244285821915,
0.03488631173968315,
0.012788407504558563,
-0.023050229996442795,
-0.04372935742139816,
-0.008357166312634945,
-0.04120277240872383,
-0.006501097697764635,
0.01799705997109413,
0.029677657410502434,
0.012127608992159367,
-0.03475026413798332,
0.01644223928451538,
0.006700309459120035,
0.07012245804071426,
-0.012127608992159367,
0.010563069023191929,
-0.03778216615319252,
0.06223173439502716,
0.04761641100049019,
-0.003476483980193734,
-0.07292113453149796,
0.016413085162639618,
0.05360247567296028,
0.015421886928379536,
-0.02569342777132988,
0.025635121390223503,
-0.005679957568645477,
-0.04271872341632843,
0.0082940012216568,
0.03121304325759411,
-0.016811508685350418,
-0.0026189025957137346,
-0.030921515077352524,
-0.021398233249783516,
-0.025149239227175713,
0.0017455301713198423,
0.007336814422160387,
0.003641683841124177,
-0.03725741431117058,
-0.03511953353881836,
0.007399979047477245,
-0.006812062114477158,
0.03222367912530899,
-0.038967717438936234,
0.07641948014497757,
-0.0682566687464714,
0.02921121194958687,
-0.03045506775379181,
0.029269516468048096,
0.03177666664123535,
0.025635121390223503,
0.03511953353881836,
0.0224866084754467,
0.03785990551114082,
0.022525478154420853,
0.02617930993437767,
0.030824339017271996,
-0.019804541021585464,
0.0897132083773613,
0.07435934245586395,
-0.005446734372526407,
0.0000587233662372455,
-0.0031873842235654593,
0.04738318920135498,
0.02178693749010563,
-0.022078467532992363,
0.023749900981783867,
0.006097815930843353,
-0.043845970183610916,
0.03395341709256172,
-0.038967717438936234,
0.007424273062497377,
-0.04742205888032913,
0.021845243871212006,
0.06790683418512344,
0.018327459692955017,
0.026509707793593407,
0.050609443336725235,
0.003138796193525195,
-0.010990645736455917,
-0.040697455406188965,
0.02231168933212757,
-0.004885541275143623,
0.008386319503188133,
0.018123390153050423,
0.009115141816437244,
-0.002976025687530637,
-0.046255942434072495,
0.01360468938946724,
0.01938668265938759,
-0.013352030888199806,
-0.01826915331184864,
-0.050609443336725235,
-0.008434907533228397,
-0.06059917435050011,
-0.02507149800658226,
0.05546826124191284,
0.012040150351822376,
0.00047009059926494956,
0.016413085162639618,
-0.007404837757349014,
-0.003542077960446477,
0.044118061661720276,
-0.02196185477077961,
0.057411789894104004,
0.005266958381980658,
0.045983850955963135,
0.02489658072590828,
-0.04128051549196243,
0.06639088690280914,
0.007361108437180519,
0.033720195293426514,
0.006360192317515612,
-0.024643922224640846,
-0.017802707850933075,
0.044390156865119934,
0.028608717024326324,
-0.0026359085459262133,
-0.0417080894112587,
0.07187163084745407,
0.030260715633630753,
-0.050609443336725235,
-0.025013193488121033,
0.0158300269395113,
-0.02124275080859661,
-0.055273909121751785,
0.06911182403564453,
0.009678764268755913,
-0.04765528440475464,
0.04590610787272453,
0.0279090479016304,
0.025907214730978012,
0.04858817532658577,
-0.0417858324944973,
-0.0024099734146147966,
-0.014683346264064312,
0.01716134324669838,
-0.04392370954155922,
-0.05884999781847,
-0.06845102459192276,
0.04217453673481941,
0.05667324736714363,
0.003027043305337429,
0.03661604970693588,
-0.029366692528128624,
0.06398090720176697,
-0.08287199586629868,
0.012185914441943169,
-0.04334065318107605,
-0.012992477975785732,
-0.027967354282736778,
-0.0009237827034667134,
0.05084266886115074,
-0.024857711046934128,
-0.023633288219571114,
0.03933698683977127,
-0.05511842668056488,
-0.007093873806297779,
-0.005223229061812162,
0.016199298202991486,
0.0024828556925058365,
0.07198823988437653,
-0.0341283343732357,
-0.009387235157191753,
-0.027773000299930573,
-0.026198744773864746,
-0.02707333117723465,
-0.05208652466535568,
-0.0791015475988388,
0.02054307982325554,
-0.02279757149517536,
0.03084377385675907,
-0.035935815423727036,
0.007030709180980921,
-0.03877336531877518,
0.021223315969109535,
0.023127971217036247,
-0.02600439079105854,
0.024974321946501732,
0.016063250601291656,
0.010213234461843967,
-0.11972126364707947,
0.027092766016721725,
0.05080379545688629,
-0.03185440972447395,
0.028569847345352173,
-0.012010997161269188,
-0.04788850620388985,
0.059238702058792114,
0.03432268649339676,
0.0010580074740573764,
-0.0006626212270930409,
-0.02596552111208439,
0.045361921191215515,
-0.010796292684972286,
-0.08551518619060516,
-0.0059277573600411415,
0.022350560873746872,
-0.0042028771713376045,
-0.0635533332824707,
0.01479995809495449,
0.0022180501837283373,
-0.016724050045013428,
0.040775198489427567,
-0.040114399045705795,
0.06701280921697617,
-0.007803260814398527,
0.005422440357506275,
-0.05507955700159073,
0.03912319988012314,
-0.019658776000142097,
0.014479276724159718,
0.0029638786800205708,
0.040697455406188965,
-0.06281479448080063,
0.06946165859699249,
-0.031232479959726334,
-0.003981801215559244,
0.04275759309530258,
0.0331760048866272,
-0.016519980505108833,
0.08077298104763031,
-0.013420053757727146,
0.0026359085459262133,
-0.010475610382854939,
-0.05480746179819107,
0.059549666941165924,
0.03395341709256172,
0.015334428288042545,
0.01453758217394352,
0.04897687956690788,
-0.025712862610816956,
0.026431968435645103,
0.017268236726522446,
0.0029517316725105047,
0.04703335464000702,
0.05511842668056488,
0.04578949511051178,
-0.007808119989931583,
-0.006748897489160299,
0.06891746819019318,
0.0022131914738565683,
-0.02240886725485325,
0.0433795228600502,
0.06223173439502716,
-0.01555793359875679,
0.027714695781469345,
-0.07435934245586395,
0.03525558114051819,
0.004331635776907206,
-0.047499801963567734,
0.02310853637754917,
0.00411298917606473,
0.010922621935606003,
0.03373963013291359,
-0.00042089508497156203,
0.02689841389656067,
0.018463507294654846,
0.014401535503566265,
0.05612906068563461,
-0.01871616579592228,
-0.014663911424577236,
-0.017054449766874313,
0.05947192758321762,
0.00025569528224878013,
-0.004623164888471365,
-0.005752840079367161,
0.07000584155321121,
-0.005150346551090479,
-0.002190111903473735,
-0.008075354620814323,
-0.00024400374968536198,
-0.05099814757704735,
-0.021942419931292534,
-0.0024111883249133825,
0.007157038431614637,
0.05208652466535568,
0.0696948766708374,
-0.009741929359734058,
0.014207182452082634,
0.009343505837023258,
0.006617709528654814,
0.08504874259233475,
-0.02542133443057537,
-0.08528196811676025,
-0.04617820307612419,
-0.01689896732568741,
-0.0154704749584198,
-0.030571680516004562,
0.015703698620200157,
-0.012788407504558563,
0.001350751263089478,
-0.006428215652704239,
-0.029716528952121735,
0.04058084264397621,
-0.005704252049326897,
0.026334790512919426,
-0.028414364904165268,
-0.00791015475988388,
-0.02635422721505165,
-0.04520643875002861,
0.023244583979249,
-0.050959277898073196,
-0.017812425270676613,
0.021223315969109535,
0.06300914287567139,
0.05193104222416878,
0.02538246288895607,
-0.002112370915710926,
-0.052203137427568436,
0.004129995126277208,
-0.0480051189661026,
0.010475610382854939,
0.010737987235188484,
-0.053408123552799225,
0.014343229122459888,
0.037898775190114975,
0.011350197717547417,
-0.055895838886499405,
-0.019658776000142097,
0.017239084467291832,
0.03148513659834862,
-0.0031169315334409475,
-0.09313381463289261,
-0.009858541190624237,
0.006914097350090742,
-0.006151263136416674,
0.03121304325759411,
-0.014906852506101131,
-0.006267874501645565,
-0.08714774996042252,
-0.015081769786775112,
-0.0510370209813118,
0.01996002346277237,
0.013536665588617325,
0.025907214730978012,
-0.024741098284721375,
-0.029619351029396057,
-0.0076574962586164474,
-0.009853682480752468,
0.016111839562654495,
-0.029930315911769867,
-0.035935815423727036,
0.015227533876895905,
-0.03970625624060631,
0.01996002346277237,
-0.01264264341443777,
0.0028594140894711018,
0.038520704954862595,
-0.002425764687359333,
0.01938668265938759,
-0.060482561588287354,
0.03300108760595322,
-0.02178693749010563,
-0.04901575297117233,
0.04462337866425514,
0.05379682779312134,
-0.02254491299390793,
-0.015898050740361214,
0.06930617243051529,
-0.010495046153664589,
-0.015217816457152367,
-0.011923538520932198,
-0.03486687317490578,
0.044079191982746124,
-0.02130105532705784,
-0.03338979557156563,
-0.035935815423727036,
-0.004375365097075701,
-0.00386761873960495,
-0.02254491299390793,
0.00951356440782547,
0.0007494725869037211,
-0.00575769878923893,
-0.01526640448719263,
-0.03049393929541111,
0.006778050679713488,
0.020426468923687935,
0.07284339517354965,
-0.018774470314383507,
-0.034167204052209854,
0.012147043831646442,
0.012584337033331394,
0.0325346440076828,
0.054030049592256546,
0.06930617243051529,
-0.043845970183610916,
-0.03743233159184456,
-0.013050784356892109,
0.017579201608896255,
-0.06215399503707886,
-0.017948472872376442,
0.007686649449169636,
-0.06409752368927002,
-0.01142793893814087,
0.008517507463693619,
0.016257602721452713,
-0.032865043729543686,
-0.060482561588287354,
0.026840107515454292,
-0.0041470006108284,
-0.07579755038022995,
-0.06771247833967209,
0.04302968829870224,
0.04610045999288559,
0.025013193488121033,
-0.013089654967188835,
-0.01160285621881485,
0.053757958114147186,
-0.05193104222416878,
-0.08403810858726501,
0.0349251814186573,
0.014207182452082634,
0.01992115192115307,
-0.03457534685730934,
0.040386490523815155,
0.008775024674832821,
-0.03813200071454048,
-0.05138685554265976,
-0.0025022909976541996,
-0.01996002346277237,
0.03080490417778492,
-0.03597468510270119,
0.020426468923687935,
0.05333038046956062,
0.008099649101495743,
-0.030105233192443848,
-0.01113640982657671,
-0.03146570175886154,
-0.0803842768073082,
0.0386761873960495,
0.022972488775849342,
0.009785658679902554,
-0.036246780306100845,
-0.030260715633630753,
-0.013935089111328125,
0.026820672675967216,
0.01151539757847786,
-0.014897135086357594,
0.020737433806061745,
-0.013041066005825996,
-0.01246772613376379,
-0.0026383379008620977,
0.014527864754199982,
-0.02365272305905819,
-0.0032456901390105486,
0.02858928218483925,
-0.08846934884786606,
-0.0008253916166722775,
0.02341950125992298,
-0.0834939181804657,
0.0020540652330964804,
-0.017929036170244217,
-0.0262764859944582,
0.08815838396549225,
0.009848822839558125,
0.032068196684122086,
0.004839382134377956,
-0.014576452784240246,
0.02528528682887554,
-0.014955440536141396,
-0.009839105419814587,
0.059938374906778336,
-0.02652914449572563,
0.018327459692955017,
-0.03992004692554474,
-0.01769581437110901,
-0.0013155248016119003,
-0.010961492545902729,
0.010154929012060165,
0.012584337033331394,
-0.02755921334028244,
-0.010893468745052814,
0.031038125976920128,
-0.0006869153585284948,
0.024119170382618904,
-0.01840520091354847,
0.011719468049705029,
-0.011855514720082283,
-0.040114399045705795,
-0.05193104222416878,
-0.026062697172164917,
-0.048160601407289505,
-0.06122110038995743,
-0.008711859583854675,
-0.01876475289463997,
0.02279757149517536,
0.022078467532992363,
0.046644650399684906,
0.025712862610816956,
0.08497100323438644
]
|
30,571 | networkx.generators.degree_seq | directed_configuration_model | Returns a directed_random graph with the given degree sequences.
The configuration model generates a random directed pseudograph
(graph with parallel edges and self loops) by randomly assigning
edges to match the given degree sequences.
Parameters
----------
in_degree_sequence : list of nonnegative integers
Each list entry corresponds to the in-degree of a node.
out_degree_sequence : list of nonnegative integers
Each list entry corresponds to the out-degree of a node.
create_using : NetworkX graph constructor, optional (default MultiDiGraph)
Graph type to create. If graph instance, then cleared before populated.
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
Returns
-------
G : MultiDiGraph
A graph with the specified degree sequences.
Nodes are labeled starting at 0 with an index
corresponding to the position in deg_sequence.
Raises
------
NetworkXError
If the degree sequences do not have the same sum.
See Also
--------
configuration_model
Notes
-----
Algorithm as described by Newman [1]_.
A non-graphical degree sequence (not realizable by some simple
graph) is allowed since this function returns graphs with self
loops and parallel edges. An exception is raised if the degree
sequences does not have the same sum.
This configuration model construction process can lead to
duplicate edges and loops. You can remove the self-loops and
parallel edges (see below) which will likely result in a graph
that doesn't have the exact degree sequence specified. This
"finite-size effect" decreases as the size of the graph increases.
References
----------
.. [1] Newman, M. E. J. and Strogatz, S. H. and Watts, D. J.
Random graphs with arbitrary degree distributions and their applications
Phys. Rev. E, 64, 026118 (2001)
Examples
--------
One can modify the in- and out-degree sequences from an existing
directed graph in order to create a new directed graph. For example,
here we modify the directed path graph:
>>> D = nx.DiGraph([(0, 1), (1, 2), (2, 3)])
>>> din = list(d for n, d in D.in_degree())
>>> dout = list(d for n, d in D.out_degree())
>>> din.append(1)
>>> dout[0] = 2
>>> # We now expect an edge from node 0 to a new node, node 3.
... D = nx.directed_configuration_model(din, dout)
The returned graph is a directed multigraph, which may have parallel
edges. To remove any parallel edges from the returned graph:
>>> D = nx.DiGraph(D)
Similarly, to remove self-loops:
>>> D.remove_edges_from(nx.selfloop_edges(D))
| def generate(self):
# remaining_degree is mapping from int->remaining degree
self.remaining_degree = dict(enumerate(self.degree))
# add all nodes to make sure we get isolated nodes
self.graph = nx.Graph()
self.graph.add_nodes_from(self.remaining_degree)
# remove zero degree nodes
for n, d in list(self.remaining_degree.items()):
if d == 0:
del self.remaining_degree[n]
if len(self.remaining_degree) > 0:
# build graph in three phases according to how many unmatched edges
self.phase1()
self.phase2()
self.phase3()
return self.graph
| (in_degree_sequence, out_degree_sequence, create_using=None, seed=None, *, backend=None, **backend_kwargs) | [
-0.02255886048078537,
0.003668749937787652,
-0.030325323343276978,
-0.0212223082780838,
-0.01601155288517475,
0.04858553782105446,
-0.0715959370136261,
-0.03926578536629677,
0.03426273912191391,
-0.03131870925426483,
0.03233015537261963,
0.08040996640920639,
-0.03393762931227684,
0.04031335189938545,
-0.013699676841497421,
0.005079807713627815,
0.023931538686156273,
0.013654522597789764,
-0.014386015012860298,
0.0017056865617632866,
-0.019199416041374207,
-0.01542455330491066,
-0.0069807847030460835,
0.033522214740514755,
-0.03399181365966797,
-0.005007561296224594,
-0.0168333537876606,
0.0133745688945055,
-0.028970707207918167,
-0.01807056926190853,
-0.0585193857550621,
0.0013083326630294323,
-0.027164554223418236,
0.0043392847292125225,
0.013519061729311943,
0.04645427688956261,
-0.018693692982196808,
0.02680332213640213,
-0.051836613565683365,
0.029530614614486694,
0.09702658653259277,
-0.02931387722492218,
-0.035834092646837234,
0.015569046139717102,
-0.023931538686156273,
-0.03084910660982132,
0.039807628840208054,
0.037567999213933945,
-0.0005875644274055958,
-0.07845932245254517,
0.021294552832841873,
-0.018025415018200874,
0.009455215185880661,
0.015442615374922752,
0.010764677077531815,
0.015135569497942924,
-0.010891107842326164,
0.0168965682387352,
0.08337206393480301,
0.021457107737660408,
-0.020861076191067696,
-0.012706291861832142,
0.0003677216300275177,
-0.0006699701771140099,
-0.029422245919704437,
0.020933322608470917,
-0.04891064763069153,
-0.02441919967532158,
0.009536492638289928,
0.05664098262786865,
0.05093353986740112,
-0.012868845835328102,
0.05129477009177208,
-0.0021211018320173025,
0.053498275578022,
-0.01966901496052742,
0.009563584811985493,
-0.027670277282595634,
0.020535968244075775,
-0.03001827746629715,
-0.0318966768682003,
-0.003429434495046735,
-0.021059753373265266,
-0.0015307153807953,
0.05317316949367523,
0.038471076637506485,
0.0027543846517801285,
-0.04215563088655472,
-0.03807372227311134,
-0.050680678337812424,
-0.019127169623970985,
-0.02718261443078518,
-0.004822430666536093,
0.012652107514441013,
0.03825433924794197,
-0.01696881465613842,
-0.038218215107917786,
-0.05205335468053818,
0.03966313973069191,
-0.023028461262583733,
-0.01735713891685009,
0.025412583723664284,
-0.14376984536647797,
0.03413630649447441,
0.02236018516123295,
-0.06567175686359406,
-0.004133834503591061,
-0.044973231852054596,
0.03561735525727272,
-0.010213799774646759,
-0.049849845468997955,
0.04685163125395775,
0.07199329137802124,
0.040204983204603195,
-0.010638246312737465,
0.02064433880150318,
-0.001000722055323422,
-0.02077076956629753,
0.02584606222808361,
0.021005569025874138,
-0.033648647367954254,
0.023498062044382095,
-0.018729815259575844,
0.057038336992263794,
0.0030659460462629795,
0.02263110689818859,
0.015632260590791702,
-0.030505938455462456,
0.06899507343769073,
-0.05230621621012688,
0.05497932434082031,
0.0054771616123616695,
0.025936368852853775,
-0.0079109538346529,
-0.0660691037774086,
-0.012751446105539799,
-0.016923662275075912,
-0.042011138051748276,
0.022540800273418427,
0.051511507481336594,
-0.01269726175814867,
-0.03959089145064354,
0.009879661723971367,
0.04800757020711899,
0.01015961542725563,
0.044323015958070755,
-0.007305892184376717,
0.008963038213551044,
-0.015776753425598145,
-0.03475039824843407,
0.02860947698354721,
-0.010213799774646759,
0.0092926612123847,
-0.002725034486502409,
-0.0069220843724906445,
0.023877354338765144,
-0.002171899890527129,
0.03299843147397041,
-0.05093353986740112,
-0.0022588211577385664,
-0.03749575465917587,
0.00277244602330029,
0.008877245709300041,
0.01742035336792469,
0.0016864961944520473,
-0.029801538214087486,
0.09659310430288315,
-0.05674935504794121,
-0.02557513862848282,
-0.0084482841193676,
-0.0384349524974823,
-0.04255298525094986,
-0.04461199790239334,
-0.02506941556930542,
-0.033847324550151825,
0.00722913071513176,
0.020283106714487076,
0.006574399769306183,
-0.004510869272053242,
0.05122252181172371,
0.0038313039112836123,
-0.0340459980070591,
-0.03720676898956299,
-0.029801538214087486,
0.039121292531490326,
-0.014223461039364338,
0.06285415589809418,
0.005571984685957432,
0.05497932434082031,
-0.05057230591773987,
-0.039879877120256424,
0.007450384553521872,
0.05266744643449783,
0.08575618267059326,
0.0801209807395935,
-0.01735713891685009,
0.028970707207918167,
0.06567175686359406,
-0.06765852123498917,
0.05111415311694145,
0.03231209143996239,
-0.010529876686632633,
0.02416633814573288,
-0.03810984641313553,
-0.025033291429281235,
0.02062627673149109,
-0.02944030798971653,
-0.009328784421086311,
0.011839338578283787,
0.03375701606273651,
-0.015207814984023571,
-0.002542161615565419,
0.07105409353971481,
0.009816446341574192,
-0.05378726124763489,
0.0012010922655463219,
0.02030116878449917,
0.01400672271847725,
0.013771923258900642,
-0.04125255346298218,
-0.04659876972436905,
0.0033052614890038967,
-0.006583430804312229,
-0.07701440155506134,
-0.01278756931424141,
-0.032564952969551086,
-0.034172430634498596,
-0.0439617857336998,
-0.10555163025856018,
0.0010515202302485704,
0.06913956999778748,
-0.03413630649447441,
-0.03599664568901062,
-0.012345061637461185,
0.02441919967532158,
0.0298918467015028,
-0.01779964566230774,
-0.005404915194958448,
-0.013329415582120419,
0.031986985355615616,
-0.04338381439447403,
-0.056785475462675095,
0.009319753386080265,
0.03361252322793007,
0.046887755393981934,
0.06473255157470703,
0.021583538502454758,
-0.03626756742596626,
0.0071478537283837795,
0.03702615201473236,
-0.04840492457151413,
-0.05161987617611885,
-0.026532400399446487,
-0.022071199491620064,
0.006452484522014856,
-0.05270357057452202,
-0.02217956818640232,
-0.03901292383670807,
0.03541867807507515,
0.013284261338412762,
0.021258430555462837,
0.051583752036094666,
-0.08662313967943192,
0.026279538869857788,
0.03469621390104294,
-0.002618923084810376,
-0.003944188356399536,
0.014729184098541737,
-0.053245414048433304,
-0.007938046008348465,
0.01066533848643303,
0.052739690989255905,
0.016417939215898514,
-0.00970807671546936,
0.036213383078575134,
-0.018025415018200874,
0.0119928615167737,
0.04851329326629639,
-0.04280584678053856,
0.02192670665681362,
-0.04616529121994972,
0.011685815639793873,
-0.0012112519470974803,
-0.0007399586611427367,
-0.06578012555837631,
0.0482243075966835,
0.009843538515269756,
-0.03836270794272423,
0.029476430267095566,
-0.061228614300489426,
0.0012022211449220777,
0.00819993857294321,
-0.014548568986356258,
0.04009661450982094,
0.09435347467660904,
-0.01416927669197321,
-0.003896776819601655,
-0.004876615479588509,
0.0010385384084656835,
0.064046211540699,
0.06245679780840874,
-0.020843015983700752,
0.0017361653735861182,
-0.03523806110024452,
-0.0029349999967962503,
-0.005815815180540085,
0.02584606222808361,
0.0011954481014981866,
0.044648122042417526,
0.011351676657795906,
-0.06303476542234421,
-0.01407896913588047,
0.09290855377912521,
0.02024698443710804,
0.02115006186068058,
-0.04356443136930466,
-0.013546153903007507,
-0.04410627484321594,
0.06729729473590851,
0.05487095192074776,
0.0017903499538078904,
0.05302867665886879,
-0.06451581418514252,
0.014069938100874424,
-0.0869121253490448,
0.04742959886789322,
0.037820860743522644,
0.037062276154756546,
-0.00176438654307276,
-0.04757409170269966,
-0.056207507848739624,
-0.0014291192637756467,
-0.0161379836499691,
0.031210338696837425,
-0.07018713653087616,
0.02049984596669674,
0.09103015065193176,
-0.04854941368103027,
0.0037184192333370447,
-0.015993492677807808,
0.09876049309968948,
0.007287830580025911,
-0.05082516744732857,
0.029548676684498787,
0.0067595308646559715,
-0.009166230447590351,
0.030325323343276978,
-0.04197501391172409,
-0.022161507979035378,
0.010909168981015682,
-0.020427599549293518,
0.09160812199115753,
-0.0060867383144795895,
0.06520215421915054,
0.04735735431313515,
0.0444675087928772,
0.01166775356978178,
0.009726138785481453,
-0.05086129158735275,
0.030162768438458443,
-0.010764677077531815,
0.016417939215898514,
-0.02949449233710766,
0.048043690621852875,
-0.011198153719305992,
-0.047863077372312546,
0.04208338260650635,
0.05895286053419113,
0.03388344496488571,
-0.021944768726825714,
0.00180728267878294,
-0.04273359850049019,
-0.043347690254449844,
0.022902030497789383,
-0.01108978409320116,
0.02597249299287796,
0.007960623130202293,
0.004361861385405064,
0.06780301779508591,
-0.035906337201595306,
-0.026189230382442474,
-0.004835976753383875,
-0.0041880193166434765,
0.024780429899692535,
0.01677916944026947,
-0.03299843147397041,
0.06653870642185211,
0.006271869409829378,
0.060144923627376556,
-0.015993492677807808,
0.0009138009627349675,
-0.03585215285420418,
0.025864122435450554,
-0.015532922931015491,
0.023118769749999046,
0.03079492226243019,
0.06928405910730362,
0.02268529124557972,
-0.040457844734191895,
-0.008583745919167995,
-0.017917046323418617,
-0.06570787727832794,
0.008746299892663956,
0.0555211678147316,
-0.00759939244017005,
-0.08221612125635147,
0.07802584767341614,
0.0391935370862484,
0.0597836934030056,
-0.037315137684345245,
-0.028591414913535118,
0.011658722534775734,
-0.00877339206635952,
0.0022497903555631638,
0.03411824628710747,
-0.05320929363369942,
0.013817076571285725,
-0.018928492441773415,
0.060831259936094284,
0.016445031389594078,
0.0600365549325943,
0.036610737442970276,
0.06538277119398117,
0.010385384783148766,
0.012688230723142624,
0.0270019993185997,
-0.02115006186068058,
0.01359130721539259,
-0.05082516744732857,
0.07246289402246475,
-0.01099044643342495,
-0.014963984489440918,
0.009897722862660885,
-0.050500061362981796,
0.01237215381115675,
-0.02409409172832966,
0.016083799302577972,
-0.018160875886678696,
-0.021294552832841873,
0.00555843859910965,
0.03574378415942192,
0.0028108269907534122,
0.024057969450950623,
-0.01979544572532177,
0.036664921790361404,
-0.011053661815822124,
-0.020337292924523354,
-0.015343276783823967,
-0.02763415314257145,
0.026207292452454567,
0.01665273867547512,
0.007188492454588413,
0.03135482966899872,
-0.020662399008870125,
-0.03760412335395813,
0.0821438729763031,
0.014449230395257473,
-0.04031335189938545,
-0.05519606173038483,
0.005219784565269947,
0.055882398039102554,
0.022414369508624077,
-0.03527418524026871,
0.06437132507562637,
-0.033269353210926056,
-0.014467292465269566,
-0.0007935788598842919,
0.0068453229032456875,
-0.04248073697090149,
0.00352877308614552,
0.004682453814893961,
0.0009657279006205499,
-0.019253600388765335,
-0.08965747803449631,
-0.008583745919167995,
-0.04154153913259506,
-0.02539452351629734,
-0.01916329190135002,
0.008177361451089382,
-0.054545845836400986,
-0.04417852312326431,
-0.007766461465507746,
0.003503938438370824,
0.034551721066236496,
-0.03886843100190163,
0.04024110734462738,
-0.01749259978532791,
-0.026731077581644058,
-0.03552704676985741,
-0.044503629207611084,
-0.060831259936094284,
-0.08171039819717407,
-0.03260107710957527,
0.013799015432596207,
0.01416927669197321,
0.0442146472632885,
-0.009762261062860489,
-0.03556316718459129,
-0.002192219253629446,
-0.02396766096353531,
-0.0016390846576541662,
0.0017768038669601083,
0.0069220843724906445,
0.02250467613339424,
0.017248768359422684,
0.006962723098695278,
-0.030614307150244713,
-0.03760412335395813,
0.011008507572114468,
0.03984375298023224,
0.03489489108324051,
0.007233646232634783,
-0.0013839653693139553,
0.04782695323228836,
0.0035829576663672924,
0.010015122592449188,
0.007314923219382763,
0.00035417548497207463,
-0.024798491969704628,
-0.009428123012185097,
0.010891107842326164,
0.02777864597737789,
0.006678253877907991,
0.03180636838078499,
-0.005048200022429228,
0.03760412335395813,
-0.0437089242041111,
-0.07018713653087616,
0.01407896913588047,
-0.010845953598618507,
0.03915741667151451,
0.0042241420596838,
0.005400400143116713,
0.09225833415985107,
-0.01639987714588642,
-0.0632876306772232,
0.0632876306772232,
-0.044828739017248154,
-0.06585236638784409,
-0.05064455419778824,
-0.002062401967123151,
0.007545207627117634,
-0.009473277255892754,
-0.02017473801970482,
0.0010848211823031306,
0.00938296876847744,
0.0836610421538353,
-0.016092831268906593,
0.03498519957065582,
-0.029982153326272964,
-0.030126646161079407,
0.045804060995578766,
-0.01761903055012226,
-0.05089741572737694,
0.12448012083768845,
-0.013672584667801857,
-0.02178221568465233,
0.0036168231163173914,
0.02873590774834156,
0.019434215500950813,
0.004736638627946377,
-0.038687814027071,
-0.06397397071123123,
-0.02680332213640213,
-0.003779376856982708,
-0.006497638300061226,
-0.01411509234458208,
-0.006181561388075352,
0.0038177575916051865,
0.04782695323228836,
0.008795969188213348,
-0.03431692346930504,
0.011162030510604382,
-0.019560646265745163,
0.006438938435167074,
-0.03984375298023224,
-0.00941909197717905,
0.022540800273418427,
0.01798929274082184,
-0.02564738504588604,
0.003783892374485731,
0.004551507532596588,
-0.014196368865668774,
-0.014431169256567955,
0.004133834503591061,
0.0244914460927248,
-0.04591242969036102,
0.02346193790435791,
0.0816381499171257,
0.002001444110646844,
-0.003926126752048731,
-0.04392566159367561,
0.0020522424019873142,
-0.002372834598645568,
-0.07426904886960983,
0.04685163125395775,
-0.030831046402454376,
-0.005179146304726601,
-0.04435913637280464,
-0.01672498509287834,
-0.050355568528175354,
0.07860381156206131,
0.017917046323418617,
0.09095790982246399,
-0.020734645426273346,
0.042589105665683746,
-0.016490183770656586,
0.010367322713136673,
-0.01734810695052147,
-0.018016384914517403,
0.0005503125139512122,
-0.004944345913827419,
-0.001317363465204835,
-0.04034947603940964,
-0.04074683040380478,
-0.04331156983971596,
-0.014069938100874424,
0.007328469306230545,
-0.03680941462516785,
-0.0037477691657841206,
-0.021041691303253174,
-0.012959153391420841,
-0.06408233940601349,
0.006944661494344473,
-0.004637300036847591,
0.022450491786003113,
0.055448923259973526,
-0.007174945902079344,
0.02487073838710785,
0.024148276075720787,
0.009563584811985493,
-0.05913347750902176,
-0.07499150931835175,
-0.019759323447942734,
-0.00002407617103017401,
-0.015280061401426792,
0.015704507008194923,
0.027399353682994843,
0.02539452351629734,
-0.02732710726559162,
-0.07528049498796463,
0.04034947603940964,
-0.05263132229447365,
-0.04750184714794159,
-0.057435691356658936,
-0.024599814787507057,
0.015090415254235268,
0.03393762931227684,
-0.01787189207971096,
-0.023353569209575653,
-0.01871175318956375,
0.00983450748026371,
0.06242067739367485,
-0.027868954464793205,
0.014936892315745354,
-0.007617453578859568,
0.015018168836832047,
0.00694014597684145,
0.04016886278986931,
-0.04042172431945801,
0.006339599844068289,
0.026694953441619873,
0.08770682662725449,
-0.0059422459453344345,
0.01817893795669079,
0.040204983204603195,
0.044900983572006226,
-0.03149932250380516,
-0.04222787544131279,
-0.013744831085205078,
-0.027941199019551277,
-0.04233624413609505,
0.0675862729549408,
0.013022368773818016,
-0.056532613933086395,
0.016562430188059807,
-0.011866430751979351,
0.0049398308619856834,
0.03614113852381706,
0.030451754108071327,
0.01723070815205574,
0.03231209143996239,
-0.022468553856015205,
-0.07293248921632767,
-0.009951907210052013,
-0.012390214949846268,
-0.042589105665683746,
-0.0384349524974823,
0.003991600126028061,
-0.002186574973165989,
-0.02956673875451088,
0.0022915576118975878,
0.057435691356658936,
0.006118346005678177,
0.0095455227419734,
0.02107781544327736,
-0.03169799968600273,
-0.017086215317249298,
0.02501523122191429,
-0.030162768438458443,
0.03720676898956299,
-0.0185853224247694,
-0.014467292465269566,
0.030162768438458443,
-0.006484092213213444,
-0.008665023371577263,
0.011279430240392685,
0.0061228615231812,
-0.035328369587659836,
0.01734810695052147,
-0.01453050784766674,
0.0023412269074469805,
-0.006944661494344473,
0.0482243075966835,
-0.011812246404588223,
-0.005883546080440283,
0.0033278383780270815,
0.07658091932535172,
-0.03027113899588585,
-0.024780429899692535,
-0.0018806576263159513,
0.016490183770656586,
-0.013166861608624458,
0.04602079838514328,
-0.02557513862848282,
0.04435913637280464,
0.0006750500178895891,
-0.046309784054756165,
-0.01844083145260811,
-0.019831569865345955,
-0.026315661147236824,
0.040710706263780594,
0.0037590577267110348,
-0.029024891555309296,
0.0037771190982311964,
-0.008028353564441204,
0.02017473801970482,
0.05830264464020729,
-0.022035077214241028,
0.033142924308776855,
-0.017898984253406525,
0.008294761180877686,
-0.02539452351629734,
0.03727901354432106,
0.007721307687461376,
-0.010430538095533848,
0.03193280100822449,
0.01734810695052147,
0.0033210653346031904,
0.010385384783148766,
0.028898460790514946,
-0.003591988468542695,
0.03160769119858742,
0.025484830141067505,
-0.04475649073719978,
-0.02301039919257164,
-0.01273338496685028,
-0.025231968611478806,
-0.027110369876027107,
-0.08611741662025452,
-0.03292618319392204,
-0.032745569944381714,
0.04453975334763527,
0.011875461786985397,
-0.01220959983766079,
0.04034947603940964,
0.06942855566740036,
-0.00469148438423872
]
|
30,573 | networkx.generators.degree_seq | directed_havel_hakimi_graph | Returns a directed graph with the given degree sequences.
Parameters
----------
in_deg_sequence : list of integers
Each list entry corresponds to the in-degree of a node.
out_deg_sequence : list of integers
Each list entry corresponds to the out-degree of a node.
create_using : NetworkX graph constructor, optional (default DiGraph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : DiGraph
A graph with the specified degree sequences.
Nodes are labeled starting at 0 with an index
corresponding to the position in deg_sequence
Raises
------
NetworkXError
If the degree sequences are not digraphical.
See Also
--------
configuration_model
Notes
-----
Algorithm as described by Kleitman and Wang [1]_.
References
----------
.. [1] D.J. Kleitman and D.L. Wang
Algorithms for Constructing Graphs and Digraphs with Given Valences
and Factors Discrete Mathematics, 6(1), pp. 79-88 (1973)
| def generate(self):
# remaining_degree is mapping from int->remaining degree
self.remaining_degree = dict(enumerate(self.degree))
# add all nodes to make sure we get isolated nodes
self.graph = nx.Graph()
self.graph.add_nodes_from(self.remaining_degree)
# remove zero degree nodes
for n, d in list(self.remaining_degree.items()):
if d == 0:
del self.remaining_degree[n]
if len(self.remaining_degree) > 0:
# build graph in three phases according to how many unmatched edges
self.phase1()
self.phase2()
self.phase3()
return self.graph
| (in_deg_sequence, out_deg_sequence, create_using=None, *, backend=None, **backend_kwargs) | [
-0.02255886048078537,
0.003668749937787652,
-0.030325323343276978,
-0.0212223082780838,
-0.01601155288517475,
0.04858553782105446,
-0.0715959370136261,
-0.03926578536629677,
0.03426273912191391,
-0.03131870925426483,
0.03233015537261963,
0.08040996640920639,
-0.03393762931227684,
0.04031335189938545,
-0.013699676841497421,
0.005079807713627815,
0.023931538686156273,
0.013654522597789764,
-0.014386015012860298,
0.0017056865617632866,
-0.019199416041374207,
-0.01542455330491066,
-0.0069807847030460835,
0.033522214740514755,
-0.03399181365966797,
-0.005007561296224594,
-0.0168333537876606,
0.0133745688945055,
-0.028970707207918167,
-0.01807056926190853,
-0.0585193857550621,
0.0013083326630294323,
-0.027164554223418236,
0.0043392847292125225,
0.013519061729311943,
0.04645427688956261,
-0.018693692982196808,
0.02680332213640213,
-0.051836613565683365,
0.029530614614486694,
0.09702658653259277,
-0.02931387722492218,
-0.035834092646837234,
0.015569046139717102,
-0.023931538686156273,
-0.03084910660982132,
0.039807628840208054,
0.037567999213933945,
-0.0005875644274055958,
-0.07845932245254517,
0.021294552832841873,
-0.018025415018200874,
0.009455215185880661,
0.015442615374922752,
0.010764677077531815,
0.015135569497942924,
-0.010891107842326164,
0.0168965682387352,
0.08337206393480301,
0.021457107737660408,
-0.020861076191067696,
-0.012706291861832142,
0.0003677216300275177,
-0.0006699701771140099,
-0.029422245919704437,
0.020933322608470917,
-0.04891064763069153,
-0.02441919967532158,
0.009536492638289928,
0.05664098262786865,
0.05093353986740112,
-0.012868845835328102,
0.05129477009177208,
-0.0021211018320173025,
0.053498275578022,
-0.01966901496052742,
0.009563584811985493,
-0.027670277282595634,
0.020535968244075775,
-0.03001827746629715,
-0.0318966768682003,
-0.003429434495046735,
-0.021059753373265266,
-0.0015307153807953,
0.05317316949367523,
0.038471076637506485,
0.0027543846517801285,
-0.04215563088655472,
-0.03807372227311134,
-0.050680678337812424,
-0.019127169623970985,
-0.02718261443078518,
-0.004822430666536093,
0.012652107514441013,
0.03825433924794197,
-0.01696881465613842,
-0.038218215107917786,
-0.05205335468053818,
0.03966313973069191,
-0.023028461262583733,
-0.01735713891685009,
0.025412583723664284,
-0.14376984536647797,
0.03413630649447441,
0.02236018516123295,
-0.06567175686359406,
-0.004133834503591061,
-0.044973231852054596,
0.03561735525727272,
-0.010213799774646759,
-0.049849845468997955,
0.04685163125395775,
0.07199329137802124,
0.040204983204603195,
-0.010638246312737465,
0.02064433880150318,
-0.001000722055323422,
-0.02077076956629753,
0.02584606222808361,
0.021005569025874138,
-0.033648647367954254,
0.023498062044382095,
-0.018729815259575844,
0.057038336992263794,
0.0030659460462629795,
0.02263110689818859,
0.015632260590791702,
-0.030505938455462456,
0.06899507343769073,
-0.05230621621012688,
0.05497932434082031,
0.0054771616123616695,
0.025936368852853775,
-0.0079109538346529,
-0.0660691037774086,
-0.012751446105539799,
-0.016923662275075912,
-0.042011138051748276,
0.022540800273418427,
0.051511507481336594,
-0.01269726175814867,
-0.03959089145064354,
0.009879661723971367,
0.04800757020711899,
0.01015961542725563,
0.044323015958070755,
-0.007305892184376717,
0.008963038213551044,
-0.015776753425598145,
-0.03475039824843407,
0.02860947698354721,
-0.010213799774646759,
0.0092926612123847,
-0.002725034486502409,
-0.0069220843724906445,
0.023877354338765144,
-0.002171899890527129,
0.03299843147397041,
-0.05093353986740112,
-0.0022588211577385664,
-0.03749575465917587,
0.00277244602330029,
0.008877245709300041,
0.01742035336792469,
0.0016864961944520473,
-0.029801538214087486,
0.09659310430288315,
-0.05674935504794121,
-0.02557513862848282,
-0.0084482841193676,
-0.0384349524974823,
-0.04255298525094986,
-0.04461199790239334,
-0.02506941556930542,
-0.033847324550151825,
0.00722913071513176,
0.020283106714487076,
0.006574399769306183,
-0.004510869272053242,
0.05122252181172371,
0.0038313039112836123,
-0.0340459980070591,
-0.03720676898956299,
-0.029801538214087486,
0.039121292531490326,
-0.014223461039364338,
0.06285415589809418,
0.005571984685957432,
0.05497932434082031,
-0.05057230591773987,
-0.039879877120256424,
0.007450384553521872,
0.05266744643449783,
0.08575618267059326,
0.0801209807395935,
-0.01735713891685009,
0.028970707207918167,
0.06567175686359406,
-0.06765852123498917,
0.05111415311694145,
0.03231209143996239,
-0.010529876686632633,
0.02416633814573288,
-0.03810984641313553,
-0.025033291429281235,
0.02062627673149109,
-0.02944030798971653,
-0.009328784421086311,
0.011839338578283787,
0.03375701606273651,
-0.015207814984023571,
-0.002542161615565419,
0.07105409353971481,
0.009816446341574192,
-0.05378726124763489,
0.0012010922655463219,
0.02030116878449917,
0.01400672271847725,
0.013771923258900642,
-0.04125255346298218,
-0.04659876972436905,
0.0033052614890038967,
-0.006583430804312229,
-0.07701440155506134,
-0.01278756931424141,
-0.032564952969551086,
-0.034172430634498596,
-0.0439617857336998,
-0.10555163025856018,
0.0010515202302485704,
0.06913956999778748,
-0.03413630649447441,
-0.03599664568901062,
-0.012345061637461185,
0.02441919967532158,
0.0298918467015028,
-0.01779964566230774,
-0.005404915194958448,
-0.013329415582120419,
0.031986985355615616,
-0.04338381439447403,
-0.056785475462675095,
0.009319753386080265,
0.03361252322793007,
0.046887755393981934,
0.06473255157470703,
0.021583538502454758,
-0.03626756742596626,
0.0071478537283837795,
0.03702615201473236,
-0.04840492457151413,
-0.05161987617611885,
-0.026532400399446487,
-0.022071199491620064,
0.006452484522014856,
-0.05270357057452202,
-0.02217956818640232,
-0.03901292383670807,
0.03541867807507515,
0.013284261338412762,
0.021258430555462837,
0.051583752036094666,
-0.08662313967943192,
0.026279538869857788,
0.03469621390104294,
-0.002618923084810376,
-0.003944188356399536,
0.014729184098541737,
-0.053245414048433304,
-0.007938046008348465,
0.01066533848643303,
0.052739690989255905,
0.016417939215898514,
-0.00970807671546936,
0.036213383078575134,
-0.018025415018200874,
0.0119928615167737,
0.04851329326629639,
-0.04280584678053856,
0.02192670665681362,
-0.04616529121994972,
0.011685815639793873,
-0.0012112519470974803,
-0.0007399586611427367,
-0.06578012555837631,
0.0482243075966835,
0.009843538515269756,
-0.03836270794272423,
0.029476430267095566,
-0.061228614300489426,
0.0012022211449220777,
0.00819993857294321,
-0.014548568986356258,
0.04009661450982094,
0.09435347467660904,
-0.01416927669197321,
-0.003896776819601655,
-0.004876615479588509,
0.0010385384084656835,
0.064046211540699,
0.06245679780840874,
-0.020843015983700752,
0.0017361653735861182,
-0.03523806110024452,
-0.0029349999967962503,
-0.005815815180540085,
0.02584606222808361,
0.0011954481014981866,
0.044648122042417526,
0.011351676657795906,
-0.06303476542234421,
-0.01407896913588047,
0.09290855377912521,
0.02024698443710804,
0.02115006186068058,
-0.04356443136930466,
-0.013546153903007507,
-0.04410627484321594,
0.06729729473590851,
0.05487095192074776,
0.0017903499538078904,
0.05302867665886879,
-0.06451581418514252,
0.014069938100874424,
-0.0869121253490448,
0.04742959886789322,
0.037820860743522644,
0.037062276154756546,
-0.00176438654307276,
-0.04757409170269966,
-0.056207507848739624,
-0.0014291192637756467,
-0.0161379836499691,
0.031210338696837425,
-0.07018713653087616,
0.02049984596669674,
0.09103015065193176,
-0.04854941368103027,
0.0037184192333370447,
-0.015993492677807808,
0.09876049309968948,
0.007287830580025911,
-0.05082516744732857,
0.029548676684498787,
0.0067595308646559715,
-0.009166230447590351,
0.030325323343276978,
-0.04197501391172409,
-0.022161507979035378,
0.010909168981015682,
-0.020427599549293518,
0.09160812199115753,
-0.0060867383144795895,
0.06520215421915054,
0.04735735431313515,
0.0444675087928772,
0.01166775356978178,
0.009726138785481453,
-0.05086129158735275,
0.030162768438458443,
-0.010764677077531815,
0.016417939215898514,
-0.02949449233710766,
0.048043690621852875,
-0.011198153719305992,
-0.047863077372312546,
0.04208338260650635,
0.05895286053419113,
0.03388344496488571,
-0.021944768726825714,
0.00180728267878294,
-0.04273359850049019,
-0.043347690254449844,
0.022902030497789383,
-0.01108978409320116,
0.02597249299287796,
0.007960623130202293,
0.004361861385405064,
0.06780301779508591,
-0.035906337201595306,
-0.026189230382442474,
-0.004835976753383875,
-0.0041880193166434765,
0.024780429899692535,
0.01677916944026947,
-0.03299843147397041,
0.06653870642185211,
0.006271869409829378,
0.060144923627376556,
-0.015993492677807808,
0.0009138009627349675,
-0.03585215285420418,
0.025864122435450554,
-0.015532922931015491,
0.023118769749999046,
0.03079492226243019,
0.06928405910730362,
0.02268529124557972,
-0.040457844734191895,
-0.008583745919167995,
-0.017917046323418617,
-0.06570787727832794,
0.008746299892663956,
0.0555211678147316,
-0.00759939244017005,
-0.08221612125635147,
0.07802584767341614,
0.0391935370862484,
0.0597836934030056,
-0.037315137684345245,
-0.028591414913535118,
0.011658722534775734,
-0.00877339206635952,
0.0022497903555631638,
0.03411824628710747,
-0.05320929363369942,
0.013817076571285725,
-0.018928492441773415,
0.060831259936094284,
0.016445031389594078,
0.0600365549325943,
0.036610737442970276,
0.06538277119398117,
0.010385384783148766,
0.012688230723142624,
0.0270019993185997,
-0.02115006186068058,
0.01359130721539259,
-0.05082516744732857,
0.07246289402246475,
-0.01099044643342495,
-0.014963984489440918,
0.009897722862660885,
-0.050500061362981796,
0.01237215381115675,
-0.02409409172832966,
0.016083799302577972,
-0.018160875886678696,
-0.021294552832841873,
0.00555843859910965,
0.03574378415942192,
0.0028108269907534122,
0.024057969450950623,
-0.01979544572532177,
0.036664921790361404,
-0.011053661815822124,
-0.020337292924523354,
-0.015343276783823967,
-0.02763415314257145,
0.026207292452454567,
0.01665273867547512,
0.007188492454588413,
0.03135482966899872,
-0.020662399008870125,
-0.03760412335395813,
0.0821438729763031,
0.014449230395257473,
-0.04031335189938545,
-0.05519606173038483,
0.005219784565269947,
0.055882398039102554,
0.022414369508624077,
-0.03527418524026871,
0.06437132507562637,
-0.033269353210926056,
-0.014467292465269566,
-0.0007935788598842919,
0.0068453229032456875,
-0.04248073697090149,
0.00352877308614552,
0.004682453814893961,
0.0009657279006205499,
-0.019253600388765335,
-0.08965747803449631,
-0.008583745919167995,
-0.04154153913259506,
-0.02539452351629734,
-0.01916329190135002,
0.008177361451089382,
-0.054545845836400986,
-0.04417852312326431,
-0.007766461465507746,
0.003503938438370824,
0.034551721066236496,
-0.03886843100190163,
0.04024110734462738,
-0.01749259978532791,
-0.026731077581644058,
-0.03552704676985741,
-0.044503629207611084,
-0.060831259936094284,
-0.08171039819717407,
-0.03260107710957527,
0.013799015432596207,
0.01416927669197321,
0.0442146472632885,
-0.009762261062860489,
-0.03556316718459129,
-0.002192219253629446,
-0.02396766096353531,
-0.0016390846576541662,
0.0017768038669601083,
0.0069220843724906445,
0.02250467613339424,
0.017248768359422684,
0.006962723098695278,
-0.030614307150244713,
-0.03760412335395813,
0.011008507572114468,
0.03984375298023224,
0.03489489108324051,
0.007233646232634783,
-0.0013839653693139553,
0.04782695323228836,
0.0035829576663672924,
0.010015122592449188,
0.007314923219382763,
0.00035417548497207463,
-0.024798491969704628,
-0.009428123012185097,
0.010891107842326164,
0.02777864597737789,
0.006678253877907991,
0.03180636838078499,
-0.005048200022429228,
0.03760412335395813,
-0.0437089242041111,
-0.07018713653087616,
0.01407896913588047,
-0.010845953598618507,
0.03915741667151451,
0.0042241420596838,
0.005400400143116713,
0.09225833415985107,
-0.01639987714588642,
-0.0632876306772232,
0.0632876306772232,
-0.044828739017248154,
-0.06585236638784409,
-0.05064455419778824,
-0.002062401967123151,
0.007545207627117634,
-0.009473277255892754,
-0.02017473801970482,
0.0010848211823031306,
0.00938296876847744,
0.0836610421538353,
-0.016092831268906593,
0.03498519957065582,
-0.029982153326272964,
-0.030126646161079407,
0.045804060995578766,
-0.01761903055012226,
-0.05089741572737694,
0.12448012083768845,
-0.013672584667801857,
-0.02178221568465233,
0.0036168231163173914,
0.02873590774834156,
0.019434215500950813,
0.004736638627946377,
-0.038687814027071,
-0.06397397071123123,
-0.02680332213640213,
-0.003779376856982708,
-0.006497638300061226,
-0.01411509234458208,
-0.006181561388075352,
0.0038177575916051865,
0.04782695323228836,
0.008795969188213348,
-0.03431692346930504,
0.011162030510604382,
-0.019560646265745163,
0.006438938435167074,
-0.03984375298023224,
-0.00941909197717905,
0.022540800273418427,
0.01798929274082184,
-0.02564738504588604,
0.003783892374485731,
0.004551507532596588,
-0.014196368865668774,
-0.014431169256567955,
0.004133834503591061,
0.0244914460927248,
-0.04591242969036102,
0.02346193790435791,
0.0816381499171257,
0.002001444110646844,
-0.003926126752048731,
-0.04392566159367561,
0.0020522424019873142,
-0.002372834598645568,
-0.07426904886960983,
0.04685163125395775,
-0.030831046402454376,
-0.005179146304726601,
-0.04435913637280464,
-0.01672498509287834,
-0.050355568528175354,
0.07860381156206131,
0.017917046323418617,
0.09095790982246399,
-0.020734645426273346,
0.042589105665683746,
-0.016490183770656586,
0.010367322713136673,
-0.01734810695052147,
-0.018016384914517403,
0.0005503125139512122,
-0.004944345913827419,
-0.001317363465204835,
-0.04034947603940964,
-0.04074683040380478,
-0.04331156983971596,
-0.014069938100874424,
0.007328469306230545,
-0.03680941462516785,
-0.0037477691657841206,
-0.021041691303253174,
-0.012959153391420841,
-0.06408233940601349,
0.006944661494344473,
-0.004637300036847591,
0.022450491786003113,
0.055448923259973526,
-0.007174945902079344,
0.02487073838710785,
0.024148276075720787,
0.009563584811985493,
-0.05913347750902176,
-0.07499150931835175,
-0.019759323447942734,
-0.00002407617103017401,
-0.015280061401426792,
0.015704507008194923,
0.027399353682994843,
0.02539452351629734,
-0.02732710726559162,
-0.07528049498796463,
0.04034947603940964,
-0.05263132229447365,
-0.04750184714794159,
-0.057435691356658936,
-0.024599814787507057,
0.015090415254235268,
0.03393762931227684,
-0.01787189207971096,
-0.023353569209575653,
-0.01871175318956375,
0.00983450748026371,
0.06242067739367485,
-0.027868954464793205,
0.014936892315745354,
-0.007617453578859568,
0.015018168836832047,
0.00694014597684145,
0.04016886278986931,
-0.04042172431945801,
0.006339599844068289,
0.026694953441619873,
0.08770682662725449,
-0.0059422459453344345,
0.01817893795669079,
0.040204983204603195,
0.044900983572006226,
-0.03149932250380516,
-0.04222787544131279,
-0.013744831085205078,
-0.027941199019551277,
-0.04233624413609505,
0.0675862729549408,
0.013022368773818016,
-0.056532613933086395,
0.016562430188059807,
-0.011866430751979351,
0.0049398308619856834,
0.03614113852381706,
0.030451754108071327,
0.01723070815205574,
0.03231209143996239,
-0.022468553856015205,
-0.07293248921632767,
-0.009951907210052013,
-0.012390214949846268,
-0.042589105665683746,
-0.0384349524974823,
0.003991600126028061,
-0.002186574973165989,
-0.02956673875451088,
0.0022915576118975878,
0.057435691356658936,
0.006118346005678177,
0.0095455227419734,
0.02107781544327736,
-0.03169799968600273,
-0.017086215317249298,
0.02501523122191429,
-0.030162768438458443,
0.03720676898956299,
-0.0185853224247694,
-0.014467292465269566,
0.030162768438458443,
-0.006484092213213444,
-0.008665023371577263,
0.011279430240392685,
0.0061228615231812,
-0.035328369587659836,
0.01734810695052147,
-0.01453050784766674,
0.0023412269074469805,
-0.006944661494344473,
0.0482243075966835,
-0.011812246404588223,
-0.005883546080440283,
0.0033278383780270815,
0.07658091932535172,
-0.03027113899588585,
-0.024780429899692535,
-0.0018806576263159513,
0.016490183770656586,
-0.013166861608624458,
0.04602079838514328,
-0.02557513862848282,
0.04435913637280464,
0.0006750500178895891,
-0.046309784054756165,
-0.01844083145260811,
-0.019831569865345955,
-0.026315661147236824,
0.040710706263780594,
0.0037590577267110348,
-0.029024891555309296,
0.0037771190982311964,
-0.008028353564441204,
0.02017473801970482,
0.05830264464020729,
-0.022035077214241028,
0.033142924308776855,
-0.017898984253406525,
0.008294761180877686,
-0.02539452351629734,
0.03727901354432106,
0.007721307687461376,
-0.010430538095533848,
0.03193280100822449,
0.01734810695052147,
0.0033210653346031904,
0.010385384783148766,
0.028898460790514946,
-0.003591988468542695,
0.03160769119858742,
0.025484830141067505,
-0.04475649073719978,
-0.02301039919257164,
-0.01273338496685028,
-0.025231968611478806,
-0.027110369876027107,
-0.08611741662025452,
-0.03292618319392204,
-0.032745569944381714,
0.04453975334763527,
0.011875461786985397,
-0.01220959983766079,
0.04034947603940964,
0.06942855566740036,
-0.00469148438423872
]
|
30,582 | networkx.generators.small | dodecahedral_graph |
Returns the Platonic Dodecahedral graph.
The dodecahedral graph has 20 nodes and 30 edges. The skeleton of the
dodecahedron forms a graph. It is one of 5 Platonic graphs [1]_.
It can be described in LCF notation as:
``[10, 7, 4, -4, -7, 10, -4, 7, -7, 4]^2`` [2]_.
Parameters
----------
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : networkx Graph
Dodecahedral Graph with 20 nodes and 30 edges
References
----------
.. [1] https://en.wikipedia.org/wiki/Regular_dodecahedron#Dodecahedral_graph
.. [2] https://mathworld.wolfram.com/DodecahedralGraph.html
| def sedgewick_maze_graph(create_using=None):
"""
Return a small maze with a cycle.
This is the maze used in Sedgewick, 3rd Edition, Part 5, Graph
Algorithms, Chapter 18, e.g. Figure 18.2 and following [1]_.
Nodes are numbered 0,..,7
Parameters
----------
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Returns
-------
G : networkx Graph
Small maze with a cycle
References
----------
.. [1] Figure 18.2, Chapter 18, Graph Algorithms (3rd Ed), Sedgewick
"""
G = empty_graph(0, create_using)
G.add_nodes_from(range(8))
G.add_edges_from([[0, 2], [0, 7], [0, 5]])
G.add_edges_from([[1, 7], [2, 6]])
G.add_edges_from([[3, 4], [3, 5]])
G.add_edges_from([[4, 5], [4, 7], [4, 6]])
G.name = "Sedgewick Maze"
return G
| (create_using=None, *, backend=None, **backend_kwargs) | [
0.0845668613910675,
-0.022300876677036285,
-0.01378017757087946,
-0.03377138078212738,
-0.06186806410551071,
0.02337353304028511,
-0.06280231475830078,
0.0550169013440609,
-0.00026897512725554407,
-0.015804383903741837,
-0.006768982391804457,
0.03150496259331703,
-0.006920365151017904,
0.07736968249082565,
0.024048268795013428,
-0.01339090708643198,
0.0429062657058239,
-0.003423418151214719,
-0.024498092010617256,
0.05252557247877121,
-0.010942826978862286,
-0.03999971225857735,
0.04003431275486946,
0.04411732777953148,
-0.02695482224225998,
0.027681460604071617,
-0.014757678844034672,
0.054255664348602295,
-0.008274161256849766,
-0.033131249248981476,
-0.01726631075143814,
-0.04411732777953148,
-0.0583040751516819,
0.018581179901957512,
0.030120888724923134,
0.06394417583942413,
0.0019139135256409645,
0.048096537590026855,
-0.08041464537382126,
-0.05235256254673004,
0.03771599009633064,
-0.00533733144402504,
0.052214156836271286,
-0.004589067306369543,
0.040068913251161575,
-0.012845927849411964,
0.05103769153356552,
0.020968707278370857,
-0.025934068486094475,
-0.03183367848396301,
0.026660706847906113,
-0.023961763828992844,
-0.016418566927313805,
0.03595129773020744,
0.03480943664908409,
-0.01682513765990734,
-0.02243928425014019,
-0.00803194846957922,
0.10262901335954666,
-0.04757751151919365,
0.005285428836941719,
-0.014238650910556316,
0.02728353999555111,
0.04096856340765953,
-0.04581281915307045,
-0.013935885392129421,
-0.03415200114250183,
-0.05487849563360214,
-0.0006028286879882216,
0.004753425717353821,
0.045189984142780304,
0.03581288829445839,
0.04512077942490578,
-0.01017293706536293,
0.0366087332367897,
0.02965376526117325,
-0.014757678844034672,
-0.03591669350862503,
-0.044359542429447174,
-0.04740450158715248,
0.019723040983080864,
0.0170414000749588,
-0.027145132422447205,
-0.053494423627853394,
0.031210847198963165,
0.03212779387831688,
0.03046690858900547,
0.043044671416282654,
-0.011842475272715092,
-0.09653909504413605,
0.01617635414004326,
-0.013070839457213879,
-0.027145132422447205,
-0.011531058698892593,
-0.008624505251646042,
0.004124104976654053,
0.020380474627017975,
-0.0600687712430954,
0.0058087813667953014,
-0.01941162347793579,
-0.04169519990682602,
0.009524152614176273,
-0.08470527082681656,
0.012456657364964485,
-0.052663978189229965,
-0.04283706098794937,
-0.02453269436955452,
0.004078690428286791,
-0.017171155661344528,
-0.040345728397369385,
-0.041729800403118134,
-0.0021323375403881073,
0.02728353999555111,
0.004502562806010246,
0.03140115737915039,
0.036331918090581894,
0.02415207400918007,
0.01660887710750103,
0.034619126468896866,
-0.06557045876979828,
-0.019619235768914223,
0.00973176397383213,
-0.04740450158715248,
-0.037162359803915024,
0.03692014887928963,
-0.029601862654089928,
0.03477483615279198,
-0.01308814063668251,
0.008559626527130604,
-0.012863229028880596,
0.020484281703829765,
0.006228328682482243,
-0.0393768772482872,
0.03216239809989929,
-0.05176433175802231,
0.008256861008703709,
-0.04183360934257507,
-0.04384051263332367,
0.025380440056324005,
0.02903093211352825,
0.011366699822247028,
-0.028684914112091064,
0.0018295715562999249,
0.028286993503570557,
-0.06318293511867523,
-0.0024805183056741953,
-0.018563879653811455,
0.00852935016155243,
0.060864612460136414,
0.027923673391342163,
0.028425399214029312,
-0.009039727039635181,
0.02134932577610016,
0.027093229815363884,
-0.021435830742120743,
-0.031712573021650314,
-0.001302974997088313,
0.05951514095067978,
0.015146949328482151,
0.05878850072622299,
0.011271544732153416,
-0.02569185569882393,
0.012854577973484993,
0.012041435576975346,
-0.03678173944354057,
-0.010449751280248165,
0.008663431741297245,
0.011721368879079819,
-0.012223094701766968,
0.013243848457932472,
-0.027421947568655014,
0.01061411015689373,
-0.05740442872047424,
-0.024982517585158348,
0.06394417583942413,
-0.00002748885344772134,
-0.02557075023651123,
-0.005242176819592714,
0.020120961591601372,
-0.043909717351198196,
-0.019498128443956375,
-0.012387453578412533,
0.014489514753222466,
-0.0058736600913107395,
0.002737869508564472,
0.0039100064896047115,
0.012223094701766968,
-0.00855530146509409,
0.0326814241707325,
0.01666942983865738,
-0.010518955066800117,
0.005371933337301016,
0.033909790217876434,
0.07204100489616394,
0.04051873832941055,
-0.02365034818649292,
0.030345801264047623,
0.02420397661626339,
-0.05615876242518425,
0.07543198019266129,
-0.014117544516921043,
0.03235270828008652,
0.011755970306694508,
-0.026972122490406036,
0.05297539383172989,
0.03503434732556343,
0.0047274744138121605,
-0.08110667765140533,
-0.018771490082144737,
0.03788900002837181,
-0.04775052145123482,
-0.01601199433207512,
0.056297171860933304,
0.026920219883322716,
-0.013408207334578037,
-0.03128005191683769,
0.008187657222151756,
0.06121062859892845,
0.03406549617648125,
-0.026037873700261116,
-0.0507262758910656,
0.007037146482616663,
-0.048926983028650284,
-0.019999856129288673,
0.014255952090024948,
-0.04335608705878258,
-0.04508617892861366,
-0.03910006210207939,
-0.015164250507950783,
-0.07425551861524582,
0.02074379473924637,
-0.028944427147507668,
0.03892705589532852,
-0.012586413882672787,
0.013226548209786415,
-0.011747320182621479,
-0.013313052244484425,
-0.018909897655248642,
0.008023298345506191,
-0.02084759995341301,
-0.05069167539477348,
-0.06380576640367508,
0.010034529492259026,
-0.03406549617648125,
0.04712768644094467,
0.03806200996041298,
-0.007482644636183977,
0.01837356947362423,
0.003094700863584876,
0.00836066622287035,
-0.032871734350919724,
-0.014800931327044964,
0.03278522938489914,
0.00010907684918493032,
-0.004567441064864397,
0.013840730302035809,
-0.05802726373076439,
0.00356182549148798,
-0.016262859106063843,
0.02198946103453636,
-0.02145313285291195,
-0.027404645457863808,
-0.023114020004868507,
-0.017283612862229347,
0.04058794304728508,
0.011141788214445114,
-0.05615876242518425,
0.07494755834341049,
-0.08664297312498093,
-0.045674409717321396,
0.03775059059262276,
0.014550067484378815,
0.01479228027164936,
0.006397012621164322,
0.01720575802028179,
-0.003445044392719865,
-0.025812963023781776,
-0.003817013930529356,
-0.0014403009554371238,
-0.03557067736983299,
-0.09550104290246964,
-0.03546687215566635,
0.012127939611673355,
0.054151859134435654,
-0.05100309103727341,
-0.0021907282061874866,
0.016124451532959938,
0.009446298703551292,
0.04145298898220062,
-0.03013819083571434,
-0.017447970807552338,
-0.042214225977659225,
0.014134845696389675,
0.0007217724341899157,
0.04169519990682602,
-0.004450659733265638,
0.02205866388976574,
-0.008559626527130604,
-0.028788719326257706,
0.047612112015485764,
0.08913430571556091,
-0.06121062859892845,
0.007811362389475107,
0.018494676798582077,
0.023114020004868507,
0.038961656391620636,
0.001902019139379263,
-0.024013666436076164,
0.04982662945985794,
-0.03553607687354088,
-0.0896187275648117,
0.014965289272367954,
-0.004952386487275362,
0.05743902921676636,
-0.02745654806494713,
-0.04207582026720047,
-0.029238542541861534,
-0.0300343856215477,
0.05588194727897644,
0.049030788242816925,
-0.007811362389475107,
0.018079454079270363,
-0.015925491228699684,
0.008499073795974255,
-0.06736975163221359,
0.014446262270212173,
0.018287064507603645,
0.04615883529186249,
0.012612365186214447,
0.018010251224040985,
-0.026816414669156075,
-0.036885544657707214,
0.015925491228699684,
0.018131356686353683,
-0.05131450667977333,
0.01887529529631138,
0.013659071177244186,
-0.007703231647610664,
-0.02228357642889023,
-0.044636353850364685,
0.09058757871389389,
0.02387526072561741,
-0.013174645602703094,
-0.011124487034976482,
0.06166045367717743,
0.016513722017407417,
-0.007897866889834404,
-0.05044946074485779,
-0.012101988308131695,
0.0469546765089035,
0.03650492802262306,
0.0704147145152092,
-0.017076000571250916,
0.006950641982257366,
0.030293898656964302,
0.03392709046602249,
0.01617635414004326,
0.01025944110006094,
-0.03524196147918701,
0.02910013496875763,
-0.06339054554700851,
0.021764548495411873,
0.004926435183733702,
-0.0016241231933236122,
-0.021799150854349136,
-0.02567455545067787,
-0.017015447840094566,
0.03240460902452469,
0.05363282933831215,
-0.0593075305223465,
-0.02122822031378746,
-0.0593075305223465,
-0.021366627886891365,
0.03290633484721184,
-0.008235234767198563,
0.065362848341465,
-0.03442881628870964,
0.009723112918436527,
0.06352895498275757,
0.004312252625823021,
0.01191167812794447,
-0.0017463108524680138,
0.008477447554469109,
-0.002954130992293358,
0.08055304735898972,
-0.028460001572966576,
0.04505157843232155,
0.03503434732556343,
0.017361465841531754,
-0.056297171860933304,
-0.0943937823176384,
-0.024290481582283974,
0.056954603642225266,
0.0681309923529625,
-0.005523316562175751,
0.025311235338449478,
0.08214473724365234,
0.046504855155944824,
-0.03622811287641525,
0.04647025093436241,
0.07750809192657471,
-0.0429062657058239,
0.03205859288573265,
0.04387511685490608,
-0.028235089033842087,
-0.06543204933404922,
-0.02705862745642662,
0.010839021764695644,
0.02655690163373947,
0.018581179901957512,
0.048926983028650284,
-0.048719372600317,
-0.04858096316456795,
0.0180448517203331,
-0.0027767964638769627,
0.010882274247705936,
0.015389162115752697,
0.026089776307344437,
0.05847708508372307,
0.00694199139252305,
0.05134911090135574,
-0.012231745757162571,
0.00036737407208420336,
0.03871944174170494,
0.042491041123867035,
-0.016954895108938217,
-0.024498092010617256,
-0.005713626276701689,
-0.05235256254673004,
0.04788892716169357,
-0.010060480795800686,
-0.06089921295642853,
0.05764664337038994,
-0.021435830742120743,
-0.017733436077833176,
0.005207574926316738,
0.033252354711294174,
-0.018563879653811455,
0.022352779284119606,
0.018615782260894775,
0.03185098245739937,
-0.014143496751785278,
-0.029601862654089928,
-0.030622616410255432,
0.019982554018497467,
-0.030882129445672035,
-0.007257733028382063,
-0.006284556817263365,
0.016375314444303513,
0.009307891130447388,
0.030726421624422073,
0.011608912609517574,
-0.03598589822649956,
0.011781921610236168,
-0.061729658395051956,
0.008127103559672832,
0.02711053006350994,
0.011557010002434254,
-0.03318314999341965,
0.05134911090135574,
0.0383734256029129,
-0.014541417360305786,
-0.020484281703829765,
0.06660851836204529,
-0.03889245167374611,
-0.015363210812211037,
0.021695345640182495,
0.005661723669618368,
0.0009137044544331729,
-0.06792338192462921,
0.03188558295369148,
-0.02965376526117325,
-0.05889230594038963,
-0.04588202014565468,
0.08878828585147858,
-0.04515538364648819,
-0.06342514604330063,
-0.022370079532265663,
0.03934227675199509,
-0.016980845481157303,
-0.06155664846301079,
-0.009550103917717934,
0.004887507762759924,
0.030882129445672035,
-0.010579508729279041,
0.0004625291039701551,
0.04999963939189911,
-0.08518969267606735,
-0.022075964137911797,
-0.04224883019924164,
0.002858975902199745,
-0.034740231931209564,
-0.027975575998425484,
-0.000006158381438581273,
-0.006371061317622662,
0.07806172221899033,
-0.030536111444234848,
-0.031435757875442505,
-0.004502562806010246,
-0.07640083134174347,
0.02882332168519497,
-0.015691928565502167,
-0.03833882138133049,
-0.021141715347766876,
-0.023183222860097885,
0.04397892206907272,
0.02320052497088909,
-0.012422055937349796,
0.018460074439644814,
0.027594955638051033,
0.05615876242518425,
-0.009039727039635181,
0.003326100530102849,
0.07667764276266098,
0.02216246910393238,
0.0300343856215477,
-0.007621052209287882,
0.01499124150723219,
0.05491309612989426,
-0.05923832580447197,
0.015380511991679668,
0.02425587922334671,
0.02809668332338333,
0.03591669350862503,
-0.04397892206907272,
0.05999956652522087,
0.030449606478214264,
0.03375408053398132,
0.04027652367949486,
0.037612184882164,
0.0315568670630455,
0.0714181661605835,
-0.028581108897924423,
0.07937658578157425,
0.03361567482352257,
-0.044463347643613815,
0.04740450158715248,
0.0143251558765769,
-0.019705740734934807,
-0.03851183131337166,
0.005198924336582422,
-0.029601862654089928,
-0.0340828001499176,
-0.02294101007282734,
-0.011392651125788689,
0.0017949696630239487,
0.09480900317430496,
-0.02903093211352825,
-0.02365034818649292,
-0.09813077747821808,
-0.021868353709578514,
0.03228350356221199,
-0.005211899988353252,
-0.0053459820337593555,
0.08636615425348282,
-0.04965361952781677,
-0.0230967178940773,
-0.029498057439923286,
0.016704032197594643,
0.012794025242328644,
-0.06387496739625931,
-0.011167739517986774,
0.014013739302754402,
-0.009065678343176842,
-0.009005125612020493,
0.022456584498286247,
0.0054454621858894825,
0.022318176925182343,
-0.02430778183043003,
0.025709155946969986,
0.02980947308242321,
0.04397892206907272,
0.08622775226831436,
-0.025380440056324005,
-0.02821778878569603,
-0.007815686985850334,
0.00032682507298886776,
0.03145305812358856,
0.04954981431365013,
-0.023684950545430183,
-0.033961690962314606,
-0.014178098179399967,
0.005605496000498533,
0.040345728397369385,
-0.018944500014185905,
0.03934227675199509,
-0.0366087332367897,
0.008373641408979893,
-0.02188565395772457,
0.013191945850849152,
0.051279906183481216,
-0.051279906183481216,
0.041279979050159454,
-0.001974466722458601,
-0.04256024584174156,
-0.002980082295835018,
0.025432342663407326,
0.01991335116326809,
0.023442737758159637,
0.01621960662305355,
-0.05076088011264801,
0.07224861532449722,
0.03536306694149971,
0.034186605364084244,
0.03560527786612511,
0.023338930681347847,
0.018581179901957512,
-0.018581179901957512,
0.001426244038157165,
-0.04394431784749031,
-0.010008578188717365,
0.007499945815652609,
-0.01666942983865738,
-0.053978849202394485,
-0.05913452059030533,
0.008196307346224785,
-0.023252427577972412,
0.00902242586016655,
-0.03157416731119156,
-0.0244807917624712,
0.009299241006374359,
-0.010908225551247597,
0.0016911642160266638,
-0.032871734350919724,
-0.012162541970610619,
0.003992185462266207,
0.02167804352939129,
0.00989612191915512,
-0.013373605906963348,
0.04076094925403595,
-0.021747248247265816,
-0.045397594571113586,
-0.011842475272715092,
-0.03321775421500206,
-0.01996525377035141,
-0.03096863441169262,
0.00021315265621524304,
0.000005926069661654765,
0.010769817978143692,
0.0580618642270565,
-0.041660599410533905,
0.027179734781384468,
0.02745654806494713,
0.017249010503292084,
-0.06754276156425476,
-0.01951543055474758,
0.0635981559753418,
-0.0008693708805367351,
-0.0426640510559082,
0.01133209839463234,
-0.008196307346224785,
0.005320030730217695,
0.023252427577972412,
0.01726631075143814,
0.05494770035147667,
0.03664333373308182,
-0.034895941615104675,
-0.06705833971500397,
0.054151859134435654,
-0.04712768644094467,
0.03892705589532852,
0.008810490369796753,
0.009316541254520416,
0.023633047938346863,
0.021954858675599098,
0.04563980922102928,
0.006141824182122946,
0.028131283819675446,
0.0325603187084198,
-0.02778526581823826,
-0.02579566091299057,
-0.04384051263332367,
-0.008693709038197994,
-0.052110351622104645,
-0.06480921804904938,
-0.045432198792696,
-0.02491331472992897,
0.02288910746574402,
-0.04671246558427811,
-0.037162359803915024,
0.03906546160578728,
0.05186813697218895,
-0.013001635670661926,
-0.0446709580719471,
-0.0056098210625350475,
0.03626271337270737,
-0.05269858241081238,
-0.021418530493974686,
0.030484208837151527,
0.00757779972627759,
-0.0230967178940773,
-0.0403803326189518,
0.02453269436955452,
0.050138045102357864,
-0.01056220754981041,
0.00712365098297596,
-0.016704032197594643,
-0.018217861652374268,
0.002437266055494547,
-0.06345974653959274,
0.03262952342629433,
0.04456715285778046,
0.0023896885104477406,
0.021470433101058006,
0.039965108036994934,
-0.043529096990823746,
-0.039895907044410706,
0.048753973096609116,
-0.0027984227053821087,
0.0063061825931072235,
-0.02072649449110031,
-0.03152226284146309,
0.0419028103351593,
0.028996329754590988,
0.000490913400426507,
-0.05899611487984657,
-0.0037218588404357433,
-0.0009558754391036928,
-0.022525789216160774,
0.006989568937569857,
0.01221444457769394,
0.0012013321975246072,
-0.01865038461983204,
0.02079569734632969,
-0.062352489680051804,
-0.0014976102393120527,
-0.04615883529186249,
-0.05972275137901306,
0.0037845748011022806,
-0.05615876242518425,
-0.04335608705878258,
0.008157380856573582,
-0.004965362139046192,
0.0524909682571888,
0.0069549670442938805,
0.003068749327212572,
0.0003587236278690398,
0.05989576131105423,
-0.018667684867978096,
0.037196964025497437,
-0.03441151604056358,
-0.01830436661839485,
-0.08145269751548767,
0.00615912489593029,
-0.00975771527737379,
0.01270752027630806,
0.030726421624422073,
0.045189984142780304,
-0.04681627079844475,
0.012629666365683079,
0.05968815088272095,
-0.05560513585805893,
0.06698913127183914,
0.028079381212592125,
-0.024947917088866234,
0.02541504055261612,
-0.04017271846532822,
-0.04422113299369812,
-0.036158908158540726,
-0.07100294530391693,
-0.018269764259457588,
0.024169376119971275,
0.014524116180837154,
-0.02294101007282734,
-0.044740159064531326,
0.02233547903597355,
0.022854505106806755,
0.056124161928892136
]
|
30,587 | networkx.generators.classic | dorogovtsev_goltsev_mendes_graph | Returns the hierarchically constructed Dorogovtsev-Goltsev-Mendes graph.
The Dorogovtsev-Goltsev-Mendes [1]_ procedure produces a scale-free graph
deterministically with the following properties for a given `n`:
- Total number of nodes = ``3 * (3**n + 1) / 2``
- Total number of edges = ``3 ** (n + 1)``
.. plot::
>>> nx.draw(nx.dorogovtsev_goltsev_mendes_graph(3))
Parameters
----------
n : integer
The generation number.
create_using : NetworkX Graph, optional
Graph type to be returned. Directed graphs and multi graphs are not
supported.
Returns
-------
G : NetworkX Graph
Examples
--------
>>> G = nx.dorogovtsev_goltsev_mendes_graph(3)
>>> G.number_of_nodes()
15
>>> G.number_of_edges()
27
>>> nx.is_planar(G)
True
References
----------
.. [1] S. N. Dorogovtsev, A. V. Goltsev and J. F. F. Mendes,
"Pseudofractal scale-free web", Physical Review E 65, 066122, 2002.
https://arxiv.org/pdf/cond-mat/0112143.pdf
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (n, create_using=None, *, backend=None, **backend_kwargs) | [
0.022252662107348442,
-0.006846289616078138,
0.021755395457148552,
-0.05018836632370949,
-0.012698046863079071,
0.06666918843984604,
-0.0475599579513073,
0.007396834436804056,
-0.0007081603398546576,
0.005105858203023672,
0.004133525304496288,
0.06247794255614281,
0.016933688893914223,
0.07615276426076889,
0.02704772911965847,
-0.007641027681529522,
0.014820308424532413,
0.011854470707476139,
-0.02290976420044899,
0.037934307008981705,
-0.019855128601193428,
0.015175498090684414,
0.03425808623433113,
0.013887934386730194,
-0.02090293914079666,
0.012067584320902824,
0.022234901785850525,
0.032446619123220444,
-0.037366002798080444,
0.0273318812251091,
0.03321027755737305,
-0.012111983262002468,
0.0012076464481651783,
0.01834557019174099,
0.0206898245960474,
0.04237418249249458,
-0.02148900367319584,
0.05310092493891716,
-0.10442589968442917,
-0.015717163681983948,
0.046352311968803406,
-0.0058739567175507545,
0.014829187653958797,
-0.03299716114997864,
0.01216526236385107,
0.028450729325413704,
0.08339864015579224,
0.004497595131397247,
-0.06869377195835114,
-0.01761743053793907,
0.0428004115819931,
0.004304460249841213,
-0.043226636946201324,
-0.058428775519132614,
-0.0018514285329729319,
0.010149558074772358,
-0.007552230264991522,
-0.012280698865652084,
0.059494346380233765,
-0.03999440744519234,
0.033583227545022964,
0.032091427594423294,
0.0062380265444517136,
-0.02356686443090439,
-0.05622659623622894,
-0.021790914237499237,
-0.03882228210568428,
-0.061412371695041656,
-0.014260883443057537,
-0.019002672284841537,
0.05402441695332527,
0.04148620739579201,
0.030137881636619568,
-0.009616772644221783,
0.012849003076553345,
0.026355108246207237,
0.03647802770137787,
0.010886577889323235,
-0.010540267452597618,
-0.009052908048033714,
-0.0227676872164011,
-0.03633594885468483,
0.02191523090004921,
-0.04802170395851135,
0.0462457537651062,
0.09824559092521667,
-0.01969529315829277,
0.021009495481848717,
-0.044647399336099625,
-0.023922055959701538,
-0.024437081068754196,
-0.027793627232313156,
-0.026141993701457977,
0.0054566082544624805,
-0.012724686414003372,
0.01593915745615959,
0.050294920802116394,
-0.0924915075302124,
0.01241389475762844,
-0.0009556834120303392,
-0.03747255727648735,
-0.03333459421992302,
-0.08865545690059662,
-0.021897470578551292,
-0.05665282532572746,
-0.03138104826211929,
-0.025378335267305374,
0.05690145865082741,
-0.013150914572179317,
0.02853952720761299,
-0.019073709845542908,
0.01744871586561203,
0.06613640487194061,
-0.013657060451805592,
0.029729414731264114,
0.0426938533782959,
-0.018239013850688934,
0.038644686341285706,
0.06531946361064911,
-0.02298080176115036,
-0.058499813079833984,
0.04425669088959694,
-0.04031407833099365,
0.0297649335116148,
0.026816854253411293,
-0.0003568550746422261,
0.04454084113240242,
-0.05317196249961853,
0.030226679518818855,
0.02106277458369732,
-0.0015428571496158838,
0.01898491196334362,
-0.0009445837349630892,
0.06826753914356232,
-0.035359177738428116,
0.013257471844553947,
-0.07878117263317108,
-0.0283974502235651,
-0.0012587050441652536,
-0.014269763603806496,
0.033867377787828445,
-0.03413376957178116,
0.038786761462688446,
0.04958454146981239,
-0.060701992362737656,
0.015459650196135044,
0.018718520179390907,
0.019215786829590797,
0.013284110464155674,
-0.01451839692890644,
0.023708941414952278,
0.0020878519862890244,
0.09540406614542007,
0.03068842738866806,
-0.022110585123300552,
-0.018381088972091675,
0.02713652513921261,
-0.022323699668049812,
-0.012103104032576084,
0.029818210750818253,
-0.007481192238628864,
0.011934388428926468,
0.03992336988449097,
-0.01664065755903721,
-0.07622379809617996,
-0.0033765260595828295,
-0.006264666095376015,
-0.0043666185811161995,
0.006557697895914316,
-0.02711876668035984,
-0.04159276559948921,
-0.0009001849684864283,
0.0013142034877091646,
-0.055977962911129,
-0.0046219113282859325,
-0.0021178212482482195,
-0.030866021290421486,
-0.011152969673275948,
-0.01723560132086277,
-0.02584008127450943,
0.029711654409766197,
-0.07064731419086456,
0.029072312638163567,
-0.04166380316019058,
-0.012049824930727482,
0.017679588869214058,
0.00988316535949707,
0.014056649059057236,
0.029232148081064224,
0.033583227545022964,
0.04667198285460472,
0.02505866438150406,
-0.012875642627477646,
0.055977962911129,
0.02283872477710247,
-0.05839325860142708,
0.06993693858385086,
0.03621163219213486,
-0.07224567234516144,
0.05519654601812363,
0.07743144780397415,
0.0712866559624672,
0.020458951592445374,
-0.010398191399872303,
0.04844793304800987,
-0.0006498869624920189,
-0.05132497474551201,
-0.04819929972290993,
-0.051786720752716064,
0.02875264175236225,
-0.007960698567330837,
0.019659774377942085,
0.03796982392668724,
0.044505324214696884,
-0.06485771387815475,
0.06968830525875092,
0.039070915430784225,
0.031665198504924774,
0.010087399743497372,
-0.061128221452236176,
-0.03519934043288231,
-0.015690524131059647,
0.0032189106568694115,
0.03425808623433113,
-0.008497923612594604,
-0.005723000969737768,
-0.008395806886255741,
-0.016791613772511482,
-0.0046174717135727406,
-0.06269105523824692,
0.026497183367609978,
-0.026514943689107895,
0.04418565332889557,
-0.015326454304158688,
0.012547091580927372,
-0.015202137641608715,
0.03345891088247299,
-0.011641356162726879,
-0.04233866184949875,
0.03232230246067047,
-0.055125508457422256,
-0.01948217861354351,
0.007392394356429577,
-0.009332620538771152,
-0.013808016665279865,
0.0797046646475792,
-0.01045146957039833,
0.031434327363967896,
0.002508530393242836,
-0.01166799571365118,
-0.004413237329572439,
-0.019091470167040825,
0.012795723974704742,
-0.030919300392270088,
0.01891387440264225,
0.030528591945767403,
-0.05690145865082741,
-0.007361315656453371,
0.015228777192533016,
0.04272937402129173,
-0.027562754228711128,
-0.00883091427385807,
-0.058002546429634094,
-0.02841521054506302,
0.061767563223838806,
0.01806141808629036,
-0.06876480579376221,
0.05281677097082138,
-0.05945882946252823,
-0.02861056476831436,
0.05711457133293152,
0.08140958100557327,
0.10534939169883728,
0.004499814938753843,
0.012742445804178715,
-0.056049004197120667,
0.0025618087965995073,
0.0398523323237896,
-0.04290696606040001,
-0.031665198504924774,
-0.053846824914216995,
-0.0371173694729805,
-0.011756793595850468,
0.04283592849969864,
0.025360574945807457,
0.03232230246067047,
0.04997524991631508,
-0.004044727422297001,
0.025644727051258087,
-0.028805918991565704,
0.019801849499344826,
-0.014811428263783455,
-0.03683321550488472,
-0.0030857142992317677,
0.03054635040462017,
0.020228078588843346,
-0.026461664587259293,
0.015282055363059044,
0.0023353751748800278,
0.052497100085020065,
0.09419642388820648,
-0.05310092493891716,
0.03669114038348198,
0.022536814212799072,
0.045357778668403625,
0.026994450017809868,
0.0004301130538806319,
0.01045146957039833,
0.01273356657475233,
0.014749269932508469,
-0.05445064604282379,
0.014296403154730797,
0.00499486131593585,
0.009377019479870796,
-0.010504747740924358,
-0.05867740884423256,
-0.020441191270947456,
-0.02140020579099655,
0.03789878636598587,
0.038218457251787186,
0.019180266186594963,
0.005252373870462179,
-0.052639178931713104,
0.021258128806948662,
-0.05246158316731453,
0.053349558264017105,
-0.010016361251473427,
0.05711457133293152,
-0.04922935366630554,
0.021009495481848717,
0.019073709845542908,
-0.01955321617424488,
-0.031061377376317978,
0.035447973757982254,
-0.07199703902006149,
0.035519011318683624,
0.013870174996554852,
-0.032570935785770416,
-0.015504049137234688,
-0.0511118583381176,
0.0297649335116148,
0.01055802684277296,
-0.01552180852741003,
0.007028324529528618,
-0.030173402279615402,
0.038644686341285706,
0.046991653740406036,
-0.09348604083061218,
-0.037934307008981705,
-0.026745816692709923,
0.031594160944223404,
0.07878117263317108,
-0.026319589465856552,
-0.029800452291965485,
0.040207523852586746,
0.0664205551147461,
0.005345611367374659,
0.012396135367453098,
-0.06411182135343552,
-0.010629064403474331,
-0.0036517984699457884,
0.003587420331314206,
0.062122754752635956,
-0.009821007028222084,
-0.005754080135375261,
0.021098293364048004,
-0.013621541671454906,
0.08695054054260254,
0.011650236323475838,
-0.006517739035189152,
-0.02411741018295288,
-0.07359539717435837,
-0.07679210603237152,
0.0504014790058136,
-0.005807358771562576,
0.054130975157022476,
-0.015406372025609016,
-0.03175399824976921,
0.027154285460710526,
-0.0018136895960196853,
-0.042018990963697433,
-0.01976633071899414,
0.04248074069619179,
0.006832970306277275,
0.026426145806908607,
0.000011472571713966317,
0.04113101586699486,
0.01926906406879425,
-0.0426938533782959,
-0.027580512687563896,
-0.053633708506822586,
-0.046494387090206146,
0.062335867434740067,
-0.004866104573011398,
-0.02933870442211628,
0.0022199382074177265,
0.09561718255281448,
0.0490872748196125,
-0.05288780853152275,
0.017386557534337044,
0.051786720752716064,
-0.04567744955420494,
0.025538170710206032,
0.0026261869352310896,
-0.004701829515397549,
-0.03704633191227913,
0.010646823793649673,
-0.0099897226318717,
-0.026159752160310745,
-0.026674779132008553,
0.02005048282444477,
-0.07871013134717941,
-0.0304753128439188,
-0.00040236383210867643,
0.07153528928756714,
0.006229146849364042,
0.010415950790047646,
0.0008724357467144728,
0.029445262625813484,
0.004644110798835754,
0.02390429563820362,
-0.093912273645401,
-0.015184378251433372,
0.09682483226060867,
0.05302988737821579,
-0.050721149891614914,
0.02806002087891102,
-0.016329865902662277,
-0.012005425989627838,
0.07263638079166412,
0.03420481085777283,
-0.023815497756004333,
0.035998519510030746,
0.006753052119165659,
0.007343555800616741,
-0.06158996745944023,
0.025431612506508827,
0.006113709881901741,
-0.0017359917983412743,
0.0013031037524342537,
0.03097257949411869,
-0.005358931142836809,
0.018683001399040222,
-0.02111605368554592,
-0.0026350668631494045,
-0.0157704409211874,
0.03825397789478302,
0.034719835966825485,
-0.002299856161698699,
-0.03395617753267288,
-0.006717533338814974,
-0.03146984428167343,
0.052212949842214584,
0.0003449229116085917,
-0.038857799023389816,
-0.007689866237342358,
0.019020430743694305,
-0.045784007757902145,
-0.059707459062337875,
0.04713372886180878,
-0.010886577889323235,
0.026887893676757812,
-0.020885178819298744,
0.021879712119698524,
-0.016685055568814278,
-0.04237418249249458,
0.02806002087891102,
-0.005838437937200069,
-0.04116653650999069,
-0.07054075598716736,
0.02447259984910488,
0.013159794732928276,
-0.03896435722708702,
-0.031025858595967293,
0.038147419691085815,
-0.03477311506867409,
-0.026355108246207237,
-0.04663646221160889,
-0.0002497430541552603,
-0.030848262831568718,
-0.06073751300573349,
0.015370853245258331,
-0.010229475796222687,
0.03953266143798828,
-0.04706269130110741,
-0.02377997897565365,
0.023158395662903786,
-0.04752444103360176,
0.0018813976785168052,
-0.03539469465613365,
-0.0030546351335942745,
-0.022643370553851128,
-0.015219897031784058,
0.016010195016860962,
-0.030652908608317375,
0.07089594751596451,
-0.017466474324464798,
-0.03839605301618576,
-0.0019557655323296785,
-0.009297101758420467,
0.019251305609941483,
-0.0021733196917921305,
-0.022021787241101265,
0.014935744926333427,
0.006881808862090111,
0.05814462527632713,
-0.006628735922276974,
-0.012893402017652988,
0.00827592983841896,
0.04272937402129173,
0.03910643234848976,
0.038573648780584335,
0.02461467683315277,
0.04194795340299606,
-0.022643370553851128,
0.00801397766917944,
-0.02170211635529995,
-0.007747584488242865,
0.04312008246779442,
-0.057363204658031464,
0.04123757407069206,
0.03818294033408165,
0.009865405969321728,
0.04191243648529053,
-0.025325056165456772,
-0.00592279527336359,
0.03839605301618576,
-0.026657018810510635,
0.01621442846953869,
-0.000594943470787257,
0.022394737228751183,
0.061767563223838806,
-0.03942610323429108,
0.01074450183659792,
-0.04134413227438927,
-0.08084127306938171,
0.034648798406124115,
0.046707503497600555,
0.008160493336617947,
-0.02026359736919403,
0.002695005154237151,
-0.0021999587770551443,
-0.011081932112574577,
0.0019302363507449627,
0.0011194038670510054,
0.02962285652756691,
0.006069311406463385,
-0.06752164661884308,
0.026355108246207237,
-0.059636421501636505,
0.034293606877326965,
-0.0038715724367648363,
0.007534470409154892,
0.006562137510627508,
0.08368279784917831,
-0.00611814996227622,
0.008027296513319016,
-0.026887893676757812,
0.004166824277490377,
0.03242885693907738,
-0.062193792313337326,
0.006517739035189152,
-0.001729331910610199,
-0.029640616849064827,
0.018683001399040222,
0.000013857271369488444,
0.008648879826068878,
-0.023034079000353813,
0.02470347285270691,
0.0075477901846170425,
-0.005634203553199768,
0.06428941339254379,
0.0896499902009964,
-0.009261582978069782,
-0.016072353348135948,
-0.007254758384078741,
-0.0426938533782959,
-0.004732908681035042,
-0.03974577412009239,
-0.017928222194314003,
-0.020316874608397484,
-0.019677532836794853,
0.002590667922049761,
0.0005397225031629205,
-0.002677245531231165,
0.06386318802833557,
-0.09433849900960922,
-0.004581952467560768,
-0.0178216639906168,
0.01564612425863743,
0.045073628425598145,
-0.056865938007831573,
0.06421837210655212,
0.033441152423620224,
-0.04375942423939705,
0.010735621675848961,
-0.020174799486994743,
-0.04567744955420494,
0.026514943689107895,
0.005971633829176426,
-0.046778541058301926,
0.08865545690059662,
-0.02090293914079666,
0.03278404846787453,
0.062193792313337326,
0.043013524264097214,
0.03162968158721924,
-0.015965797007083893,
-0.016285467892885208,
-0.08453524857759476,
-0.006064871326088905,
0.05381130427122116,
-0.02099173702299595,
-0.04869656637310982,
-0.050152845680713654,
0.012751325964927673,
-0.028663843870162964,
0.051999833434820175,
-0.06539050489664078,
-0.029924768954515457,
-0.01584148034453392,
0.03539469465613365,
-0.015219897031784058,
-0.00772538548335433,
-0.029001273214817047,
0.0011765672825276852,
0.01848764531314373,
-0.028965754434466362,
0.0013608222361654043,
0.004069146700203419,
0.010664583183825016,
-0.05484135448932648,
-0.023016320541501045,
-0.03459551930427551,
-0.011525919660925865,
-0.0075433505699038506,
0.009394778870046139,
-0.02761603333055973,
0.003929290920495987,
0.09625652432441711,
-0.04297800734639168,
0.008280369453132153,
-0.029090071097016335,
-0.026319589465856552,
-0.0038116341456770897,
-0.031061377376317978,
0.018647482618689537,
-0.036584582179784775,
-0.006526618730276823,
-0.02818433754146099,
-0.039141952991485596,
-0.0029880369547754526,
0.01766182854771614,
0.018807318061590195,
0.0426938533782959,
0.037294965237379074,
-0.03480863198637962,
-0.06240690499544144,
0.005390010308474302,
-0.061696525663137436,
0.05388234183192253,
-0.01565500535070896,
0.0297649335116148,
0.061554450541734695,
0.001243165461346507,
0.06109270080924034,
-0.003687317483127117,
-0.061554450541734695,
0.006055991631001234,
-0.0003898766590282321,
0.0046219113282859325,
0.008111654780805111,
0.038289494812488556,
-0.01688041165471077,
-0.055054470896720886,
-0.015015662647783756,
-0.014944625087082386,
0.02813105843961239,
-0.04461187869310379,
-0.009803247638046741,
0.009456937201321125,
-0.009172785095870495,
0.0329083651304245,
-0.024437081068754196,
-0.0199261661618948,
-0.0178216639906168,
-0.04095342010259628,
-0.051999833434820175,
0.018718520179390907,
0.011161849834024906,
-0.017510874196887016,
0.02820209600031376,
0.010717862285673618,
0.01624106802046299,
-0.019499938935041428,
0.014864707365632057,
-0.01598355546593666,
0.027207564562559128,
0.004260061774402857,
-0.05075667053461075,
0.03662010282278061,
-0.0013896813616156578,
-0.00931486114859581,
0.037650153040885925,
0.0174931138753891,
0.022803205996751785,
-0.03416929021477699,
0.012156382203102112,
-0.0413796491920948,
0.0356966070830822,
-0.07132218033075333,
-0.023211674764752388,
0.004235642496496439,
0.02177315577864647,
-0.08730573207139969,
0.005194655619561672,
0.02983597107231617,
0.005221294704824686,
-0.0518222413957119,
-0.0015162178315222263,
0.033654265105724335,
-0.047346845269203186,
-0.025875600054860115,
0.0511118583381176,
-0.035945240408182144,
0.009070668369531631,
-0.03221574425697327,
-0.0371173694729805,
-0.04223210737109184,
-0.02948078140616417,
-0.021009495481848717,
0.030457554385066032,
0.011872230097651482,
-0.016090113669633865,
0.01891387440264225,
-0.001652744016610086,
0.02092069946229458,
0.027598273009061813,
-0.016605138778686523,
-0.016658417880535126,
0.002996916649863124,
-0.021506762132048607,
-0.06656263023614883,
-0.02092069946229458,
-0.01664065755903721,
-0.014456238597631454,
0.008267050608992577,
-0.018434368073940277,
0.0011676875874400139,
0.02932094596326351,
0.04134413227438927,
-0.0027016648091375828,
0.008941911160945892,
0.02655046246945858,
-0.044860512018203735,
-0.024010851979255676,
0.015326454304158688,
-0.005523206666111946,
-0.01783054508268833,
-0.043510790914297104,
-0.022785447537899017,
0.028379691764712334,
0.06396973878145218,
-0.011010893620550632,
-0.045144665986299515,
0.0032988283783197403,
0.04574848711490631,
-0.003112353617325425
]
|
30,589 | networkx.drawing.nx_pylab | draw | Draw the graph G with Matplotlib.
Draw the graph as a simple representation with no node
labels or edge labels and using the full Matplotlib figure area
and no axis labels by default. See draw_networkx() for more
full-featured drawing that allows title, axis labels etc.
Parameters
----------
G : graph
A networkx graph
pos : dictionary, optional
A dictionary with nodes as keys and positions as values.
If not specified a spring layout positioning will be computed.
See :py:mod:`networkx.drawing.layout` for functions that
compute node positions.
ax : Matplotlib Axes object, optional
Draw the graph in specified Matplotlib axes.
kwds : optional keywords
See networkx.draw_networkx() for a description of optional keywords.
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> nx.draw(G)
>>> nx.draw(G, pos=nx.spring_layout(G)) # use spring layout
See Also
--------
draw_networkx
draw_networkx_nodes
draw_networkx_edges
draw_networkx_labels
draw_networkx_edge_labels
Notes
-----
This function has the same name as pylab.draw and pyplot.draw
so beware when using `from networkx import *`
since you might overwrite the pylab.draw function.
With pyplot use
>>> import matplotlib.pyplot as plt
>>> G = nx.dodecahedral_graph()
>>> nx.draw(G) # networkx draw()
>>> plt.draw() # pyplot draw()
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
| def draw(G, pos=None, ax=None, **kwds):
"""Draw the graph G with Matplotlib.
Draw the graph as a simple representation with no node
labels or edge labels and using the full Matplotlib figure area
and no axis labels by default. See draw_networkx() for more
full-featured drawing that allows title, axis labels etc.
Parameters
----------
G : graph
A networkx graph
pos : dictionary, optional
A dictionary with nodes as keys and positions as values.
If not specified a spring layout positioning will be computed.
See :py:mod:`networkx.drawing.layout` for functions that
compute node positions.
ax : Matplotlib Axes object, optional
Draw the graph in specified Matplotlib axes.
kwds : optional keywords
See networkx.draw_networkx() for a description of optional keywords.
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> nx.draw(G)
>>> nx.draw(G, pos=nx.spring_layout(G)) # use spring layout
See Also
--------
draw_networkx
draw_networkx_nodes
draw_networkx_edges
draw_networkx_labels
draw_networkx_edge_labels
Notes
-----
This function has the same name as pylab.draw and pyplot.draw
so beware when using `from networkx import *`
since you might overwrite the pylab.draw function.
With pyplot use
>>> import matplotlib.pyplot as plt
>>> G = nx.dodecahedral_graph()
>>> nx.draw(G) # networkx draw()
>>> plt.draw() # pyplot draw()
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
"""
import matplotlib.pyplot as plt
if ax is None:
cf = plt.gcf()
else:
cf = ax.get_figure()
cf.set_facecolor("w")
if ax is None:
if cf.axes:
ax = cf.gca()
else:
ax = cf.add_axes((0, 0, 1, 1))
if "with_labels" not in kwds:
kwds["with_labels"] = "labels" in kwds
draw_networkx(G, pos=pos, ax=ax, **kwds)
ax.set_axis_off()
plt.draw_if_interactive()
return
| (G, pos=None, ax=None, **kwds) | [
0.04690265655517578,
-0.01290199439972639,
0.0715961903333664,
-0.014172431081533432,
-0.005768725648522377,
-0.003338426351547241,
-0.053113680332899094,
-0.010144675150513649,
0.10622736066579819,
-0.047279082238674164,
0.006225141696631908,
-0.012346765957772732,
0.04325132444500923,
0.05601216107606888,
-0.026538019999861717,
-0.013626614585518837,
0.004822955466806889,
0.009382412768900394,
-0.03854600340127945,
-0.025295814499258995,
0.023338399827480316,
0.0062345522455871105,
0.005260550417006016,
-0.005015873815864325,
-0.011433933861553669,
0.012525568716228008,
0.007142679765820503,
0.0011863294057548046,
-0.02996349334716797,
0.039072997868061066,
0.03207147866487503,
-0.04268668591976166,
-0.06948820501565933,
-0.018077848479151726,
0.028928322717547417,
0.034104179590940475,
0.006248668301850557,
0.021663304418325424,
-0.005194676108658314,
0.01185741275548935,
0.030885737389326096,
-0.005641681607812643,
0.051984403282403946,
-0.01845427416265011,
-0.0033548949286341667,
0.03726615384221077,
-0.0029549426399171352,
0.0834912434220314,
-0.07291367650032043,
-0.015254655852913857,
-0.001388070173561573,
-0.01689210720360279,
-0.028344862163066864,
-0.019498856738209724,
-0.01229030266404152,
-0.04630037397146225,
0.01410655677318573,
0.05661443993449211,
0.0396752804517746,
-0.016863876953721046,
0.023413684219121933,
0.003764257999137044,
-0.015565207228064537,
-0.04242318868637085,
-0.029380034655332565,
0.027686117216944695,
0.008060217835009098,
-0.05123155191540718,
0.023827753961086273,
0.00878483708947897,
0.008370769210159779,
0.07148326188325882,
-0.05262432619929314,
-0.01678859069943428,
0.05947527661919594,
-0.005994581151753664,
0.030038779601454735,
0.033069007098674774,
0.0017021504463627934,
-0.0007475581369362772,
0.03145037591457367,
-0.0200634952634573,
0.023827753961086273,
0.0033690109848976135,
0.06700379401445389,
0.01496292557567358,
-0.00781554076820612,
0.028702467679977417,
-0.0048464820720255375,
-0.04415474832057953,
0.037774328142404556,
-0.011989162303507328,
0.039336495101451874,
0.0076461490243673325,
-0.04991406202316284,
-0.033690109848976135,
-0.019480034708976746,
-0.018943628296256065,
0.024053608998656273,
0.010699903592467308,
-0.027083836495876312,
-0.0005734611768275499,
-0.050064630806446075,
-0.014812355861067772,
-0.03677679970860481,
-0.022303229197859764,
-0.04916121065616608,
0.018905986100435257,
-0.0006957995938137174,
0.014210074208676815,
0.006855654995888472,
0.007542632054537535,
0.12075740098953247,
-0.0447193868458271,
0.036287449300289154,
0.0033478369005024433,
-0.02258554846048355,
-0.041256267577409744,
-0.0474296510219574,
-0.05992698669433594,
-0.0784471407532692,
0.05537223443388939,
0.022943152114748955,
-0.02757319062948227,
0.029003608971834183,
-0.04283725842833519,
-0.019150663167238235,
-0.007603801321238279,
0.03656976670026779,
-0.04434296116232872,
0.0759250819683075,
-0.005448763724416494,
0.026745053008198738,
0.014407698065042496,
0.03331368416547775,
0.01345722284168005,
-0.02518288604915142,
0.02132452093064785,
-0.036287449300289154,
-0.0017162663862109184,
0.024655889719724655,
-0.07543572783470154,
-0.029003608971834183,
0.03615569695830345,
-0.023790111765265465,
0.03641919791698456,
-0.02478763833642006,
-0.036946192383766174,
-0.003865422448143363,
0.004354775883257389,
0.03527109697461128,
-0.01637452282011509,
0.010154086165130138,
-0.0037948426324874163,
-0.023093722760677338,
-0.034574709832668304,
-0.03719086945056915,
0.04215969145298004,
-0.01981881819665432,
0.06323953717947006,
-0.041707977652549744,
-0.017061499878764153,
0.08386766910552979,
0.023583076894283295,
0.010474047623574734,
0.05966348946094513,
-0.008615445345640182,
-0.007406177930533886,
-0.011650378815829754,
-0.02367718331515789,
-0.008224903605878353,
-0.055635735392570496,
-0.05409238860011101,
-0.018096670508384705,
0.04151976481080055,
-0.014511214569211006,
-0.0196117851883173,
0.03771786391735077,
-0.043364252895116806,
-0.028589539229869843,
0.037115585058927536,
0.012233838438987732,
0.028721289709210396,
-0.013428990729153156,
-0.014878230169415474,
-0.0004052458971273154,
0.010492869652807713,
-0.012883173301815987,
0.03118687868118286,
-0.015179370529949665,
-0.02522052824497223,
0.04735436663031578,
-0.023583076894283295,
0.043176040053367615,
0.0734783187508583,
-0.02452414110302925,
0.004613568540662527,
-0.019743533805012703,
0.01204562559723854,
0.0016962687950581312,
0.05529695004224777,
0.007824951782822609,
0.028495432808995247,
-0.01938592828810215,
-0.01161273568868637,
-0.008309599943459034,
0.02027053013443947,
0.007876710034906864,
-0.025484027341008186,
-0.015122906304895878,
0.0286271832883358,
-0.04475702717900276,
0.015151138417422771,
0.012120910920202732,
-0.04976348951458931,
0.03743554651737213,
-0.011640967801213264,
0.025502847507596016,
-0.06387946009635925,
-0.004074809141457081,
-0.007664970587939024,
0.024392392486333847,
0.0007234433433040977,
0.009081272408366203,
0.03227851167321205,
-0.0693376362323761,
0.018284883350133896,
-0.0005293487920425832,
0.016835644841194153,
-0.10502280294895172,
0.04001406207680702,
0.010841063223779202,
0.010154086165130138,
0.06719200313091278,
0.011960930190980434,
-0.09418173879384995,
0.020157601684331894,
0.029775280505418777,
0.035026419907808304,
0.055635735392570496,
-0.06199733167886734,
0.01769201271235943,
-0.011236310005187988,
0.008450759574770927,
0.031168056651949883,
0.07701671868562698,
0.030415205284953117,
0.01845427416265011,
0.004714732989668846,
-0.0015974569832906127,
-0.08326538652181625,
-0.025465205311775208,
-0.01767319068312645,
0.003764257999137044,
-0.01197034027427435,
0.03732261806726456,
-0.09388059377670288,
-0.0018938923021778464,
-0.001046934281475842,
0.03397242724895477,
0.012798476964235306,
0.007119153160601854,
-0.0775437131524086,
0.04479467123746872,
0.10186082124710083,
-0.012422051280736923,
0.010050568729639053,
-0.0002355602046009153,
-0.0392235703766346,
-0.01583811640739441,
0.011321006342768669,
0.050290487706661224,
0.05254904180765152,
-0.014163020998239517,
0.05409238860011101,
0.04464409872889519,
-0.057141438126564026,
-0.005773430690169334,
0.08778249472379684,
0.001964472234249115,
-0.052247900515794754,
-0.08311481773853302,
-0.04539695382118225,
0.028777752071619034,
-0.058647140860557556,
0.005288782529532909,
0.006540398579090834,
0.03032109886407852,
-0.01633688062429428,
0.010690492577850819,
0.06628858298063278,
0.013626614585518837,
0.011415112763643265,
0.04720379412174225,
-0.016750948503613472,
-0.022303229197859764,
0.004411240108311176,
-0.010436405427753925,
-0.05593687295913696,
0.03491349518299103,
0.0784471407532692,
-0.052661970257759094,
0.018181366845965385,
0.0028396621346473694,
0.049650564789772034,
0.007895531132817268,
0.025916917249560356,
-0.010408173315227032,
0.033276040107011795,
0.014614732004702091,
-0.06783193349838257,
0.010069389827549458,
0.005641681607812643,
0.05966348946094513,
-0.007542632054537535,
0.004787665791809559,
-0.022961974143981934,
-0.061733830720186234,
0.05025284364819527,
-0.015179370529949665,
0.002396185416728258,
0.05702850967645645,
-0.046827368438243866,
0.012610264122486115,
-0.05729200690984726,
0.022227942943572998,
0.00425361143425107,
0.08379238098859787,
0.04133155196905136,
0.057819005101919174,
-0.03493231534957886,
0.0006416883552446961,
-0.013476043939590454,
-0.01761672832071781,
-0.07370417565107346,
0.0011239838786423206,
0.03990113362669945,
-0.0011210431111976504,
-0.008050806820392609,
-0.005519343540072441,
0.01539581548422575,
0.016732126474380493,
0.011443344876170158,
0.009514162316918373,
0.010812831111252308,
-0.0019703537691384554,
-0.0033501896541565657,
-0.008469580672681332,
-0.006606272887438536,
0.04633801802992821,
-0.0256534181535244,
0.0657239481806755,
-0.0305657759308815,
-0.007010930683463812,
-0.0499517060816288,
0.0714079737663269,
0.014690017327666283,
0.0026914444752037525,
-0.043401896953582764,
0.0026490965392440557,
-0.018200187012553215,
0.012497336603701115,
-0.005462879315018654,
0.0037336733657866716,
-0.06948820501565933,
0.0007169735035859048,
-0.03278668597340584,
-0.03081045299768448,
0.05303839594125748,
-0.014718248508870602,
0.013833648525178432,
-0.014341822825372219,
-0.09229961037635803,
-0.0008110799826681614,
0.018651898950338364,
0.04592394828796387,
-0.009123620577156544,
-0.010897527448832989,
0.019047144800424576,
-0.025992201641201973,
0.004700617399066687,
-0.05604980140924454,
0.023376042023301125,
-0.001137511688284576,
-0.00036730922874994576,
-0.00656863022595644,
0.02305608056485653,
0.08198554068803787,
-0.018303705379366875,
-0.013946576043963432,
-0.07355359941720963,
-0.021870339289307594,
0.023733647540211678,
0.022698476910591125,
-0.08424409478902817,
-0.0335395373404026,
0.057141438126564026,
0.04494524002075195,
-0.06734257936477661,
-0.041896190494298935,
0.00711444765329361,
0.032654937356710434,
0.0232631154358387,
0.020308172330260277,
0.019894104450941086,
-0.007490873336791992,
-0.01229030266404152,
-0.022867867723107338,
0.050290487706661224,
0.0396752804517746,
0.04547223821282387,
0.03687090799212456,
-0.05510873720049858,
0.017607316374778748,
0.0784471407532692,
-0.030471669510006905,
-0.03233497589826584,
0.035195812582969666,
0.08130797743797302,
-0.027027372270822525,
-0.03611805662512779,
0.0016315706307068467,
0.030716346576809883,
0.026011023670434952,
0.06463231146335602,
0.02540874108672142,
-0.0036089823115617037,
-0.018426043912768364,
-0.029643531888723373,
0.028307219967246056,
-0.03959999606013298,
0.009029514156281948,
-0.013918343931436539,
0.06786957383155823,
0.00111869047395885,
-0.055485162883996964,
0.021023381501436234,
-0.039035357534885406,
-0.027723761275410652,
0.023338399827480316,
-0.014285359531641006,
0.002171506406739354,
0.003583103185519576,
-0.059550561010837555,
-0.007552042603492737,
0.04848364368081093,
0.007029751781374216,
-0.013109028339385986,
0.03402889147400856,
0.008309599943459034,
0.028570719063282013,
0.020345814526081085,
0.06226082891225815,
0.02881539613008499,
-0.10667907446622849,
-0.04050341621041298,
0.01454885769635439,
0.008822480216622353,
-0.04735436663031578,
0.020759882405400276,
0.0008228432852774858,
-0.017522621899843216,
-0.056990865617990494,
0.011885644868016243,
-0.017644960433244705,
0.044869955629110336,
0.08002812415361404,
0.04054106026887894,
-0.051344480365514755,
0.009834123775362968,
0.05123155191540718,
-0.00905304029583931,
-0.0524737574160099,
-0.02435475029051304,
0.0060086967423558235,
0.03291843831539154,
0.016430987045168877,
0.013061975128948689,
-0.04863421246409416,
-0.028062542900443077,
-0.023093722760677338,
0.029812924563884735,
0.0019327112240716815,
0.010182318277657032,
0.0200634952634573,
0.025709882378578186,
0.046827368438243866,
0.04291254281997681,
0.00242088851518929,
-0.03033991903066635,
0.03440531715750694,
-0.05424295738339424,
-0.037153225392103195,
0.002646744018420577,
0.05484523996710777,
0.016506271436810493,
-0.02866482548415661,
-0.06523459404706955,
-0.03180798143148422,
-0.032410260289907455,
0.027874330058693886,
0.0024749997537583113,
0.01441710814833641,
0.017833173274993896,
0.017372051253914833,
-0.018698951229453087,
0.0023879511281847954,
0.07201025635004044,
0.026782695204019547,
-0.020722240209579468,
-0.016506271436810493,
0.029248284175992012,
0.0702410563826561,
0.008836595341563225,
0.04155740886926651,
0.07167147099971771,
-0.02840132638812065,
0.0275920107960701,
0.038433074951171875,
-0.03784961625933647,
0.0198376402258873,
0.01302433293312788,
-0.009090683422982693,
0.019131841138005257,
-0.06775664538145065,
0.07852242141962051,
0.022642012685537338,
0.025465205311775208,
-0.005938116926699877,
0.004154799971729517,
0.0026373332366347313,
0.022340871393680573,
-0.005152328405529261,
0.008535454981029034,
0.011499808169901371,
0.013711309991776943,
-0.010784598998725414,
0.03269258141517639,
-0.029380034655332565,
-0.010125854052603245,
0.02802490070462227,
-0.004345365334302187,
-0.013579560443758965,
-0.013071386143565178,
0.018491918221116066,
-0.013005511835217476,
0.05420531705021858,
-0.038621287792921066,
0.03274904564023018,
-0.054581742733716965,
-0.010154086165130138,
-0.03013288602232933,
-0.03892242908477783,
-0.005994581151753664,
0.03809428960084915,
0.015066443011164665,
-0.03705912083387375,
0.053490106016397476,
-0.036701515316963196,
-0.0022314991801977158,
-0.06689086556434631,
0.005001757759600878,
-0.005773430690169334,
-0.03690854832530022,
0.067719005048275,
-0.011697432026267052,
0.004700617399066687,
-0.039750564843416214,
0.033050186932086945,
-0.02522052824497223,
-0.0006569806719198823,
0.04242318868637085,
0.041896190494298935,
0.005632271058857441,
-0.01033288799226284,
0.07313953340053558,
0.011518629267811775,
0.03805664926767349,
0.0022373809479177,
-0.020383456721901894,
-0.05894828215241432,
-0.02262319065630436,
0.0014751185663044453,
0.020308172330260277,
0.019235359504818916,
-0.0017986095044761896,
-0.03978820890188217,
-0.023338399827480316,
0.016835644841194153,
-0.03726615384221077,
-0.02237851358950138,
-0.03293725848197937,
0.0761885792016983,
0.019028324633836746,
0.023394864052534103,
0.0254275631159544,
-0.010276424698531628,
0.028947144746780396,
-0.0032913731411099434,
0.0533771775662899,
-0.06052926927804947,
0.0485965721309185,
0.03449942544102669,
0.005669913720339537,
-0.006832128390669823,
0.017974331974983215,
0.03058459609746933,
0.0040442245081067085,
-0.014323001727461815,
-0.08401823788881302,
-0.01699562557041645,
0.03873421624302864,
-0.010370531119406223,
-0.04302547127008438,
-0.020119959488511086,
-0.09516044706106186,
-0.0030890442430973053,
0.012553800828754902,
0.004286549054086208,
0.06451938301324844,
0.03990113362669945,
-0.03448060527443886,
-0.0572543665766716,
-0.06177147477865219,
-0.011575093492865562,
0.060830410569906235,
-0.026199236512184143,
-0.02627452090382576,
-0.04287489876151085,
0.029643531888723373,
0.01672271639108658,
-0.022980796173214912,
-0.06218554452061653,
0.026952087879180908,
0.016845054924488068,
-0.09237489104270935,
-0.025709882378578186,
-0.0026443912647664547,
0.021268058568239212,
0.013617203570902348,
-0.010125854052603245,
-0.009382412768900394,
-0.03077280893921852,
-0.022566726431250572,
0.0258792731910944,
0.0023114897776395082,
-0.005251139868050814,
-0.03726615384221077,
0.051796190440654755,
0.014144199900329113,
0.024392392486333847,
-0.015791062265634537,
-0.0003973056736867875,
-0.030076421797275543,
0.04072927311062813,
0.07125740498304367,
-0.02734733559191227,
-0.049876417964696884,
0.03997642174363136,
-0.036287449300289154,
-0.0017456746427342296,
-0.01979999803006649,
0.0513068363070488,
0.02476881816983223,
-0.03956235200166702,
0.009490635246038437,
-0.021211594343185425,
-0.008987165987491608,
-0.0387718565762043,
-0.08492165803909302,
-0.040164634585380554,
-0.02027053013443947,
-0.038433074951171875,
-0.009325949475169182,
-0.08281368017196655,
-0.02860836125910282,
0.026820339262485504,
0.0033431316260248423,
0.0200634952634573,
-0.021907981485128403,
0.04419238865375519,
-0.0025714586954563856,
-0.023827753961086273,
-0.04182090610265732,
-0.006738021969795227,
-0.008163734339177608,
0.006036928854882717,
-0.07332774996757507,
0.006695673801004887,
0.006930940318852663,
0.014661785215139389,
-0.007434409577399492,
0.04287489876151085,
-0.027930794283747673,
0.0256534181535244,
-0.0320526584982872,
0.00910479947924614,
-0.021663304418325424,
-0.023169009014964104,
-0.00889776460826397,
0.03161976858973503,
-0.01473707053810358,
0.018303705379366875,
0.06003991514444351,
-0.03246672451496124,
-0.02087281085550785,
-0.06975170224905014,
0.03751083090901375,
-0.010502279736101627,
0.04453117400407791,
-0.052398473024368286,
0.00798022747039795,
0.07046691328287125,
-0.04430531710386276,
0.004194795154035091,
-0.02821311354637146,
-0.017663780599832535,
-0.012064446695148945,
-0.07106918841600418,
-0.03269258141517639,
-0.018840111792087555,
0.020176423713564873,
-0.019113020971417427,
0.04502052441239357,
0.043552465736866,
-0.03854600340127945,
-0.03011406399309635,
-0.05872242525219917,
0.0017539089312776923,
-0.0107751889154315,
0.023601897060871124,
0.05149504914879799,
-0.05514638125896454,
-0.012610264122486115,
-0.060868050903081894,
0.013645435683429241,
-0.03485703095793724,
0.0013586619170382619,
-0.020722240209579468,
0.039035357534885406,
-0.05051634460687637,
-0.02586045302450657,
-0.042310260236263275,
-0.041256267577409744,
0.025672240182757378,
-0.032824330031871796,
-0.02239733561873436,
0.03207147866487503,
0.02478763833642006,
0.03830132633447647,
0.018840111792087555,
-0.004931177943944931,
-0.022924331948161125,
0.039750564843416214,
0.021663304418325424,
0.014454751275479794,
-0.027441442012786865,
-0.01957414112985134,
0.018529560416936874,
-0.08748135715723038,
-0.019028324633836746,
0.00409833574667573,
0.008540160022675991,
-0.027046194300055504,
0.0018856580136343837,
-0.008149618282914162,
0.031563304364681244,
0.048747140914201736
]
|
30,590 | networkx.drawing.nx_pylab | draw_circular | Draw the graph `G` with a circular layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.circular_layout(G), **kwargs)
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called. For
repeated drawing it is much more efficient to call
`~networkx.drawing.layout.circular_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.circular_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(5)
>>> nx.draw_circular(G)
See Also
--------
:func:`~networkx.drawing.layout.circular_layout`
| def draw_circular(G, **kwargs):
"""Draw the graph `G` with a circular layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.circular_layout(G), **kwargs)
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called. For
repeated drawing it is much more efficient to call
`~networkx.drawing.layout.circular_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.circular_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(5)
>>> nx.draw_circular(G)
See Also
--------
:func:`~networkx.drawing.layout.circular_layout`
"""
draw(G, circular_layout(G), **kwargs)
| (G, **kwargs) | [
0.02543662302196026,
-0.016087044030427933,
0.02174362912774086,
0.0030602312181144953,
-0.02972410060465336,
0.022860534489154816,
-0.01994216814637184,
0.009034325368702412,
0.11579788476228714,
-0.06942829489707947,
0.034317824989557266,
-0.0055890316143631935,
0.04186594486236572,
0.03808287903666496,
-0.012979523278772831,
0.02965204231441021,
0.05627762898802757,
-0.021959803998470306,
-0.03262445330619812,
-0.010484500788152218,
0.0446401946246624,
0.03424576669931412,
-0.010574573650956154,
-0.016906708478927612,
-0.026175223290920258,
-0.009673843160271645,
-0.011853611096739769,
0.028967486694455147,
-0.035704948008060455,
0.006773491855710745,
0.05278279632329941,
-0.001045973040163517,
-0.07955250144004822,
-0.016789613291621208,
-0.011115011759102345,
0.05566513165831566,
0.0314895324409008,
0.07159004360437393,
-0.05134162679314613,
-0.016168108209967613,
0.004620746243745089,
-0.006895090453326702,
0.009241492487490177,
-0.018248796463012695,
0.011015931144356728,
0.01580781675875187,
-0.0005004682461731136,
0.053755585104227066,
-0.06611360609531403,
-0.021563483402132988,
-0.000005356882411433617,
0.008552433922886848,
-0.05181000754237175,
-0.028481092303991318,
0.014114444144070148,
-0.014186502434313297,
0.0012891702353954315,
0.04712621122598648,
0.02149142511188984,
-0.009754909202456474,
-0.012907464988529682,
-0.017474167048931122,
0.04528871923685074,
0.016861671581864357,
-0.03138144314289093,
0.040893156081438065,
0.006561820395290852,
-0.028463076800107956,
0.020734811201691628,
-0.024824127554893494,
-0.0005497269448824227,
0.09036126732826233,
-0.028967486694455147,
-0.03210202977061272,
0.04752252995967865,
-0.04110933095216751,
0.05930408462882042,
0.04118138924241066,
0.00024361940450035036,
-0.039091695100069046,
0.01264625322073698,
-0.015834838151931763,
0.022175980731844902,
0.017897510901093483,
0.028084771707654,
0.02372523583471775,
-0.0147089259698987,
0.027976682409644127,
-0.0053413305431604385,
-0.02900351583957672,
0.021797673776745796,
-0.0030827494338154793,
0.026985879987478256,
-0.04226226732134819,
-0.029616013169288635,
-0.03165166452527046,
-0.02792263962328434,
-0.02280649170279503,
-0.016429319977760315,
0.012204895727336407,
-0.01571774296462536,
-0.019257614389061928,
-0.07407605648040771,
-0.040821097791194916,
-0.022428184747695923,
-0.06831138581037521,
-0.03642553463578224,
-0.014267567545175552,
-0.010016120970249176,
0.04860340803861618,
-0.001594292582012713,
0.006246564444154501,
0.08092161267995834,
-0.028445063158869743,
0.043703433126211166,
0.06362758576869965,
-0.03945198655128479,
-0.035380687564611435,
-0.03293069824576378,
-0.041397564113140106,
-0.021149147301912308,
0.0606011338531971,
0.04150565341114998,
-0.02857116609811783,
0.04719826951622963,
-0.00016170923481695354,
-0.05018869414925575,
0.03383142873644829,
0.028048740699887276,
-0.004208662547171116,
0.02019437402486801,
-0.03415569290518761,
0.07796721160411835,
-0.009295537136495113,
0.032660480588674545,
0.01714089699089527,
-0.013583012856543064,
-0.017816444858908653,
-0.041145361959934235,
0.03797478973865509,
-0.014483743347227573,
-0.04964825510978699,
-0.057538650929927826,
0.05033281072974205,
0.04968428239226341,
0.04719826951622963,
-0.03484024852514267,
-0.015420502983033657,
0.012385041452944279,
0.035704948008060455,
0.02866123802959919,
-0.030768947675824165,
0.0635555312037468,
0.023364944383502007,
-0.009007303044199944,
0.003143548732623458,
-0.02727411314845085,
0.037758614867925644,
-0.024824127554893494,
0.05685409530997276,
-0.02033849060535431,
0.012637246400117874,
0.04993648827075958,
0.010781741701066494,
0.02727411314845085,
0.07371576875448227,
0.026499485597014427,
-0.0294178519397974,
-0.011952690780162811,
0.0147089259698987,
0.012195887975394726,
-0.057862915098667145,
0.039343900978565216,
-0.05534087121486664,
0.023599134758114815,
-0.01498815231025219,
-0.018410926684737206,
0.038839489221572876,
-0.03880346193909645,
-0.033309005200862885,
0.0010161363752558827,
-0.0061069512739777565,
0.04662179946899414,
-0.015555612742900848,
-0.02413957193493843,
0.06319523602724075,
0.0360652394592762,
-0.05699821189045906,
0.07180622220039368,
-0.04820708557963371,
-0.041145361959934235,
0.04766664654016495,
-0.0005469121970236301,
0.022554287686944008,
0.05930408462882042,
-0.0662216916680336,
0.00021575305436272174,
0.024824127554893494,
0.023166783154010773,
0.05393572896718979,
0.014123450964689255,
0.013087611645460129,
0.03559686243534088,
-0.01580781675875187,
-0.015366459265351295,
-0.017176926136016846,
-0.005746659357100725,
0.014051392674446106,
0.005940316244959831,
-0.004701812285929918,
0.013384852558374405,
-0.00010653950448613614,
0.06431214511394501,
-0.036695752292871475,
-0.037506408989429474,
0.09382006525993347,
-0.046333566308021545,
0.0017507944721728563,
-0.026337353512644768,
0.003197592683136463,
0.011169055476784706,
0.03419172391295433,
-0.04993648827075958,
-0.05634968727827072,
0.04258652776479721,
-0.09807151556015015,
-0.009340573102235794,
-0.006773491855710745,
0.029093589633703232,
-0.09958474338054657,
0.05833129584789276,
0.001120846252888441,
0.004670286551117897,
0.0573585070669651,
0.0034903299529105425,
-0.10621411353349686,
-0.003195340745151043,
0.01622215285897255,
0.004508154932409525,
0.02947189472615719,
-0.06337538361549377,
0.017276007682085037,
-0.03451598435640335,
0.02628331072628498,
0.03475017473101616,
0.03046269901096821,
-0.021275250241160393,
0.019906139001250267,
0.033489152789115906,
-0.004841425456106663,
-0.11161849647760391,
-0.006877075880765915,
-0.046585772186517715,
-0.02066275291144848,
0.013177684508264065,
0.0216535571962595,
-0.11075379699468613,
-0.000583222892601043,
-0.01755523309111595,
0.06315921247005463,
0.011763537302613258,
-0.004091567359864712,
-0.03271452337503433,
0.04193800315260887,
0.05397175997495651,
-0.018410926684737206,
-0.020554665476083755,
-0.024157587438821793,
-0.06276288628578186,
-0.007584149017930031,
-0.034948334097862244,
0.03226415812969208,
0.05825923755764961,
-0.019744008779525757,
0.08495688438415527,
0.03154357522726059,
-0.021185176447033882,
0.03626340255141258,
0.07623781263828278,
-0.045432835817337036,
0.006242061033844948,
-0.02513037621974945,
-0.023869352415204048,
-0.008759601972997189,
-0.056385718286037445,
0.0011754530714824796,
0.016294211149215698,
0.029688071459531784,
-0.02561677061021328,
0.012799377553164959,
0.07969661802053452,
-0.019383715465664864,
0.0030962603632360697,
0.05797100067138672,
0.012484122067689896,
0.03757846727967262,
0.007061725482344627,
0.003064734861254692,
-0.048315174877643585,
0.013537976890802383,
0.03822699561715126,
-0.01739310286939144,
-0.01828482560813427,
0.01170048676431179,
0.08265101164579391,
0.04067698121070862,
0.02323884144425392,
-0.031021151691675186,
-0.002808026736602187,
0.01640229858458042,
-0.06535699218511581,
-0.033489152789115906,
0.003298924770206213,
0.06957241147756577,
-0.031021151691675186,
-0.005854746792465448,
-0.019293643534183502,
-0.012889450415968895,
0.06146583706140518,
-0.04874752461910248,
0.012952501885592937,
0.009322558529675007,
-0.053575437515974045,
0.01714089699089527,
-0.0950450599193573,
0.029309764504432678,
0.01821276731789112,
0.11695082485675812,
-0.007259886246174574,
0.07652604579925537,
-0.028120800852775574,
0.02626529522240162,
-0.05130559951066971,
0.019149526953697205,
-0.03790273144841194,
0.0012283709365874529,
0.01596994884312153,
-0.029778143391013145,
0.032840628176927567,
0.003819096367806196,
0.038263022899627686,
-0.003618683898821473,
0.013655071146786213,
-0.005314308684319258,
0.022049877792596817,
0.023509060963988304,
0.058763645589351654,
0.009034325368702412,
0.040316689759492874,
0.00424469169229269,
0.02833697572350502,
0.094900943338871,
-0.02035650424659252,
-0.011430267244577408,
-0.04399166628718376,
0.0978553369641304,
0.011952690780162811,
-0.020950986072421074,
-0.010025128722190857,
0.0062105352990329266,
-0.009065850637853146,
0.030750932171940804,
0.034804217517375946,
0.00028696705703623593,
-0.006868068594485521,
0.0447843112051487,
-0.07883191853761673,
-0.00011097278911620378,
0.030624831095337868,
-0.011277143843472004,
-0.01017825212329626,
-0.0044721257872879505,
-0.060997456312179565,
-0.0062105352990329266,
-0.011385231278836727,
0.1036200150847435,
-0.0005598602001555264,
0.002531052101403475,
0.010079172439873219,
-0.022842520847916603,
-0.0459732748568058,
-0.07724662870168686,
0.008750595152378082,
0.007912916131317616,
-0.006507776211947203,
0.010277332738041878,
0.0013533473247662187,
0.018347876146435738,
-0.007498579565435648,
0.007295915391296148,
-0.09670240432024002,
-0.027778523042798042,
0.054079845547676086,
0.007413010578602552,
-0.0663658082485199,
-0.028931457549333572,
0.06146583706140518,
0.05080118775367737,
-0.03334503620862961,
-0.03894757851958275,
0.03622737154364586,
-0.02109510451555252,
0.031183283776044846,
0.016618473455309868,
0.0237972941249609,
0.004123093094676733,
0.007291411980986595,
0.007930930703878403,
0.04770267754793167,
0.015960941091179848,
0.03312886133790016,
-0.017519203945994377,
0.010097187012434006,
0.03451598435640335,
0.086614228785038,
-0.025760887190699577,
-0.038515228778123856,
0.0038506221026182175,
0.036533620208501816,
0.012240924872457981,
0.006485258229076862,
0.00984498206526041,
0.024121558293700218,
0.021023044362664223,
0.038839489221572876,
0.030174465849995613,
0.04604533314704895,
0.0041388557292521,
-0.01560965646058321,
0.06380773335695267,
-0.05494454875588417,
0.06550110876560211,
-0.018266810104250908,
0.026391398161649704,
-0.009709872305393219,
-0.022175980731844902,
0.030264537781476974,
-0.060168784111738205,
-0.00019661254191305488,
0.034209735691547394,
0.018185744062066078,
0.025959046557545662,
0.005039586219936609,
-0.07119372487068176,
-0.015411495231091976,
0.037110090255737305,
-0.014384662732481956,
0.005309805274009705,
0.029093589633703232,
-0.018753204494714737,
0.025977062061429024,
0.030048362910747528,
0.029381822794675827,
0.019491802901029587,
-0.09266713261604309,
-0.05224235728383064,
-0.026373382657766342,
0.0029746617656201124,
-0.0750848799943924,
-0.025490667670965195,
0.00794894527643919,
0.004181640222668648,
-0.04719826951622963,
-0.032912686467170715,
0.000261634006164968,
0.01909548230469227,
0.05526881292462349,
0.011187070049345493,
-0.05663792043924332,
0.01264625322073698,
0.05278279632329941,
-0.018068650737404823,
-0.08207454532384872,
-0.02109510451555252,
0.03188585117459297,
0.006476250942796469,
0.007786813657730818,
-0.0037020016461610794,
-0.04561298340559006,
-0.02579691633582115,
-0.03165166452527046,
-0.001423153909854591,
-0.038983605802059174,
0.008462361060082912,
-0.01714089699089527,
0.030030347406864166,
0.0158888828009367,
0.03226415812969208,
0.01959989219903946,
-0.043126966804265976,
0.004280720837414265,
0.026913821697235107,
-0.025923017412424088,
-0.013655071146786213,
0.043379172682762146,
0.06103348359465599,
-0.05137765780091286,
-0.025220448151230812,
-0.034642089158296585,
-0.019491802901029587,
0.00589077640324831,
0.027652420103549957,
0.07530105113983154,
-0.002857566811144352,
-0.019383715465664864,
-0.010349391028285027,
-0.001993991667404771,
0.026157207787036896,
0.02181568741798401,
-0.012240924872457981,
0.02223002351820469,
0.06571727991104126,
0.046585772186517715,
0.04752252995967865,
0.01829383336007595,
0.027129996567964554,
-0.03338106349110603,
0.02008628658950329,
0.010475493036210537,
-0.07674222439527512,
0.013078603893518448,
0.000454587338026613,
-0.003879895666614175,
0.0388755202293396,
-0.07472458481788635,
0.05966437608003616,
0.0375424399971962,
-0.018717175349593163,
-0.025508681312203407,
-0.023364944383502007,
-0.015312415547668934,
0.03399356082081795,
-0.023761264979839325,
0.01383521780371666,
0.01623116061091423,
-0.010286340489983559,
0.006818528287112713,
0.003573647467419505,
-0.026643602177500725,
0.02792263962328434,
-0.018086664378643036,
0.03855125606060028,
-0.0016719806008040905,
-0.009619799442589283,
0.022590316832065582,
0.020032241940498352,
0.06301508843898773,
-0.04860340803861618,
0.02322082780301571,
-0.03952404484152794,
-0.0372542068362236,
-0.02758036181330681,
-0.049720313400030136,
-0.043523289263248444,
0.04399166628718376,
0.0367317833006382,
-0.05476440116763115,
0.011961698532104492,
0.010880822315812111,
-0.008710062131285667,
-0.012871435843408108,
0.005791695788502693,
-0.016357261687517166,
-0.06002466753125191,
0.04982839897274971,
-0.032660480588674545,
0.013528969138860703,
-0.022103922441601753,
0.05015266314148903,
-0.01190765481442213,
0.025670813396573067,
-0.009448660537600517,
0.02948991023004055,
-0.019996212795376778,
0.02098701521754265,
0.020572680979967117,
0.026787718757987022,
0.048387233167886734,
-0.0002989298664033413,
-0.013015552423894405,
-0.025923017412424088,
-0.04618944972753525,
0.021473409608006477,
0.012754340656101704,
0.003618683898821473,
0.009872004389762878,
-0.009394616819918156,
-0.018095672130584717,
0.007079740054905415,
-0.05451219901442528,
0.027148012071847916,
-0.01878923363983631,
0.06514081358909607,
0.01449275016784668,
-0.01408742181956768,
-0.005399878136813641,
-0.05541292950510979,
0.019888125360012054,
-0.02898550033569336,
0.022175980731844902,
-0.07364370673894882,
0.061826128512620926,
0.007980470545589924,
0.036695752292871475,
-0.08610981702804565,
0.0237972941249609,
-0.006516783963888884,
-0.005242250394076109,
0.008701054379343987,
-0.04373946413397789,
-0.010718690231442451,
0.03440789878368378,
-0.012294968590140343,
-0.03424576669931412,
-0.012276954017579556,
-0.04669385775923729,
-0.041469622403383255,
0.0009131153346970677,
-0.015762779861688614,
0.04110933095216751,
0.00681402487680316,
-0.005796199664473534,
-0.041829913854599,
-0.05840335413813591,
-0.04276667535305023,
0.06942829489707947,
-0.06697830557823181,
-0.041721828281879425,
-0.025580741465091705,
0.030841005966067314,
0.02495022863149643,
-0.007048214785754681,
-0.052350446581840515,
0.042298294603824615,
-0.020770840346813202,
-0.08834362775087357,
-0.046585772186517715,
-0.0008495012880302966,
0.01904143951833248,
0.014303597621619701,
-0.03368731215596199,
-0.014853042550384998,
-0.0548364594578743,
0.001531241461634636,
0.01013321615755558,
-0.05170191824436188,
-0.011988719925284386,
-0.025148389860987663,
0.02215796522796154,
0.017573248594999313,
-0.01909548230469227,
0.012132837437093258,
0.04413578659296036,
-0.0010825652861967683,
0.02759837731719017,
0.06809520721435547,
-0.007345455698668957,
-0.03411966562271118,
0.05890776216983795,
-0.030768947675824165,
-0.003711008932441473,
-0.013078603893518448,
0.006850054021924734,
0.04240638390183449,
-0.05429602414369583,
-0.011295158416032791,
0.0009553370764479041,
-0.052422504872083664,
0.0011169055942445993,
-0.0663658082485199,
-0.027382200583815575,
-0.010412442497909069,
0.02817484363913536,
0.013781174086034298,
-0.062402594834566116,
-0.01851901412010193,
0.031183283776044846,
0.013907276093959808,
0.03779464215040207,
0.017888503149151802,
0.027526317164301872,
-0.031741734594106674,
-0.0011045205174013972,
-0.02257230132818222,
-0.006242061033844948,
0.031183283776044846,
0.02561677061021328,
-0.027940653264522552,
0.011511333286762238,
0.017005788162350655,
0.02965204231441021,
0.024103542789816856,
0.02577890083193779,
-0.022175980731844902,
0.02857116609811783,
-0.02469802461564541,
-0.01994216814637184,
0.0034678117372095585,
0.0028778333216905594,
-0.00034255898208357394,
0.039091695100069046,
-0.028192859143018723,
0.020860914140939713,
0.0004143359255976975,
-0.061826128512620926,
-0.030606815591454506,
-0.04676591604948044,
0.012673275545239449,
-0.01046648621559143,
0.0336332693696022,
-0.021203191950917244,
0.008322748355567455,
0.035380687564611435,
-0.027202054858207703,
0.005507965572178364,
-0.03626340255141258,
-0.007039207499474287,
-0.028048740699887276,
-0.05570116266608238,
-0.03478620573878288,
-0.0024432309437543154,
0.05029677972197533,
-0.019545847550034523,
0.03518252447247505,
0.005742155481129885,
-0.022950608283281326,
-0.017023801803588867,
-0.04654974117875099,
-0.021797673776745796,
-0.019419744610786438,
0.018555045127868652,
0.0533592626452446,
-0.03930786997079849,
0.00806603953242302,
-0.017915526404976845,
-0.005138666369020939,
-0.02413957193493843,
-0.0011180314468219876,
-0.046081360429525375,
0.012880443595349789,
-0.07414811849594116,
-0.007399499416351318,
-0.040316689759492874,
-0.020068271085619926,
-0.004264958202838898,
-0.0573585070669651,
-0.010529537685215473,
0.004638761281967163,
0.005715133622288704,
-0.013889261521399021,
0.019311657175421715,
0.005188206676393747,
-0.017023801803588867,
0.0016719806008040905,
-0.017005788162350655,
0.014798998832702637,
-0.03212004154920578,
-0.0026436434127390385,
0.011628428474068642,
-0.03905566409230232,
-0.052350446581840515,
-0.028048740699887276,
0.029381822794675827,
0.004373045638203621,
0.049468107521533966,
0.026175223290920258,
-0.0004982164246030152,
0.04503651335835457
]
|
30,591 | networkx.drawing.nx_pylab | draw_kamada_kawai | Draw the graph `G` with a Kamada-Kawai force-directed layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.kamada_kawai_layout(G), **kwargs)
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.kamada_kawai_layout` directly and reuse the
result::
>>> G = nx.complete_graph(5)
>>> pos = nx.kamada_kawai_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(5)
>>> nx.draw_kamada_kawai(G)
See Also
--------
:func:`~networkx.drawing.layout.kamada_kawai_layout`
| def draw_kamada_kawai(G, **kwargs):
"""Draw the graph `G` with a Kamada-Kawai force-directed layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.kamada_kawai_layout(G), **kwargs)
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.kamada_kawai_layout` directly and reuse the
result::
>>> G = nx.complete_graph(5)
>>> pos = nx.kamada_kawai_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(5)
>>> nx.draw_kamada_kawai(G)
See Also
--------
:func:`~networkx.drawing.layout.kamada_kawai_layout`
"""
draw(G, kamada_kawai_layout(G), **kwargs)
| (G, **kwargs) | [
0.04652895778417587,
-0.014101304113864899,
0.044817548245191574,
0.026722952723503113,
-0.0454593263566494,
-0.004808883648365736,
-0.08414431661367416,
0.030270561575889587,
0.06200295314192772,
-0.028309572488069534,
-0.007692431099712849,
-0.013352562673389912,
0.036135707050561905,
0.031090613454580307,
-0.01075870729982853,
-0.02358536794781685,
-0.011685720644891262,
-0.0011208843206986785,
-0.02970009297132492,
-0.016329701989889145,
0.02438759058713913,
-0.046065449714660645,
0.018290692940354347,
-0.01405673660337925,
-0.025920728221535683,
-0.007928641512989998,
-0.006591602228581905,
0.06710153073072433,
0.02978922799229622,
0.003881869837641716,
0.041073836386203766,
-0.04531670734286308,
-0.03429950773715973,
0.019716868177056313,
0.01862940937280655,
0.01301384624093771,
0.008387691341340542,
-0.019716868177056313,
-0.06164640933275223,
-0.047313351184129715,
0.0637500211596489,
0.01550073828548193,
0.018032198771834373,
-0.03476301208138466,
0.013744760304689407,
0.028612634167075157,
0.015821628272533417,
0.030751897022128105,
-0.03704489395022392,
-0.015144194476306438,
-0.022979242727160454,
-0.05419464781880379,
-0.027043841779232025,
0.006734219845384359,
-0.00013293788651935756,
-0.020109066739678383,
0.013334735296666622,
0.0016646134899929166,
0.03458474203944206,
-0.06396394222974777,
0.010188236832618713,
0.00804451759904623,
0.0717722550034523,
0.010812188498675823,
-0.0666380226612091,
-0.014288489706814289,
-0.020305166020989418,
-0.03096582181751728,
0.019199879840016365,
-0.0055086007341742516,
0.006511379964649677,
0.08114935457706451,
-0.0070016272366046906,
-0.01197095587849617,
0.014047822915017605,
0.0132010318338871,
-0.016712987795472145,
0.007282405626028776,
-0.0446036197245121,
0.022426599636673927,
-0.01360214315354824,
-0.053481560200452805,
-0.03597526252269745,
0.015233330428600311,
0.027953028678894043,
0.005798292346298695,
0.04214346781373024,
0.06628147512674332,
0.03850672394037247,
-0.06710153073072433,
0.022373119369149208,
-0.016704073175787926,
0.04456796497106552,
0.011587671004235744,
-0.03130453824996948,
-0.0021548611111938953,
-0.02105390653014183,
-0.02686556987464428,
0.011667893268167973,
0.00607907073572278,
0.03672400489449501,
-0.02353188581764698,
0.05027266591787338,
-0.006890207529067993,
-0.004572673235088587,
-0.043533988296985626,
-0.04093122109770775,
0.005036179907619953,
-0.003529782872647047,
0.020073411986231804,
-0.022622698917984962,
-0.0387919582426548,
0.07302015274763107,
-0.01855810172855854,
0.021339142695069313,
0.011427226476371288,
0.054765116423368454,
-0.016855604946613312,
-0.013949773274362087,
-0.02358536794781685,
-0.07294884324073792,
0.004158191382884979,
0.021731339395046234,
-0.01975252293050289,
0.035654373466968536,
0.006123638711869717,
0.0030417635571211576,
0.018014371395111084,
0.01646340638399124,
-0.01941380649805069,
0.06517619639635086,
0.02155306749045849,
0.021695686504244804,
0.0037838201969861984,
-0.031090613454580307,
0.04389053210616112,
0.03836410492658615,
-0.0005994391394779086,
0.041893888264894485,
0.034923456609249115,
0.012211622670292854,
-0.07615774124860764,
-0.02101825177669525,
0.04003985971212387,
-0.005553168710321188,
-0.022087883204221725,
-0.01176594290882349,
-0.04898910969495773,
0.01075870729982853,
-0.003431733464822173,
0.04599414020776749,
-0.008320839144289494,
0.08243291079998016,
0.02731124870479107,
-0.029610956087708473,
-0.04057467728853226,
-0.04214346781373024,
0.037401437759399414,
0.007162072230130434,
0.02098259888589382,
-0.008677382953464985,
-0.03173239156603813,
0.07836831361055374,
0.026722952723503113,
-0.060184579342603683,
0.019538596272468567,
-0.006154836155474186,
0.07729867845773697,
0.03754405304789543,
-0.014627206139266491,
-0.020893462002277374,
-0.014529156498610973,
-0.05911495164036751,
-0.022622698917984962,
0.006168206688016653,
-0.017845014110207558,
-0.0330694317817688,
-0.009822779335081577,
0.042286086827516556,
-0.051413606852293015,
-0.03599308803677559,
0.024548035115003586,
-0.017960891127586365,
0.01569683663547039,
-0.02476196177303791,
-0.03483432158827782,
0.01576814614236355,
0.0028478929307311773,
0.038185834884643555,
0.002371015725657344,
-0.04759858921170235,
0.050557900220155716,
0.01176594290882349,
0.037793636322021484,
0.017078444361686707,
-0.014965922571718693,
0.05130664259195328,
-0.02973574586212635,
-0.006203860975801945,
0.07466025650501251,
0.02194526605308056,
0.01564335636794567,
-0.014992663636803627,
0.03294464200735092,
0.050985753536224365,
0.020964771509170532,
0.01483221910893917,
-0.007897443138062954,
-0.039469391107559204,
-0.016374271363019943,
-0.02720428630709648,
-0.01574140600860119,
-0.004955957643687725,
0.011248954571783543,
0.014154786244034767,
-0.024458900094032288,
-0.005178797524422407,
0.059685420244932175,
-0.030858859419822693,
-0.03317639231681824,
-0.07993710041046143,
0.01822829805314541,
-0.03588612750172615,
-0.015233330428600311,
0.0439261868596077,
-0.055585168302059174,
0.04043205827474594,
0.013824982568621635,
0.00683226902037859,
-0.07205748558044434,
0.023228824138641357,
-0.012122486717998981,
0.016347529366612434,
0.006859010085463524,
0.0024178121238946915,
-0.08164851367473602,
-0.022551391273736954,
-0.04667157307267189,
0.0056378478184342384,
0.005726983770728111,
-0.004135907161980867,
-0.03782929107546806,
0.008147024549543858,
-0.0165347158908844,
-0.02064388245344162,
0.032391998916864395,
-0.024993715807795525,
-0.01822829805314541,
0.05048659071326256,
0.0004949829890392721,
-0.07751260697841644,
-0.006087983958423138,
0.04178692400455475,
0.028790906071662903,
0.008548135869204998,
0.008013320155441761,
-0.03918415680527687,
0.04923868924379349,
-0.001709181466139853,
0.03055579774081707,
-0.035262174904346466,
0.034531258046627045,
-0.11944214999675751,
0.038150180131196976,
0.03918415680527687,
0.043997496366500854,
0.009564285166561604,
0.01574140600860119,
-0.048525601625442505,
-0.032053280621767044,
0.0037793635856360197,
0.05066486448049545,
-0.004238413646817207,
-0.028808733448386192,
0.045637596398591995,
0.05522862449288368,
0.005865144077688456,
0.027810411527752876,
-0.006965972948819399,
-0.03226720541715622,
-0.004777685739099979,
-0.05661914497613907,
-0.02183830365538597,
0.05669045075774193,
-0.0818624421954155,
0.035796988755464554,
0.0057849218137562275,
0.010705225169658661,
0.04706377163529396,
0.011908560059964657,
0.07858223468065262,
-0.006533663719892502,
-0.014965922571718693,
0.043533988296985626,
0.02312185987830162,
0.02192743867635727,
-0.0370805487036705,
0.04756293445825577,
-0.04449665546417236,
0.006368762347847223,
0.06517619639635086,
-0.05661914497613907,
0.08949247747659683,
0.015001577325165272,
0.056013017892837524,
0.06260907649993896,
0.04160865396261215,
-0.007447306998074055,
0.00801777746528387,
0.0247797891497612,
-0.0892072394490242,
-0.02816695347428322,
0.03340814635157585,
0.016855604946613312,
-0.07950925081968307,
-0.05986369028687477,
0.020536918193101883,
-0.021410450339317322,
0.03552958369255066,
0.015411602333188057,
0.006021132227033377,
-0.002823380520567298,
-0.058437515050172806,
-0.007242294494062662,
-0.008521394804120064,
0.00802669022232294,
0.059685420244932175,
0.022141365334391594,
0.04253566637635231,
0.005713613238185644,
-0.03765101730823517,
-0.008138110861182213,
-0.04171561449766159,
-0.0027698990888893604,
-0.054693806916475296,
0.019110742956399918,
-0.003320313524454832,
0.002034527715295553,
-0.0651048868894577,
-0.05052224546670914,
0.01937815174460411,
-0.002562657929956913,
-0.012479030527174473,
-0.010446731001138687,
0.06859901547431946,
0.04496016353368759,
-0.03975462540984154,
-0.020554745569825172,
-0.04014682397246361,
0.07294884324073792,
0.011587671004235744,
0.050950098782777786,
0.008882395923137665,
-0.011935301125049591,
0.04503147304058075,
0.04624371975660324,
0.059293221682310104,
-0.009519717656075954,
-0.07679951936006546,
0.08029364794492722,
0.0264911986887455,
0.0164901465177536,
-0.02727559581398964,
-0.0040066600777208805,
0.015188762918114662,
0.014564811252057552,
-0.06414221972227097,
-0.03768667206168175,
0.06385698169469833,
-0.02567114867269993,
0.019645558670163155,
-0.0329802930355072,
-0.06143248453736305,
0.026348581537604332,
0.00972472969442606,
0.08350253850221634,
0.040253788232803345,
0.04378356784582138,
-0.023389268666505814,
0.021784821525216103,
0.026509026065468788,
-0.061325520277023315,
0.03765101730823517,
0.016811037436127663,
0.02608117274940014,
-0.036135707050561905,
0.018362002447247505,
-0.008802173659205437,
-0.026669470593333244,
-0.04143038019537926,
-0.02980705536901951,
-0.04913172498345375,
0.10653526335954666,
0.019235534593462944,
-0.013102982193231583,
0.003935351502150297,
0.007331430446356535,
0.018255038186907768,
-0.0413590706884861,
-0.010803274810314178,
0.022408774122595787,
-0.09305791556835175,
-0.01943163387477398,
-0.030751897022128105,
0.018896818161010742,
-0.01574140600860119,
-0.025350259616971016,
0.0015643355436623096,
-0.0028902324847877026,
0.05872275307774544,
0.055585168302059174,
0.03893457353115082,
-0.04125211015343666,
0.029165277257561684,
0.09148912131786346,
-0.010018878616392612,
-0.024993715807795525,
0.06752938032150269,
0.03317639231681824,
0.009136432781815529,
-0.0020590401254594326,
-0.02223050221800804,
0.03331901133060455,
-0.015821628272533417,
0.08485740423202515,
-0.002522546797990799,
-0.05034397542476654,
0.004075740464031696,
-0.04125211015343666,
0.020002102479338646,
0.004516963381320238,
-0.0034228197764605284,
0.016178172081708908,
0.06325085461139679,
-0.04745597019791603,
0.02850567176938057,
0.03060927800834179,
-0.010607175529003143,
0.032017625868320465,
-0.025368086993694305,
0.060469817370176315,
-0.03722316399216652,
0.004666266031563282,
-0.006457898300141096,
-0.022141365334391594,
-0.009350359439849854,
0.022872280329465866,
-0.018896818161010742,
0.06125421077013016,
0.025920728221535683,
0.031589772552251816,
0.009189914911985397,
0.0028590350411832333,
0.025724628940224648,
-0.05273281782865524,
-0.0075230724178254604,
-0.015358121134340763,
-0.03182152658700943,
-0.051877111196517944,
0.030217081308364868,
0.03839975968003273,
-0.004227271769195795,
-0.01605338044464588,
0.025047196075320244,
0.049809157848358154,
0.0036144619807600975,
-0.014992663636803627,
0.021196523681282997,
-0.005624477285891771,
-0.034816496074199677,
-0.011133077554404736,
-0.0061102681793272495,
-0.0666380226612091,
-0.002533688908442855,
0.038257140666246414,
-0.04011116921901703,
-0.022872280329465866,
-0.001182165346108377,
-0.08542788028717041,
0.005847317166626453,
-0.023050552234053612,
-0.01612468995153904,
0.02768561989068985,
-0.0023197627160698175,
0.03299812227487564,
-0.005236736033111811,
0.016418838873505592,
-0.03996855020523071,
-0.012363153509795666,
-0.04421142116189003,
0.007995492778718472,
-0.021588722243905067,
-0.0009080722811631858,
-0.017212148755788803,
0.06403525173664093,
0.025902900844812393,
-0.005521970801055431,
-0.036937929689884186,
-0.08150589466094971,
-0.04039640352129936,
-0.03331901133060455,
0.022016575559973717,
-0.03130453824996948,
-0.002386614680290222,
-0.008815543726086617,
-0.02843436226248741,
0.07886747270822525,
0.03139367327094078,
0.0428922101855278,
0.04385487735271454,
-0.01975252293050289,
-0.008704124018549919,
0.07394716888666153,
0.030234908685088158,
-0.0005710270488634706,
0.022016575559973717,
-0.06153944879770279,
-0.007959838956594467,
0.027026014402508736,
-0.02271183580160141,
0.019895140081644058,
0.006596059072762728,
0.027008187025785446,
0.020037757232785225,
-0.06913382560014725,
0.06788592785596848,
0.09797821938991547,
0.02763213962316513,
-0.01197095587849617,
0.0075364429503679276,
-0.0469924621284008,
0.014172612689435482,
0.02852349728345871,
0.1249329224228859,
-0.026259444653987885,
-0.010874583385884762,
-0.04342702403664589,
0.02431628294289112,
-0.07105916738510132,
-0.00742502324283123,
0.02067953534424305,
0.027150804176926613,
-0.04381922259926796,
-0.07373324036598206,
0.005713613238185644,
0.010402163490653038,
0.01733693853020668,
-0.015910763293504715,
-0.035262174904346466,
-0.042713940143585205,
-0.01361997053027153,
-0.004080197308212519,
0.011641152203083038,
0.033657729625701904,
0.04652895778417587,
0.05119967833161354,
-0.01345061231404543,
0.025385912507772446,
0.029468338936567307,
-0.019912967458367348,
-0.05251888930797577,
-0.004508049692958593,
-0.007995492778718472,
-0.05505035072565079,
0.02679426036775112,
-0.037401437759399414,
-0.005504143889993429,
-0.0034985854290425777,
-0.0168734323233366,
0.03558306396007538,
-0.015937505289912224,
-0.021410450339317322,
0.06578231602907181,
-0.018362002447247505,
-0.08521395176649094,
0.024280628189444542,
-0.0314471572637558,
0.01729237101972103,
0.008592703379690647,
-0.020786499604582787,
-0.0021882872097194195,
0.03173239156603813,
-0.01605338044464588,
0.09462670236825943,
0.013691279105842113,
0.05751050263643265,
0.04125211015343666,
-0.012095745652914047,
-0.051449257880449295,
-0.041109491139650345,
-0.020750844851136208,
-0.023638848215341568,
0.015892935916781425,
-0.014921355061233044,
-0.018433310091495514,
0.017069531604647636,
0.04018247872591019,
0.006404416635632515,
0.038257140666246414,
0.014181526377797127,
-0.025439394637942314,
0.023478403687477112,
-0.0073537142015993595,
0.0011453967308625579,
0.04100252687931061,
0.10396815091371536,
0.0190572626888752,
0.021766994148492813,
0.00017841113731265068,
-0.06164640933275223,
-0.04121645539999008,
0.020055584609508514,
0.021570894867181778,
-0.0013905204832553864,
-0.059221912175416946,
-0.027471693232655525,
0.038257140666246414,
-0.04039640352129936,
-0.0321245901286602,
0.01944945938885212,
-0.018032198771834373,
-0.025100678205490112,
0.0015342521946877241,
-0.019895140081644058,
-0.00113982567563653,
0.02524329535663128,
0.010464558377861977,
-0.00930579099804163,
-0.006324194371700287,
0.035654373466968536,
0.007714714854955673,
0.01697148196399212,
-0.04517408832907677,
-0.01074087992310524,
0.015447257086634636,
-0.07116612792015076,
-0.014466761611402035,
-0.015598787926137447,
0.010072359815239906,
0.006065700203180313,
-0.08157720416784286,
0.02228398248553276,
-0.039398081600666046,
0.02684774249792099,
0.02230180986225605,
-0.035690028220415115,
0.011828337796032429,
-0.021339142695069313,
-0.042678285390138626,
-0.010027792304754257,
-0.01483221910893917,
-0.03428167849779129,
-0.04100252687931061,
-0.026544680818915367,
0.03996855020523071,
0.057153958827257156,
0.028256090357899666,
-0.018896818161010742,
0.002255139173939824,
-0.060434162616729736,
0.007157615385949612,
0.0011314692674204707,
-0.06161075457930565,
0.032498959451913834,
0.014341971836984158,
0.038257140666246414,
-0.014930268749594688,
-0.022070055827498436,
0.033336836844682693,
-0.035796988755464554,
-0.03549392893910408,
0.010678485035896301,
-0.0034941285848617554,
-0.04471058398485184,
-0.04713508114218712,
-0.004153734538704157,
0.05084313452243805,
0.03390730917453766,
0.04210781306028366,
-0.04046771302819252,
0.02429845556616783,
0.012746438384056091,
-0.00212477776221931,
-0.015572046861052513,
-0.04517408832907677,
0.04581587016582489,
-0.007411652710288763,
-0.03388947993516922,
0.011427226476371288,
-0.020002102479338646,
0.007162072230130434,
-0.03921981155872345,
0.03394296392798424,
0.03437081351876259,
0.009983224794268608,
-0.02148175984621048,
-0.004100252874195576,
0.017845014110207558,
-0.020519090816378593,
0.003538696561008692,
0.037793636322021484,
0.0037548511754721403,
-0.00356098054908216,
0.022854452952742577,
-0.05904364213347435,
-0.02155306749045849,
-0.04371226206421852,
0.023246651515364647,
-0.03062710538506508,
0.051021408289670944,
-0.024637171998620033,
-0.017631087452173233,
0.023335786536335945,
-0.04706377163529396,
0.016347529366612434,
-0.055977366864681244,
-0.049809157848358154,
-0.07205748558044434,
-0.0446036197245121,
0.0034807580523192883,
-0.018451137468218803,
0.009591026231646538,
-0.030858859419822693,
0.010847843252122402,
-0.03718750923871994,
-0.009314704686403275,
0.009965397417545319,
-0.07993710041046143,
0.037793636322021484,
-0.0031286710873246193,
0.0020133578218519688,
0.021749166771769524,
-0.04873952642083168,
-0.017265629023313522,
-0.0018172587733715773,
0.028291745111346245,
-0.01531355269253254,
-0.009270137175917625,
0.037793636322021484,
0.04467492923140526,
-0.023656675592064857,
0.043177444487810135,
-0.041537344455718994,
-0.028790906071662903,
0.04702811688184738,
-0.04706377163529396,
-0.03690227493643761,
0.06820681691169739,
0.010616089217364788,
0.044389694929122925,
0.04089556634426117,
0.017702395096421242,
0.02440541796386242,
0.024619344621896744,
0.05811662599444389,
0.01364671066403389,
-0.03012794442474842,
-0.02155306749045849,
0.06036285310983658,
-0.06153944879770279,
-0.06478399783372879,
-0.054729461669921875,
0.00786178931593895,
-0.02438759058713913,
0.015046144835650921,
-0.04100252687931061,
-0.001577705959789455,
0.0230683796107769
]
|
30,592 | networkx.drawing.nx_pylab | draw_networkx | Draw the graph G using Matplotlib.
Draw the graph with Matplotlib with options for node positions,
labeling, titles, and many other drawing features.
See draw() for simple drawing without labels or axes.
Parameters
----------
G : graph
A networkx graph
pos : dictionary, optional
A dictionary with nodes as keys and positions as values.
If not specified a spring layout positioning will be computed.
See :py:mod:`networkx.drawing.layout` for functions that
compute node positions.
arrows : bool or None, optional (default=None)
If `None`, directed graphs draw arrowheads with
`~matplotlib.patches.FancyArrowPatch`, while undirected graphs draw edges
via `~matplotlib.collections.LineCollection` for speed.
If `True`, draw arrowheads with FancyArrowPatches (bendable and stylish).
If `False`, draw edges using LineCollection (linear and fast).
For directed graphs, if True draw arrowheads.
Note: Arrows will be the same color as edges.
arrowstyle : str (default='-\|>' for directed graphs)
For directed graphs, choose the style of the arrowsheads.
For undirected graphs default to '-'
See `matplotlib.patches.ArrowStyle` for more options.
arrowsize : int or list (default=10)
For directed graphs, choose the size of the arrow head's length and
width. A list of values can be passed in to assign a different size for arrow head's length and width.
See `matplotlib.patches.FancyArrowPatch` for attribute `mutation_scale`
for more info.
with_labels : bool (default=True)
Set to True to draw labels on the nodes.
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
nodelist : list (default=list(G))
Draw only specified nodes
edgelist : list (default=list(G.edges()))
Draw only specified edges
node_size : scalar or array (default=300)
Size of nodes. If an array is specified it must be the
same length as nodelist.
node_color : color or array of colors (default='#1f78b4')
Node color. Can be a single color or a sequence of colors with the same
length as nodelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the cmap and vmin,vmax parameters. See
matplotlib.scatter for more details.
node_shape : string (default='o')
The shape of the node. Specification is as matplotlib.scatter
marker, one of 'so^>v<dph8'.
alpha : float or None (default=None)
The node and edge transparency
cmap : Matplotlib colormap, optional
Colormap for mapping intensities of nodes
vmin,vmax : float, optional
Minimum and maximum for node colormap scaling
linewidths : scalar or sequence (default=1.0)
Line width of symbol border
width : float or array of floats (default=1.0)
Line width of edges
edge_color : color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edgelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.
edge_cmap : Matplotlib colormap, optional
Colormap for mapping intensities of edges
edge_vmin,edge_vmax : floats, optional
Minimum and maximum for edge colormap scaling
style : string (default=solid line)
Edge line style e.g.: '-', '--', '-.', ':'
or words like 'solid' or 'dashed'.
(See `matplotlib.patches.FancyArrowPatch`: `linestyle`)
labels : dictionary (default=None)
Node labels in a dictionary of text labels keyed by node
font_size : int (default=12 for nodes, 10 for edges)
Font size for text labels
font_color : color (default='k' black)
Font color string. Color can be string or rgb (or rgba) tuple of
floats from 0-1.
font_weight : string (default='normal')
Font weight
font_family : string (default='sans-serif')
Font family
label : string, optional
Label for graph legend
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
kwds : optional keywords
See networkx.draw_networkx_nodes(), networkx.draw_networkx_edges(), and
networkx.draw_networkx_labels() for a description of optional keywords.
Notes
-----
For directed graphs, arrows are drawn at the head end. Arrows can be
turned off with keyword arrows=False.
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> nx.draw(G)
>>> nx.draw(G, pos=nx.spring_layout(G)) # use spring layout
>>> import matplotlib.pyplot as plt
>>> limits = plt.axis("off") # turn off axis
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx_nodes
draw_networkx_edges
draw_networkx_labels
draw_networkx_edge_labels
| def draw_networkx(G, pos=None, arrows=None, with_labels=True, **kwds):
r"""Draw the graph G using Matplotlib.
Draw the graph with Matplotlib with options for node positions,
labeling, titles, and many other drawing features.
See draw() for simple drawing without labels or axes.
Parameters
----------
G : graph
A networkx graph
pos : dictionary, optional
A dictionary with nodes as keys and positions as values.
If not specified a spring layout positioning will be computed.
See :py:mod:`networkx.drawing.layout` for functions that
compute node positions.
arrows : bool or None, optional (default=None)
If `None`, directed graphs draw arrowheads with
`~matplotlib.patches.FancyArrowPatch`, while undirected graphs draw edges
via `~matplotlib.collections.LineCollection` for speed.
If `True`, draw arrowheads with FancyArrowPatches (bendable and stylish).
If `False`, draw edges using LineCollection (linear and fast).
For directed graphs, if True draw arrowheads.
Note: Arrows will be the same color as edges.
arrowstyle : str (default='-\|>' for directed graphs)
For directed graphs, choose the style of the arrowsheads.
For undirected graphs default to '-'
See `matplotlib.patches.ArrowStyle` for more options.
arrowsize : int or list (default=10)
For directed graphs, choose the size of the arrow head's length and
width. A list of values can be passed in to assign a different size for arrow head's length and width.
See `matplotlib.patches.FancyArrowPatch` for attribute `mutation_scale`
for more info.
with_labels : bool (default=True)
Set to True to draw labels on the nodes.
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
nodelist : list (default=list(G))
Draw only specified nodes
edgelist : list (default=list(G.edges()))
Draw only specified edges
node_size : scalar or array (default=300)
Size of nodes. If an array is specified it must be the
same length as nodelist.
node_color : color or array of colors (default='#1f78b4')
Node color. Can be a single color or a sequence of colors with the same
length as nodelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the cmap and vmin,vmax parameters. See
matplotlib.scatter for more details.
node_shape : string (default='o')
The shape of the node. Specification is as matplotlib.scatter
marker, one of 'so^>v<dph8'.
alpha : float or None (default=None)
The node and edge transparency
cmap : Matplotlib colormap, optional
Colormap for mapping intensities of nodes
vmin,vmax : float, optional
Minimum and maximum for node colormap scaling
linewidths : scalar or sequence (default=1.0)
Line width of symbol border
width : float or array of floats (default=1.0)
Line width of edges
edge_color : color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edgelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.
edge_cmap : Matplotlib colormap, optional
Colormap for mapping intensities of edges
edge_vmin,edge_vmax : floats, optional
Minimum and maximum for edge colormap scaling
style : string (default=solid line)
Edge line style e.g.: '-', '--', '-.', ':'
or words like 'solid' or 'dashed'.
(See `matplotlib.patches.FancyArrowPatch`: `linestyle`)
labels : dictionary (default=None)
Node labels in a dictionary of text labels keyed by node
font_size : int (default=12 for nodes, 10 for edges)
Font size for text labels
font_color : color (default='k' black)
Font color string. Color can be string or rgb (or rgba) tuple of
floats from 0-1.
font_weight : string (default='normal')
Font weight
font_family : string (default='sans-serif')
Font family
label : string, optional
Label for graph legend
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
kwds : optional keywords
See networkx.draw_networkx_nodes(), networkx.draw_networkx_edges(), and
networkx.draw_networkx_labels() for a description of optional keywords.
Notes
-----
For directed graphs, arrows are drawn at the head end. Arrows can be
turned off with keyword arrows=False.
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> nx.draw(G)
>>> nx.draw(G, pos=nx.spring_layout(G)) # use spring layout
>>> import matplotlib.pyplot as plt
>>> limits = plt.axis("off") # turn off axis
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx_nodes
draw_networkx_edges
draw_networkx_labels
draw_networkx_edge_labels
"""
from inspect import signature
import matplotlib.pyplot as plt
# Get all valid keywords by inspecting the signatures of draw_networkx_nodes,
# draw_networkx_edges, draw_networkx_labels
valid_node_kwds = signature(draw_networkx_nodes).parameters.keys()
valid_edge_kwds = signature(draw_networkx_edges).parameters.keys()
valid_label_kwds = signature(draw_networkx_labels).parameters.keys()
# Create a set with all valid keywords across the three functions and
# remove the arguments of this function (draw_networkx)
valid_kwds = (valid_node_kwds | valid_edge_kwds | valid_label_kwds) - {
"G",
"pos",
"arrows",
"with_labels",
}
if any(k not in valid_kwds for k in kwds):
invalid_args = ", ".join([k for k in kwds if k not in valid_kwds])
raise ValueError(f"Received invalid argument(s): {invalid_args}")
node_kwds = {k: v for k, v in kwds.items() if k in valid_node_kwds}
edge_kwds = {k: v for k, v in kwds.items() if k in valid_edge_kwds}
label_kwds = {k: v for k, v in kwds.items() if k in valid_label_kwds}
if pos is None:
pos = nx.drawing.spring_layout(G) # default to spring layout
draw_networkx_nodes(G, pos, **node_kwds)
draw_networkx_edges(G, pos, arrows=arrows, **edge_kwds)
if with_labels:
draw_networkx_labels(G, pos, **label_kwds)
plt.draw_if_interactive()
| (G, pos=None, arrows=None, with_labels=True, **kwds) | [
0.021232442930340767,
-0.011076925322413445,
0.04883461818099022,
-0.0219936054199934,
-0.03014606237411499,
0.011908194981515408,
-0.062215063720941544,
-0.003943525720387697,
0.07499458640813828,
-0.04198415204882622,
-0.015724025666713715,
0.014712479896843433,
0.06009181961417198,
0.049435537308454514,
-0.012068440206348896,
-0.0032474619802087545,
0.009945196099579334,
-0.0004970094305463135,
-0.0017213801620528102,
0.009143971838057041,
0.005723745562136173,
-0.049435537308454514,
0.027441930025815964,
-0.021693145856261253,
0.02319544181227684,
-0.013180138543248177,
0.0063296714797616005,
0.012759496457874775,
-0.016274867579340935,
0.05236000567674637,
0.0030446520540863276,
-0.043586600571870804,
-0.09806984663009644,
-0.026059819385409355,
0.02307525835931301,
0.031948816031217575,
0.0007480179192498326,
0.0046846577897667885,
-0.007706775795668364,
0.003688135417178273,
0.004299068823456764,
0.0017689529340714216,
0.027261655777692795,
-0.015984423458576202,
-0.010616221465170383,
0.03815830498933792,
0.018918907269835472,
0.07375269383192062,
-0.04891474172472954,
-0.03683628514409065,
0.0033776608761399984,
-0.047071922570466995,
-0.0168557558208704,
0.012449021451175213,
0.007641676347702742,
-0.03843873366713524,
0.03172848001122475,
0.04146335646510124,
0.02437724731862545,
-0.021172350272536278,
0.040061213076114655,
0.011197108775377274,
-0.01848824881017208,
-0.04314592480659485,
-0.0314280204474926,
0.008608153089880943,
0.010736404918134212,
-0.0651395320892334,
-0.016905831173062325,
-0.011307276785373688,
0.02321547269821167,
0.03168841823935509,
-0.02660064585506916,
-0.03493337705731392,
0.04979608580470085,
0.012208654545247555,
0.012809572741389275,
-0.00047760477173142135,
-0.029765481129288673,
-0.0007955906330607831,
0.0329703763127327,
0.011868134140968323,
-0.004183892626315355,
0.0042139389552176,
0.06850467622280121,
-0.0076016150414943695,
-0.0009451942169107497,
0.07599612325429916,
0.009118933230638504,
-0.054082635790109634,
0.007671722210943699,
-0.011307276785373688,
0.023916544392704964,
0.02423703297972679,
-0.06618112325668335,
-0.030586736276745796,
0.0038283495232462883,
-0.07932119816541672,
0.03467297926545143,
0.03513368219137192,
-0.04386702924966812,
0.017737101763486862,
-0.06349702179431915,
-0.002556406194344163,
-0.05660649389028549,
-0.04643094539642334,
-0.10183560103178024,
0.03381166234612465,
-0.016585342586040497,
-0.0201808363199234,
-0.02914453111588955,
-0.014241760596632957,
0.09278176724910736,
-0.03403199836611748,
0.0580887570977211,
0.027602175250649452,
-0.008212548680603504,
-0.042585067451000214,
-0.02187342196702957,
-0.03633552044630051,
-0.05897010490298271,
0.02335568703711033,
0.021773269400000572,
-0.0348532535135746,
-0.01152761373668909,
-0.04502880200743675,
0.01659535802900791,
0.024116849526762962,
0.030606765300035477,
-0.05700710415840149,
0.07755851000547409,
-0.008107387460768223,
-0.007471416145563126,
0.03577466309070587,
0.029424959793686867,
-0.005583531688898802,
-0.04326611012220383,
0.022975105792284012,
-0.02539880946278572,
0.029605235904455185,
0.04294561967253685,
-0.0647389218211174,
-0.013490613549947739,
0.03208903223276138,
-0.05207957699894905,
-0.0006034219986759126,
-0.03613521531224251,
-0.04294561967253685,
-0.017096122726798058,
-0.013530674390494823,
0.04266519099473953,
-0.03295034542679787,
-0.009649744257330894,
-0.011677843518555164,
-0.029424959793686867,
-0.04326611012220383,
-0.050437066704034805,
0.012418976053595543,
-0.009023788385093212,
0.07755851000547409,
-0.022734738886356354,
-0.04182390496134758,
0.08613160997629166,
0.01779719442129135,
-0.004857421852648258,
0.038779255002737045,
0.028663797304034233,
-0.026400338858366013,
0.010786481201648712,
0.021272502839565277,
0.029885664582252502,
-0.049395475536584854,
-0.06726277619600296,
0.008693283423781395,
0.01868855580687523,
-0.00240993220359087,
0.007381278555840254,
0.0265605840831995,
-0.035474203526973724,
-0.008447907865047455,
0.0011786760296672583,
0.0019517322070896626,
0.020571433007717133,
0.0033125614281743765,
0.003562944009900093,
-0.006069273687899113,
0.020130759105086327,
0.008242594078183174,
0.022874951362609863,
-0.031948816031217575,
-0.018968984484672546,
0.015323413535952568,
-0.01209848653525114,
0.052800677716732025,
0.04538935422897339,
-0.020270973443984985,
0.006134373135864735,
-0.028303246945142746,
-0.006149396300315857,
0.02684101276099682,
0.04839394614100456,
0.017456673085689545,
0.03925998881459236,
-0.01965002529323101,
-0.01862846314907074,
-0.02547893114387989,
0.020631523802876472,
0.0002661879698280245,
0.01965002529323101,
-0.018207820132374763,
0.013470582664012909,
-0.02894422598183155,
0.019419671967625618,
0.04214439541101456,
-0.07791905850172043,
-0.004544443916529417,
-0.06261567771434784,
0.028122970834374428,
-0.06313647329807281,
-0.01612463779747486,
-0.0004916887846775353,
0.03026624582707882,
0.006294617895036936,
-0.02788260392844677,
0.03449270501732826,
-0.04839394614100456,
0.015663934871554375,
-0.013410490937530994,
0.04967590421438217,
-0.08909613639116287,
0.07868021726608276,
0.014902770519256592,
0.00755654601380229,
0.05684686079621315,
0.019409656524658203,
-0.09903131425380707,
0.0036080130375921726,
0.012489083223044872,
0.006009181961417198,
0.04619057849049568,
-0.05604563653469086,
-0.01444206666201353,
-0.02073167823255062,
-0.008077342063188553,
0.08709307760000229,
0.08008236438035965,
0.03281013295054436,
0.030967317521572113,
-0.015373489819467068,
-0.005638615693897009,
-0.0711887776851654,
-0.020040621981024742,
0.0026891089510172606,
0.002547642681747675,
-0.006775352638214827,
0.01917930506169796,
-0.06341689825057983,
-0.015513704158365726,
0.014311867766082287,
0.04843400418758392,
-0.003983587026596069,
0.025839481502771378,
-0.07142914086580276,
0.03319071605801582,
0.10616221278905869,
-0.01724635250866413,
0.008212548680603504,
0.039941027760505676,
-0.05240006744861603,
-0.04146335646510124,
0.06706246733665466,
0.06566032767295837,
0.030606765300035477,
0.006845459807664156,
0.059571024030447006,
0.010686328634619713,
-0.048033393919467926,
0.00042471144115552306,
0.07243067026138306,
-0.03347114101052284,
-0.055084165185689926,
-0.018838785588741302,
-0.03333092853426933,
0.004136320203542709,
-0.05236000567674637,
-0.02329559437930584,
-0.005348172038793564,
0.008287663571536541,
-0.02561914548277855,
-0.014311867766082287,
0.04727223142981529,
-0.011798026971518993,
0.01044596079736948,
0.02309528924524784,
-0.01813771389424801,
-0.008077342063188553,
-0.0036080130375921726,
0.011096956208348274,
-0.048033393919467926,
0.029424959793686867,
0.0697065070271492,
-0.04843400418758392,
0.04390708729624748,
-0.01281958818435669,
0.03865906968712807,
0.04867437109351158,
0.053922392427921295,
-0.003082209499552846,
0.014802617952227592,
-0.00637474050745368,
-0.044628191739320755,
-0.0016550287837162614,
0.018868830054998398,
0.03695646673440933,
-0.011307276785373688,
-0.021272502839565277,
0.0045169019140303135,
-0.06357714533805847,
0.06317653506994247,
-0.010225624777376652,
-0.021532902494072914,
0.048073455691337585,
-0.0643383041024208,
0.019800255075097084,
-0.07952150702476501,
0.06065267696976662,
0.03285019472241402,
0.11265213042497635,
0.022774798795580864,
0.03966059908270836,
-0.006494923960417509,
-0.01224871538579464,
-0.01746668852865696,
-0.01323021575808525,
-0.09230103343725204,
0.02539880946278572,
0.03793796896934509,
0.013490613549947739,
0.023796360939741135,
-0.00168131897225976,
0.03295034542679787,
0.051759086549282074,
-0.0008343999506905675,
0.029665328562259674,
0.017596887424588203,
0.02912450209259987,
0.03611518442630768,
0.0041588544845581055,
-0.029785512015223503,
0.04659118875861168,
-0.042184457182884216,
0.09734874218702316,
-0.044828496873378754,
-0.011858118698000908,
-0.04266519099473953,
0.0024875509552657604,
0.026039788499474525,
-0.02315538004040718,
-0.021212412044405937,
0.03279010206460953,
-0.035273898392915726,
0.00008622549648862332,
-0.00789706688374281,
0.02670079842209816,
-0.04743247479200363,
-0.011307276785373688,
0.00015648911357857287,
-0.013220200315117836,
0.08525025844573975,
-0.04338629171252251,
0.046070393174886703,
-0.02772235870361328,
-0.0798419937491417,
-0.009359301067888737,
-0.013039924204349518,
0.0357946939766407,
-0.02533871680498123,
-0.00727611780166626,
0.038699131458997726,
-0.012649327516555786,
0.004486855585128069,
-0.07835973054170609,
0.02329559437930584,
0.028563644737005234,
0.025999726727604866,
0.012989847920835018,
0.06766338646411896,
0.048313822597265244,
0.00423897709697485,
-0.049155108630657196,
-0.06541995704174042,
-0.005588538944721222,
0.03972069174051285,
0.03829851746559143,
-0.0748744085431099,
-0.016154684126377106,
0.07499458640813828,
0.03230936825275421,
-0.0371367447078228,
-0.05344165861606598,
0.016354989260435104,
0.024577554315328598,
0.03711671382188797,
0.02073167823255062,
0.030406460165977478,
-0.00695562781766057,
0.012439006008207798,
-0.01567394845187664,
0.07110865414142609,
0.06237530708312988,
0.040161363780498505,
0.031067470088601112,
-0.04859425127506256,
0.0001988976582651958,
0.06397775560617447,
0.002588955918326974,
-0.03377160057425499,
0.0719899982213974,
0.06417806446552277,
-0.056286003440618515,
-0.019640009850263596,
-0.006194464862346649,
0.03699652850627899,
0.025318685919046402,
0.029485052451491356,
0.03587481379508972,
-0.015533735044300556,
-0.0037682577967643738,
-0.02794269472360611,
0.03264988958835602,
-0.019269442185759544,
-0.009249132126569748,
0.021232442930340767,
0.04574990272521973,
0.017626933753490448,
-0.04100264981389046,
0.043466415256261826,
-0.057367656379938126,
-0.03725692629814148,
0.012038393877446651,
-0.013580750674009323,
-0.027181532233953476,
-0.0046846577897667885,
-0.038819313049316406,
-0.018237866461277008,
0.046030331403017044,
-0.017096122726798058,
-0.019289473071694374,
0.02321547269821167,
-0.0015035474207252264,
0.018698571249842644,
0.021693145856261253,
0.03859897702932358,
0.017636949196457863,
-0.10271694511175156,
-0.023596053943037987,
-0.030847134068608284,
0.00046696350909769535,
-0.06546001881361008,
-0.002224649302661419,
0.01795743778347969,
-0.019269442185759544,
-0.05528447404503822,
0.024978166446089745,
-0.013140077702701092,
0.012298792600631714,
0.06301628798246384,
0.028804011642932892,
-0.0344526432454586,
0.02792266570031643,
0.07026736438274384,
-0.05676673725247383,
-0.05776826664805412,
-0.054122697561979294,
0.031988877803087234,
0.03861900791525841,
0.023836420848965645,
0.011187093332409859,
-0.05099792405962944,
-0.05772820860147476,
-0.0038934489712119102,
-0.019720131531357765,
0.027021287009119987,
0.015944361686706543,
0.01907915249466896,
0.03160829469561577,
0.024597585201263428,
0.011487552896142006,
-0.017927393317222595,
-0.021172350272536278,
-0.0034252337645739317,
-0.05444318801164627,
-0.03032633848488331,
-0.0140013936907053,
0.034412581473588943,
0.04859425127506256,
-0.03377160057425499,
-0.08725331723690033,
-0.01441202126443386,
-0.052920863032341,
0.017697039991617203,
0.013059955090284348,
0.03479316458106041,
0.013851163908839226,
0.03607512265443802,
0.014131592586636543,
-0.008818474598228931,
0.06898541003465652,
0.03353123366832733,
-0.020451249554753304,
0.030907224863767624,
0.028143001720309258,
0.0817248746752739,
0.01783725433051586,
0.0339118167757988,
0.03222924470901489,
-0.0032174161169677973,
0.04963584244251251,
0.0327700711786747,
-0.03641564026474953,
0.021452778950333595,
0.007216026075184345,
-0.01274948101490736,
-0.004399221856147051,
-0.04851412773132324,
0.09318237751722336,
0.037857845425605774,
-0.0004810475220438093,
-0.0018052583327516913,
0.006524969823658466,
-0.006990681402385235,
0.046671312302351,
-0.006645153742283583,
0.021152319386601448,
0.010896650142967701,
0.010175547562539577,
0.010065379552543163,
0.03689637780189514,
0.0006259564543142915,
-0.016094591468572617,
0.029284745454788208,
0.0032048970460891724,
-0.04735235124826431,
-0.004556962754577398,
0.001872861641459167,
-0.02335568703711033,
0.09470470249652863,
-0.03515371307730675,
0.003966060001403093,
-0.05488386005163193,
-0.02103213593363762,
-0.014952847734093666,
-0.01388121023774147,
-0.003167339600622654,
0.04546947777271271,
-0.01667547971010208,
-0.010676313191652298,
0.018007514998316765,
-0.0005489637842401862,
0.0018490753136575222,
-0.08188511431217194,
0.00336263794451952,
-0.02020086720585823,
-0.055044107139110565,
0.059771329164505005,
-0.0035053561441600323,
-0.021212412044405937,
-0.02085186168551445,
0.03150814399123192,
0.00609931955114007,
0.022454310208559036,
0.04635082185268402,
0.01927945762872696,
-0.010075394995510578,
-0.025939634069800377,
0.008222564123570919,
0.017737101763486862,
0.051638901233673096,
-0.013270276598632336,
-0.02658061496913433,
-0.057608023285865784,
0.012969817034900188,
0.03515371307730675,
0.028203092515468597,
0.03166838735342026,
0.018247881904244423,
-0.030686888843774796,
0.013029909692704678,
0.007321186363697052,
-0.04310586303472519,
-0.012669358402490616,
-0.024978166446089745,
0.06730283796787262,
0.0052279881201684475,
-0.000047142344556050375,
0.02900431677699089,
0.0157140102237463,
0.04683155566453934,
0.019860345870256424,
0.025939634069800377,
-0.03988093510270119,
0.04987620934844017,
0.027161501348018646,
0.024717768654227257,
-0.004724719095975161,
0.00803227350115776,
0.03026624582707882,
0.008973711170256138,
-0.007872028276324272,
-0.06389763206243515,
0.027141470462083817,
0.030606765300035477,
-0.018758662045001984,
-0.08236585557460785,
-0.048233699053525925,
-0.07399305701255798,
-0.010135486721992493,
0.027401870116591454,
0.0140013936907053,
0.00582389859482646,
0.026180002838373184,
-0.022694677114486694,
-0.04514898732304573,
-0.03134789690375328,
-0.010626236908137798,
0.025218533352017403,
-0.013470582664012909,
-0.01501293946057558,
-0.017737101763486862,
0.029485052451491356,
-0.004058701451867819,
-0.03260982781648636,
-0.021292533725500107,
-0.0000793399813119322,
0.008818474598228931,
-0.07082822173833847,
-0.009409377351403236,
-0.012449021451175213,
-0.0014922801638022065,
-0.015253306366503239,
-0.013390460051596165,
-0.031107531860470772,
-0.022614553570747375,
-0.009714843705296516,
-0.017757132649421692,
0.012008348479866982,
0.0344526432454586,
-0.026420369744300842,
0.05364196375012398,
0.00022221454128157347,
0.0038358611054718494,
0.004571985919028521,
-0.01453220471739769,
-0.009804981760680676,
0.017436642199754715,
0.04731229320168495,
-0.03815830498933792,
-0.04995633289217949,
0.02091195248067379,
-0.03944026306271553,
-0.0033426072914153337,
-0.01604451611638069,
0.057527899742126465,
0.029805541038513184,
-0.023616084828972816,
-0.017126169055700302,
-0.02032105065882206,
-0.0023035197518765926,
0.0077217984944581985,
-0.03934010863304138,
-0.04623064026236534,
-0.043546538800001144,
-0.017166228964924812,
-0.021773269400000572,
-0.015934348106384277,
-0.04999639466404915,
0.021733207628130913,
0.022734738886356354,
0.009224094450473785,
-0.04635082185268402,
0.038819313049316406,
0.028163032606244087,
-0.04422757774591446,
-0.058529432862997055,
-0.022754767909646034,
-0.013470582664012909,
-0.015243290923535824,
-0.049235228449106216,
0.014381974935531616,
0.04619057849049568,
0.005548478104174137,
-0.00035178751568309963,
0.0441875159740448,
0.003272500354796648,
0.015533735044300556,
-0.04554959759116173,
-0.006524969823658466,
-0.022274034097790718,
-0.026861043646931648,
-0.0405619777739048,
0.015683963894844055,
-0.024016696959733963,
-0.016515234485268593,
0.036756161600351334,
-0.01950981095433235,
-0.022554462775588036,
-0.08436891436576843,
0.03934010863304138,
-0.021292533725500107,
0.02201363630592823,
-0.026039788499474525,
-0.010956741869449615,
0.05344165861606598,
-0.04306580498814583,
-0.0018490753136575222,
-0.03170844912528992,
0.009634721092879772,
-0.025879543274641037,
-0.06377744674682617,
-0.017817223444581032,
-0.004319099243730307,
0.009960219264030457,
-0.03497343882918358,
0.060812920331954956,
0.02095201425254345,
0.00439171027392149,
-0.026159971952438354,
-0.07355238497257233,
-0.018307974562048912,
-0.0054633477702736855,
0.03224927559494972,
0.06393769383430481,
-0.023656146600842476,
0.01669551059603691,
-0.053121168166399,
0.0052780648693442345,
-0.012348868884146214,
0.03701655939221382,
-0.04538935422897339,
0.0578884519636631,
-0.012979832477867603,
-0.05027681961655617,
-0.07190987467765808,
-0.044788435101509094,
0.010786481201648712,
-0.017156213521957397,
-0.013460567221045494,
0.031087500974535942,
0.021272502839565277,
0.01683572493493557,
0.030967317521572113,
0.0019079152261838317,
-0.021232442930340767,
-0.013520658947527409,
0.038699131458997726,
0.016034500673413277,
-0.02427709475159645,
0.012018363922834396,
-0.008332732133567333,
-0.10135486721992493,
-0.010956741869449615,
-0.018798723816871643,
0.012008348479866982,
-0.047152046114206314,
0.026400338858366013,
0.012168592773377895,
-0.005192934535443783,
0.07479428499937057
]
|
30,593 | networkx.drawing.nx_pylab | draw_networkx_edge_labels | Draw edge labels.
Parameters
----------
G : graph
A networkx graph
pos : dictionary
A dictionary with nodes as keys and positions as values.
Positions should be sequences of length 2.
edge_labels : dictionary (default=None)
Edge labels in a dictionary of labels keyed by edge two-tuple.
Only labels for the keys in the dictionary are drawn.
label_pos : float (default=0.5)
Position of edge label along edge (0=head, 0.5=center, 1=tail)
font_size : int (default=10)
Font size for text labels
font_color : color (default='k' black)
Font color string. Color can be string or rgb (or rgba) tuple of
floats from 0-1.
font_weight : string (default='normal')
Font weight
font_family : string (default='sans-serif')
Font family
alpha : float or None (default=None)
The text transparency
bbox : Matplotlib bbox, optional
Specify text box properties (e.g. shape, color etc.) for edge labels.
Default is {boxstyle='round', ec=(1.0, 1.0, 1.0), fc=(1.0, 1.0, 1.0)}.
horizontalalignment : string (default='center')
Horizontal alignment {'center', 'right', 'left'}
verticalalignment : string (default='center')
Vertical alignment {'center', 'top', 'bottom', 'baseline', 'center_baseline'}
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
rotate : bool (default=True)
Rotate edge labels to lie parallel to edges
clip_on : bool (default=True)
Turn on clipping of edge labels at axis boundaries
node_size : scalar or array (default=300)
Size of nodes. If an array it must be the same length as nodelist.
nodelist : list, optional (default=G.nodes())
This provides the node order for the `node_size` array (if it is an array).
connectionstyle : string or iterable of strings (default="arc3")
Pass the connectionstyle parameter to create curved arc of rounding
radius rad. For example, connectionstyle='arc3,rad=0.2'.
See `matplotlib.patches.ConnectionStyle` and
`matplotlib.patches.FancyArrowPatch` for more info.
If Iterable, index indicates i'th edge key of MultiGraph
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
Returns
-------
dict
`dict` of labels keyed by edge
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> edge_labels = nx.draw_networkx_edge_labels(G, pos=nx.spring_layout(G))
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx
draw_networkx_nodes
draw_networkx_edges
draw_networkx_labels
| def draw_networkx_edge_labels(
G,
pos,
edge_labels=None,
label_pos=0.5,
font_size=10,
font_color="k",
font_family="sans-serif",
font_weight="normal",
alpha=None,
bbox=None,
horizontalalignment="center",
verticalalignment="center",
ax=None,
rotate=True,
clip_on=True,
node_size=300,
nodelist=None,
connectionstyle="arc3",
hide_ticks=True,
):
"""Draw edge labels.
Parameters
----------
G : graph
A networkx graph
pos : dictionary
A dictionary with nodes as keys and positions as values.
Positions should be sequences of length 2.
edge_labels : dictionary (default=None)
Edge labels in a dictionary of labels keyed by edge two-tuple.
Only labels for the keys in the dictionary are drawn.
label_pos : float (default=0.5)
Position of edge label along edge (0=head, 0.5=center, 1=tail)
font_size : int (default=10)
Font size for text labels
font_color : color (default='k' black)
Font color string. Color can be string or rgb (or rgba) tuple of
floats from 0-1.
font_weight : string (default='normal')
Font weight
font_family : string (default='sans-serif')
Font family
alpha : float or None (default=None)
The text transparency
bbox : Matplotlib bbox, optional
Specify text box properties (e.g. shape, color etc.) for edge labels.
Default is {boxstyle='round', ec=(1.0, 1.0, 1.0), fc=(1.0, 1.0, 1.0)}.
horizontalalignment : string (default='center')
Horizontal alignment {'center', 'right', 'left'}
verticalalignment : string (default='center')
Vertical alignment {'center', 'top', 'bottom', 'baseline', 'center_baseline'}
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
rotate : bool (default=True)
Rotate edge labels to lie parallel to edges
clip_on : bool (default=True)
Turn on clipping of edge labels at axis boundaries
node_size : scalar or array (default=300)
Size of nodes. If an array it must be the same length as nodelist.
nodelist : list, optional (default=G.nodes())
This provides the node order for the `node_size` array (if it is an array).
connectionstyle : string or iterable of strings (default="arc3")
Pass the connectionstyle parameter to create curved arc of rounding
radius rad. For example, connectionstyle='arc3,rad=0.2'.
See `matplotlib.patches.ConnectionStyle` and
`matplotlib.patches.FancyArrowPatch` for more info.
If Iterable, index indicates i'th edge key of MultiGraph
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
Returns
-------
dict
`dict` of labels keyed by edge
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> edge_labels = nx.draw_networkx_edge_labels(G, pos=nx.spring_layout(G))
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx
draw_networkx_nodes
draw_networkx_edges
draw_networkx_labels
"""
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
class CurvedArrowText(mpl.text.Text):
def __init__(
self,
arrow,
*args,
label_pos=0.5,
labels_horizontal=False,
ax=None,
**kwargs,
):
# Bind to FancyArrowPatch
self.arrow = arrow
# how far along the text should be on the curve,
# 0 is at start, 1 is at end etc.
self.label_pos = label_pos
self.labels_horizontal = labels_horizontal
if ax is None:
ax = plt.gca()
self.ax = ax
self.x, self.y, self.angle = self._update_text_pos_angle(arrow)
# Create text object
super().__init__(self.x, self.y, *args, rotation=self.angle, **kwargs)
# Bind to axis
self.ax.add_artist(self)
def _get_arrow_path_disp(self, arrow):
"""
This is part of FancyArrowPatch._get_path_in_displaycoord
It omits the second part of the method where path is converted
to polygon based on width
The transform is taken from ax, not the object, as the object
has not been added yet, and doesn't have transform
"""
dpi_cor = arrow._dpi_cor
# trans_data = arrow.get_transform()
trans_data = self.ax.transData
if arrow._posA_posB is not None:
posA = arrow._convert_xy_units(arrow._posA_posB[0])
posB = arrow._convert_xy_units(arrow._posA_posB[1])
(posA, posB) = trans_data.transform((posA, posB))
_path = arrow.get_connectionstyle()(
posA,
posB,
patchA=arrow.patchA,
patchB=arrow.patchB,
shrinkA=arrow.shrinkA * dpi_cor,
shrinkB=arrow.shrinkB * dpi_cor,
)
else:
_path = trans_data.transform_path(arrow._path_original)
# Return is in display coordinates
return _path
def _update_text_pos_angle(self, arrow):
# Fractional label position
path_disp = self._get_arrow_path_disp(arrow)
(x1, y1), (cx, cy), (x2, y2) = path_disp.vertices
# Text position at a proportion t along the line in display coords
# default is 0.5 so text appears at the halfway point
t = self.label_pos
tt = 1 - t
x = tt**2 * x1 + 2 * t * tt * cx + t**2 * x2
y = tt**2 * y1 + 2 * t * tt * cy + t**2 * y2
if self.labels_horizontal:
# Horizontal text labels
angle = 0
else:
# Labels parallel to curve
change_x = 2 * tt * (cx - x1) + 2 * t * (x2 - cx)
change_y = 2 * tt * (cy - y1) + 2 * t * (y2 - cy)
angle = (np.arctan2(change_y, change_x) / (2 * np.pi)) * 360
# Text is "right way up"
if angle > 90:
angle -= 180
if angle < -90:
angle += 180
(x, y) = self.ax.transData.inverted().transform((x, y))
return x, y, angle
def draw(self, renderer):
# recalculate the text position and angle
self.x, self.y, self.angle = self._update_text_pos_angle(self.arrow)
self.set_position((self.x, self.y))
self.set_rotation(self.angle)
# redraw text
super().draw(renderer)
# use default box of white with white border
if bbox is None:
bbox = {"boxstyle": "round", "ec": (1.0, 1.0, 1.0), "fc": (1.0, 1.0, 1.0)}
if isinstance(connectionstyle, str):
connectionstyle = [connectionstyle]
elif np.iterable(connectionstyle):
connectionstyle = list(connectionstyle)
else:
raise nx.NetworkXError(
"draw_networkx_edges arg `connectionstyle` must be"
"string or iterable of strings"
)
if ax is None:
ax = plt.gca()
if edge_labels is None:
kwds = {"keys": True} if G.is_multigraph() else {}
edge_labels = {tuple(edge): d for *edge, d in G.edges(data=True, **kwds)}
# NOTHING TO PLOT
if not edge_labels:
return {}
edgelist, labels = zip(*edge_labels.items())
if nodelist is None:
nodelist = list(G.nodes())
# set edge positions
edge_pos = np.asarray([(pos[e[0]], pos[e[1]]) for e in edgelist])
if G.is_multigraph():
key_count = collections.defaultdict(lambda: itertools.count(0))
edge_indices = | (G, pos, edge_labels=None, label_pos=0.5, font_size=10, font_color='k', font_family='sans-serif', font_weight='normal', alpha=None, bbox=None, horizontalalignment='center', verticalalignment='center', ax=None, rotate=True, clip_on=True, node_size=300, nodelist=None, connectionstyle='arc3', hide_ticks=True) | [
0.02288002334535122,
-0.05558069422841072,
0.033515576273202896,
0.03353647142648697,
-0.05060768499970436,
-0.05064947530627251,
-0.003923035692423582,
0.0436287559568882,
0.10514362901449203,
-0.06318647414445877,
-0.013069821521639824,
0.015660801902413368,
0.06377153098583221,
-0.004087584093213081,
-0.04110046103596687,
0.0349782258272171,
0.04197805002331734,
-0.0020046138670295477,
-0.012714606709778309,
-0.005495384335517883,
0.027414238080382347,
-0.10414066910743713,
0.0403064526617527,
-0.03063206747174263,
0.006054325494915247,
-0.025408318266272545,
-0.025053102523088455,
-0.007997560314834118,
0.002854779129847884,
0.0311962328851223,
-0.02107260562479496,
-0.055831436067819595,
-0.091269351541996,
-0.011920596472918987,
0.0031211902387440205,
0.01606825366616249,
-0.0004067994887009263,
-0.05967611446976662,
0.0052785989828407764,
-0.009601251222193241,
-0.03341110050678253,
-0.009982584975659847,
0.004004003945738077,
-0.020383071154356003,
-0.006080444436520338,
0.023214342072606087,
-0.02779034711420536,
0.020759180188179016,
-0.017604036256670952,
-0.011137033812701702,
0.014835448935627937,
-0.06602819263935089,
-0.0013020195765420794,
0.03184397891163826,
-0.000023404845705954358,
-0.0015906317858025432,
0.03460211679339409,
0.02430088259279728,
-0.014887685887515545,
-0.007590108085423708,
0.02707991749048233,
0.019672641530632973,
0.004353995434939861,
0.010426604188978672,
-0.03731846809387207,
-0.0074125006794929504,
0.06356258690357208,
-0.07192058116197586,
0.011095244437456131,
-0.0024421028792858124,
0.04684658721089363,
-0.020884551107883453,
-0.010760923847556114,
-0.02545010857284069,
0.000504744821228087,
-0.014166808687150478,
-0.023047182708978653,
0.01133553683757782,
0.062225304543972015,
-0.009496776387095451,
-0.012380286119878292,
0.0169876329600811,
0.04350338503718376,
-0.02352776750922203,
0.07518020272254944,
-0.032512616366147995,
0.006775203160941601,
0.04885250702500343,
0.004970397800207138,
-0.011126586236059666,
0.004999128170311451,
-0.02666201815009117,
0.02107260562479496,
0.04738985747098923,
-0.08608739078044891,
-0.029294786974787712,
0.01403099112212658,
-0.07463693618774414,
0.0013333620736375451,
0.010896741412580013,
-0.0160995963960886,
0.008974401280283928,
-0.0623924657702446,
0.025262052193284035,
-0.014166808687150478,
-0.04034824296832085,
-0.06916244328022003,
0.007046838290989399,
0.013372798450291157,
-0.03690056502819061,
-0.0032439485657960176,
0.0021965866908431053,
0.08483368903398514,
-0.04855997487902641,
0.03861395642161369,
-0.00288612162694335,
-0.026118747889995575,
-0.07008182257413864,
-0.025345632806420326,
-0.0400766059756279,
0.0005657973815687001,
-0.020174121484160423,
-0.03476927801966667,
-0.021375583484768867,
-0.049061454832553864,
0.004706598352640867,
-0.0007267541368491948,
0.012568341568112373,
0.0321991927921772,
-0.05641649663448334,
0.08901268988847733,
0.008196063339710236,
0.025847112759947777,
0.022900918498635292,
0.02935747243463993,
-0.010134073905646801,
-0.02145916223526001,
0.05378372594714165,
-0.00846769753843546,
0.011774331331253052,
0.07864877581596375,
-0.04655405506491661,
0.006534910760819912,
-0.004892041441053152,
-0.01663241907954216,
0.010948979295790195,
-0.0026745598297566175,
-0.055329956114292145,
0.013508616015315056,
-0.021877063438296318,
0.05031515657901764,
-0.025888903066515923,
-0.04229147732257843,
-0.012589236721396446,
0.05758661404252052,
-0.08140691369771957,
-0.03247082605957985,
0.012108650989830494,
-0.022190488874912262,
0.11199718713760376,
0.022629283368587494,
-0.08642171323299408,
0.016893606632947922,
-0.00036631544935517013,
0.012610130943357944,
0.04726448655128479,
0.03746473044157028,
-0.011293746531009674,
-0.014908581040799618,
-0.008055021986365318,
-0.013519063591957092,
-0.037485625594854355,
-0.09143651276826859,
0.021114395931363106,
-0.011899701319634914,
0.03182308375835419,
0.003792442148551345,
0.0872575119137764,
-0.024217301979660988,
0.008133377879858017,
-0.0025021759793162346,
0.00026118746609427035,
0.004576004575937986,
-0.0021769977174699306,
0.045300357043743134,
0.018983105197548866,
0.052989713847637177,
0.045091405510902405,
0.028730621561408043,
-0.020236805081367493,
-0.03660803660750389,
-0.0068483357317745686,
-0.01098032109439373,
0.07375933974981308,
0.029670897871255875,
0.008384117856621742,
-0.006153577007353306,
-0.026411278173327446,
-0.055747855454683304,
-0.006320736836642027,
0.005944626871496439,
0.0025570252910256386,
0.004834580235183239,
-0.020205462351441383,
-0.014689183793962002,
-0.022483017295598984,
0.03959602117538452,
0.05666723474860191,
-0.0395333357155323,
-0.007219221908599138,
-0.013728014193475246,
-0.027184393256902695,
0.005228973459452391,
0.005996864289045334,
-0.02699633687734604,
-0.002946194726973772,
-0.06815948337316513,
0.05294792354106903,
-0.04400486499071121,
0.015942882746458054,
-0.015556326135993004,
0.055037423968315125,
0.03263798728585243,
-0.01559811644256115,
0.03249172121286392,
-0.05704334378242493,
0.046721216291189194,
0.037548311054706573,
0.05650007352232933,
-0.07033256441354752,
0.07935920357704163,
-0.007323696743696928,
-0.0013372799148783088,
0.002307591261342168,
0.023653138428926468,
-0.04270937666296959,
0.02557547762989998,
-0.023465082049369812,
-0.007313249167054892,
0.021051710471510887,
-0.02074873261153698,
-0.010583316907286644,
-0.07133552432060242,
0.006816993001848459,
0.05875673517584801,
0.046930164098739624,
0.06703115254640579,
0.011795226484537125,
-0.012265363708138466,
-0.05152706429362297,
-0.03690056502819061,
-0.007438619155436754,
-0.0017055541975423694,
-0.024321777746081352,
0.0013203027192503214,
-0.052195705473423004,
-0.040473610162734985,
-0.02735155262053013,
0.02310986816883087,
0.04797491431236267,
-0.004818908870220184,
0.021709902212023735,
-0.0932752713561058,
0.030820121988654137,
0.09803932905197144,
0.016820473596453667,
-0.019933829084038734,
0.04122583195567131,
-0.08934701234102249,
-0.051359906792640686,
0.0461779460310936,
0.010557197965681553,
-0.01935921609401703,
0.03359915688633919,
0.026891862973570824,
0.03560507670044899,
-0.04181089252233505,
-0.010390037670731544,
0.06619535386562347,
-0.008352775126695633,
-0.039115436375141144,
-0.014166808687150478,
-0.05741945654153824,
-0.006195366848260164,
-0.044589925557374954,
-0.003870798507705331,
-0.002833884209394455,
-0.018398046493530273,
-0.009878110140562057,
-0.027393342927098274,
0.023005392402410507,
0.013822041451931,
0.056541863828897476,
0.020195014774799347,
0.0042547439225018024,
0.03913633152842522,
0.028333617374300957,
0.009146785363554955,
-0.05094200372695923,
-0.006002088077366352,
0.0664878860116005,
-0.037130411714315414,
0.007104299496859312,
-0.04655405506491661,
-0.010948979295790195,
0.0015475357649847865,
0.04337801784276962,
0.017144346609711647,
0.07990247011184692,
-0.03140518069267273,
-0.050356946885585785,
0.0014835448237136006,
0.012129546143114567,
0.04776596650481224,
-0.0026536646764725447,
0.054326996207237244,
0.02983805723488331,
-0.029023151844739914,
0.06999824196100235,
-0.01687271147966385,
-0.031446970999240875,
0.021271107718348503,
-0.07033256441354752,
-0.009611698798835278,
-0.004252132028341293,
0.035145387053489685,
-0.004105867352336645,
0.08683960884809494,
0.06469091773033142,
-0.013226534239947796,
0.024635203182697296,
0.003324916586279869,
-0.04229147732257843,
-0.06176561489701271,
-0.09009923040866852,
0.02985895238816738,
0.05558069422841072,
0.023778507485985756,
-0.01257878914475441,
-0.04178999736905098,
0.0009050146327354014,
0.016945842653512955,
-0.042333267629146576,
0.05223749577999115,
0.04170641675591469,
0.06364616751670837,
0.02029949054121971,
0.004722269717603922,
-0.006775203160941601,
0.05666723474860191,
-0.041330307722091675,
0.0791502520442009,
-0.040118396282196045,
-0.018857736140489578,
-0.04642868414521217,
-0.005495384335517883,
0.020320385694503784,
-0.05294792354106903,
-0.01257878914475441,
0.006514015607535839,
-0.021051710471510887,
-0.04521677643060684,
-0.019986065104603767,
0.022211382165551186,
-0.056834395974874496,
-0.010546750389039516,
-0.022691968828439713,
0.030736541375517845,
0.06577745079994202,
0.009303498081862926,
0.025429213419556618,
-0.005610307212918997,
0.0019145042169839144,
-0.009204247035086155,
0.005166288465261459,
0.027560502290725708,
-0.03539612516760826,
-0.008948283270001411,
0.008425908163189888,
-0.03276335820555687,
0.010008703917264938,
-0.05804630368947983,
-0.024405358359217644,
0.042103420943021774,
0.01633988879621029,
-0.004197282716631889,
0.10781819373369217,
0.0053125531412661076,
0.04634510725736618,
-0.03424690291285515,
-0.05215391516685486,
-0.005558069329708815,
0.05599859356880188,
-0.004643913358449936,
-0.03054848685860634,
-0.024363568052649498,
0.017593588680028915,
0.03602297604084015,
0.005249868147075176,
0.007830400951206684,
-0.017802538350224495,
0.04475708678364754,
-0.006571476813405752,
-0.010583316907286644,
0.01389517355710268,
0.04141388460993767,
0.04734806716442108,
0.01297579426318407,
0.06076265498995781,
0.05996864289045334,
-0.023047182708978653,
0.05608217418193817,
-0.016026463359594345,
-0.020633811131119728,
0.0033876015804708004,
-0.018533863127231598,
-0.04655405506491661,
0.042751166969537735,
0.014845896512269974,
-0.048936083912849426,
-0.05060768499970436,
-0.005552845541387796,
0.0311962328851223,
-0.029336577281355858,
0.02699633687734604,
-0.018606996163725853,
-0.03719309717416763,
-0.01595333032310009,
-0.004784954711794853,
0.027811242267489433,
-0.04379591718316078,
-0.03767368197441101,
-0.019421901553869247,
0.001776074874214828,
-0.023694928735494614,
-0.0011759966146200895,
-0.0019079744815826416,
-0.061932776123285294,
-0.022859128192067146,
-0.02352776750922203,
-0.000745690253097564,
0.006973705720156431,
0.004677867516875267,
-0.00480323750525713,
0.037778157740831375,
-0.008164720609784126,
-0.037631891667842865,
-0.008786346763372421,
0.02622322179377079,
-0.016830921173095703,
-0.002213563770055771,
0.03533344343304634,
0.04321085661649704,
0.007496080361306667,
-0.09143651276826859,
0.0019497645553201437,
0.02595158852636814,
-0.011314641684293747,
-0.021877063438296318,
0.035793133080005646,
-0.010029599070549011,
0.024697888642549515,
-0.03596029058098793,
0.021354688331484795,
0.036921460181474686,
0.007203550543636084,
0.05637470632791519,
0.03176039829850197,
-0.05487026646733284,
0.025972481817007065,
0.08128154277801514,
-0.06652967631816864,
-0.03483196347951889,
-0.026473961770534515,
0.045634675770998,
0.022712862119078636,
-0.006566253025084734,
0.03153055161237717,
-0.0266411229968071,
-0.0507330559194088,
0.029315682128071785,
-0.030736541375517845,
0.01278773881494999,
-0.02459341287612915,
-0.004317428916692734,
0.037903524935245514,
0.015827961266040802,
0.006968481931835413,
-0.038488585501909256,
-0.019777115434408188,
-0.03683788329362869,
-0.0034476746805012226,
-0.02962910756468773,
0.010311681777238846,
0.009674384258687496,
0.03113354742527008,
-0.006764755584299564,
-0.04114225134253502,
0.007851295173168182,
-0.07601600140333176,
-0.0016533167799934745,
0.002930523594841361,
0.021051710471510887,
-0.020853208377957344,
0.050858426839113235,
0.0026928428560495377,
-0.036858778446912766,
0.05282255634665489,
0.038634851574897766,
-0.007276683114469051,
-0.009705726988613605,
0.035793133080005646,
0.0882604718208313,
0.0114086689427495,
-0.004651749040931463,
0.027038127183914185,
-0.005124498158693314,
0.035500600934028625,
0.025262052193284035,
-0.022274067625403404,
-0.022775547578930855,
0.006362527143210173,
-0.05733587592840195,
-0.05232107639312744,
-0.027476921677589417,
0.06799232214689255,
0.005965522024780512,
0.004474141635000706,
0.03959602117538452,
0.007553542032837868,
-0.028375407680869102,
0.04784954711794853,
0.037715472280979156,
0.019421901553869247,
0.03894827514886856,
0.032429035753011703,
0.0034320035483688116,
0.04074524715542793,
0.02808287739753723,
0.020633811131119728,
0.02107260562479496,
-0.024321777746081352,
-0.04379591718316078,
-0.0012445583706721663,
0.010760923847556114,
0.013738460838794708,
0.10054673254489899,
-0.006404316984117031,
0.046094365417957306,
-0.01332056149840355,
-0.0010473617585375905,
0.01900400035083294,
-0.021856168285012245,
-0.005918508395552635,
-0.01080271415412426,
0.03949154540896416,
0.017175689339637756,
0.01201462373137474,
0.014104124158620834,
0.009136337786912918,
-0.06109697371721268,
0.03681698814034462,
-0.004690926987677813,
-0.05436878651380539,
0.07221311330795288,
0.040201976895332336,
-0.024823257699608803,
0.04755701497197151,
0.03403795138001442,
-0.029817162081599236,
0.030088797211647034,
0.005046142265200615,
-0.0019131982699036598,
-0.025282947346568108,
-0.036566246300935745,
0.02062336355447769,
0.005189795047044754,
0.00523942057043314,
0.025199368596076965,
-0.0011420422233641148,
-0.012213126756250858,
0.011251956224441528,
0.049646515399217606,
0.018648786470294,
0.03850948065519333,
0.025763532146811485,
0.01911892369389534,
0.02331881783902645,
-0.04584362730383873,
-0.032930515706539154,
-0.04521677643060684,
-0.027414238080382347,
0.08303672075271606,
-0.006059549283236265,
0.009747516363859177,
0.008175168186426163,
0.041037775576114655,
0.056249335408210754,
0.009684831835329533,
0.009141561575233936,
-0.03470659255981445,
0.022086013108491898,
-0.010525855235755444,
0.03917812183499336,
-0.01421904657036066,
0.04087061807513237,
0.03999302536249161,
-0.0013183437986299396,
-0.028730621561408043,
-0.03389168530702591,
-0.0004485895042307675,
0.03844679519534111,
0.009439315646886826,
-0.09210515022277832,
-0.041539255529642105,
-0.07367576658725739,
-0.03138428553938866,
-0.0030663409270346165,
-0.008169944398105145,
0.004218177869915962,
0.017687615007162094,
-0.01651749573647976,
-0.04655405506491661,
0.009549014270305634,
-0.03161413222551346,
0.06485807150602341,
0.0019719654228538275,
-0.024112828075885773,
-0.027644082903862,
0.029315682128071785,
-0.011262403801083565,
-0.030005216598510742,
-0.0598432756960392,
-0.016413021832704544,
0.013487720862030983,
-0.017959250137209892,
-0.02471878193318844,
-0.02488594315946102,
0.0230889730155468,
0.027685873210430145,
-0.04080793261528015,
-0.015284691005945206,
-0.0679505318403244,
0.014522023499011993,
-0.030736541375517845,
0.05854778364300728,
0.003358870977535844,
-0.046930164098739624,
0.010149745270609856,
0.02400835230946541,
0.058380626142024994,
0.024844152852892876,
-0.0003114660794381052,
-0.0263694878667593,
0.0007626674487255514,
0.06778337061405182,
-0.033724527806043625,
-0.045509304851293564,
-0.0019745773170143366,
-0.012965346686542034,
0.0029357471503317356,
-0.015848856419324875,
0.0639386922121048,
-0.0073341443203389645,
0.008770675398409367,
-0.03056938201189041,
0.010285562835633755,
0.01399964839220047,
0.0562911257147789,
-0.05386730656027794,
0.01580706611275673,
-0.02530384249985218,
-0.02515757828950882,
-0.014835448935627937,
-0.0026184043381363153,
0.005991640500724316,
0.06527597457170486,
-0.0289186779409647,
0.029378367587924004,
-0.011847464367747307,
0.015190663747489452,
0.0035390902776271105,
-0.07229669392108917,
-0.027623187750577927,
-0.014626498334109783,
-0.023924773558974266,
0.036294613033533096,
-0.010494512505829334,
0.026056062430143356,
-0.01389517355710268,
-0.001557983341626823,
0.02983805723488331,
0.022984497249126434,
0.01787567138671875,
0.042458634823560715,
-0.023423293605446815,
-0.010019151493906975,
-0.04120493680238724,
0.0005706946249119937,
-0.03148876130580902,
0.03583492338657379,
-0.03545881062746048,
-0.02480236254632473,
0.0010545444674789906,
-0.015577221289277077,
-0.03512449190020561,
-0.0963677316904068,
0.013874278403818607,
-0.04454813525080681,
-0.0022788606584072113,
-0.039972130209207535,
0.005228973459452391,
0.02983805723488331,
-0.05307329446077347,
-0.007005047984421253,
-0.0230889730155468,
-0.017039870843291283,
-0.02530384249985218,
-0.08934701234102249,
-0.011126586236059666,
-0.008744556456804276,
0.031300708651542664,
-0.0049338312819600105,
0.05516279488801956,
-0.04981367662549019,
0.029441053047776222,
-0.03759010136127472,
-0.029963428154587746,
-0.061723824590444565,
0.0157130379229784,
-0.016914501786231995,
0.06531776487827301,
-0.017593588680028915,
0.03669161722064018,
-0.06769979745149612,
0.03719309717416763,
0.0215427428483963,
-0.012108650989830494,
0.0017799925990402699,
0.06644609570503235,
-0.008410236798226833,
-0.04237505793571472,
-0.08420684188604355,
-0.011575829237699509,
0.006132681854069233,
0.024760572239756584,
-0.03623192757368088,
0.07271459698677063,
0.04201984032988548,
0.006211038213223219,
0.036566246300935745,
0.017384639009833336,
-0.0172592680901289,
-0.019275635480880737,
-0.014887685887515545,
-0.0436287559568882,
-0.008755004033446312,
0.00479540228843689,
-0.028626147657632828,
-0.041601940989494324,
0.007125194184482098,
-0.007908756844699383,
-0.004160716664046049,
0.0034502865746617317,
0.017154794186353683,
0.04592720419168472,
-0.03362005203962326,
0.08767541497945786
]
|
30,594 | networkx.drawing.nx_pylab | draw_networkx_edges | Draw the edges of the graph G.
This draws only the edges of the graph G.
Parameters
----------
G : graph
A networkx graph
pos : dictionary
A dictionary with nodes as keys and positions as values.
Positions should be sequences of length 2.
edgelist : collection of edge tuples (default=G.edges())
Draw only specified edges
width : float or array of floats (default=1.0)
Line width of edges
edge_color : color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edgelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.
style : string or array of strings (default='solid')
Edge line style e.g.: '-', '--', '-.', ':'
or words like 'solid' or 'dashed'.
Can be a single style or a sequence of styles with the same
length as the edge list.
If less styles than edges are given the styles will cycle.
If more styles than edges are given the styles will be used sequentially
and not be exhausted.
Also, `(offset, onoffseq)` tuples can be used as style instead of a strings.
(See `matplotlib.patches.FancyArrowPatch`: `linestyle`)
alpha : float or array of floats (default=None)
The edge transparency. This can be a single alpha value,
in which case it will be applied to all specified edges. Otherwise,
if it is an array, the elements of alpha will be applied to the colors
in order (cycling through alpha multiple times if necessary).
edge_cmap : Matplotlib colormap, optional
Colormap for mapping intensities of edges
edge_vmin,edge_vmax : floats, optional
Minimum and maximum for edge colormap scaling
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
arrows : bool or None, optional (default=None)
If `None`, directed graphs draw arrowheads with
`~matplotlib.patches.FancyArrowPatch`, while undirected graphs draw edges
via `~matplotlib.collections.LineCollection` for speed.
If `True`, draw arrowheads with FancyArrowPatches (bendable and stylish).
If `False`, draw edges using LineCollection (linear and fast).
Note: Arrowheads will be the same color as edges.
arrowstyle : str (default='-\|>' for directed graphs)
For directed graphs and `arrows==True` defaults to '-\|>',
For undirected graphs default to '-'.
See `matplotlib.patches.ArrowStyle` for more options.
arrowsize : int (default=10)
For directed graphs, choose the size of the arrow head's length and
width. See `matplotlib.patches.FancyArrowPatch` for attribute
`mutation_scale` for more info.
connectionstyle : string or iterable of strings (default="arc3")
Pass the connectionstyle parameter to create curved arc of rounding
radius rad. For example, connectionstyle='arc3,rad=0.2'.
See `matplotlib.patches.ConnectionStyle` and
`matplotlib.patches.FancyArrowPatch` for more info.
If Iterable, index indicates i'th edge key of MultiGraph
node_size : scalar or array (default=300)
Size of nodes. Though the nodes are not drawn with this function, the
node size is used in determining edge positioning.
nodelist : list, optional (default=G.nodes())
This provides the node order for the `node_size` array (if it is an array).
node_shape : string (default='o')
The marker used for nodes, used in determining edge positioning.
Specification is as a `matplotlib.markers` marker, e.g. one of 'so^>v<dph8'.
label : None or string
Label for legend
min_source_margin : int (default=0)
The minimum margin (gap) at the beginning of the edge at the source.
min_target_margin : int (default=0)
The minimum margin (gap) at the end of the edge at the target.
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
Returns
-------
matplotlib.collections.LineCollection or a list of matplotlib.patches.FancyArrowPatch
If ``arrows=True``, a list of FancyArrowPatches is returned.
If ``arrows=False``, a LineCollection is returned.
If ``arrows=None`` (the default), then a LineCollection is returned if
`G` is undirected, otherwise returns a list of FancyArrowPatches.
Notes
-----
For directed graphs, arrows are drawn at the head end. Arrows can be
turned off with keyword arrows=False or by passing an arrowstyle without
an arrow on the end.
Be sure to include `node_size` as a keyword argument; arrows are
drawn considering the size of nodes.
Self-loops are always drawn with `~matplotlib.patches.FancyArrowPatch`
regardless of the value of `arrows` or whether `G` is directed.
When ``arrows=False`` or ``arrows=None`` and `G` is undirected, the
FancyArrowPatches corresponding to the self-loops are not explicitly
returned. They should instead be accessed via the ``Axes.patches``
attribute (see examples).
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> edges = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
>>> G = nx.DiGraph()
>>> G.add_edges_from([(1, 2), (1, 3), (2, 3)])
>>> arcs = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
>>> alphas = [0.3, 0.4, 0.5]
>>> for i, arc in enumerate(arcs): # change alpha values of arcs
... arc.set_alpha(alphas[i])
The FancyArrowPatches corresponding to self-loops are not always
returned, but can always be accessed via the ``patches`` attribute of the
`matplotlib.Axes` object.
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> G = nx.Graph([(0, 1), (0, 0)]) # Self-loop at node 0
>>> edge_collection = nx.draw_networkx_edges(G, pos=nx.circular_layout(G), ax=ax)
>>> self_loop_fap = ax.patches[0]
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx
draw_networkx_nodes
draw_networkx_labels
draw_networkx_edge_labels
| def draw_networkx_edges(
G,
pos,
edgelist=None,
width=1.0,
edge_color="k",
style="solid",
alpha=None,
arrowstyle=None,
arrowsize=10,
edge_cmap=None,
edge_vmin=None,
edge_vmax=None,
ax=None,
arrows=None,
label=None,
node_size=300,
nodelist=None,
node_shape="o",
connectionstyle="arc3",
min_source_margin=0,
min_target_margin=0,
hide_ticks=True,
):
r"""Draw the edges of the graph G.
This draws only the edges of the graph G.
Parameters
----------
G : graph
A networkx graph
pos : dictionary
A dictionary with nodes as keys and positions as values.
Positions should be sequences of length 2.
edgelist : collection of edge tuples (default=G.edges())
Draw only specified edges
width : float or array of floats (default=1.0)
Line width of edges
edge_color : color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edgelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.
style : string or array of strings (default='solid')
Edge line style e.g.: '-', '--', '-.', ':'
or words like 'solid' or 'dashed'.
Can be a single style or a sequence of styles with the same
length as the edge list.
If less styles than edges are given the styles will cycle.
If more styles than edges are given the styles will be used sequentially
and not be exhausted.
Also, `(offset, onoffseq)` tuples can be used as style instead of a strings.
(See `matplotlib.patches.FancyArrowPatch`: `linestyle`)
alpha : float or array of floats (default=None)
The edge transparency. This can be a single alpha value,
in which case it will be applied to all specified edges. Otherwise,
if it is an array, the elements of alpha will be applied to the colors
in order (cycling through alpha multiple times if necessary).
edge_cmap : Matplotlib colormap, optional
Colormap for mapping intensities of edges
edge_vmin,edge_vmax : floats, optional
Minimum and maximum for edge colormap scaling
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
arrows : bool or None, optional (default=None)
If `None`, directed graphs draw arrowheads with
`~matplotlib.patches.FancyArrowPatch`, while undirected graphs draw edges
via `~matplotlib.collections.LineCollection` for speed.
If `True`, draw arrowheads with FancyArrowPatches (bendable and stylish).
If `False`, draw edges using LineCollection (linear and fast).
Note: Arrowheads will be the same color as edges.
arrowstyle : str (default='-\|>' for directed graphs)
For directed graphs and `arrows==True` defaults to '-\|>',
For undirected graphs default to '-'.
See `matplotlib.patches.ArrowStyle` for more options.
arrowsize : int (default=10)
For directed graphs, choose the size of the arrow head's length and
width. See `matplotlib.patches.FancyArrowPatch` for attribute
`mutation_scale` for more info.
connectionstyle : string or iterable of strings (default="arc3")
Pass the connectionstyle parameter to create curved arc of rounding
radius rad. For example, connectionstyle='arc3,rad=0.2'.
See `matplotlib.patches.ConnectionStyle` and
`matplotlib.patches.FancyArrowPatch` for more info.
If Iterable, index indicates i'th edge key of MultiGraph
node_size : scalar or array (default=300)
Size of nodes. Though the nodes are not drawn with this function, the
node size is used in determining edge positioning.
nodelist : list, optional (default=G.nodes())
This provides the node order for the `node_size` array (if it is an array).
node_shape : string (default='o')
The marker used for nodes, used in determining edge positioning.
Specification is as a `matplotlib.markers` marker, e.g. one of 'so^>v<dph8'.
label : None or string
Label for legend
min_source_margin : int (default=0)
The minimum margin (gap) at the beginning of the edge at the source.
min_target_margin : int (default=0)
The minimum margin (gap) at the end of the edge at the target.
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
Returns
-------
matplotlib.collections.LineCollection or a list of matplotlib.patches.FancyArrowPatch
If ``arrows=True``, a list of FancyArrowPatches is returned.
If ``arrows=False``, a LineCollection is returned.
If ``arrows=None`` (the default), then a LineCollection is returned if
`G` is undirected, otherwise returns a list of FancyArrowPatches.
Notes
-----
For directed graphs, arrows are drawn at the head end. Arrows can be
turned off with keyword arrows=False or by passing an arrowstyle without
an arrow on the end.
Be sure to include `node_size` as a keyword argument; arrows are
drawn considering the size of nodes.
Self-loops are always drawn with `~matplotlib.patches.FancyArrowPatch`
regardless of the value of `arrows` or whether `G` is directed.
When ``arrows=False`` or ``arrows=None`` and `G` is undirected, the
FancyArrowPatches corresponding to the self-loops are not explicitly
returned. They should instead be accessed via the ``Axes.patches``
attribute (see examples).
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> edges = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
>>> G = nx.DiGraph()
>>> G.add_edges_from([(1, 2), (1, 3), (2, 3)])
>>> arcs = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
>>> alphas = [0.3, 0.4, 0.5]
>>> for i, arc in enumerate(arcs): # change alpha values of arcs
... arc.set_alpha(alphas[i])
The FancyArrowPatches corresponding to self-loops are not always
returned, but can always be accessed via the ``patches`` attribute of the
`matplotlib.Axes` object.
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> G = nx.Graph([(0, 1), (0, 0)]) # Self-loop at node 0
>>> edge_collection = nx.draw_networkx_edges(G, pos=nx.circular_layout(G), ax=ax)
>>> self_loop_fap = ax.patches[0]
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx
draw_networkx_nodes
draw_networkx_labels
draw_networkx_edge_labels
"""
import warnings
import matplotlib as mpl
import matplotlib.collections # call as mpl.collections
import matplotlib.colors # call as mpl.colors
import matplotlib.pyplot as plt
import numpy as np
# The default behavior is to use LineCollection to draw edges for
# undirected graphs (for performance reasons) and use FancyArrowPatches
# for directed graphs.
# The `arrows` keyword can be used to override the default behavior
if arrows is None:
use_linecollection = not (G.is_directed() or G.is_multigraph())
else:
if not isinstance(arrows, bool):
raise TypeError("Argument `arrows` must be of type bool or None")
use_linecollection = not arrows
if isinstance(connectionstyle, str):
connectionstyle = [connectionstyle]
elif np.iterable(connectionstyle):
connectionstyle = list(connectionstyle)
else:
msg = "draw_networkx_edges arg `connectionstyle` must be str or iterable"
raise nx.NetworkXError(msg)
# Some kwargs only apply to FancyArrowPatches. Warn users when they use
# non-default values for these kwargs when LineC | (G, pos, edgelist=None, width=1.0, edge_color='k', style='solid', alpha=None, arrowstyle=None, arrowsize=10, edge_cmap=None, edge_vmin=None, edge_vmax=None, ax=None, arrows=None, label=None, node_size=300, nodelist=None, node_shape='o', connectionstyle='arc3', min_source_margin=0, min_target_margin=0, hide_ticks=True) | [
0.028787486255168915,
-0.03823879733681679,
0.029654579237103462,
0.0005869813030585647,
-0.059352513402700424,
-0.00008095125667750835,
-0.05852877348661423,
0.01895681954920292,
0.05493033677339554,
-0.028505681082606316,
-0.007083065342158079,
0.03130205348134041,
0.05141860991716385,
0.03739338368177414,
0.005977522116154432,
0.017970500513911247,
0.0033843722194433212,
0.00047656241804361343,
0.03080347739160061,
0.03650461137294769,
0.006904227659106255,
-0.062213920056819916,
0.04664960131049156,
-0.03032657504081726,
0.01817643642425537,
0.029221031814813614,
-0.006925904657691717,
0.04318122938275337,
-0.0034412750974297523,
0.03099857270717621,
-0.04404832050204277,
-0.048947397619485855,
-0.07608740776777267,
-0.0003637725894805044,
0.06338449567556381,
0.03414178639650345,
-0.03043496236205101,
0.0004941752413287759,
-0.002742181532084942,
0.052502479404211044,
0.032190825790166855,
0.006508616264909506,
0.02683652564883232,
-0.01837153173983097,
0.01572689786553383,
0.046302761882543564,
0.039387695491313934,
0.045479025691747665,
-0.02664143033325672,
-0.06347120553255081,
0.01096330676227808,
-0.052805960178375244,
0.02703162282705307,
0.004042821004986763,
0.03076012246310711,
0.007478676736354828,
0.013017232529819012,
0.031692247837781906,
0.006183456629514694,
0.004969526547938585,
0.0010181567631661892,
-0.013873486779630184,
0.02168816141784191,
-0.03336140140891075,
-0.002540311310440302,
-0.025405822321772575,
-0.0051619126461446285,
-0.05735819786787033,
-0.01376510038971901,
0.009814408607780933,
0.026034465059638023,
0.052329059690237045,
-0.02020326629281044,
-0.05293602496385574,
0.005641523282974958,
0.00008687865192769095,
0.00756538612768054,
0.014577999711036682,
-0.011174660176038742,
-0.04047156125307083,
0.019249463453888893,
0.05848541855812073,
0.007944739423692226,
0.010004084557294846,
0.08176686614751816,
-0.017331020906567574,
-0.0167132169008255,
0.0990220159292221,
0.00149573537055403,
-0.04172884672880173,
0.03661299869418144,
-0.018382370471954346,
-0.027768651023507118,
0.009147830307483673,
-0.08328427374362946,
-0.02753020077943802,
0.001314865192398429,
-0.08354440331459045,
0.029242709279060364,
0.009407958015799522,
-0.021178744733333588,
-0.008107319474220276,
-0.05341292545199394,
0.03810873627662659,
-0.039344340562820435,
-0.04981448873877525,
-0.07786494493484497,
-0.003454823512583971,
-0.01716843992471695,
-0.04439515992999077,
-0.01669153943657875,
0.009039443917572498,
0.0686737596988678,
-0.036006033420562744,
0.006118424702435732,
0.05757497251033783,
0.011304724030196667,
-0.06091327965259552,
0.029741287231445312,
-0.04708314687013626,
-0.03138876333832741,
0.004728366155177355,
0.006329778581857681,
0.008681767620146275,
-0.013060587458312511,
-0.03158386051654816,
-0.01524999737739563,
0.02037668414413929,
0.035745907574892044,
-0.08948399126529694,
0.0655522271990776,
0.008719703182578087,
-0.021807387471199036,
0.032581016421318054,
-0.002368247602134943,
-0.014881482347846031,
-0.04172884672880173,
0.03453197702765465,
-0.022284287959337234,
-0.0027855359949171543,
0.03056502528488636,
-0.058962319046258926,
-0.006589906290173531,
0.032082438468933105,
-0.09650744497776031,
-0.008855186402797699,
-0.0076575144194066525,
-0.017244311049580574,
0.038477249443531036,
0.005852877162396908,
0.023151380941271782,
-0.02748684585094452,
-0.0017192827071994543,
-0.002300505992025137,
0.028267230838537216,
-0.04185891151428223,
-0.08922386169433594,
0.03990795090794563,
0.0033003725111484528,
0.06195379048585892,
-0.035702552646398544,
-0.06303765624761581,
0.04803694784641266,
-0.035203974694013596,
-0.011066273786127567,
0.032125793397426605,
0.02369331382215023,
-0.06060979515314102,
0.0029156000819057226,
0.04513218626379967,
0.035550810396671295,
-0.042075686156749725,
-0.05406324565410614,
0.003408759133890271,
0.009678925387561321,
0.039214279502630234,
0.014046905562281609,
0.055797431617975235,
-0.02735678292810917,
-0.0017856694757938385,
-0.02188325859606266,
-0.0006957065779715776,
0.02336815558373928,
-0.011348078958690166,
0.019249463453888893,
0.015629351139068604,
0.045435670763254166,
-0.020734360441565514,
0.05176544934511185,
-0.031670570373535156,
-0.0330362394452095,
-0.009483829140663147,
-0.00418914295732975,
0.04140368849039078,
0.016312185674905777,
-0.041923943907022476,
-0.0005768200499005616,
-0.018750885501503944,
0.00680126016959548,
0.0035875970497727394,
-0.009391700848937035,
0.031778957694768906,
0.018404047936201096,
-0.0032814049627631903,
0.008567961864173412,
-0.0014198647113516927,
0.03826047480106354,
-0.021048681810498238,
0.04712650179862976,
0.02057177945971489,
-0.029264386743307114,
-0.024452021345496178,
0.005126687232404947,
0.020430877804756165,
-0.05159202963113785,
-0.014458774589002132,
-0.07985925674438477,
0.042769357562065125,
-0.05037809908390045,
0.028050456196069717,
-0.012204333208501339,
0.016225475817918777,
-0.012388590723276138,
-0.029047613963484764,
0.04031982272863388,
-0.03780525177717209,
0.031952373683452606,
-0.006069650407880545,
0.042314134538173676,
-0.048990752547979355,
0.05740155279636383,
-0.03379494696855545,
0.000013982296877657063,
0.022631125524640083,
0.017526116222143173,
-0.017753727734088898,
-0.004991203546524048,
0.01963965594768524,
-0.02186158113181591,
0.06290759146213531,
-0.04131697863340378,
-0.026229562237858772,
0.017396051436662674,
-0.009971569292247295,
0.062127210199832916,
0.055320531129837036,
0.042119041085243225,
0.020961971953511238,
-0.022154225036501884,
0.008459575474262238,
-0.045305605977773666,
-0.017894631251692772,
0.01734185963869095,
0.0064544230699539185,
0.011868334375321865,
-0.001721992390230298,
-0.04660624638199806,
-0.04060162603855133,
0.010627307929098606,
0.03756680339574814,
0.020929455757141113,
0.04153375327587128,
-0.0328628234565258,
0.04088343307375908,
0.09000425040721893,
0.005419330671429634,
-0.007386547978967428,
0.02343318611383438,
-0.08428143709897995,
-0.011228853836655617,
0.035789262503385544,
-0.00783093273639679,
0.012963039800524712,
0.042119041085243225,
0.025557564571499825,
0.027920393273234367,
-0.05016132816672325,
0.007359451148658991,
0.02755187824368477,
-0.06199714541435242,
-0.05172209441661835,
0.0042595942504704,
-0.049771133810281754,
0.007104742806404829,
-0.052285704761743546,
-0.029351096600294113,
-0.007055968977510929,
0.0039181760512292385,
-0.03713325411081314,
-0.011727431789040565,
0.055537302047014236,
-0.02046339400112629,
0.032125793397426605,
-0.005565652623772621,
0.02203499898314476,
0.013537488877773285,
0.028137166053056717,
-0.007955578155815601,
-0.016268830746412277,
0.0015133481938391924,
0.08861690014600754,
-0.06303765624761581,
0.066939577460289,
-0.006324359215795994,
0.009256216697394848,
0.021373841911554337,
0.03774021938443184,
-0.002411602297797799,
0.0169516671448946,
-0.021829064935445786,
-0.032450951635837555,
0.006318939849734306,
-0.03646125644445419,
-0.003159469924867153,
-0.016420572996139526,
-0.022696157917380333,
0.008546284399926662,
-0.027877038344740868,
0.06065315008163452,
0.003238050267100334,
-0.042617619037628174,
0.06047973409295082,
-0.05349963530898094,
0.029676256701350212,
-0.02731342799961567,
0.07743140310049057,
0.035941001027822495,
0.1033574789762497,
0.026034465059638023,
0.04181555658578873,
0.0066386801190674305,
-0.008920218795537949,
-0.04114355891942978,
0.002188054844737053,
-0.07539372891187668,
0.0341201089322567,
0.04073169082403183,
0.022349320352077484,
0.005831200163811445,
-0.04500212520360947,
0.046216052025556564,
0.0692807286977768,
0.0341201089322567,
0.016615668311715126,
0.017439406365156174,
0.04131697863340378,
0.056577812880277634,
-0.002052571624517441,
-0.0041539170779287815,
0.04985784366726875,
-0.0005978199187666178,
0.0672430545091629,
-0.04487206041812897,
-0.011770786717534065,
-0.024430343881249428,
-0.03832550719380379,
-0.03049999475479126,
-0.052415769547224045,
0.014361226931214333,
0.06169366464018822,
-0.014556323178112507,
-0.013234006240963936,
0.016832441091537476,
0.019520429894328117,
-0.04420006275177002,
-0.008931057527661324,
-0.010096213780343533,
-0.02201332151889801,
0.04716985672712326,
-0.01880507729947567,
0.012518654577434063,
-0.019715525209903717,
-0.02375834621489048,
-0.04721321165561676,
-0.012366913259029388,
-0.00024437796673737466,
0.00031821633456274867,
0.008952734991908073,
0.07569721341133118,
0.035138942301273346,
0.021189583465456963,
-0.06147688999772072,
0.02192661352455616,
0.04036317765712738,
0.048947397619485855,
-0.00392630510032177,
0.0684136301279068,
0.01828482188284397,
0.03635287284851074,
-0.032320890575647354,
-0.04443851485848427,
0.002496956614777446,
0.07630418241024017,
0.015119933523237705,
-0.066245898604393,
-0.026186207309365273,
0.07084149122238159,
0.03336140140891075,
-0.025340791791677475,
-0.042509231716394424,
0.006866292096674442,
0.04380987212061882,
0.051938869059085846,
0.004181013908237219,
0.03956111520528793,
-0.019487913697957993,
0.03999466076493263,
0.0033735334873199463,
0.07357283681631088,
0.04062330350279808,
0.031952373683452606,
0.04179387912154198,
-0.05055151879787445,
0.004438431933522224,
0.04526225104928017,
0.017374373972415924,
-0.05063822865486145,
0.039019182324409485,
0.06273417174816132,
-0.01539089996367693,
-0.0019103140803053975,
0.014957353472709656,
0.03624448552727699,
0.015401738695800304,
-0.004972236230969429,
-0.016106251627206802,
-0.017753727734088898,
0.02410518378019333,
-0.04044988751411438,
0.02395344339311123,
0.0060533927753567696,
-0.01830649934709072,
0.01815475896000862,
0.01725514978170395,
-0.01496819220483303,
-0.03089018538594246,
0.029242709279060364,
-0.06446836143732071,
-0.0004271110228728503,
-0.035745907574892044,
-0.015553480014204979,
-0.01504406239837408,
-0.017937984317541122,
-0.05388982594013214,
0.035745907574892044,
-0.0019794106483459473,
-0.006281004287302494,
-0.011402272619307041,
0.02772529609501362,
-0.00757080502808094,
-0.008708864450454712,
0.024647116661071777,
0.04487206041812897,
-0.0019672170747071505,
-0.09520680457353592,
-0.001507928827777505,
0.014827289618551731,
0.013309876434504986,
-0.0662025436758995,
0.0005199170554988086,
0.05016132816672325,
-0.026272915303707123,
-0.07682443410158157,
-0.025037309154868126,
-0.0024156668223440647,
0.003037534886971116,
0.06520538777112961,
0.05393318086862564,
-0.05341292545199394,
0.02000816911458969,
0.0655088722705841,
-0.09598718583583832,
-0.05766168236732483,
-0.02308635041117668,
0.04790688678622246,
0.049727778881788254,
-0.005264880135655403,
-0.001403606729581952,
-0.04433012753725052,
-0.08722954988479614,
-0.03008812479674816,
-0.04424341768026352,
0.012746266089379787,
-0.032212503254413605,
0.010210019536316395,
0.007001775316894054,
0.005522298160940409,
-0.00016960811626631767,
-0.062257274985313416,
-0.008768477477133274,
-0.0078038363717496395,
-0.029849674552679062,
-0.0668962225317955,
0.03496552258729935,
0.07053801417350769,
0.05484362691640854,
0.02319473586976528,
-0.0690205991268158,
0.03071676753461361,
-0.07287916541099548,
0.027855360880494118,
-0.008329511620104313,
0.025015631690621376,
0.010892855003476143,
0.06342785060405731,
0.00666035758331418,
-0.02419189363718033,
0.049684423953294754,
0.02386673353612423,
-0.021211260929703712,
0.05753161758184433,
0.035659197717905045,
0.09520680457353592,
0.024213571101427078,
-0.012171817012131214,
0.013775939121842384,
-0.011402272619307041,
0.04729992151260376,
0.04517554119229317,
-0.016810763627290726,
0.002131151966750622,
0.009711440652608871,
-0.035550810396671295,
-0.006161779165267944,
-0.06156359985470772,
0.06104334443807602,
0.04073169082403183,
0.006719970144331455,
0.03314462676644325,
-0.004752753302454948,
-0.0004921429790556431,
0.07053801417350769,
0.013060587458312511,
0.04179387912154198,
-0.010237116366624832,
0.01824146695435047,
-0.01175994798541069,
0.031627215445041656,
-0.02735678292810917,
-0.029697934165596962,
0.032320890575647354,
0.05982941389083862,
-0.0656389370560646,
-0.016637345775961876,
-0.03466204181313515,
-0.025167372077703476,
0.08887702971696854,
-0.028310583904385567,
0.008307834155857563,
-0.05818193778395653,
0.018642498180270195,
0.02989302948117256,
-0.011651561595499516,
-0.009234540164470673,
-0.022977963089942932,
-0.02432195656001568,
0.02367163822054863,
-0.007115581538528204,
-0.00045827217400074005,
0.0066115837544202805,
-0.05766168236732483,
0.020105717703700066,
-0.03687312826514244,
-0.05072493851184845,
0.0661158338189125,
0.014274518005549908,
0.009738537482917309,
-0.005297395866364241,
0.018339015543460846,
0.02033332921564579,
0.0006103521445766091,
0.012236849404871464,
0.008183189667761326,
-0.022999640554189682,
-0.007538289297372103,
0.0013846390647813678,
0.004403206519782543,
0.0028885032515972853,
-0.008177770301699638,
-0.04703979194164276,
-0.045045480132102966,
-0.014729741029441357,
0.02666310779750347,
-0.000215418403968215,
0.03019651211798191,
0.04055827111005783,
-0.038867440074682236,
0.0350305549800396,
-0.032212503254413605,
-0.024647116661071777,
-0.01013414841145277,
-0.06134682521224022,
0.026272915303707123,
-0.01350497268140316,
-0.021005326882004738,
0.010741113685071468,
0.020961971953511238,
0.04404832050204277,
0.007597901858389378,
0.05150531977415085,
-0.04491541534662247,
0.04738662764430046,
0.039019182324409485,
0.01372174546122551,
-0.0349438451230526,
-0.028657421469688416,
0.04181555658578873,
-0.014263679273426533,
-0.0003449742798693478,
-0.038824085146188736,
-0.010535179637372494,
0.0694541409611702,
0.0054762340150773525,
-0.07777823507785797,
-0.07682443410158157,
-0.06017624959349632,
-0.03091186285018921,
0.066939577460289,
0.016095412895083427,
-0.010329244658350945,
0.019162753596901894,
-0.04170716926455498,
-0.010735694319009781,
-0.026056142523884773,
-0.009332087822258472,
0.04456857591867447,
0.008020609617233276,
-0.01692998968064785,
-0.015932831913232803,
0.03711157664656639,
-0.004861139692366123,
-0.03791363909840584,
-0.03630951792001724,
0.00006964687054278329,
0.009229120798408985,
-0.08722954988479614,
0.012171817012131214,
-0.011976721696555614,
0.0006415132666006684,
0.009223701432347298,
-0.031800635159015656,
0.005394943989813328,
-0.05809522792696953,
0.0027150847017765045,
-0.045782506465911865,
0.023151380941271782,
0.027942070737481117,
-0.03669970855116844,
0.04010304808616638,
0.025579242035746574,
0.005259460769593716,
0.049077458679676056,
-0.05306608974933624,
0.016008703038096428,
0.005652362015098333,
0.08397795259952545,
-0.00008217907452490181,
-0.05727148801088333,
-0.004544109106063843,
-0.02720504067838192,
0.015900317579507828,
-0.006763325072824955,
0.01910855993628502,
0.010518921539187431,
0.0010615114588290453,
-0.018815916031599045,
0.007960997521877289,
0.01366755273193121,
0.033339723944664,
-0.002426505321636796,
-0.028332261368632317,
-0.038824085146188736,
-0.05428001657128334,
-0.007381128612905741,
-0.007202290929853916,
-0.05835535377264023,
0.009142410941421986,
0.009695182554423809,
0.007966415956616402,
-0.02388841100037098,
0.02323809079825878,
0.0344669446349144,
-0.07127504050731659,
-0.00579868396744132,
-0.008584219962358475,
-0.0033897915855050087,
0.009532603435218334,
-0.018382370471954346,
0.0048584300093352795,
0.02427860163152218,
0.015423416160047054,
0.025449177250266075,
0.029611224308609962,
0.023151380941271782,
-0.004877397790551186,
-0.04647618159651756,
-0.012822137214243412,
-0.03375159204006195,
-0.0074624186381697655,
-0.0349438451230526,
0.035052232444286346,
-0.011337240226566792,
-0.017027538269758224,
0.041923943907022476,
0.01199839822947979,
-0.02306467294692993,
-0.09373274445533752,
0.012778782285749912,
-0.03021818958222866,
0.03763183206319809,
-0.042834389954805374,
0.013927680440247059,
0.04868726804852486,
-0.05519046634435654,
-0.012204333208501339,
-0.04738662764430046,
-0.007202290929853916,
-0.05293602496385574,
-0.0679367333650589,
0.02192661352455616,
-0.015651026740670204,
0.04088343307375908,
-0.04495877027511597,
0.045739151537418365,
-0.011283046565949917,
0.027920393273234367,
-0.03715493157505989,
-0.05519046634435654,
-0.05120183899998665,
0.0015770252794027328,
0.012583686038851738,
0.04049323871731758,
0.009299571625888348,
0.019238624721765518,
-0.029351096600294113,
-0.025427499786019325,
0.003500887658447027,
0.02341150864958763,
-0.02653304487466812,
0.042812712490558624,
-0.0036201130133122206,
-0.09095805138349533,
-0.09407958388328552,
-0.029286064207553864,
-0.016030380502343178,
-0.0006228843703866005,
-0.015098256058990955,
0.04712650179862976,
0.003850434673950076,
0.0022178611252456903,
-0.0034033397678285837,
0.0017626374028623104,
-0.01701669953763485,
-0.014621354639530182,
-0.008698025718331337,
-0.00591249018907547,
-0.03650461137294769,
-0.012692073360085487,
-0.03084683232009411,
-0.09590047597885132,
-0.014751418493688107,
0.0060533927753567696,
0.019097721204161644,
-0.013060587458312511,
0.009868601337075233,
0.0342068150639534,
-0.018078887835144997,
0.07092820107936859
]
|
30,595 | networkx.drawing.nx_pylab | draw_networkx_labels | Draw node labels on the graph G.
Parameters
----------
G : graph
A networkx graph
pos : dictionary
A dictionary with nodes as keys and positions as values.
Positions should be sequences of length 2.
labels : dictionary (default={n: n for n in G})
Node labels in a dictionary of text labels keyed by node.
Node-keys in labels should appear as keys in `pos`.
If needed use: `{n:lab for n,lab in labels.items() if n in pos}`
font_size : int (default=12)
Font size for text labels
font_color : color (default='k' black)
Font color string. Color can be string or rgb (or rgba) tuple of
floats from 0-1.
font_weight : string (default='normal')
Font weight
font_family : string (default='sans-serif')
Font family
alpha : float or None (default=None)
The text transparency
bbox : Matplotlib bbox, (default is Matplotlib's ax.text default)
Specify text box properties (e.g. shape, color etc.) for node labels.
horizontalalignment : string (default='center')
Horizontal alignment {'center', 'right', 'left'}
verticalalignment : string (default='center')
Vertical alignment {'center', 'top', 'bottom', 'baseline', 'center_baseline'}
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
clip_on : bool (default=True)
Turn on clipping of node labels at axis boundaries
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
Returns
-------
dict
`dict` of labels keyed on the nodes
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> labels = nx.draw_networkx_labels(G, pos=nx.spring_layout(G))
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx
draw_networkx_nodes
draw_networkx_edges
draw_networkx_edge_labels
| def draw_networkx_labels(
G,
pos,
labels=None,
font_size=12,
font_color="k",
font_family="sans-serif",
font_weight="normal",
alpha=None,
bbox=None,
horizontalalignment="center",
verticalalignment="center",
ax=None,
clip_on=True,
hide_ticks=True,
):
"""Draw node labels on the graph G.
Parameters
----------
G : graph
A networkx graph
pos : dictionary
A dictionary with nodes as keys and positions as values.
Positions should be sequences of length 2.
labels : dictionary (default={n: n for n in G})
Node labels in a dictionary of text labels keyed by node.
Node-keys in labels should appear as keys in `pos`.
If needed use: `{n:lab for n,lab in labels.items() if n in pos}`
font_size : int (default=12)
Font size for text labels
font_color : color (default='k' black)
Font color string. Color can be string or rgb (or rgba) tuple of
floats from 0-1.
font_weight : string (default='normal')
Font weight
font_family : string (default='sans-serif')
Font family
alpha : float or None (default=None)
The text transparency
bbox : Matplotlib bbox, (default is Matplotlib's ax.text default)
Specify text box properties (e.g. shape, color etc.) for node labels.
horizontalalignment : string (default='center')
Horizontal alignment {'center', 'right', 'left'}
verticalalignment : string (default='center')
Vertical alignment {'center', 'top', 'bottom', 'baseline', 'center_baseline'}
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
clip_on : bool (default=True)
Turn on clipping of node labels at axis boundaries
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
Returns
-------
dict
`dict` of labels keyed on the nodes
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> labels = nx.draw_networkx_labels(G, pos=nx.spring_layout(G))
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx
draw_networkx_nodes
draw_networkx_edges
draw_networkx_edge_labels
"""
import matplotlib.pyplot as plt
if ax is None:
ax = plt.gca()
if labels is None:
labels = {n: n for n in G.nodes()}
text_items = {} # there is no text collection so we'll fake one
for n, label in labels.items():
(x, y) = pos[n]
if not isinstance(label, str):
label = str(label) # this makes "1" and 1 labeled the same
t = ax.text(
x,
y,
label,
size=font_size,
color=font_color,
family=font_family,
weight=font_weight,
alpha=alpha,
horizontalalignment=horizontalalignment,
verticalalignment=verticalalignment,
transform=ax.transData,
bbox=bbox,
clip_on=clip_on,
)
text_items[n] = t
if hide_ticks:
ax.tick_params(
axis="both",
which="both",
bottom=False,
left=False,
labelbottom=False,
labelleft=False,
)
return text_items
| (G, pos, labels=None, font_size=12, font_color='k', font_family='sans-serif', font_weight='normal', alpha=None, bbox=None, horizontalalignment='center', verticalalignment='center', ax=None, clip_on=True, hide_ticks=True) | [
0.025728754699230194,
-0.02676868997514248,
0.01875734142959118,
-0.02355259656906128,
-0.025882819667458534,
0.0008876757929101586,
-0.019739501178264618,
0.018795857205986977,
0.13973641395568848,
-0.051496028900146484,
-0.024380691349506378,
-0.01628268137574196,
0.06782685220241547,
0.009754202328622341,
-0.012190345674753189,
-0.03158320114016533,
0.02399553172290325,
-0.02513175643980503,
-0.02287856489419937,
-0.04051893949508667,
0.03183355927467346,
-0.02659536711871624,
0.06832756102085114,
-0.003993638325482607,
-0.0014961097622290254,
-0.0256324652582407,
-0.008815372362732887,
-0.0005780424107797444,
-0.027616044506430626,
0.049570221453905106,
0.02788565680384636,
-0.043638743460178375,
-0.09043580293655396,
-0.030196623876690865,
-0.023186692968010902,
0.01457834430038929,
0.002134032780304551,
-0.009349783882498741,
-0.00701474491506815,
-0.030158106237649918,
-0.0188247449696064,
-0.029695913195610046,
-0.0232444666326046,
-0.02834784984588623,
-0.009975669905543327,
0.053884025663137436,
0.00036680567427538335,
0.02613317407667637,
-0.04121222719550133,
0.01932545378804207,
0.03433710336685181,
-0.04698964208364487,
-0.014809440821409225,
-0.010043073445558548,
-0.015030908398330212,
-0.025420626625418663,
0.03570442646741867,
0.023109661415219307,
-0.005050423555076122,
-0.0016742467414587736,
0.0116029754281044,
0.03655178099870682,
-0.027750851586461067,
-0.00805467925965786,
-0.04533345252275467,
0.008531316183507442,
0.026710916310548782,
-0.07310356199741364,
0.0164174884557724,
-0.019518034532666206,
0.04417796805500984,
-0.025902077555656433,
-0.002374758245423436,
-0.013268796727061272,
0.009744573384523392,
0.00403937604278326,
-0.013085844926536083,
0.021588275209069252,
0.027577528730034828,
0.032141685485839844,
-0.03090917132794857,
-0.012979925610125065,
0.03506891056895256,
-0.027461979538202286,
0.058852601796388626,
-0.01113115344196558,
0.0035482957027852535,
0.04579564556479454,
-0.0011494648642838001,
-0.01863216422498226,
-0.013653958216309547,
-0.027635302394628525,
0.03508816659450531,
0.023321500048041344,
-0.07934316992759705,
0.00972050055861473,
0.030466236174106598,
-0.0384390689432621,
0.009966040961444378,
0.029214462265372276,
0.008377252146601677,
0.017871471121907234,
-0.06771130859851837,
0.019932081922888756,
-0.03986416384577751,
-0.019989855587482452,
-0.10946276038885117,
0.020413532853126526,
0.007895800285041332,
-0.022223791107535362,
-0.015281262807548046,
0.017101148143410683,
0.11901475489139557,
-0.04086558148264885,
0.07830323278903961,
-0.01700485870242119,
-0.025208787992596626,
-0.039633069187402725,
-0.05723492428660393,
-0.03487632796168327,
-0.0022014358546584845,
0.006475519388914108,
-0.008305034600198269,
-0.022801531478762627,
-0.05330628529191017,
0.005969995632767677,
0.007472123485058546,
0.036128103733062744,
0.044755708426237106,
-0.023109661415219307,
0.0657084658741951,
0.0021376435179263353,
0.025555433705449104,
0.05172712355852127,
0.07291097939014435,
-0.018766969442367554,
-0.055655766278505325,
0.05715789273381233,
0.004689335357397795,
0.0368213914334774,
0.07468272000551224,
-0.08565980941057205,
-0.0023374459706246853,
0.0009039247524924576,
0.0015069424407556653,
-0.008348365314304829,
-0.0020858875941485167,
-0.05465434864163399,
-0.022339338436722755,
-0.02517027221620083,
0.048299189656972885,
-0.0067740194499492645,
0.02451549842953682,
0.010062331333756447,
0.017322616651654243,
-0.036898422986269,
-0.00752989761531353,
-0.028636721894145012,
-0.038516100496053696,
0.08542871475219727,
0.010197137482464314,
-0.04040338844060898,
0.014520569704473019,
0.004576194100081921,
-0.010071960277855396,
0.05107235163450241,
0.016561923548579216,
-0.005450028460472822,
0.005618536379188299,
-0.027096077799797058,
-0.02497769147157669,
-0.045410484075546265,
-0.05634905397891998,
0.0036734731402248144,
0.01676413230597973,
-0.039190132170915604,
-0.0003270859597250819,
0.03986416384577751,
-0.04706667363643646,
-0.00018746509158518165,
-0.0027490868233144283,
0.00980716198682785,
0.017187809571623802,
-0.02784714102745056,
0.006610326003283262,
0.036455489695072174,
0.029734430834650993,
0.06035473197698593,
-0.009417186491191387,
-0.019989855587482452,
-0.003880497068166733,
0.025247303768992424,
-0.03657103702425957,
0.10052702575922012,
0.036744359880685806,
0.027192367240786552,
-0.026787947863340378,
-0.01456871535629034,
-0.08288665115833282,
0.007125478703528643,
0.060162149369716644,
0.023282982409000397,
-0.0022688391618430614,
-0.008502429351210594,
-0.03541555628180504,
-0.018381809815764427,
0.022146757692098618,
0.04452461376786232,
-0.048106610774993896,
-0.039016809314489365,
0.0208179522305727,
-0.027153851464390755,
-0.013153248466551304,
0.021183855831623077,
-0.05796673148870468,
0.014934618026018143,
-0.0673261433839798,
0.031968362629413605,
-0.06451446563005447,
-0.021376436576247215,
-0.017938874661922455,
0.030716590583324432,
0.037899844348430634,
-0.01863216422498226,
-0.016099730506539345,
-0.029252978041768074,
0.029907751828432083,
0.02769307605922222,
0.060162149369716644,
-0.06771130859851837,
0.08126897364854813,
-0.0005536689423024654,
0.022859305143356323,
0.03526148945093155,
0.013422860763967037,
-0.078611359000206,
0.04229068011045456,
-0.011516313999891281,
0.033874910324811935,
0.030716590583324432,
-0.0328734926879406,
-0.019518034532666206,
-0.06382118165493011,
-0.0152138601988554,
0.07506787776947021,
0.044139452278614044,
0.05842892453074455,
-0.004660448059439659,
-0.011265959590673447,
-0.02773159183561802,
-0.04953170567750931,
-0.024053305387496948,
0.029869236052036285,
-0.026691658422350883,
-0.0027177922893315554,
-0.01464574784040451,
-0.0801134929060936,
0.007534712087363005,
0.01591677963733673,
0.02434217557311058,
-0.021742338314652443,
0.017592228949069977,
-0.12132571637630463,
0.00917164608836174,
0.09344006329774857,
0.037610974162817,
0.00016098526248242706,
0.04575712978839874,
-0.039479002356529236,
-0.049724284559488297,
0.05396105721592903,
0.04517938569188118,
0.02353333681821823,
0.0010158622171729803,
0.04371577501296997,
0.0057244556955993176,
-0.04279138892889023,
-0.013769506476819515,
0.08904922753572464,
-0.006273310165852308,
-0.046065255999565125,
-0.026036884635686874,
-0.03651326522231102,
-0.027096077799797058,
-0.022936338558793068,
0.010668960399925709,
-0.009710871614515781,
0.021723080426454544,
-0.013316942378878593,
-0.025998368859291077,
0.03298904001712799,
-0.003911791369318962,
0.013480635359883308,
0.03530000522732735,
-0.03888200223445892,
0.01633082702755928,
-0.009595323354005814,
-0.003495336277410388,
-0.04105816408991814,
0.007919873110949993,
0.03878571465611458,
-0.06952156126499176,
-0.010303056798875332,
-0.04425499960780144,
0.03630142658948898,
0.036436229944229126,
0.055655766278505325,
0.02436143346130848,
0.03543481230735779,
-0.002517990069463849,
-0.05962292477488518,
0.000741434923838824,
0.04521790146827698,
0.023148177191615105,
-0.007245841436088085,
0.024919917806982994,
0.018112195655703545,
-0.036436229944229126,
0.08288665115833282,
-0.030832139775156975,
-0.01033194363117218,
0.034028973430395126,
-0.08265554904937744,
0.03955603390932083,
-0.019989855587482452,
0.05815931409597397,
0.014770925045013428,
0.09328600019216537,
0.07133182138204575,
0.001183768268674612,
0.04402390494942665,
-0.03329716995358467,
-0.031101752072572708,
-0.039517518132925034,
-0.06501518189907074,
0.03250759094953537,
0.06956008076667786,
0.024111079052090645,
-0.011497056111693382,
-0.031198041513562202,
-0.028713753446936607,
0.007375833112746477,
-0.06493814289569855,
0.021684564650058746,
0.0368599072098732,
0.03304681554436684,
0.014193182811141014,
0.013066587038338184,
-0.016821907833218575,
0.047336287796497345,
-0.05365292727947235,
0.10846134275197983,
-0.05376847833395004,
-0.02850191481411457,
-0.0320068784058094,
0.00873352587223053,
0.05850595608353615,
-0.014684263616800308,
-0.0076502603478729725,
0.010659330524504185,
-0.046874094754457474,
-0.019537292420864105,
0.03225723281502724,
-0.0008419379009865224,
-0.043330613523721695,
-0.0023049479350447655,
0.004506384022533894,
0.016706358641386032,
0.08773967623710632,
-0.00024238061450887471,
0.03695619851350784,
0.004568972624838352,
-0.05627202242612839,
0.007337317336350679,
-0.011718523688614368,
0.04248325899243355,
-0.04452461376786232,
-0.05384550988674164,
-0.024399949237704277,
-0.049916867166757584,
-0.013336200267076492,
-0.05384550988674164,
0.007804324850440025,
0.037553198635578156,
0.022531919181346893,
0.004578601568937302,
0.10784508287906647,
0.03379787877202034,
0.014684263616800308,
-0.012999184429645538,
-0.05527060478925705,
-0.004658041056245565,
0.035011135041713715,
0.03832352161407471,
-0.06848162412643433,
-0.005387439858168364,
0.027616044506430626,
0.0052381898276507854,
-0.028790784999728203,
-0.030235139653086662,
-0.0018391438061371446,
0.026518335565924644,
-0.00815578456968069,
-0.02613317407667637,
0.008184671401977539,
0.050879769027233124,
0.007216954603791237,
-0.025748014450073242,
0.03907458484172821,
0.06012363359332085,
-0.028097495436668396,
0.05973847210407257,
0.014626489020884037,
-0.02501620724797249,
0.014289473183453083,
-0.024438466876745224,
-0.04914654418826103,
0.051149383187294006,
0.053113702684640884,
-0.060624342411756516,
-0.06385969370603561,
-0.04356171190738678,
0.04629635438323021,
-0.0036518077831715345,
0.04656596481800079,
0.001537033123895526,
0.005570391193032265,
-0.022166015580296516,
-0.007842840626835823,
0.036782875657081604,
-0.05746602267026901,
-0.01753445528447628,
0.00230976240709424,
0.014713150449097157,
0.015454585663974285,
-0.04259880632162094,
0.011670378968119621,
-0.06424485892057419,
-0.06694098562002182,
0.035627394914627075,
-0.023437047377228737,
0.012296264991164207,
0.03090917132794857,
-0.0006854662206023932,
-0.0025300264824181795,
0.032430555671453476,
-0.045256417244672775,
0.0039840093813836575,
0.05542466789484024,
-0.011554830707609653,
0.006018140818923712,
-0.015194602310657501,
0.08150006830692291,
0.00752989761531353,
-0.08242445439100266,
-0.0011584920575842261,
-0.013981345109641552,
-0.008415767922997475,
-0.02725014090538025,
0.006562180817127228,
-0.000029733377232332714,
0.003194429213181138,
-0.024091821163892746,
0.06647878885269165,
0.001457593753002584,
0.015079053118824959,
0.04887693375349045,
0.01386579591780901,
-0.025516916066408157,
0.02497769147157669,
0.0641293078660965,
-0.04791402816772461,
-0.006956970784813166,
-0.060778409242630005,
0.0062636807560920715,
0.038843486458063126,
0.0023795729503035545,
0.028867818415164948,
-0.0545002818107605,
-0.04864583536982536,
0.00993715412914753,
-0.00612406013533473,
0.013490264303982258,
0.00925830751657486,
-0.012440701015293598,
0.03555035963654518,
0.027423463761806488,
0.02898336574435234,
-0.014308731071650982,
-0.020548339933156967,
-0.011025234125554562,
-0.033374201506376266,
-0.00917164608836174,
-0.015290891751646996,
0.007852470502257347,
0.008536131121218204,
-0.03495336323976517,
-0.05045609176158905,
-0.014992392621934414,
-0.0320453941822052,
0.00402733962982893,
0.025420626625418663,
0.0561179593205452,
-0.0006902807508595288,
0.05249744653701782,
-0.020105404779314995,
-0.004330654162913561,
0.06828904896974564,
0.03828500583767891,
-0.005026351194828749,
-0.018054421991109848,
0.022994112223386765,
0.07079259306192398,
0.008983880281448364,
0.005098568741232157,
0.04032635688781738,
-0.036262910813093185,
0.026152431964874268,
0.03857387602329254,
-0.01224812027066946,
0.007375833112746477,
0.040095262229442596,
-0.012912523001432419,
-0.016552293673157692,
-0.03876645490527153,
0.06451446563005447,
0.027827883139252663,
0.003683102084323764,
-0.013730989769101143,
0.0256517231464386,
-0.028598204255104065,
0.025882819667458534,
0.007207325194031,
-0.028405625373125076,
0.024592529982328415,
0.008059494197368622,
0.042059581726789474,
0.04976280406117439,
0.039016809314489365,
0.04440906271338463,
0.047798480838537216,
-0.04579564556479454,
0.019258050248026848,
-0.0024505869951099157,
0.033874910324811935,
0.03088991343975067,
0.08681529015302658,
-0.015021279454231262,
0.03530000522732735,
-0.026942012831568718,
-0.02224304899573326,
-0.0344526506960392,
-0.05754305422306061,
-0.023822208866477013,
0.004253621678799391,
0.021106824278831482,
-0.029676655307412148,
0.04063448682427406,
0.00986012164503336,
0.012710313312709332,
-0.06216498836874962,
0.013750247657299042,
0.0025083611253648996,
-0.05269002541899681,
0.04178997129201889,
0.009436444379389286,
-0.05785118415951729,
0.00023019388027023524,
0.028733011335134506,
-0.018304776400327682,
0.022031210362911224,
0.02451549842953682,
0.01792924478650093,
-0.02149198390543461,
-0.029888493940234184,
0.006562180817127228,
-0.028116753324866295,
0.017630744725465775,
0.019383227452635765,
-0.020548339933156967,
-0.039016809314489365,
0.01505979523062706,
0.032757945358753204,
0.017582600936293602,
0.04248325899243355,
0.04244474321603775,
-0.025728754699230194,
0.018776599317789078,
-0.014992392621934414,
-0.0040538194589316845,
-0.019267680123448372,
0.004479904193431139,
0.09474960714578629,
0.00880092941224575,
0.026306496933102608,
-0.004845806863158941,
0.03828500583767891,
0.044794224202632904,
0.016870051622390747,
0.018930664286017418,
-0.010620814748108387,
0.026653142645955086,
-0.021511241793632507,
0.036436229944229126,
-0.000012440625141607597,
0.01899806596338749,
0.04048042371869087,
-0.004171775188297033,
-0.003362937131896615,
-0.057928215712308884,
0.013653958216309547,
0.026499077677726746,
-0.0015490694204345345,
-0.07083111256361008,
-0.011901475489139557,
-0.06382118165493011,
-0.023340757936239243,
-0.02626798115670681,
-0.008945364505052567,
-0.01792924478650093,
0.005339294672012329,
-0.011391136795282364,
-0.016908569261431694,
-0.024900659918785095,
-0.018728453665971756,
0.04745183512568474,
-0.023745175451040268,
-0.00216412334702909,
-0.024631045758724213,
0.0028092681895941496,
-0.0037697632797062397,
-0.000906331988517195,
-0.04976280406117439,
0.01097708847373724,
-0.0064707049168646336,
-0.02420737035572529,
-0.028559688478708267,
-0.047798480838537216,
0.014414650388062,
0.03591626510024071,
-0.02031724341213703,
-0.060470279306173325,
-0.047490350902080536,
0.0027129778172820807,
-0.03264239430427551,
-0.00872389692813158,
0.027962690219283104,
-0.03865090757608414,
0.027192367240786552,
-0.017081890255212784,
0.04625783860683441,
-0.006114431191235781,
0.007558784913271666,
-0.04945467412471771,
0.002012466313317418,
0.0608939565718174,
-0.036128103733062744,
-0.0184106957167387,
-0.0012577914167195559,
-0.0344141349196434,
-0.009966040961444378,
-0.007399905938655138,
0.08304071426391602,
0.001972746569663286,
-0.03223797678947449,
-0.023321500048041344,
-0.006374414544552565,
0.010100847110152245,
0.02482362650334835,
-0.06266569346189499,
-0.00664884177967906,
-0.029984785243868828,
-0.018834372982382774,
-0.021703822538256645,
-0.017852213233709335,
-0.004621932283043861,
0.03478004038333893,
0.019402485340833664,
0.03439487889409065,
-0.0256517231464386,
0.02384146675467491,
0.003736061742529273,
-0.04722074046730995,
-0.02676868997514248,
-0.025536175817251205,
-0.003244981402531266,
0.03664806857705116,
-0.03649400547146797,
0.030369944870471954,
0.014376134611666203,
0.014308731071650982,
0.03160246089100838,
0.04398538917303085,
0.020086146891117096,
0.04629635438323021,
0.017630744725465775,
0.01049563754349947,
-0.017438163980841637,
-0.025112498551607132,
0.0020726476795971394,
-0.006932897958904505,
-0.04024932533502579,
-0.03506891056895256,
0.03543481230735779,
-0.018131455406546593,
-0.04575712978839874,
-0.07217917591333389,
0.03426007181406021,
-0.043484676629304886,
0.03662881255149841,
-0.03934419900178909,
-0.009431630373001099,
0.055347636342048645,
-0.05003241449594498,
-0.03934419900178909,
-0.03693694248795509,
0.007549155969172716,
-0.03368233144283295,
-0.08365697413682938,
-0.026325754821300507,
-0.007741736248135567,
0.024785110726952553,
0.007679147645831108,
0.06659433990716934,
-0.005570391193032265,
-0.008382066152989864,
-0.019951339811086655,
-0.05592538043856621,
-0.04367725923657417,
0.018487729132175446,
0.02180011384189129,
0.08450432866811752,
-0.044909775257110596,
-0.021684564650058746,
-0.06959859281778336,
0.021260887384414673,
-0.007390276994556189,
-0.012912523001432419,
-0.01748630963265896,
0.06628620624542236,
-0.0029970339965075254,
0.011641491204500198,
-0.059854019433259964,
-0.005883334204554558,
0.00669217249378562,
-0.00146120460703969,
-0.01106374990195036,
0.05049460753798485,
0.04514086991548538,
0.0038347593508660793,
0.05715789273381233,
0.02149198390543461,
-0.037553198635578156,
-0.04371577501296997,
0.02946481667459011,
-0.035184457898139954,
-0.01281623262912035,
-0.0019366376800462604,
-0.009499032981693745,
-0.039517518132925034,
0.020586855709552765,
-0.03295052424073219,
-0.01947951875627041,
-0.008507243357598782,
-0.007544341497123241,
0.015464214608073235,
-0.015859004110097885,
0.06447595357894897
]
|
30,596 | networkx.drawing.nx_pylab | draw_networkx_nodes | Draw the nodes of the graph G.
This draws only the nodes of the graph G.
Parameters
----------
G : graph
A networkx graph
pos : dictionary
A dictionary with nodes as keys and positions as values.
Positions should be sequences of length 2.
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
nodelist : list (default list(G))
Draw only specified nodes
node_size : scalar or array (default=300)
Size of nodes. If an array it must be the same length as nodelist.
node_color : color or array of colors (default='#1f78b4')
Node color. Can be a single color or a sequence of colors with the same
length as nodelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the cmap and vmin,vmax parameters. See
matplotlib.scatter for more details.
node_shape : string (default='o')
The shape of the node. Specification is as matplotlib.scatter
marker, one of 'so^>v<dph8'.
alpha : float or array of floats (default=None)
The node transparency. This can be a single alpha value,
in which case it will be applied to all the nodes of color. Otherwise,
if it is an array, the elements of alpha will be applied to the colors
in order (cycling through alpha multiple times if necessary).
cmap : Matplotlib colormap (default=None)
Colormap for mapping intensities of nodes
vmin,vmax : floats or None (default=None)
Minimum and maximum for node colormap scaling
linewidths : [None | scalar | sequence] (default=1.0)
Line width of symbol border
edgecolors : [None | scalar | sequence] (default = node_color)
Colors of node borders. Can be a single color or a sequence of colors with the
same length as nodelist. Color can be string or rgb (or rgba) tuple of floats
from 0-1. If numeric values are specified they will be mapped to colors
using the cmap and vmin,vmax parameters. See `~matplotlib.pyplot.scatter` for more details.
label : [None | string]
Label for legend
margins : float or 2-tuple, optional
Sets the padding for axis autoscaling. Increase margin to prevent
clipping for nodes that are near the edges of an image. Values should
be in the range ``[0, 1]``. See :meth:`matplotlib.axes.Axes.margins`
for details. The default is `None`, which uses the Matplotlib default.
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
Returns
-------
matplotlib.collections.PathCollection
`PathCollection` of the nodes.
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> nodes = nx.draw_networkx_nodes(G, pos=nx.spring_layout(G))
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx
draw_networkx_edges
draw_networkx_labels
draw_networkx_edge_labels
| def draw_networkx_nodes(
G,
pos,
nodelist=None,
node_size=300,
node_color="#1f78b4",
node_shape="o",
alpha=None,
cmap=None,
vmin=None,
vmax=None,
ax=None,
linewidths=None,
edgecolors=None,
label=None,
margins=None,
hide_ticks=True,
):
"""Draw the nodes of the graph G.
This draws only the nodes of the graph G.
Parameters
----------
G : graph
A networkx graph
pos : dictionary
A dictionary with nodes as keys and positions as values.
Positions should be sequences of length 2.
ax : Matplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
nodelist : list (default list(G))
Draw only specified nodes
node_size : scalar or array (default=300)
Size of nodes. If an array it must be the same length as nodelist.
node_color : color or array of colors (default='#1f78b4')
Node color. Can be a single color or a sequence of colors with the same
length as nodelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the cmap and vmin,vmax parameters. See
matplotlib.scatter for more details.
node_shape : string (default='o')
The shape of the node. Specification is as matplotlib.scatter
marker, one of 'so^>v<dph8'.
alpha : float or array of floats (default=None)
The node transparency. This can be a single alpha value,
in which case it will be applied to all the nodes of color. Otherwise,
if it is an array, the elements of alpha will be applied to the colors
in order (cycling through alpha multiple times if necessary).
cmap : Matplotlib colormap (default=None)
Colormap for mapping intensities of nodes
vmin,vmax : floats or None (default=None)
Minimum and maximum for node colormap scaling
linewidths : [None | scalar | sequence] (default=1.0)
Line width of symbol border
edgecolors : [None | scalar | sequence] (default = node_color)
Colors of node borders. Can be a single color or a sequence of colors with the
same length as nodelist. Color can be string or rgb (or rgba) tuple of floats
from 0-1. If numeric values are specified they will be mapped to colors
using the cmap and vmin,vmax parameters. See `~matplotlib.pyplot.scatter` for more details.
label : [None | string]
Label for legend
margins : float or 2-tuple, optional
Sets the padding for axis autoscaling. Increase margin to prevent
clipping for nodes that are near the edges of an image. Values should
be in the range ``[0, 1]``. See :meth:`matplotlib.axes.Axes.margins`
for details. The default is `None`, which uses the Matplotlib default.
hide_ticks : bool, optional
Hide ticks of axes. When `True` (the default), ticks and ticklabels
are removed from the axes. To set ticks and tick labels to the pyplot default,
use ``hide_ticks=False``.
Returns
-------
matplotlib.collections.PathCollection
`PathCollection` of the nodes.
Examples
--------
>>> G = nx.dodecahedral_graph()
>>> nodes = nx.draw_networkx_nodes(G, pos=nx.spring_layout(G))
Also see the NetworkX drawing examples at
https://networkx.org/documentation/latest/auto_examples/index.html
See Also
--------
draw
draw_networkx
draw_networkx_edges
draw_networkx_labels
draw_networkx_edge_labels
"""
from collections.abc import Iterable
import matplotlib as mpl
import matplotlib.collections # call as mpl.collections
import matplotlib.pyplot as plt
import numpy as np
if ax is None:
ax = plt.gca()
if nodelist is None:
nodelist = list(G)
if len(nodelist) == 0: # empty nodelist, no drawing
return mpl.collections.PathCollection(None)
try:
xy = np.asarray([pos[v] for v in nodelist])
except KeyError as err:
raise nx.NetworkXError(f"Node {err} has no position.") from err
if isinstance(alpha, Iterable):
node_color = apply_alpha(node_color, alpha, nodelist, cmap, vmin, vmax)
alpha = None
node_collection = ax.scatter(
xy[:, 0],
xy[:, 1],
s=node_size,
c=node_color,
marker=node_shape,
cmap=cmap,
vmin=vmin,
vmax=vmax,
alpha=alpha,
linewidths=linewidths,
edgecolors=edgecolors,
label=label,
)
if hide_ticks:
ax.tick_params(
axis="both",
which="both",
bottom=False,
left=False,
labelbottom=False,
labelleft=False,
)
if margins is not None:
if isinstance(margins, Iterable):
ax.margins(*margins)
else:
ax.margins(margins)
node_collection.set_zorder(2)
return node_collection
| (G, pos, nodelist=None, node_size=300, node_color='#1f78b4', node_shape='o', alpha=None, cmap=None, vmin=None, vmax=None, ax=None, linewidths=None, edgecolors=None, label=None, margins=None, hide_ticks=True) | [
0.00028814002871513367,
-0.0009228897979483008,
-0.007508174516260624,
-0.022837163880467415,
-0.014766236767172813,
0.05617903545498848,
-0.04344255477190018,
0.008883791044354439,
0.08396072685718536,
-0.018113890662789345,
-0.0016509806737303734,
0.016690175980329514,
0.05013786628842354,
0.04628998786211014,
0.015535811893641949,
-0.023452823981642723,
0.003835854586213827,
-0.004338483791798353,
0.02533828467130661,
0.014092857949435711,
0.017555948346853256,
-0.016295768320560455,
0.049714598804712296,
-0.02747385762631893,
0.009090614505112171,
-0.02231770008802414,
0.013150127604603767,
0.03149489313364029,
-0.05821841210126877,
0.05044569820165634,
-0.009076185524463654,
-0.02429935708642006,
-0.10196880251169205,
-0.026858197525143623,
0.0015018753474578261,
0.049060460180044174,
0.011341623961925507,
0.010100683197379112,
0.00659430306404829,
-0.0224908534437418,
0.015814783051609993,
0.004805039148777723,
0.007349449209868908,
-0.020855505019426346,
-0.0068299854174256325,
0.048791106790304184,
0.03291860595345497,
0.0680689811706543,
-0.06102736294269562,
-0.06945422291755676,
0.015622389502823353,
-0.0559481643140316,
-0.03414992615580559,
0.011389722116291523,
0.03678572550415993,
-0.033111002296209335,
0.02379913255572319,
0.04417365416884422,
0.03303404152393341,
-0.001123099704273045,
0.025684593245387077,
0.01145706046372652,
-0.02429935708642006,
-0.03693963959813118,
-0.03288012742996216,
-0.0004665553569793701,
-0.012053481303155422,
-0.06183541938662529,
-0.00848938338458538,
0.01401589997112751,
0.029051488265395164,
0.0028474305290728807,
-0.0026165577583014965,
-0.03007117658853531,
0.06168150529265404,
0.009840951301157475,
0.01044699177145958,
0.025761552155017853,
-0.047290436923503876,
-0.007320590317249298,
0.018594875931739807,
0.012909634970128536,
0.029936499893665314,
0.013477196916937828,
0.08634641021490097,
-0.027512336149811745,
-0.010677864775061607,
0.06568329781293869,
-0.01873917132616043,
-0.02258705161511898,
0.004968573804944754,
-0.024106962606310844,
-0.007036808878183365,
0.01644006371498108,
-0.04859871417284012,
-0.0007016367162577808,
0.03341883048415184,
-0.06272043287754059,
0.034823305904865265,
0.03293784707784653,
-0.020085928961634636,
0.02050919644534588,
-0.05040721595287323,
0.029801825061440468,
-0.05621751397848129,
-0.05852624401450157,
-0.10081443190574646,
0.04490474984049797,
-0.027627773582935333,
-0.007378308568149805,
-0.022625530138611794,
0.011004934087395668,
0.11766814440488815,
-0.028281912207603455,
0.029224643483757973,
0.01720963977277279,
-0.017959976568818092,
-0.028993770480155945,
-0.016459302976727486,
-0.04325016215443611,
-0.03645865619182587,
0.014737376943230629,
0.013390619307756424,
0.006565443705767393,
-0.019604943692684174,
-0.012601803988218307,
0.01038927398622036,
0.030263569205999374,
0.005781438667327166,
-0.059334296733140945,
0.053562477231025696,
0.01901814341545105,
-0.010995314456522465,
0.042326670140028,
0.05117679387331009,
-0.03111010417342186,
-0.0645289346575737,
0.010533569380640984,
-0.016738275066018105,
0.06441349536180496,
0.020913222804665565,
-0.08750077337026596,
0.007825624197721481,
0.022298460826277733,
-0.03291860595345497,
-0.0006944219348952174,
-0.02006668969988823,
-0.02462642639875412,
-0.023010317236185074,
-0.011582116596400738,
0.022106066346168518,
-0.023549020290374756,
0.007734237238764763,
-0.0039969845674932,
-0.01555505208671093,
-0.053447041660547256,
-0.04005642235279083,
-0.025107411667704582,
-0.02362597920000553,
0.05729492008686066,
-0.011437821201980114,
-0.05094591900706291,
0.04428908973932266,
0.013294422999024391,
-0.017555948346853256,
0.016132233664393425,
0.02705059014260769,
-0.03253381699323654,
-0.01929711364209652,
0.007873723283410072,
0.01919129677116871,
-0.04952220618724823,
-0.06587569415569305,
-0.0026935155037790537,
0.04590519890189171,
-0.024722624570131302,
0.007998778484761715,
0.014468025416135788,
-0.03805552423000336,
-0.003381323767825961,
-0.03678572550415993,
0.007104146759957075,
0.025800030678510666,
0.021355729550123215,
-0.008123834617435932,
0.01781568117439747,
0.024607187137007713,
0.011668693274259567,
-0.005569804925471544,
-0.04348103329539299,
-0.02599242329597473,
0.02791636437177658,
-0.015218362212181091,
0.06029626727104187,
0.02610786072909832,
-0.014881673268973827,
-0.017623286694288254,
-0.03588147461414337,
-0.03742062672972679,
0.044596921652555466,
0.03824792057275772,
0.027185266837477684,
0.02281792461872101,
-0.018710313364863396,
-0.010110302828252316,
-0.004117230884730816,
0.0264926478266716,
-0.0006168631371110678,
-0.0023484088014811277,
0.002453023102134466,
-0.00175559485796839,
-0.025472959503531456,
0.03045596368610859,
0.022125305607914925,
-0.09150256961584091,
-0.013736928813159466,
-0.09042516350746155,
0.021682798862457275,
-0.07214773446321487,
-0.014795095659792423,
-0.005055151414126158,
0.016411203891038895,
-0.0034342322032898664,
-0.032630015164613724,
0.028993770480155945,
-0.033111002296209335,
0.02000897191464901,
-0.026184817776083946,
0.03717051446437836,
-0.06733788549900055,
0.056640781462192535,
-0.010908737778663635,
0.0029051487799733877,
0.06372088193893433,
0.0004331870295573026,
-0.06606808304786682,
0.04413517564535141,
0.01928749494254589,
-0.02172127738595009,
0.0396716333925724,
-0.07830434292554855,
-0.0346309132874012,
0.0001380577014060691,
-0.006878084037452936,
0.07834281772375107,
0.06499067693948746,
0.027069829404354095,
0.02962866984307766,
-0.03270697221159935,
0.010273837484419346,
-0.04725195840001106,
-0.026030903682112694,
0.018921945244073868,
-0.009715895168483257,
-0.021240293979644775,
-0.0027199697215110064,
-0.094734787940979,
-0.026454169303178787,
0.006632781587541103,
0.025049693882465363,
-0.012159298174083233,
0.026858197525143623,
-0.047290436923503876,
0.02483806014060974,
0.107740618288517,
-0.01335214078426361,
0.009331107139587402,
0.05140766501426697,
-0.08426855504512787,
-0.004049893002957106,
0.05102287977933884,
0.04502018541097641,
0.042134277522563934,
0.005396650638431311,
0.056371431797742844,
0.015757065266370773,
-0.04686716943979263,
-0.002218542853370309,
0.060873448848724365,
-0.007666899356991053,
-0.039825551211833954,
-0.007907391525804996,
-0.03649713471531868,
0.009985246695578098,
-0.04063360393047333,
-0.03105238452553749,
0.0048723770305514336,
0.06883855909109116,
-0.031148582696914673,
-0.018777649849653244,
0.021528884768486023,
-0.022875642403960228,
0.004172543995082378,
0.004973384086042643,
-0.022125305607914925,
0.0023087274748831987,
-0.0049084508791565895,
-0.017017245292663574,
-0.036747246980667114,
0.03139869496226311,
0.07707302272319794,
-0.05879559367895126,
0.049714598804712296,
-0.04063360393047333,
0.04398125782608986,
0.0660296082496643,
0.020047450438141823,
0.008811643347144127,
-0.0005215679993852973,
-0.0006210717256180942,
-0.05106135830283165,
0.007565892301499844,
0.011736031621694565,
-0.0015535812126472592,
-0.024472512304782867,
-0.004516448359936476,
0.011399341747164726,
-0.058680158108472824,
0.06368239969015121,
0.006656831130385399,
-0.045751284807920456,
0.02401076629757881,
-0.0831911489367485,
0.039113692939281464,
-0.04005642235279083,
0.06703005731105804,
0.0341884084045887,
0.13244400918483734,
0.03524657338857651,
0.04852175712585449,
-0.01792149804532528,
-0.009249339811503887,
-0.038825102150440216,
0.008681777864694595,
-0.07087793201208115,
0.010985694825649261,
0.0346309132874012,
-0.0011014554183930159,
0.022183023393154144,
0.0013082788791507483,
0.006310522090643644,
0.041518617421388626,
-0.03732442855834961,
0.04371190816164017,
0.004514043219387531,
0.022875642403960228,
0.050599612295627594,
0.010206499136984348,
-0.028628220781683922,
0.026742760092020035,
-0.01209196075797081,
0.08950167149305344,
-0.049445249140262604,
-0.015179883688688278,
-0.029263122007250786,
0.019095100462436676,
0.04325016215443611,
-0.024607187137007713,
-0.023491302505135536,
0.04094143584370613,
-0.02489577792584896,
-0.010456611402332783,
0.030917709693312645,
0.009946768172085285,
-0.03447699919342995,
0.011062652803957462,
0.03424612432718277,
-0.014612321741878986,
0.1074327901005745,
-0.05787210166454315,
0.010677864775061607,
-0.014804715290665627,
-0.08827035129070282,
-0.016074515879154205,
-0.032630015164613724,
0.026954393833875656,
-0.003915217239409685,
-0.014641180634498596,
0.02726222388446331,
-0.005237925797700882,
-0.004206213168799877,
-0.06298978626728058,
0.034765589982271194,
0.02379913255572319,
0.015901360660791397,
-0.030648358166217804,
0.0808054655790329,
0.05271594598889351,
0.003636245848610997,
-0.036362458020448685,
-0.04875262826681137,
-0.005189827177673578,
0.04063360393047333,
0.027685491368174553,
-0.05460140481591225,
-0.019758859649300575,
0.06529851257801056,
0.022356178611516953,
-0.047405872493982315,
-0.05929581820964813,
0.035208094865083694,
0.02281792461872101,
0.024376314133405685,
0.02077854797244072,
0.018402481451630592,
-0.007190724369138479,
-0.00432886416092515,
-0.0449817068874836,
0.07214773446321487,
0.0651061162352562,
0.02814723551273346,
0.01542037632316351,
0.026088621467351913,
-0.011889946646988392,
0.04517410323023796,
-0.020028211176395416,
-0.0692618265748024,
0.07641888409852982,
0.06845377385616302,
-0.03907521441578865,
-0.005069580860435963,
-0.024472512304782867,
0.0500224307179451,
0.04986851289868355,
0.03742062672972679,
0.019778098911046982,
0.013659970834851265,
-0.017382794991135597,
-0.01693066768348217,
0.03786313161253929,
-0.006863654591143131,
-0.022664008662104607,
0.0278201662003994,
0.01692104898393154,
0.024991976097226143,
-0.03386133536696434,
0.041634052991867065,
-0.06695310026407242,
-0.0411338284611702,
0.03205283358693123,
-0.011851468123495579,
0.0017628096975386143,
0.003566503059118986,
-0.01907586120069027,
0.008345087990164757,
0.030032698065042496,
-0.02533828467130661,
-0.005031101871281862,
0.039055973291397095,
-0.01138010248541832,
0.02912844531238079,
0.02326042950153351,
0.04101839289069176,
-0.015497333370149136,
-0.07541843503713608,
0.004189378581941128,
-0.044058218598365784,
0.000165789489983581,
-0.06768419593572617,
-0.030629118904471397,
0.038728903979063034,
-0.007133006118237972,
-0.051638539880514145,
-0.003821425139904022,
0.0010936394101008773,
-0.016391964629292488,
0.05656382441520691,
0.022221501916646957,
-0.014063998125493526,
0.0029412226285785437,
0.05833384767174721,
-0.06160454452037811,
-0.03824792057275772,
-0.07095488905906677,
0.021586602553725243,
0.056640781462192535,
0.010158400982618332,
0.022221501916646957,
-0.06506763398647308,
-0.05410118028521538,
-0.022837163880467415,
-0.048829585313797,
0.0559481643140316,
0.01901814341545105,
-0.005815107375383377,
0.04074903950095177,
0.009297437965869904,
0.0032370283734053373,
-0.034380801022052765,
-0.020701590925455093,
0.0061229378916323185,
-0.08919384330511093,
-0.057679709047079086,
0.004410631489008665,
0.008393186144530773,
0.03632397949695587,
-0.006425958126783371,
-0.08296027779579163,
-0.0019022952765226364,
-0.01912396028637886,
0.015362657606601715,
0.024703385308384895,
0.0760725736618042,
0.003066278761252761,
0.06429806351661682,
-0.005079200491309166,
0.004208617843687534,
0.05013786628842354,
0.022298460826277733,
-0.004453920293599367,
0.0538703091442585,
0.03313023969531059,
0.08449942618608475,
-0.005411080084741116,
0.023818371817469597,
0.05371639505028725,
-0.044596921652555466,
0.03963315486907959,
0.03886358067393303,
-0.03794008865952492,
-0.00032917404314503074,
0.038498032838106155,
0.03111010417342186,
0.018392862752079964,
-0.035746797919273376,
0.06198933348059654,
0.033996012061834335,
-0.022837163880467415,
-0.022683247923851013,
0.03084075264632702,
-0.004220642615109682,
0.03320719674229622,
-0.016690175980329514,
0.002467452548444271,
0.023125754669308662,
0.017834920436143875,
0.037189751863479614,
0.021952150389552116,
0.002312334952875972,
-0.012957733124494553,
0.03293784707784653,
-0.008008399046957493,
-0.0005197643185965717,
-0.01315974723547697,
0.0007437228923663497,
-0.00005929642065893859,
0.09688960015773773,
-0.04375038668513298,
-0.003956100903451443,
-0.05567881092429161,
0.013573394156992435,
-0.023664457723498344,
-0.03357274457812309,
-0.006536584813147783,
0.03293784707784653,
-0.021009420976042747,
-0.007373498752713203,
-0.018402481451630592,
-0.01492015179246664,
-0.010216119699180126,
-0.06279738992452621,
0.002230567391961813,
-0.018421722576022148,
-0.02968638762831688,
0.03105238452553749,
-0.011033793911337852,
-0.03901749476790428,
-0.024549469351768494,
0.029878782108426094,
0.016093755140900612,
0.02939779683947563,
0.037285950034856796,
-0.0012132844422012568,
-0.007282111328095198,
-0.01808503270149231,
-0.015362657606601715,
0.0207208301872015,
0.023433584719896317,
0.007753476500511169,
-0.0449817068874836,
-0.041903406381607056,
0.008874171413481236,
0.050984401255846024,
0.01395818218588829,
0.03441927954554558,
0.04040273278951645,
-0.04463540017604828,
0.00702237943187356,
0.021528884768486023,
-0.021952150389552116,
0.0023772679269313812,
-0.04148013889789581,
0.07522603869438171,
-0.0006282865069806576,
-0.025203607976436615,
0.006209515035152435,
0.01214967854321003,
0.04694412648677826,
0.018662214279174805,
0.03490026295185089,
-0.018325524404644966,
0.0500224307179451,
0.034380801022052765,
0.04640542343258858,
-0.00041034023161046207,
-0.036131586879491806,
0.031629566103219986,
-0.014189054258167744,
-0.02181747555732727,
-0.024915017187595367,
0.0258962269872427,
0.03151413053274155,
0.0002953547809738666,
-0.07476429641246796,
-0.03282240778207779,
-0.050868961960077286,
-0.026088621467351913,
0.03578527644276619,
0.03326491639018059,
-0.011341623961925507,
0.02258705161511898,
-0.00015068355423863977,
-0.016584359109401703,
-0.013178986497223377,
0.009509071707725525,
0.010629766620695591,
0.004629479721188545,
-0.011899566277861595,
-0.029378557577729225,
0.01626690849661827,
0.0024422009009867907,
-0.01244788896292448,
-0.031475652009248734,
0.0009547549998387694,
-0.02160584181547165,
-0.06703005731105804,
-0.007051238790154457,
-0.010745203122496605,
-0.0021812664344906807,
0.021067138761281967,
-0.007854483090341091,
-0.05206180736422539,
-0.03853651136159897,
-0.024222400039434433,
-0.040595125406980515,
-0.017026865854859352,
0.04621303081512451,
-0.009412874467670918,
0.036131586879491806,
0.006781887263059616,
-0.012197776697576046,
0.021355729550123215,
0.0047184620052576065,
-0.004417846444994211,
0.014304490759968758,
0.03336111456155777,
-0.03940228372812271,
-0.03584299609065056,
0.015699347481131554,
-0.048675671219825745,
-0.006666450761258602,
-0.0036699147894978523,
0.07980501651763916,
0.0069742812775075436,
-0.00748893478885293,
-0.03457319363951683,
0.0061806561425328255,
-0.0025925086811184883,
0.00032496542553417385,
0.009571599774062634,
-0.0680689811706543,
-0.06106584146618843,
-0.038498032838106155,
-0.014612321741878986,
-0.01291925460100174,
-0.050599612295627594,
-0.0005167581257410347,
0.027993321418762207,
0.004230262245982885,
-0.035150375217199326,
0.03780541196465492,
0.033611223101615906,
-0.05883407220244408,
-0.029282361268997192,
-0.02483806014060974,
0.04348103329539299,
-0.012688381597399712,
-0.06529851257801056,
0.023972287774086,
0.04478931427001953,
0.03370742127299309,
0.006358620245009661,
0.04386582225561142,
0.008859741501510143,
-0.004670363385230303,
0.00019945843087043613,
-0.007387928199023008,
-0.014140956103801727,
-0.004934905096888542,
-0.036747246980667114,
-0.009860190562903881,
-0.014929771423339844,
-0.02462642639875412,
0.05425509810447693,
-0.017738722264766693,
-0.04255754500627518,
-0.07942022383213043,
0.05160006135702133,
-0.01973962038755417,
0.04051816835999489,
-0.026723520830273628,
-0.01901814341545105,
0.04451996088027954,
-0.011043413542211056,
-0.042788416147232056,
-0.047636743634939194,
0.014516124501824379,
-0.0341884084045887,
-0.02628101408481598,
-0.018373623490333557,
-0.0005477215745486319,
-0.012505607679486275,
-0.026646563783288002,
0.08342202007770538,
0.01401589997112751,
-0.007811194751411676,
-0.03726670891046524,
-0.09073299169540405,
-0.003121592104434967,
-0.004869971890002489,
0.009340726770460606,
0.06410566717386246,
-0.008749115280807018,
0.008845312520861626,
-0.02424163930118084,
-0.00008680274186190218,
-0.018181229010224342,
0.042134277522563934,
-0.05448596924543381,
0.03336111456155777,
0.001701484085060656,
-0.046366944909095764,
-0.06703005731105804,
-0.02628101408481598,
0.006440388038754463,
-0.005507277324795723,
0.009768803603947163,
0.034438520669937134,
0.008936699479818344,
-0.00969665590673685,
0.043288640677928925,
0.022356178611516953,
-0.03466939181089401,
-0.0023303718771785498,
0.040979914367198944,
-0.009080994874238968,
-0.028705179691314697,
0.010042964480817318,
-0.024587947875261307,
-0.1038927361369133,
-0.02429935708642006,
-0.019431790336966515,
-0.0046174549497663975,
-0.04582824185490608,
0.03249533846974373,
0.04105687141418457,
-0.005189827177673578,
0.07095488905906677
]
|
30,597 | networkx.drawing.nx_pylab | draw_planar | Draw a planar networkx graph `G` with planar layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.planar_layout(G), **kwargs)
Parameters
----------
G : graph
A planar networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Raises
------
NetworkXException
When `G` is not planar
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.planar_layout` directly and reuse the result::
>>> G = nx.path_graph(5)
>>> pos = nx.planar_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(4)
>>> nx.draw_planar(G)
See Also
--------
:func:`~networkx.drawing.layout.planar_layout`
| def draw_planar(G, **kwargs):
"""Draw a planar networkx graph `G` with planar layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.planar_layout(G), **kwargs)
Parameters
----------
G : graph
A planar networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Raises
------
NetworkXException
When `G` is not planar
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.planar_layout` directly and reuse the result::
>>> G = nx.path_graph(5)
>>> pos = nx.planar_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(4)
>>> nx.draw_planar(G)
See Also
--------
:func:`~networkx.drawing.layout.planar_layout`
"""
draw(G, planar_layout(G), **kwargs)
| (G, **kwargs) | [
0.062314920127391815,
-0.024399107322096825,
0.008002834394574165,
0.021219775080680847,
-0.012780917808413506,
-0.00021517269487958401,
-0.021056266501545906,
0.004741747863590717,
-0.0017963229911401868,
-0.030812276527285576,
0.012308559380471706,
-0.013880058191716671,
0.00937449000775814,
0.05413949489593506,
-0.03112112544476986,
0.007103537674993277,
0.010391876101493835,
-0.027287758886814117,
-0.03920571506023407,
0.012372146360576153,
0.004796250723302364,
0.018449213355779648,
0.05730066075921059,
0.014225242659449577,
-0.004764457233250141,
0.03422778844833374,
0.0019178189104422927,
0.005940810311585665,
-0.047417476773262024,
0.036171723157167435,
0.038769692182540894,
0.03435496240854263,
-0.05944443866610527,
0.010973240248858929,
-0.03462747484445572,
0.07023600488901138,
-0.016505278646945953,
0.053812477737665176,
-0.06373199820518494,
-0.050324294716119766,
0.0011280954349786043,
-0.0013307778863236308,
0.013453119434416294,
-0.00995585322380066,
0.016423525288701057,
-0.016841379925608635,
0.008125466294586658,
0.008357102982699871,
-0.0735425055027008,
0.0073624262586236,
0.004417001735419035,
0.013916393741965294,
-0.0193303432315588,
-0.013534873723983765,
0.0038924117106944323,
-0.008520611561834812,
-0.009483495727181435,
0.06678415834903717,
0.053485460579395294,
-0.051450688391923904,
-0.028032630681991577,
-0.019257672131061554,
-0.034718312323093414,
-0.012199553661048412,
0.0022982032969594,
-0.0156695693731308,
-0.03146630898118019,
-0.032483696937561035,
0.013662046752870083,
0.03428228944540024,
-0.012989845126867294,
0.06533074378967285,
-0.024889633059501648,
-0.0331558994948864,
0.04861653968691826,
-0.005277692340314388,
0.06184256449341774,
0.028959179297089577,
-0.011236670427024364,
0.0060089388862252235,
0.018140364438295364,
-0.050360631197690964,
0.04527369886636734,
0.005654670298099518,
0.024562615901231766,
0.0008220846066251397,
0.04345693811774254,
-0.016805045306682587,
-0.0029068184085190296,
-0.06878259032964706,
0.026034193113446236,
-0.04211253300309181,
0.029849393293261528,
-0.008679578080773354,
-0.0829169973731041,
-0.01916683465242386,
-0.007203459739685059,
-0.03815199434757233,
-0.03141180798411369,
0.01325327530503273,
-0.02280035801231861,
-0.0165779497474432,
-0.05871773511171341,
-0.04636375606060028,
0.02078375220298767,
-0.010927820578217506,
-0.0313028022646904,
0.004546445794403553,
-0.03281071409583092,
0.04709045961499214,
0.04291190952062607,
0.031211962923407555,
0.02706974744796753,
-0.026960741728544235,
0.005877223797142506,
0.04196719080209732,
-0.06166088953614235,
-0.047780830413103104,
-0.059153757989406586,
-0.027614776045084,
-0.015342551283538342,
0.07434188574552536,
0.046109408140182495,
-0.03328307345509529,
0.005123267415910959,
-0.03444579988718033,
0.006154279690235853,
0.007662191987037659,
0.014670349657535553,
-0.008089130744338036,
0.039314720779657364,
0.021855641156435013,
0.011663609184324741,
0.03757062926888466,
-0.00949257891625166,
0.017422743141651154,
0.017222899943590164,
-0.007003616075962782,
-0.024417275562882423,
0.008525153622031212,
0.021637629717588425,
-0.02632487565279007,
0.00957433320581913,
0.03073960542678833,
0.02924986183643341,
0.010464546270668507,
0.0009441482834517956,
0.003976436797529459,
0.03073960542678833,
0.026542887091636658,
0.07237978279590607,
-0.05206838622689247,
0.015524227172136307,
0.009247316047549248,
0.003227022709324956,
-0.0151881268247962,
-0.008357102982699871,
0.03017641045153141,
-0.0033269445411860943,
-0.0004158680676482618,
-0.04102247580885887,
0.008547862991690636,
0.01914866641163826,
0.040768127888441086,
-0.020020712167024612,
0.04124048724770546,
0.039678074419498444,
-0.007485057692974806,
0.011681776493787766,
0.008992969989776611,
0.06569410115480423,
-0.08611449599266052,
-0.04956125468015671,
-0.009179187938570976,
0.0025525500532239676,
-0.0036494198720902205,
-0.013162437826395035,
0.02448994666337967,
0.02169213257730007,
-0.002766019431874156,
0.03346474841237068,
0.002693349029868841,
0.02795996144413948,
-0.004248951096087694,
0.012081464752554893,
0.032501865178346634,
-0.0057455082423985004,
-0.03749796003103256,
0.0174863301217556,
-0.031393639743328094,
-0.03749796003103256,
0.05250440910458565,
0.014098069630563259,
0.010764311999082565,
-0.02536199241876602,
-0.04472867026925087,
-0.008402522653341293,
-0.004787166602909565,
-0.013244192115962505,
0.05748233571648598,
0.01695946976542473,
-0.02063841186463833,
0.03072143904864788,
0.017041223123669624,
-0.0029658633284270763,
0.002772832289338112,
-0.008924840949475765,
-0.02045673504471779,
0.04636375606060028,
0.0012899007415398955,
0.043929293751716614,
-0.028832005336880684,
0.014988282695412636,
-0.01896699145436287,
-0.047780830413103104,
0.06311430037021637,
-0.056610289961099625,
0.04356594383716583,
-0.014861109666526318,
0.0087431650608778,
-0.0016975365579128265,
0.029177190735936165,
-0.03419145196676254,
-0.03279254585504532,
0.05101466551423073,
-0.0829169973731041,
0.019366677850484848,
-0.034482136368751526,
-0.020729249343276024,
-0.04807151108980179,
0.008625075221061707,
-0.026415713131427765,
0.008556947112083435,
0.04374761879444122,
0.0060089388862252235,
-0.07964682579040527,
-0.009092891588807106,
-0.025834349915385246,
0.015315299853682518,
0.0058000111021101475,
-0.039096709340810776,
0.003735715989023447,
-0.025852516293525696,
-0.02354522980749607,
-0.011145832017064095,
0.06107952445745468,
-0.03408244624733925,
-0.003955998457968235,
0.035426851361989975,
0.005809095222502947,
-0.09636103361845016,
-0.027651110664010048,
-0.0423668809235096,
0.006594844628125429,
-0.018694477155804634,
-0.029776722192764282,
-0.04345693811774254,
-0.01858547143638134,
0.014870193786919117,
0.07219810783863068,
-0.015796741470694542,
-0.041676510125398636,
-0.07307015359401703,
0.022509675472974777,
0.11074978858232498,
-0.018449213355779648,
-0.030140073969960213,
-0.019366677850484848,
-0.005386698059737682,
-0.019748197868466377,
0.02321821264922619,
0.059735119342803955,
0.0007783687906339765,
0.024199264124035835,
0.07252512127161026,
0.0718347504734993,
-0.02063841186463833,
0.0239267498254776,
0.08371637016534805,
-0.059153757989406586,
-0.0027614776045084,
-0.04494668170809746,
-0.02225532941520214,
0.015914831310510635,
-0.0404774472117424,
-0.023054704070091248,
0.02483513019979,
-0.029940230771899223,
-0.03435496240854263,
-0.0008743164944462478,
0.06747452169656754,
0.03141180798411369,
0.0009498256840743124,
0.040223103016614914,
0.047417476773262024,
0.040005091577768326,
-0.000345468579325825,
-0.042257875204086304,
-0.040005091577768326,
-0.02245517261326313,
0.0266700591892004,
-0.05261341482400894,
0.07405120134353638,
0.011454681865870953,
0.0386970229446888,
0.042439550161361694,
-0.0405137836933136,
-0.013934561051428318,
-0.003167978022247553,
0.023327218368649483,
-0.03793398290872574,
-0.04534636810421944,
-0.005050597246736288,
0.044474322348833084,
0.0024003961589187384,
-0.0070490348152816296,
-0.011009574867784977,
-0.010419127531349659,
0.0193485114723444,
-0.04916156828403473,
-0.00019714701920747757,
0.04273023083806038,
-0.03698926419019699,
0.007475974038243294,
-0.05777301639318466,
0.046654436737298965,
0.008025544695556164,
0.03351924940943718,
0.02835964784026146,
0.03960540145635605,
-0.006649347487837076,
0.028577659279108047,
-0.05097832903265953,
0.03898770362138748,
-0.06496739387512207,
0.024762460961937904,
0.04080446437001228,
0.02100176364183426,
0.014570428058505058,
0.04770815744996071,
0.04669077321887016,
0.023145541548728943,
-0.004982468672096729,
0.010192031972110271,
0.04196719080209732,
0.041894521564245224,
-0.028068967163562775,
-0.0014250223757699132,
-0.009142852388322353,
0.07085370272397995,
-0.018676308915019035,
0.024617118760943413,
-0.0368439257144928,
-0.003508620895445347,
-0.07074469327926636,
0.03742528706789017,
0.049779266119003296,
0.0017656651325523853,
-0.06391367316246033,
0.05261341482400894,
-0.0006421116413548589,
0.009701507166028023,
-0.004037752747535706,
-0.005463910289108753,
-0.008443399332463741,
-0.00399914663285017,
-0.04160384088754654,
-0.053267449140548706,
0.05188671126961708,
-0.016696039587259293,
0.010228367522358894,
-0.008547862991690636,
-0.050505973398685455,
0.04382028803229332,
0.005813636817038059,
0.09621569514274597,
0.028105301782488823,
0.035245172679424286,
0.00011965078010689467,
0.0053185694850981236,
-0.014697601087391376,
-0.04654543101787567,
0.10079393535852432,
0.00818905234336853,
0.004532820079475641,
0.040404777973890305,
-0.029377033933997154,
0.03404611349105835,
-0.03261087089776993,
-0.0442199781537056,
-0.1031193882226944,
0.015542395412921906,
0.0211834404617548,
-0.0001659214321989566,
-0.016114674508571625,
-0.012917174957692623,
0.012472067959606647,
0.07165307551622391,
-0.04084080085158348,
-0.017222899943590164,
0.010173864662647247,
-0.0312664657831192,
-0.055665574967861176,
0.007198917679488659,
0.02080192044377327,
-0.02098359540104866,
0.06235125660896301,
0.03017641045153141,
0.049597591161727905,
0.041349492967128754,
0.07485057413578033,
0.01860363781452179,
0.002202823292464018,
-0.021819306537508965,
0.013071599416434765,
-0.014561343938112259,
-0.008125466294586658,
0.08407972753047943,
0.056428615003824234,
0.016823211684823036,
0.02832331322133541,
-0.0035313302651047707,
0.02834147959947586,
-0.00474628945812583,
0.05185037478804588,
-0.02027505822479725,
0.024344604462385178,
0.019966209307312965,
0.004909798037260771,
0.051995716989040375,
-0.010319205932319164,
-0.018821649253368378,
0.01985720358788967,
0.036353398114442825,
0.009528914466500282,
-0.011345676146447659,
0.06533074378967285,
-0.01397998072206974,
-0.02171030081808567,
0.06344131380319595,
0.10929637402296066,
-0.028541324660182,
-0.033955272287130356,
-0.018340207636356354,
-0.02594335563480854,
0.023690570145845413,
0.003967353142797947,
-0.04956125468015671,
0.029922062531113625,
0.02225532941520214,
0.03222934901714325,
0.04403829947113991,
0.03204767405986786,
-0.01580582559108734,
-0.08219029009342194,
-0.03459114208817482,
0.016686955466866493,
0.0038151992484927177,
-0.10384608805179596,
0.00126492022536695,
0.04621841385960579,
-0.0018224389059469104,
-0.016795961186289787,
0.010846066288650036,
0.0221099890768528,
0.007312465459108353,
0.012281307950615883,
0.02503497526049614,
-0.004846211522817612,
-0.037279948592185974,
0.023799575865268707,
0.012780917808413506,
-0.07601330429315567,
-0.04138582944869995,
0.05399415269494057,
0.02579801343381405,
-0.004905256442725658,
0.03479098528623581,
-0.05025162547826767,
0.01744999550282955,
-0.046472761780023575,
0.038006652146577835,
0.011718112044036388,
0.016441691666841507,
-0.010228367522358894,
0.019748197868466377,
0.001786103704944253,
0.07884745299816132,
0.008579656481742859,
-0.03720727562904358,
0.022328000515699387,
-0.009855931624770164,
-0.0053185694850981236,
0.002586614340543747,
-0.031557150185108185,
0.02721508778631687,
-0.0442199781537056,
-0.034718312323093414,
-0.0013523518573492765,
-0.007480515632778406,
0.03557218983769417,
-0.014243410900235176,
0.028995513916015625,
-0.054175831377506256,
-0.02320004440844059,
0.010864234529435635,
0.05177770555019379,
0.06718384474515915,
0.03222934901714325,
0.05268608406186104,
-0.028032630681991577,
0.049197904765605927,
0.008979343809187412,
0.002427647588774562,
0.040041424334049225,
0.14316080510616302,
0.007076286245137453,
-0.013970896601676941,
0.007058118470013142,
-0.023436224088072777,
0.014570428058505058,
0.007035409100353718,
0.03738895431160927,
0.027287758886814117,
-0.07136239111423492,
0.06943662464618683,
0.021038098260760307,
-0.019548354670405388,
0.01695038564503193,
-0.007430554833263159,
-0.013280526734888554,
0.03073960542678833,
-0.003385989461094141,
0.018639974296092987,
0.03564486280083656,
0.04069545865058899,
-0.040404777973890305,
0.020565740764141083,
-0.03003106825053692,
0.009188272058963776,
-0.009501663036644459,
-0.011145832017064095,
-0.033373910933732986,
-0.019275840371847153,
-0.03333757445216179,
-0.04669077321887016,
0.04901622608304024,
-0.031175628304481506,
0.02743309922516346,
-0.03902404010295868,
-0.0009929738007485867,
-0.025870684534311295,
-0.025507332757115364,
0.013598460704088211,
0.03938739001750946,
0.041858185082674026,
-0.047780830413103104,
0.03092128224670887,
-0.023672403767704964,
0.0033769055735319853,
-0.053122106939554214,
0.010909653268754482,
0.005872681736946106,
-0.040404777973890305,
0.017958687618374825,
-0.04025943577289581,
-0.011917956173419952,
0.014788439497351646,
0.06224225088953972,
-0.0068855262361466885,
0.04894355684518814,
-0.05210472270846367,
-0.0014261577744036913,
-0.05166869983077049,
0.0010026253294199705,
-0.007521392777562141,
0.0069400290958583355,
0.046872448176145554,
0.021256109699606895,
-0.00845702551305294,
-0.04956125468015671,
0.003383718430995941,
0.01714114472270012,
0.01020111609250307,
-0.050142619758844376,
0.042439550161361694,
-0.005777301732450724,
-0.033791765570640564,
0.04171284660696983,
-0.010391876101493835,
-0.007743946276605129,
-0.0002461144176777452,
0.06605745106935501,
-0.0026797233149409294,
-0.0023776867892593145,
-0.006367749534547329,
-0.016305435448884964,
0.00958341732621193,
0.0042898282408714294,
-0.001720246160402894,
-0.041676510125398636,
0.05017895624041557,
0.027923624962568283,
0.0009095162386074662,
-0.007108079735189676,
-0.015778575092554092,
0.0016441692132502794,
0.004151300061494112,
-0.023454392328858376,
-0.0460004024207592,
-0.023127375170588493,
0.03640790283679962,
0.010355540551245213,
-0.07245244830846786,
-0.028305144980549812,
-0.04767182469367981,
-0.09040205925703049,
0.03942372649908066,
-0.009329070337116718,
0.03898770362138748,
-0.015315299853682518,
0.017976855859160423,
-0.010282870382070541,
-0.05966245010495186,
-0.04360227659344673,
0.08756791055202484,
-0.021492289379239082,
-0.0809548944234848,
-0.0165779497474432,
0.035790201276540756,
-0.021673966199159622,
-0.010782480239868164,
-0.05875406786799431,
0.02396308444440365,
-0.022418837994337082,
-0.14098069071769714,
-0.03789764642715454,
0.003063514130190015,
0.0442199781537056,
-0.010237451642751694,
-0.0442199781537056,
-0.015751322731375694,
-0.029758553951978683,
-0.02062024362385273,
0.0682012289762497,
-0.01049179770052433,
-0.034500300884246826,
-0.024035755544900894,
0.032320186495780945,
0.007957415655255318,
-0.01546972431242466,
-0.011618190445005894,
0.03033991903066635,
-0.006263285409659147,
0.029776722192764282,
0.1140926256775856,
-0.021619463339447975,
0.00799829326570034,
0.04560071602463722,
-0.024199264124035835,
0.0020801920909434557,
-0.024399107322096825,
-0.05802736431360245,
0.017004888504743576,
-0.03408244624733925,
0.0405501164495945,
-0.03533601388335228,
-0.03797031566500664,
-0.027542104944586754,
-0.062314920127391815,
-0.014670349657535553,
-0.01536071952432394,
0.017604419961571693,
-0.010709809139370918,
-0.04269389808177948,
-0.009528914466500282,
-0.027469435706734657,
-0.0422942079603672,
-0.005831804592162371,
-0.04356594383716583,
0.006785604637116194,
-0.077176034450531,
0.001386416144669056,
-0.028468653559684753,
-0.0515596941113472,
0.06166088953614235,
-0.022727686911821365,
-0.0386243499815464,
0.01731373742222786,
-0.019239505752921104,
0.04451065883040428,
0.0057137152180075645,
0.06642080098390579,
-0.022037317976355553,
0.029340699315071106,
-0.031030287966132164,
0.008920298889279366,
0.0147157683968544,
0.002189197577536106,
-0.017086641862988472,
-0.011927039362490177,
-0.055847249925136566,
-0.02243700623512268,
0.01527896523475647,
-0.061043187975883484,
0.007957415655255318,
-0.013071599416434765,
0.026397544890642166,
-0.02706974744796753,
-0.017041223123669624,
-0.030812276527285576,
0.027324093505740166,
0.05116000398993492,
-0.11154916137456894,
0.0035449559800326824,
-0.02154679223895073,
-0.005323111545294523,
-0.03459114208817482,
-0.03588104248046875,
-0.023617900907993317,
-0.04160384088754654,
0.03517250344157219,
-0.06107952445745468,
0.013970896601676941,
-0.00005226737994235009,
-0.0174954142421484,
-0.037606965750455856,
-0.05323111265897751,
0.0211471039801836,
-0.0367530882358551,
0.03555402532219887,
0.07325182855129242,
-0.02579801343381405,
0.026470215991139412,
-0.014606762677431107,
0.06398634612560272,
-0.050360631197690964,
-0.0019087351392954588,
-0.023617900907993317,
0.05581091716885567,
-0.01408898551017046,
0.0348999910056591,
-0.02045673504471779,
-0.04749014601111412,
0.01050088182091713,
0.018930654972791672,
-0.03275620937347412,
0.07270679622888565,
-0.017004888504743576,
0.019984377548098564,
0.0313028022646904,
-0.0010571281891316175,
0.005482078064233065,
0.04182185232639313,
0.007285214029252529,
-0.007775739300996065,
0.023781409487128258,
-0.026760898530483246,
-0.013998148031532764,
-0.08269898593425751,
-0.0921461433172226,
-0.0031339137349277735,
-0.0202387236058712,
0.006481296848505735,
0.01878531463444233,
-0.006372291129082441,
0.008034627884626389,
0.039496395736932755
]
|
30,598 | networkx.drawing.nx_pylab | draw_random | Draw the graph `G` with a random layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.random_layout(G), **kwargs)
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.random_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.random_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.lollipop_graph(4, 3)
>>> nx.draw_random(G)
See Also
--------
:func:`~networkx.drawing.layout.random_layout`
| def draw_random(G, **kwargs):
"""Draw the graph `G` with a random layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.random_layout(G), **kwargs)
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.random_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.random_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.lollipop_graph(4, 3)
>>> nx.draw_random(G)
See Also
--------
:func:`~networkx.drawing.layout.random_layout`
"""
draw(G, random_layout(G), **kwargs)
| (G, **kwargs) | [
0.03376743942499161,
-0.017708830535411835,
0.015819061547517776,
-0.006241564638912678,
-0.0005220711464062333,
0.036056458950042725,
-0.033004436641931534,
-0.0033558944705873728,
0.09255437552928925,
-0.028497377410531044,
-0.004090065602213144,
0.04744831100106239,
0.0203704796731472,
0.06033068895339966,
-0.046845003962516785,
0.005784648470580578,
0.020902808755636215,
0.021310927346348763,
-0.02120446227490902,
-0.0342465378344059,
0.032205939292907715,
0.03467240184545517,
0.003213939955458045,
0.015233498997986317,
0.023298291489481926,
-0.005416453815996647,
-0.03135421499609947,
-0.002066104207187891,
0.03775991126894951,
0.01960747316479683,
0.027752116322517395,
-0.07899770885705948,
-0.029686247929930687,
0.0473773330450058,
-0.028923241421580315,
0.013671998865902424,
0.01886221207678318,
0.05802392587065697,
-0.03339480981230736,
-0.0473773330450058,
0.050464846193790436,
-0.028550609946250916,
0.033199623227119446,
-0.008894340135157108,
0.008770129643380642,
0.011862077750265598,
0.06881247460842133,
0.033572252839803696,
-0.09510955214500427,
-0.026847155764698982,
0.011303131468594074,
0.016173947602510452,
-0.03296894580125809,
0.008570506237447262,
0.002765895798802376,
-0.014639063738286495,
-0.00580682884901762,
0.021506115794181824,
0.05617851763963699,
-0.02580024115741253,
-0.015277859754860401,
-0.006600887048989534,
-0.05010996013879776,
0.011152304708957672,
-0.005784648470580578,
-0.023280547931790352,
-0.048441994935274124,
-0.013432450592517853,
-0.0138405691832304,
-0.001229903195053339,
-0.00763449352234602,
0.10327193886041641,
0.015907783061265945,
0.02425648458302021,
0.02885226346552372,
0.0005101491697132587,
0.0400666743516922,
0.018933190032839775,
0.007532463874667883,
-0.01492297276854515,
-0.003238338278606534,
-0.030466997995972633,
0.0178685300052166,
-0.0025174752809107304,
-0.013361472636461258,
-0.008086973801255226,
0.008007124066352844,
0.0524522103369236,
0.057030245661735535,
-0.07076434791088104,
0.047554776072502136,
0.017788680270314217,
0.012208092026412487,
-0.01900416612625122,
-0.03289796784520149,
-0.03186879679560661,
0.005762468092143536,
-0.013565532863140106,
0.033802930265665054,
0.012917865067720413,
-0.033714208751916885,
-0.01304207555949688,
-0.07367441803216934,
-0.02205619029700756,
-0.02603091672062874,
-0.02580024115741253,
-0.02885226346552372,
0.016244925558567047,
-0.041415244340896606,
0.05869821086525917,
0.014257561415433884,
0.015286731533706188,
0.08900550752878189,
-0.007936147041618824,
0.040882911533117294,
0.01843634806573391,
-0.01943003013730049,
-0.0018642626237124205,
-0.0056604379788041115,
-0.027663394808769226,
-0.01100147794932127,
0.03712111711502075,
0.00688479607924819,
-0.009644038043916225,
0.01175561174750328,
-0.022907916456460953,
-0.028870008885860443,
-0.0020439238287508488,
0.005234574433416128,
-0.00688479607924819,
0.03335932269692421,
-0.01503831148147583,
0.052949052304029465,
0.03960532322525978,
0.01208388153463602,
0.019483262673020363,
-0.02462911605834961,
0.0060552493669092655,
-0.016244925558567047,
0.03012985549867153,
-0.002080521546304226,
-0.0276811383664608,
0.010451404377818108,
0.04563838988542557,
0.040811937302351,
0.019039655104279518,
-0.02074310928583145,
-0.026243848726153374,
0.02411453053355217,
0.008521709591150284,
0.046419139951467514,
-0.02908294089138508,
0.03875359520316124,
-0.0006021978333592415,
-0.03878908231854439,
-0.0032228121999651194,
-0.03185105323791504,
-0.001747815520502627,
-0.027752116322517395,
-0.018329882994294167,
-0.01886221207678318,
-0.012802526354789734,
0.11051162332296371,
0.02008656971156597,
-0.021328672766685486,
0.08517273515462875,
-0.011542679741978645,
-0.026119638234376907,
0.010149750858545303,
-0.011409597471356392,
-0.02129318378865719,
-0.0379018671810627,
0.0031119100749492645,
-0.08375319093465805,
0.0005306660896167159,
0.006272617261856794,
-0.04759026691317558,
-0.0018287739949300885,
-0.02411453053355217,
-0.004409463610500097,
0.03772442415356636,
-0.04851296916604042,
0.030378276482224464,
-0.00015637182514183223,
-0.035914503037929535,
0.018755747005343437,
-0.024522650986909866,
-0.013467938639223576,
0.02280145138502121,
-0.018418604508042336,
-0.0567818246781826,
0.05983384698629379,
-0.025303401052951813,
0.010371554642915726,
0.023724155500531197,
-0.0019274767255410552,
-0.038398709148168564,
-0.016076354309916496,
0.014931845478713512,
0.052203789353370667,
0.050500333309173584,
0.00620607566088438,
-0.0012875722022727132,
-0.010149750858545303,
0.005230138078331947,
-0.002681610407307744,
0.006259308662265539,
-0.033288344740867615,
-0.03541766107082367,
-0.01442613173276186,
0.012571850791573524,
-0.030466997995972633,
0.0698416456580162,
0.005558408331125975,
-0.029863690957427025,
0.023759644478559494,
-0.07101276516914368,
0.018108079209923744,
-0.019252587109804153,
-0.019270330667495728,
-0.0011877603828907013,
-0.019447773694992065,
-0.006707353051751852,
-0.02308535948395729,
0.033998116850852966,
-0.05216830223798752,
0.018170183524489403,
-0.04631267488002777,
-0.013139668852090836,
-0.06714450567960739,
0.06572496145963669,
-0.028266701847314835,
0.06128888204693794,
0.004715553019195795,
-0.0371566042304039,
-0.08623739331960678,
0.009546443819999695,
-0.013414706103503704,
0.027006855234503746,
0.032259173691272736,
-0.07693937420845032,
0.01769108697772026,
-0.01801048405468464,
-0.006658555939793587,
0.005944347009062767,
0.08190777897834778,
-0.058059412986040115,
0.0058511896058917046,
0.018329882994294167,
-0.005895550362765789,
-0.0947546660900116,
-0.01485199574381113,
-0.010699824430048466,
0.024611372500658035,
0.04531899467110634,
0.02856835536658764,
-0.0887925773859024,
0.01118779368698597,
-0.02918940596282482,
0.06274391710758209,
-0.03871810436248779,
-0.0052523184567689896,
-0.11256996542215347,
0.05635596066713333,
0.06281489133834839,
-0.02542760968208313,
-0.04482215270400047,
0.0626729354262352,
-0.03942788019776344,
-0.0312654934823513,
0.0031008198857307434,
0.0699126198887825,
0.05873369798064232,
-0.014293049462139606,
0.07473907619714737,
0.014843123964965343,
-0.00820231158286333,
0.01909288763999939,
0.05944347009062767,
-0.034601423889398575,
0.022553030401468277,
0.01680387184023857,
-0.015677107498049736,
0.045248016715049744,
-0.02477107010781765,
0.0006304778507910669,
-0.0011328639229759574,
0.03030729852616787,
-0.030413763597607613,
-0.024948513135313988,
0.05639144778251648,
-0.011817716993391514,
0.03312864527106285,
0.05830783396959305,
-0.04542545974254608,
0.02645678073167801,
0.011409597471356392,
0.017416050657629967,
-0.05621400475502014,
0.017735447734594345,
0.07218389213085175,
-0.061821211129426956,
0.02154160477221012,
0.031549401581287384,
0.10760155320167542,
0.05415566265583038,
0.005651565734297037,
-0.026864901185035706,
0.006086301524192095,
0.01358327642083168,
-0.08126898854970932,
-0.010256216861307621,
0.03701465204358101,
0.05663986876606941,
-0.02026401273906231,
-0.026527758687734604,
-0.013760720379650593,
-0.04035058245062828,
0.046383652836084366,
-0.03818577527999878,
-0.010903884656727314,
0.03683720901608467,
-0.04059900343418121,
0.005283371079713106,
-0.05117461830377579,
0.02194972336292267,
0.0023444683756679296,
0.03293345868587494,
-0.024984002113342285,
0.06721548736095428,
-0.024877537041902542,
-0.018223416060209274,
-0.0553622767329216,
0.033998116850852966,
-0.059656403958797455,
0.031780075281858444,
-0.008362011052668095,
-0.013521172106266022,
0.056426938623189926,
-0.026669712737202644,
0.012421024031937122,
-0.013707486912608147,
-0.010682080872356892,
0.015304476022720337,
0.08957332372665405,
0.04485763981938362,
0.01815243996679783,
0.009990052320063114,
-0.03705013915896416,
0.011924182996153831,
0.019625218585133553,
0.038256753236055374,
0.01872025802731514,
-0.031230002641677856,
0.018596047535538673,
0.08283048868179321,
0.025959940627217293,
0.0385761521756649,
-0.05142303928732872,
0.059798356145620346,
-0.038221266120672226,
-0.028355423361063004,
0.029863690957427025,
-0.03105255961418152,
0.00011221895692870021,
0.015100415796041489,
-0.028231212869286537,
0.00016815515118651092,
0.03495630994439125,
-0.046845003962516785,
-0.006068557500839233,
-0.08375319093465805,
-0.09723887592554092,
0.02336926944553852,
0.03921494632959366,
0.030466997995972633,
-0.047270867973566055,
0.017478154972195625,
0.020051080733537674,
-0.017770936712622643,
-0.01717650145292282,
-0.05898211896419525,
0.09241241961717606,
0.019501008093357086,
0.004378410987555981,
0.007882914505898952,
0.022978894412517548,
0.03193977475166321,
-0.059372495859861374,
-0.029899178072810173,
-0.06696706265211105,
-0.011835461482405663,
0.03438849374651909,
0.026385802775621414,
-0.030892860144376755,
-0.010424788109958172,
0.030484741553664207,
0.034832101315259933,
-0.07658448815345764,
-0.01923484355211258,
0.005070439539849758,
-0.010566742159426212,
-0.05546874552965164,
-0.017220862209796906,
0.03618066757917404,
-0.030289553105831146,
-0.007204194087535143,
0.0001517971104476601,
0.01848958060145378,
0.03804382309317589,
0.0356660820543766,
0.02796504832804203,
-0.025250166654586792,
-0.010557870380580425,
0.1239263266324997,
-0.014009140431880951,
0.01184433326125145,
0.09432880580425262,
0.047838687896728516,
-0.00891652051359415,
0.015082672238349915,
0.013157413341104984,
0.038540661334991455,
0.012004032731056213,
0.06554751843214035,
0.004817582666873932,
-0.012562978081405163,
-0.015206881798803806,
-0.014710040763020515,
0.0590176060795784,
-0.03428202494978905,
-0.03209947422146797,
-0.024096786975860596,
0.08914746344089508,
0.054120175540447235,
-0.043189674615859985,
0.03610968962311745,
-0.03610968962311745,
-0.038824573159217834,
0.030892860144376755,
0.0699835941195488,
0.00701344246044755,
0.01646672934293747,
-0.03630487993359566,
-0.04556741192936897,
0.0196607057005167,
0.018702512606978416,
0.020423712208867073,
0.025463098660111427,
-0.025303401052951813,
0.044964104890823364,
0.04010216146707535,
0.03339480981230736,
0.028781287372112274,
-0.08247559517621994,
-0.03804382309317589,
-0.018968677148222923,
0.01825890503823757,
-0.07800403237342834,
0.01459470298141241,
-0.0005938801914453506,
0.008965317159891129,
-0.0758747085928917,
-0.004447170067578554,
0.03138970211148262,
-0.013822825625538826,
0.01533996406942606,
0.015943272039294243,
-0.018134694546461105,
0.027485951781272888,
0.0422314815223217,
-0.01723860763013363,
-0.05578814074397087,
-0.027752116322517395,
0.02496625855565071,
-0.04897432401776314,
-0.010362682864069939,
0.010362682864069939,
-0.06114692613482475,
0.01677725464105606,
-0.0037861941382288933,
0.02354671247303486,
-0.012421024031937122,
0.019270330667495728,
-0.027414973825216293,
0.02397257648408413,
0.002377738943323493,
0.06412797421216965,
0.02209167741239071,
0.010699824430048466,
0.0019718375988304615,
-0.019341308623552322,
-0.005797956604510546,
-0.027556927874684334,
-0.017708830535411835,
0.02993466705083847,
-0.028231212869286537,
-0.018418604508042336,
0.005425325594842434,
-0.04237343743443489,
-0.0014140005223453045,
-0.011214409954845905,
0.05422664061188698,
-0.010149750858545303,
-0.009794864803552628,
-0.018134694546461105,
0.03325285390019417,
0.01994461566209793,
0.0280537698417902,
0.0182056725025177,
0.03428202494978905,
0.051955368369817734,
0.049187254160642624,
0.00950208306312561,
0.06164376810193062,
0.03524021804332733,
-0.012066137976944447,
-0.012882376089692116,
0.04482215270400047,
-0.040882911533117294,
0.03621615841984749,
0.0316736102104187,
-0.014417259953916073,
0.008765693753957748,
-0.04613523185253143,
0.04666756093502045,
0.050606802105903625,
-0.000344905216479674,
0.028124747797846794,
0.00440280931070447,
-0.02097378671169281,
0.053268447518348694,
-0.0006149515975266695,
0.04908078908920288,
0.025977684184908867,
-0.010362682864069939,
-0.02097378671169281,
-0.015703722834587097,
-0.032489851117134094,
0.0009315767674706876,
-0.015961015596985817,
0.009022986516356468,
-0.016999058425426483,
-0.03392713889479637,
0.0031629251316189766,
0.013352600857615471,
0.047838687896728516,
-0.029029706493020058,
-0.01592552661895752,
-0.044928617775440216,
-0.01362763810902834,
-0.04020863026380539,
-0.04670305177569389,
-0.07672643661499023,
0.03495630994439125,
-0.007887350395321846,
-0.07658448815345764,
0.0495421402156353,
-0.0015415378147736192,
0.01304207555949688,
-0.036908186972141266,
0.02539212256669998,
0.03050248511135578,
-0.024788815528154373,
0.051210105419158936,
-0.026829412207007408,
-0.046099744737148285,
-0.014745529741048813,
0.01492297276854515,
-0.019571984186768532,
0.018471837043762207,
0.016431240364909172,
0.04709342494606972,
-0.021222205832600594,
-0.011090199463069439,
0.013636509887874126,
-0.005278935190290213,
0.04404140263795853,
0.023280547931790352,
0.019962359219789505,
-0.03903750330209732,
0.015561768785119057,
0.04382846876978874,
0.02819572389125824,
-0.01712326891720295,
0.05390724539756775,
0.009209302254021168,
-0.009271407499909401,
0.015428686514496803,
-0.03683720901608467,
-0.007594569120556116,
0.0012143768835812807,
0.03818577527999878,
-0.021009273827075958,
0.017416050657629967,
-0.0038837881293147802,
0.01344132237136364,
-0.011533807963132858,
-0.05465250462293625,
-0.017673343420028687,
-0.03804382309317589,
0.10426562279462814,
0.0087479492649436,
0.009972307831048965,
0.004280817229300737,
-0.021843258291482925,
-0.0028834519907832146,
-0.00813133455812931,
0.007097728084772825,
-0.03570157289505005,
-0.028036026284098625,
0.015615001320838928,
-0.04350907355546951,
-0.06877698749303818,
0.007226374465972185,
-0.0771523043513298,
-0.07615862041711807,
-0.0012864632299169898,
0.013964779675006866,
-0.003577698487788439,
-0.009466595016419888,
0.024220997467637062,
-0.035861268639564514,
-0.04311869665980339,
-0.019217098131775856,
0.04240892454981804,
-0.04059900343418121,
-0.056036561727523804,
-0.031549401581287384,
0.03768893703818321,
0.006006452254951,
-0.037085629999637604,
-0.047554776072502136,
-0.01943003013730049,
0.014133350923657417,
-0.1122860535979271,
-0.013450194150209427,
-0.003746269503608346,
0.027184298262000084,
-0.004300779663026333,
0.009093963541090488,
0.024291973561048508,
-0.04109584540128708,
-0.027202041819691658,
0.014346282929182053,
-0.02163032628595829,
-0.023990320041775703,
-0.009581932798027992,
0.05014544725418091,
-0.02885226346552372,
-0.018170183524489403,
0.009927947074174881,
0.037085629999637604,
0.012208092026412487,
0.05124559625983238,
0.028834519907832146,
-0.009954563342034817,
-0.02205619029700756,
0.05209732428193092,
-0.031176770105957985,
0.00865922775119543,
0.039853744208812714,
0.008725768886506557,
0.01852506957948208,
-0.05763355270028114,
0.019696194678544998,
-0.023759644478559494,
-0.058485276997089386,
-0.0038882240187376738,
-0.06877698749303818,
-0.0379018671810627,
-0.021452883258461952,
0.01717650145292282,
-0.016582066193223,
-0.06299233436584473,
-0.03981825336813927,
0.007718779146671295,
0.009883586317300797,
-0.004189877305179834,
-0.02642129175364971,
0.07087081670761108,
-0.053268447518348694,
-0.023812877014279366,
-0.07126118987798691,
-0.02168355882167816,
0.0714031457901001,
-0.008858852088451385,
-0.020051080733537674,
0.0006426770705729723,
0.023422501981258392,
0.028018280863761902,
-0.059940312057733536,
0.0677478164434433,
0.00414551654830575,
0.033235110342502594,
-0.025445355102419853,
-0.016857104375958443,
0.014914100989699364,
-0.0276811383664608,
-0.01536658126860857,
0.030573463067412376,
-0.004189877305179834,
-0.02200295589864254,
0.030857373028993607,
-0.0640215054154396,
-0.007452614139765501,
-0.08630837500095367,
0.05333942547440529,
-0.022836940363049507,
0.025356633588671684,
-0.029686247929930687,
-0.011782228015363216,
0.04031509533524513,
-0.010043284855782986,
-0.007794192526489496,
-0.03550638258457184,
0.020654387772083282,
0.0019496571039780974,
-0.08382416516542435,
-0.035116009414196014,
-0.048441994935274124,
0.019483262673020363,
-0.06359564512968063,
-0.0062193842604756355,
0.023635433986783028,
-0.0073594567365944386,
-0.001344132237136364,
-0.0640924870967865,
0.026722945272922516,
-0.020015593618154526,
0.014364026486873627,
0.030183088034391403,
-0.004640139639377594,
-0.007878477685153484,
-0.023635433986783028,
0.047696731984615326,
-0.024842048063874245,
0.010584486648440361,
-0.029544292017817497,
-0.008730205707252026,
-0.04620620980858803,
0.039108481258153915,
-0.030804138630628586,
0.003185105510056019,
-0.013077563606202602,
-0.02280145138502121,
-0.0015925527550280094,
0.024842048063874245,
0.005891114007681608,
0.015606129541993141,
0.036056458950042725,
0.03002338856458664,
-0.009298023767769337,
0.023014383390545845,
0.013272751122713089,
0.012678316794335842,
0.03673074394464493,
-0.020051080733537674,
0.06065008416771889,
-0.04627718776464462,
-0.05663986876606941,
-0.04205403849482536,
0.006694044452160597,
-0.009883586317300797,
0.01698131486773491,
0.0255163311958313,
0.01041591539978981,
0.045673880726099014
]
|
30,599 | networkx.drawing.nx_pylab | draw_shell | Draw networkx graph `G` with shell layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.shell_layout(G, nlist=nlist), **kwargs)
Parameters
----------
G : graph
A networkx graph
nlist : list of list of nodes, optional
A list containing lists of nodes representing the shells.
Default is `None`, meaning all nodes are in a single shell.
See `~networkx.drawing.layout.shell_layout` for details.
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.shell_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.shell_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(4)
>>> shells = [[0], [1, 2, 3]]
>>> nx.draw_shell(G, nlist=shells)
See Also
--------
:func:`~networkx.drawing.layout.shell_layout`
| def draw_shell(G, nlist=None, **kwargs):
"""Draw networkx graph `G` with shell layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.shell_layout(G, nlist=nlist), **kwargs)
Parameters
----------
G : graph
A networkx graph
nlist : list of list of nodes, optional
A list containing lists of nodes representing the shells.
Default is `None`, meaning all nodes are in a single shell.
See `~networkx.drawing.layout.shell_layout` for details.
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.shell_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.shell_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(4)
>>> shells = [[0], [1, 2, 3]]
>>> nx.draw_shell(G, nlist=shells)
See Also
--------
:func:`~networkx.drawing.layout.shell_layout`
"""
draw(G, shell_layout(G, nlist=nlist), **kwargs)
| (G, nlist=None, **kwargs) | [
0.00012147027155151591,
-0.02677055262029171,
-0.012117663398385048,
-0.04418027400970459,
0.03411029279232025,
0.07116357237100601,
-0.008403471671044827,
0.010389101691544056,
0.06190911680459976,
-0.04325837641954422,
0.0024399319663643837,
0.03095455840229988,
0.009281049482524395,
0.005850518122315407,
-0.014014650136232376,
-0.03267425671219826,
0.02263973094522953,
-0.031291406601667404,
0.03978352248668671,
0.0007207882590591908,
0.04836428165435791,
-0.03903891146183014,
0.04620136320590973,
-0.01647895947098732,
-0.021079594269394875,
-0.019271252676844597,
0.03519175201654434,
0.023987123742699623,
-0.02997947297990322,
0.022356070578098297,
0.022125596180558205,
-0.02267519012093544,
-0.008576327934861183,
-0.003069305792450905,
0.019271252676844597,
0.03691145032644272,
-0.015051787719130516,
0.03178781270980835,
-0.05878884345293045,
0.0040089343674480915,
0.019838575273752213,
-0.023366615176200867,
0.025334516540169716,
0.022409256547689438,
-0.0068389009684324265,
0.009981337934732437,
0.04549220949411392,
0.00567766185849905,
-0.03992535173892975,
0.028153402730822563,
-0.015760941430926323,
-0.024926751852035522,
-0.051059067249298096,
-0.05134272947907448,
-0.04403844475746155,
-0.02586638182401657,
0.006036670878529549,
-0.0050349910743534565,
0.026327330619096756,
-0.03499673679471016,
-0.008000140078365803,
0.020157694816589355,
-0.008159699849784374,
-0.008704861626029015,
0.01852663978934288,
-0.03625548258423805,
0.012800224125385284,
-0.02042362652719021,
-0.011124848388135433,
-0.01440468430519104,
-0.06382383406162262,
0.06385929137468338,
0.027054212987422943,
-0.00002901712832681369,
-0.0005376825574785471,
0.01498973648995161,
0.031078660860657692,
0.038613419979810715,
0.02042362652719021,
0.006785714533179998,
0.029128488153219223,
0.021008677780628204,
0.037443313747644424,
0.053931139409542084,
0.016097789630293846,
0.04836428165435791,
0.020813660696148872,
0.10779136419296265,
-0.016195297241210938,
-0.058150604367256165,
0.02076047472655773,
0.01397032756358385,
-0.006568536162376404,
-0.029181674122810364,
-0.051839135587215424,
-0.01953718438744545,
-0.029589438810944557,
-0.025972753763198853,
-0.04357749596238136,
-0.010220677591860294,
-0.047903332859277725,
0.03221330791711807,
-0.0049330503679811954,
-0.04194644093513489,
-0.016984231770038605,
-0.022373799234628677,
-0.025281328707933426,
0.04609499126672745,
-0.08545301854610443,
0.03322385251522064,
0.014652888290584087,
0.008620649576187134,
0.08240365982055664,
-0.046910516917705536,
0.07921247184276581,
0.03395073488354683,
-0.028100214898586273,
-0.02586638182401657,
0.038648877292871475,
-0.04386115446686745,
-0.06910702586174011,
0.00968881230801344,
0.02682373858988285,
-0.005017262417823076,
0.02377437800168991,
0.07736866921186447,
0.01951945573091507,
-0.011142577044665813,
0.01861528493463993,
0.030245404690504074,
0.052016422152519226,
0.0010881077032536268,
-0.0040089343674480915,
0.005318652838468552,
0.026132313534617424,
-0.013491649180650711,
-0.03783335164189339,
-0.027142858132719994,
0.02354390360414982,
-0.032319679856300354,
-0.006280442234128714,
-0.07187272608280182,
-0.023916209116578102,
0.07907063513994217,
-0.030121304094791412,
0.031397778540849686,
0.023065224289894104,
-0.004582905676215887,
0.058008771389722824,
0.03419893607497215,
0.0023690166417509317,
0.0066970703192055225,
0.06265372782945633,
-0.009786320850253105,
-0.009351964108645916,
0.0013230148470029235,
-0.050810862332582474,
-0.017657926306128502,
0.004033311735838652,
0.042620137333869934,
-0.05173276364803314,
-0.02152281440794468,
0.037443313747644424,
0.032567884773015976,
-0.04003172740340233,
0.008217318914830685,
-0.019962675869464874,
-0.02969581075012684,
0.025972753763198853,
0.008031165227293968,
0.05942707881331444,
-0.06272464245557785,
-0.02269291877746582,
-0.02480265125632286,
0.00010311815276509151,
0.004458803683519363,
-0.031291406601667404,
0.0430101715028286,
-0.07109265774488449,
0.01434263400733471,
-0.0034837175626307726,
-0.057228703051805496,
0.043719325214624405,
0.008567462675273418,
-0.02685919590294361,
0.01753382571041584,
0.044853970408439636,
-0.02258654497563839,
0.0620509497821331,
0.015778670087456703,
-0.07722683995962143,
0.05027899891138077,
-0.00983950775116682,
-0.0027302417438477278,
-0.007162452209740877,
-0.02044135518372059,
-0.02888028509914875,
0.00924559123814106,
-0.03458897024393082,
0.012463375926017761,
-0.02049454115331173,
0.03669870272278786,
0.05577493831515312,
-0.015503873117268085,
0.017338808625936508,
-0.029234861955046654,
-0.039570774883031845,
0.010016796179115772,
0.024075768887996674,
-0.03354296833276749,
-0.006807875353842974,
-0.011745357885956764,
0.0032022721134126186,
0.008376877754926682,
0.005305355880409479,
-0.033418867737054825,
-0.05829243361949921,
0.013642344623804092,
-0.017719978466629982,
-0.0760921910405159,
-0.046945974230766296,
0.027373332530260086,
-0.031344592571258545,
-0.01937762461602688,
-0.015734348446130753,
-0.06605766713619232,
0.02154054306447506,
-0.047761499881744385,
0.027408789843320847,
-0.010486610233783722,
-0.00589927239343524,
-0.030316321179270744,
0.01764019764959812,
0.03309974819421768,
-0.02983764186501503,
-0.04421573132276535,
-0.0515909306704998,
-0.023153867572546005,
0.030050387606024742,
0.05432117357850075,
-0.07956704497337341,
-0.03171689808368683,
0.011399645358324051,
0.008895446546375751,
0.045775871723890305,
0.10396192967891693,
-0.03519175201654434,
0.01177195180207491,
-0.019023047760128975,
0.0033862090203911066,
-0.0949556827545166,
-0.018774844706058502,
-0.013296632096171379,
-0.004915321711450815,
-0.02377437800168991,
0.08169450610876083,
-0.12693850696086884,
-0.00970654096454382,
-0.013066156767308712,
-0.011993561871349812,
-0.005323085002601147,
-0.017852945253252983,
-0.06460390239953995,
0.01439581997692585,
0.06793692708015442,
-0.022320613265037537,
0.001751831267029047,
0.03097228705883026,
-0.05978165566921234,
0.004164061974734068,
-0.02377437800168991,
0.07715592533349991,
0.01439581997692585,
-0.007140291389077902,
0.06474573165178299,
0.0394289456307888,
0.015388634987175465,
-0.010353644378483295,
0.04194644093513489,
-0.0493570975959301,
0.0373723991215229,
-0.00006198169285198674,
-0.05786694213747978,
0.009360828436911106,
-0.029199402779340744,
-0.0037873240653425455,
0.02483810856938362,
-0.02884482592344284,
-0.04219464585185051,
-0.009555846452713013,
0.07258187979459763,
0.011133712716400623,
0.024164412170648575,
0.02139871194958687,
-0.029429879039525986,
0.025511804968118668,
0.004999533761292696,
0.007095969282090664,
-0.0829709842801094,
0.026593264192342758,
0.08119809627532959,
-0.00592586537823081,
0.05286740884184837,
0.030617710202932358,
0.03201828896999359,
-0.005642204079777002,
-0.004511990584433079,
0.014147615991532803,
-0.006010077428072691,
-0.022426985204219818,
-0.03492581844329834,
-0.0001329663209617138,
0.014892227947711945,
0.012117663398385048,
-0.027160586789250374,
-0.002411122666671872,
-0.008075487799942493,
0.0016088924603536725,
-0.013544836081564426,
0.008536437526345253,
0.005832789000123739,
0.01651441678404808,
0.005956890992820263,
0.09885602444410324,
0.009316506795585155,
0.05052720010280609,
-0.004746897611767054,
0.05070449039340019,
0.022161053493618965,
0.08063077926635742,
-0.04627227783203125,
0.03563497215509415,
-0.026504619047045708,
0.02574227936565876,
-0.03161052614450455,
0.03582999110221863,
0.04737146571278572,
0.03512083739042282,
-0.023366615176200867,
-0.04836428165435791,
0.03625548258423805,
0.08169450610876083,
-0.008288233540952206,
-0.027639266103506088,
0.025121768936514854,
0.016026873141527176,
0.0006820064154453576,
0.0163637213408947,
-0.020352711901068687,
-0.002650461858138442,
0.018021367490291595,
0.06088084354996681,
-0.028490249067544937,
-0.019874032586812973,
0.00936969369649887,
0.06180274486541748,
-0.007685453165322542,
0.011107119731605053,
-0.04960530251264572,
-0.00830596312880516,
0.030617710202932358,
-0.01027386449277401,
-0.008044462651014328,
0.022214239463210106,
-0.0348726324737072,
-0.0072599612176418304,
-0.006058831699192524,
-0.0014936550287529826,
0.022125596180558205,
0.006874358747154474,
-0.02978445589542389,
-0.02581319399178028,
-0.02586638182401657,
0.03375571593642235,
0.012232901528477669,
0.03981897979974747,
-0.01283568236976862,
-0.04304562881588936,
0.04045721888542175,
0.010965288616716862,
-0.0020277362782508135,
-0.03641504421830177,
0.08275824040174484,
-0.011319865472614765,
-0.00044460612116381526,
0.017214706167578697,
-0.030103575438261032,
0.05836334824562073,
-0.02051227167248726,
-0.0620509497821331,
-0.07502846419811249,
0.02368573285639286,
0.036769621074199677,
0.04868340119719505,
-0.007898199371993542,
-0.032301951199769974,
0.04946346953511238,
0.08169450610876083,
-0.038719791918992996,
-0.031202763319015503,
0.013571429066359997,
-0.018987590447068214,
-0.009564710780978203,
0.010947559960186481,
0.0165853314101696,
-0.07899972051382065,
0.0015701105585321784,
0.028986657038331032,
0.007180181331932545,
-0.03815246745944023,
0.03194737434387207,
-0.04634319245815277,
-0.03779789060354233,
0.028472520411014557,
0.06669590622186661,
-0.0024354998022317886,
-0.061093591153621674,
0.10396192967891693,
0.00874475110322237,
-0.0594625361263752,
-0.010468881577253342,
-0.0012620720081031322,
0.03494354709982872,
0.04620136320590973,
0.02971353940665722,
0.023065224289894104,
-0.015503873117268085,
0.008017868734896183,
-0.032567884773015976,
0.04549220949411392,
-0.009063870646059513,
-0.006728095933794975,
-0.008780209347605705,
0.017985910177230835,
0.012702715583145618,
-0.04942801222205162,
0.07410655915737152,
-0.029536250978708267,
-0.03384435921907425,
0.04254922270774841,
0.027408789843320847,
0.018703928217291832,
-0.003949099685996771,
0.014440142549574375,
0.024359429255127907,
0.04864794388413429,
-0.012773631140589714,
-0.035333581268787384,
-0.0061785015277564526,
-0.021239154040813446,
0.032603342086076736,
0.00544718699529767,
0.04705234616994858,
-0.011727629229426384,
-0.04049267619848251,
-0.04744238406419754,
-0.03992535173892975,
0.028454791754484177,
-0.0942465290427208,
0.05641317740082741,
0.06726323068141937,
-0.02895119972527027,
-0.025281328707933426,
0.013411869294941425,
-0.015246804803609848,
-0.014519922435283661,
-0.0019745498429983854,
0.056058600544929504,
-0.020920034497976303,
0.014830176718533039,
0.007348605431616306,
0.011922646313905716,
-0.06343379616737366,
0.004168494138866663,
0.021859662607312202,
-0.015503873117268085,
0.05751236528158188,
-0.04836428165435791,
-0.07502846419811249,
-0.024855837225914,
-0.05644863471388817,
0.02076047472655773,
-0.025937296450138092,
0.013846226036548615,
-0.06566762924194336,
0.0005983484443277121,
0.038613419979810715,
0.024377157911658287,
0.04223010316491127,
-0.019147150218486786,
0.01753382571041584,
-0.02049454115331173,
-0.04396753013134003,
-0.019253522157669067,
0.04332929104566574,
0.016257349401712418,
-0.04038630425930023,
-0.03896799683570862,
0.010211813263595104,
-0.04829336702823639,
-0.019023047760128975,
0.020051321014761925,
0.08814780414104462,
0.02891574241220951,
0.012755902484059334,
0.04137912020087242,
0.016780348494648933,
0.0414854921400547,
-0.0031003314070403576,
-0.016195297241210938,
0.029146216809749603,
0.028401605784893036,
0.03384435921907425,
0.020920034497976303,
-0.016948772594332695,
0.009653354994952679,
0.037656061351299286,
0.06793692708015442,
0.014670616947114468,
0.036592330783605576,
0.024182140827178955,
0.005048288032412529,
-0.04446393623948097,
-0.0025463050696998835,
-0.053931139409542084,
0.041627321392297745,
0.05729961767792702,
0.002588411094620824,
-0.010991882532835007,
-0.0033684801310300827,
-0.013004105538129807,
0.06346925348043442,
-0.011452832259237766,
0.03276289999485016,
0.022019222378730774,
0.017276756465435028,
-0.033507511019706726,
0.03205374628305435,
0.016062330454587936,
-0.0038582393899559975,
-0.019342167302966118,
-0.02272837609052658,
-0.0006786822341382504,
0.019200336188077927,
0.008359149098396301,
0.03801063820719719,
0.10289820283651352,
-0.047690585255622864,
-0.0022393744438886642,
-0.01226835884153843,
-0.02590183913707733,
-0.05354110524058342,
-0.00115791498683393,
-0.009422879666090012,
-0.019164878875017166,
0.008093216456472874,
0.006484324112534523,
0.005589017644524574,
-0.023455258458852768,
-0.03226649388670921,
-0.019767658784985542,
0.010211813263595104,
-0.014200802892446518,
-0.023880749940872192,
0.07928338646888733,
-0.020228609442710876,
0.009041709825396538,
0.004179574549198151,
-0.000746273435652256,
0.008771345019340515,
-0.010460017248988152,
0.029518522322177887,
0.024589903652668,
0.00020498974481597543,
0.031557340174913406,
-0.0065995617769658566,
0.06166091561317444,
0.031078660860657692,
0.01939535327255726,
-0.027320146560668945,
-0.03582999110221863,
-0.03205374628305435,
-0.04822245240211487,
0.022267425432801247,
0.008430064655840397,
0.08098535239696503,
0.026132313534617424,
0.023455258458852768,
-0.01836708001792431,
-0.04407390207052231,
0.04566949978470802,
0.027568349614739418,
0.09233181178569794,
0.044960346072912216,
0.0098572364076972,
-0.06630586832761765,
0.007335308473557234,
0.002003359142690897,
-0.04410935938358307,
0.03687599301338196,
-0.03836521506309509,
0.06449753046035767,
0.027373332530260086,
0.04109545797109604,
0.0433647483587265,
-0.031273677945137024,
0.04045721888542175,
-0.04843519628047943,
-0.0473005510866642,
-0.042726509273052216,
-0.03309974819421768,
0.02246244251728058,
-0.017870673909783363,
-0.046804144978523254,
-0.044783055782318115,
-0.013447326608002186,
-0.023189326748251915,
-0.028224317356944084,
0.00008760541095398366,
0.00009612357098376378,
0.04120182991027832,
0.022870207205414772,
-0.03910982608795166,
-0.03829430043697357,
0.025334516540169716,
0.045598581433296204,
-0.021434171125292778,
0.017329944297671318,
-0.009786320850253105,
-0.015158160589635372,
0.04201735556125641,
-0.024164412170648575,
-0.010105440393090248,
0.032301951199769974,
-0.0102827288210392,
-0.0843183770775795,
-0.048789773136377335,
-0.0346953459084034,
-0.0030338482465595007,
-0.009538116864860058,
-0.008212885819375515,
-0.013748717494308949,
0.02473173476755619,
-0.015184753574430943,
0.03939348831772804,
-0.029146216809749603,
-0.004099794663488865,
0.020104506984353065,
0.005318652838468552,
-0.0017928292509168386,
0.0013130423612892628,
0.0435420386493206,
0.00003519798337947577,
0.04861248657107353,
0.018145469948649406,
0.09850145131349564,
-0.014245124533772469,
-0.11672669649124146,
0.031291406601667404,
-0.019235793501138687,
0.05077540501952171,
0.018898945301771164,
-0.0413082018494606,
0.049853503704071045,
-0.059249792248010635,
0.006546374876052141,
-0.008226183243095875,
-0.0414854921400547,
0.011240086518228054,
-0.03829430043697357,
-0.03354296833276749,
-0.08048894256353378,
-0.018934404477477074,
0.0021994845010340214,
-0.046910516917705536,
-0.06970980763435364,
0.01183400209993124,
0.04432210698723793,
0.011647849343717098,
-0.017046282067894936,
-0.0642847791314125,
-0.0553494468331337,
0.0066970703192055225,
-0.04818699508905411,
-0.04556312412023544,
0.044818513095378876,
-0.02779882587492466,
-0.03187645971775055,
-0.02675282396376133,
0.02476719208061695,
0.020884577184915543,
0.019803117960691452,
0.028330691158771515,
-0.004188438877463341,
0.01288886833935976,
-0.0538247674703598,
0.027142858132719994,
-0.014635159634053707,
-0.00921899825334549,
-0.0326387993991375,
0.0022958850022405386,
-0.0326387993991375,
0.007915928028523922,
0.016673976555466652,
-0.005970187485218048,
-0.027444249019026756,
-0.07722683995962143,
0.006351357791572809,
0.006581832654774189,
0.03528039529919624,
-0.0332593098282814,
-0.03201828896999359,
0.06364654749631882,
-0.028135672211647034,
-0.007871606387197971,
-0.04116637259721756,
0.02981991320848465,
0.03074181266129017,
-0.05846972391009331,
-0.0695679783821106,
0.009307642467319965,
0.02258654497563839,
0.03597182035446167,
0.032390594482421875,
0.04386115446686745,
-0.011568069458007812,
0.005770738236606121,
-0.03896799683570862,
-0.016744891181588173,
-0.018828030675649643,
-0.022923393175005913,
0.009635626338422298,
-0.02042362652719021,
-0.009094895794987679,
0.06265372782945633,
0.029234861955046654,
0.0038360783364623785,
-0.009529252536594868,
-0.0781487375497818,
-0.0329933762550354,
0.059285249561071396,
-0.045775871723890305,
-0.05768965184688568,
-0.08126901090145111,
0.027320146560668945,
-0.01332322508096695,
-0.00033767905551940203,
-0.020086778327822685,
-0.008509844541549683,
0.01957264170050621,
0.04907343536615372,
-0.0012709364527836442,
-0.023933937773108482,
0.020210880786180496,
0.04598861560225487,
0.013376411981880665,
0.007539190351963043,
0.0027302417438477278,
0.009520388208329678,
-0.04854157194495201,
-0.045846786350011826,
0.012427918612957,
-0.040705423802137375,
-0.04201735556125641,
0.026043670251965523,
0.005429457873106003,
0.03375571593642235,
-0.019058505073189735
]
|
30,600 | networkx.drawing.nx_pylab | draw_spectral | Draw the graph `G` with a spectral 2D layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.spectral_layout(G), **kwargs)
For more information about how node positions are determined, see
`~networkx.drawing.layout.spectral_layout`.
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.spectral_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.spectral_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(5)
>>> nx.draw_spectral(G)
See Also
--------
:func:`~networkx.drawing.layout.spectral_layout`
| def draw_spectral(G, **kwargs):
"""Draw the graph `G` with a spectral 2D layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.spectral_layout(G), **kwargs)
For more information about how node positions are determined, see
`~networkx.drawing.layout.spectral_layout`.
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.spectral_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.spectral_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(5)
>>> nx.draw_spectral(G)
See Also
--------
:func:`~networkx.drawing.layout.spectral_layout`
"""
draw(G, spectral_layout(G), **kwargs)
| (G, **kwargs) | [
0.0410814993083477,
-0.05017785355448723,
0.062084462493658066,
0.019597835838794708,
-0.02011551335453987,
-0.0011561105493456125,
-0.06441401690244675,
-0.021890413016080856,
0.05594627559185028,
-0.0035937069915235043,
-0.007141192443668842,
-0.01773049496114254,
0.044557344168424606,
0.0414142943918705,
0.0014293940039351583,
0.044557344168424606,
0.012683128006756306,
-0.0452229306101799,
-0.02850930392742157,
-0.03753170371055603,
0.027732785791158676,
0.0027085687033832073,
-0.0016293012304231524,
0.04215383529663086,
-0.03168933093547821,
0.026475567370653152,
-0.026586497202515602,
0.005421759560704231,
-0.050510648638010025,
0.010251886211335659,
0.05017785355448723,
-0.08186718821525574,
-0.01197131909430027,
0.0017540986882522702,
0.014864773489534855,
0.0618995800614357,
-0.011989807710051537,
0.04821807146072388,
-0.060272589325904846,
-0.002558349631726742,
0.024719156324863434,
0.03675518557429314,
0.061603762209415436,
0.016658160835504532,
0.0066142696887254715,
0.039306603372097015,
-0.011065381579101086,
0.03231794014573097,
-0.07883507013320923,
0.0009874027455225587,
-0.004559732042253017,
0.015040414407849312,
-0.0860825702548027,
-0.016038794070482254,
0.014263896271586418,
-0.03366760164499283,
-0.002317998791113496,
0.0266974288970232,
0.08046205341815948,
-0.05139809846878052,
-0.00811184011399746,
-0.03982428088784218,
-0.0020684036426246166,
0.007265990134328604,
-0.03510970622301102,
-0.017286770045757294,
-0.026623474434018135,
0.01675984635949135,
0.02536625601351261,
0.007173547521233559,
0.006221388466656208,
0.05376462638378143,
-0.019782720133662224,
-0.005759175401180983,
0.008648007176816463,
-0.018091021105647087,
0.06193655729293823,
0.011832655407488346,
-0.015068147331476212,
-0.020411331206560135,
0.017240548506379128,
0.005583534482866526,
-0.03292806074023247,
0.04041591286659241,
-0.021261801943182945,
0.031097697094082832,
-0.005088966339826584,
-0.000954470073338598,
-0.011379686184227467,
-0.036718208342790604,
0.013459645211696625,
0.008236637338995934,
0.03908473998308182,
0.013903370127081871,
-0.05594627559185028,
-0.02961861528456211,
-0.057684194296598434,
-0.02346193790435791,
0.04389175772666931,
-0.00850934349000454,
-0.059274207800626755,
-0.033316321671009064,
-0.016639672219753265,
0.010908229276537895,
0.011851144023239613,
0.005153676029294729,
-0.02749243564903736,
0.015474895015358925,
0.005786907859146595,
0.08149741590023041,
0.0330759696662426,
0.031042231246829033,
0.013894125819206238,
-0.0579800121486187,
-0.0043147592805325985,
0.043669894337654114,
-0.005897839087992907,
0.006863864604383707,
-0.008148817345499992,
-0.05117623507976532,
-0.05206368491053581,
0.040157075971364975,
0.003773970063775778,
0.03555343300104141,
0.03429621085524559,
-0.01571524515748024,
-0.0017691206885501742,
0.006757555529475212,
0.03191119432449341,
0.02717813104391098,
-0.006535693071782589,
0.02309216745197773,
0.04352198541164398,
0.014430292882025242,
0.019283531233668327,
0.049919016659259796,
0.014670643955469131,
-0.019838185980916023,
-0.015992572531104088,
0.03231794014573097,
-0.02320309728384018,
-0.028047090396285057,
-0.031985145062208176,
0.055872321128845215,
-0.0021828014869242907,
0.060494452714920044,
-0.03207758814096451,
-0.007677359506487846,
0.05165693536400795,
0.054023467004299164,
-0.009715719148516655,
-0.012803303077816963,
0.053320903331041336,
0.018303638324141502,
-0.01181416679173708,
-0.03333481028676033,
-0.00748785212635994,
0.09133330732584,
-0.007954687811434269,
0.02325856313109398,
-0.005426381714642048,
-0.037772055715322495,
0.07265990227460861,
0.005944060627371073,
-0.03483238071203232,
0.06733520328998566,
-0.009040888398885727,
0.030247226357460022,
0.02059621550142765,
-0.04910552129149437,
-0.0013542843516916037,
-0.07284478843212128,
-0.023073678836226463,
-0.07706017047166824,
-0.019653301686048508,
0.01789689064025879,
-0.0024497294798493385,
0.03424074500799179,
-0.03793845325708389,
0.0018037866102531552,
0.0662628710269928,
-0.02499648556113243,
-0.010695611126720905,
0.017480900511145592,
-0.027418481186032295,
0.03205909952521324,
-0.0326877124607563,
-0.07077407091856003,
0.05546557158231735,
-0.009054754860699177,
0.027252085506916046,
0.05801698938012123,
-0.007968554273247719,
-0.012590684927999973,
0.02808406762778759,
-0.04629526287317276,
0.04884668067097664,
-0.04363291710615158,
0.015410184860229492,
0.04618433490395546,
0.033797021955251694,
-0.03993521258234978,
-0.01786915771663189,
0.004467289429157972,
0.013968080282211304,
-0.02691929042339325,
0.029285822063684464,
0.00029206089675426483,
-0.027751274406909943,
0.024811599403619766,
0.018007822334766388,
-0.030672460794448853,
0.07964856177568436,
-0.016306878998875618,
0.020078537985682487,
0.05483696237206459,
-0.07580295205116272,
0.02924884483218193,
-0.022426579147577286,
-0.03801240399479866,
-0.04000916704535484,
-0.011342709884047508,
-0.04093359410762787,
0.012193181551992893,
-0.0069516850635409355,
-0.04093359410762787,
0.02717813104391098,
-0.05779512599110603,
-0.0029327422380447388,
-0.046110380440950394,
0.022112274542450905,
0.02876814268529415,
0.04000916704535484,
0.02904547192156315,
-0.06249121204018593,
-0.045038044452667236,
-0.024811599403619766,
0.021539131179451942,
0.04352198541164398,
0.017961600795388222,
-0.04481618106365204,
0.008777426555752754,
-0.0330759696662426,
-0.00011981429997831583,
0.0004905236419290304,
0.034739937633275986,
-0.0039403666742146015,
0.0019204954151064157,
0.03669971972703934,
-0.005001145880669355,
-0.06315679848194122,
0.0026669695507735014,
0.007959309965372086,
0.020207956433296204,
0.020189467817544937,
0.019875163212418556,
-0.09754545241594315,
0.016944732517004013,
-0.03333481028676033,
-0.01821119710803032,
-0.01980120874941349,
0.05435626208782196,
-0.09015004336833954,
0.04710875824093819,
0.03827124461531639,
-0.02118784934282303,
-0.027104176580905914,
0.018886027857661247,
-0.04422454908490181,
0.013783195056021214,
-0.021520642563700676,
0.06474681198596954,
0.019135622307658195,
-0.009798917919397354,
0.06415517628192902,
0.06681752949953079,
-0.021724015474319458,
0.02606881968677044,
0.07524829357862473,
-0.01295121107250452,
0.016981709748506546,
0.00034897090517915785,
0.007025639060884714,
0.040046144276857376,
0.02113238349556923,
-0.004044364672154188,
0.023184608668088913,
-0.007751313969492912,
-0.014818551950156689,
-0.0266419630497694,
0.1033138707280159,
0.002835677471011877,
0.04093359410762787,
0.07839134335517883,
-0.008370678871870041,
0.04622131213545799,
-0.009355193004012108,
-0.028305931016802788,
-0.030616996809840202,
-0.02102145180106163,
0.06286098062992096,
-0.004372535739094019,
0.07935274392366409,
0.053062062710523605,
0.05302508547902107,
-0.0060041481629014015,
0.0020106269512325525,
-0.04267151281237602,
0.01374621782451868,
0.022056808695197105,
-0.1194358691573143,
0.010344329290091991,
0.008389167487621307,
0.05553952604532242,
-0.04710875824093819,
-0.02431240864098072,
-0.013478133827447891,
-0.024330897256731987,
0.0028680323157459497,
0.028490815311670303,
0.033944930881261826,
0.010963695123791695,
-0.024386363103985786,
-0.0019343618769198656,
0.003965788520872593,
0.03143049031496048,
0.004991901572793722,
0.07092197984457016,
0.008587919175624847,
0.030395133420825005,
-0.06522751599550247,
-0.020633192732930183,
-0.02850930392742157,
0.024386363103985786,
-0.033038992434740067,
-0.012165448628365993,
0.0008082951535470784,
-0.05187879875302315,
0.018091021105647087,
-0.0054910918697714806,
0.007705092430114746,
-0.03812333568930626,
-0.004954924341291189,
-0.009521589614450932,
0.043928734958171844,
0.022001342847943306,
0.029711058363318443,
-0.06005072593688965,
-0.024589737877249718,
0.02209378592669964,
0.037716589868068695,
0.039195671677589417,
-0.02712266519665718,
0.02192739024758339,
-0.036810651421546936,
0.0950310155749321,
-0.032299451529979706,
-0.0005945215816609561,
-0.054763007909059525,
-0.0016200569225475192,
-0.036329951137304306,
0.10183478891849518,
-0.009040888398885727,
-0.009512345306575298,
0.025199858471751213,
0.024959508329629898,
-0.05302508547902107,
0.009826650843024254,
0.0005517668905667961,
-0.05165693536400795,
-0.021058429032564163,
-0.05357974395155907,
-0.0784652978181839,
0.054023467004299164,
0.024330897256731987,
0.0491424985229969,
0.016038794070482254,
-0.017822938039898872,
0.028231976553797722,
-0.0062398770824074745,
-0.03651483356952667,
-0.02377624250948429,
0.0533948577940464,
0.010011536069214344,
0.058682575821876526,
0.010094733908772469,
-0.011296488344669342,
0.026900801807641983,
-0.06840754300355911,
-0.025514163076877594,
-0.06752008944749832,
-0.007848378270864487,
0.032410383224487305,
0.03645937144756317,
-0.04341105371713638,
-0.028916051611304283,
0.014864773489534855,
0.06981267035007477,
-0.04274546727538109,
-0.0065772924572229385,
-0.030912812799215317,
-0.05894141644239426,
-0.06777893006801605,
0.004568976350128651,
0.015049658715724945,
-0.02017097920179367,
-0.007330699823796749,
0.008846758864820004,
0.039047762751579285,
-0.0133209815248847,
0.041118476539850235,
-0.008943823166191578,
-0.049771107733249664,
0.0009625587845221162,
0.07750388979911804,
-0.026937779039144516,
-0.0266974288970232,
0.07742994278669357,
0.035387035459280014,
0.047071781009435654,
0.014088255353271961,
-0.008957689628005028,
0.06685450673103333,
0.04252360388636589,
0.11100509762763977,
0.008569430559873581,
-0.017120372503995895,
-0.011499862186610699,
-0.021002963185310364,
0.06470983475446701,
-0.028379885479807854,
0.007677359506487846,
-0.028860585764050484,
0.0627870261669159,
0.011342709884047508,
-0.03253980353474617,
0.033575158566236496,
-0.02113238349556923,
-0.0326877124607563,
-0.004321692511439323,
0.07166151702404022,
-0.007760557811707258,
-0.04895761236548424,
-0.05968095734715462,
-0.011878876946866512,
-0.019653301686048508,
0.027141153812408447,
0.004587464965879917,
0.056944653391838074,
0.008310591802001,
0.03804938122630119,
-0.0066142696887254715,
0.04622131213545799,
0.0036306839901953936,
-0.07994437962770462,
-0.049660176038742065,
0.05690767616033554,
-0.008550942875444889,
-0.04267151281237602,
-0.02372077666223049,
0.01157381571829319,
-0.01215620432049036,
-0.061123061925172806,
-0.041747085750103,
0.03982428088784218,
0.03594169020652771,
0.028324419632554054,
0.02079959027469158,
-0.012775570154190063,
0.00708572706207633,
0.03525761514902115,
0.05309903994202614,
-0.0500299446284771,
-0.03316841274499893,
0.07328850775957108,
-0.0033418007660657167,
-0.0621214397251606,
0.0008810937288217247,
-0.0655972808599472,
-0.01555809285491705,
-0.02617974951863289,
0.02022644504904747,
-0.04000916704535484,
-0.013413424603641033,
0.01792462356388569,
0.029100937768816948,
0.011712480336427689,
0.04821807146072388,
0.01205451786518097,
-0.0246267132461071,
0.04411361739039421,
-0.0004890792188234627,
-0.013468889519572258,
-0.0287126787006855,
-0.002565282629802823,
0.05106530338525772,
-0.007779046427458525,
-0.013126851990818977,
-0.0014317050809040666,
0.02743696980178356,
-0.009761940687894821,
-0.05557650327682495,
0.05128716677427292,
-0.006022636778652668,
-0.02547718584537506,
0.014042033813893795,
-0.03403737396001816,
0.04744155332446098,
0.019727256149053574,
0.031190140172839165,
0.0053246947936713696,
0.07905692607164383,
0.017148105427622795,
0.005352427717298269,
0.022426579147577286,
0.015021925792098045,
-0.021483665332198143,
0.010353573597967625,
0.037032514810562134,
-0.03128258138895035,
-0.013949591666460037,
0.0032886462286114693,
0.008051752112805843,
0.005671354942023754,
0.004261604975908995,
0.00627685384824872,
-0.023554379120469093,
-0.00812570657581091,
0.021095406264066696,
-0.012775570154190063,
0.012692371383309364,
0.08401185274124146,
-0.01752712018787861,
0.04729364439845085,
0.05365369841456413,
-0.05413439869880676,
0.006147434469312429,
0.023702288046479225,
0.010261130519211292,
-0.02079959027469158,
-0.00746936397626996,
0.007344566285610199,
-0.01586315408349037,
-0.009299728088080883,
-0.007802157197147608,
0.007201279979199171,
0.019283531233668327,
-0.060124680399894714,
0.020152490586042404,
-0.06925801187753677,
0.0014860151568427682,
-0.023073678836226463,
-0.02351740188896656,
-0.01722205989062786,
0.017536364495754242,
0.02564358338713646,
-0.025865444913506508,
0.04048986732959747,
-0.03435167670249939,
-0.008934578858315945,
-0.05036273971199989,
0.01821119710803032,
0.005038122646510601,
-0.04906854405999184,
0.05816489830613136,
-0.04873574897646904,
0.023498913273215294,
-0.02181645855307579,
-0.002445107325911522,
-0.04699782654643059,
0.005648244172334671,
0.03849310800433159,
0.024330897256731987,
0.029322799295186996,
-0.00858329702168703,
0.06104910746216774,
0.058793507516384125,
0.014051278121769428,
-0.0002159401774406433,
-0.02941524237394333,
-0.007053371984511614,
-0.005615889094769955,
0.013552088290452957,
0.034203771501779556,
0.004363291896879673,
-0.005648244172334671,
0.0018268972635269165,
-0.03742077201604843,
-0.05894141644239426,
-0.04603642597794533,
0.010039268992841244,
-0.029692569747567177,
0.05032576248049736,
-0.03971334919333458,
-0.018969226628541946,
0.00473768450319767,
-0.03418528288602829,
0.00923501793295145,
0.009937581606209278,
0.051250189542770386,
-0.09140726178884506,
0.04422454908490181,
0.023443449288606644,
-0.011564571410417557,
-0.028416860848665237,
-0.014097499661147594,
0.034000396728515625,
0.008805159479379654,
-0.02124331332743168,
-0.05509580299258232,
-0.041488248854875565,
0.08467744290828705,
0.01926504261791706,
-0.024885553866624832,
0.022519022226333618,
-0.05032576248049736,
-0.016279146075248718,
0.012230158783495426,
0.03237340599298477,
0.02553265169262886,
-0.00866649579256773,
0.017120372503995895,
-0.04000916704535484,
-0.04078568518161774,
-0.055613480508327484,
0.09532683342695236,
-0.04662805795669556,
-0.043078262358903885,
-0.010862007737159729,
-0.0327986404299736,
-0.019135622307658195,
-0.04226476699113846,
-0.03647785633802414,
-0.011250266805291176,
0.028638724237680435,
-0.11566420644521713,
-0.040157075971364975,
-0.014864773489534855,
-0.02091052010655403,
0.04710875824093819,
-0.007261367980390787,
0.034481097012758255,
-0.024330897256731987,
-0.04378082603216171,
0.005403271410614252,
0.03444411978125572,
-0.01798933371901512,
-0.008814403787255287,
0.003059850772842765,
0.01736072450876236,
-0.0409705713391304,
-0.012775570154190063,
-0.007848378270864487,
-0.01316382922232151,
0.05912629887461662,
0.07561806589365005,
0.005597400479018688,
-0.043817803263664246,
0.06315679848194122,
-0.0082551259547472,
0.02218622900545597,
-0.006281476002186537,
0.04725666716694832,
0.0038895232137292624,
-0.042708490043878555,
-0.00295354169793427,
-0.0075248293578624725,
-0.06304586678743362,
0.018645675852894783,
-0.10834275186061859,
-0.017240548506379128,
-0.035220637917518616,
0.0043147592805325985,
0.02266693115234375,
-0.0860825702548027,
0.005703709553927183,
-0.01260917354375124,
-0.027806740254163742,
0.02394263818860054,
-0.05102832615375519,
-0.008671117946505547,
-0.021483665332198143,
0.012331845238804817,
-0.05309903994202614,
-0.005259985104203224,
0.03148595616221428,
0.009285861626267433,
-0.02998838573694229,
0.004058231133967638,
-0.0015645913081243634,
0.014448781497776508,
-0.06337866187095642,
0.0019921385683119297,
-0.016269901767373085,
0.03886287659406662,
-0.03886287659406662,
0.025125904008746147,
0.008550942875444889,
0.009359815157949924,
-0.017120372503995895,
0.014337850734591484,
0.02113238349556923,
0.009258128702640533,
0.05664883926510811,
-0.04370687156915665,
-0.010344329290091991,
-0.04788527637720108,
-0.004760794807225466,
0.0034388655330985785,
0.019653301686048508,
-0.0573144257068634,
-0.02499648556113243,
0.05047367140650749,
-0.02170552685856819,
0.010658633895218372,
-0.06019863486289978,
-0.0163993202149868,
-0.020263422280550003,
-0.030062340199947357,
-0.01263690646737814,
-0.0075618065893650055,
0.021206337958574295,
-0.015410184860229492,
0.0035636629909276962,
0.003427310148254037,
-0.007205902133136988,
0.022759372368454933,
0.0133487144485116,
0.04333709925413132,
-0.03971334919333458,
-0.0014028167352080345,
-0.0092488843947649,
-0.03525761514902115,
0.05043669417500496,
-0.009415281005203724,
0.058201875537633896,
-0.06382238864898682,
-0.034536562860012054,
-0.008079485036432743,
-0.002877276623621583,
-0.03841915354132652,
0.05287718027830124,
-0.033316321671009064,
-0.01165701448917389,
-0.06082724407315254,
0.01937597244977951,
-0.003485086839646101,
0.017314502969384193,
0.03032117895781994,
-0.01969027891755104,
0.05084343999624252,
-0.009863628074526787,
0.005417137406766415,
0.022592976689338684,
-0.004797772038727999,
0.015604314394295216,
0.016279146075248718,
-0.05657488480210304,
0.023498913273215294,
-0.0331314355134964,
-0.024811599403619766,
-0.02346193790435791,
0.04322617128491402,
0.000968914246186614,
-0.004363291896879673,
0.05261833965778351,
-0.009956070221960545,
0.00866649579256773
]
|
30,601 | networkx.drawing.nx_pylab | draw_spring | Draw the graph `G` with a spring layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.spring_layout(G), **kwargs)
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
`~networkx.drawing.layout.spring_layout` is also the default layout for
`draw`, so this function is equivalent to `draw`.
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.spring_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.spring_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(20)
>>> nx.draw_spring(G)
See Also
--------
draw
:func:`~networkx.drawing.layout.spring_layout`
| def draw_spring(G, **kwargs):
"""Draw the graph `G` with a spring layout.
This is a convenience function equivalent to::
nx.draw(G, pos=nx.spring_layout(G), **kwargs)
Parameters
----------
G : graph
A networkx graph
kwargs : optional keywords
See `draw_networkx` for a description of optional keywords.
Notes
-----
`~networkx.drawing.layout.spring_layout` is also the default layout for
`draw`, so this function is equivalent to `draw`.
The layout is computed each time this function is called.
For repeated drawing it is much more efficient to call
`~networkx.drawing.layout.spring_layout` directly and reuse the result::
>>> G = nx.complete_graph(5)
>>> pos = nx.spring_layout(G)
>>> nx.draw(G, pos=pos) # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
--------
>>> G = nx.path_graph(20)
>>> nx.draw_spring(G)
See Also
--------
draw
:func:`~networkx.drawing.layout.spring_layout`
"""
draw(G, spring_layout(G), **kwargs)
| (G, **kwargs) | [
0.0735677182674408,
0.003343377262353897,
0.027194291353225708,
0.0067046452313661575,
0.012559468857944012,
0.02238161861896515,
-0.0558556467294693,
0.003938252571970224,
0.0845169946551323,
-0.011378664523363113,
0.0040411255322396755,
-0.01052884291857481,
0.03511999547481537,
0.0352989062666893,
-0.005259948782622814,
0.035263124853372574,
-0.004866347182542086,
-0.02504737488925457,
-0.005295730661600828,
-0.03447592258453369,
0.06691227108240128,
0.0004106539417989552,
0.044298071414232254,
-0.014563258737325668,
-0.026335524395108223,
-0.05052413418889046,
-0.006543626543134451,
0.03223954886198044,
-0.02676490880548954,
-0.000305544410366565,
0.049736928194761276,
-0.04623029753565788,
-0.029895830899477005,
-0.04605138674378395,
0.03749949857592583,
0.03336668014526367,
-0.005555149633437395,
0.020860884338617325,
-0.054495930671691895,
-0.060256827622652054,
0.0002747942926362157,
0.018874986097216606,
0.009580620564520359,
0.009875821880996227,
-0.00033349907607771456,
0.009222800843417645,
0.0010896725580096245,
0.0386803038418293,
-0.05331512540578842,
0.033169880509376526,
-0.011324991472065449,
0.004638236947357655,
-0.05420967563986778,
-0.057608962059020996,
0.0026724652852863073,
-0.018114618957042694,
0.009813203476369381,
-0.0016761613078415394,
0.056929104030132294,
-0.03946750611066818,
0.04365399479866028,
-0.02964535728096962,
0.005939805880188942,
0.02349085919559002,
0.007746795192360878,
0.02914441004395485,
-0.012613141909241676,
-0.009509056806564331,
0.033223554491996765,
0.0005493090720847249,
-0.006847773212939501,
0.05456749349832535,
-0.027194291353225708,
0.020252590999007225,
0.011083463206887245,
0.009813203476369381,
0.03091561608016491,
0.01388340163975954,
0.03728480637073517,
-0.042687881737947464,
0.02597770467400551,
-0.048126742243766785,
-0.006190279498696327,
0.005228639580309391,
0.049844276160001755,
0.06007791683077812,
-0.00989371258765459,
0.055605169385671616,
-0.019626406952738762,
-0.03717745840549469,
0.022632092237472534,
0.08716486394405365,
0.0430099219083786,
-0.049128636717796326,
-0.009705857373774052,
-0.017828363925218582,
-0.03220376744866371,
-0.01889287680387497,
0.04351086914539337,
0.05013053119182587,
0.001493896939791739,
0.020628301426768303,
-0.07066937536001205,
-0.05299308896064758,
-0.006127661094069481,
-0.04050518199801445,
-0.029412774369120598,
0.026890145614743233,
-0.031183980405330658,
0.026693344116210938,
0.08022316545248032,
0.0003449604846537113,
0.051168207079172134,
-0.044083379209041595,
-0.00551489507779479,
0.06988217681646347,
0.0028290115296840668,
0.024671664461493492,
0.014160712249577045,
-0.024617990478873253,
-0.049844276160001755,
0.015269952826201916,
0.003075012471526861,
-0.02222059853374958,
0.02597770467400551,
-0.02748054824769497,
-0.05113242566585541,
0.030128413811326027,
0.07199331372976303,
-0.027247965335845947,
0.027838367968797684,
-0.0261029414832592,
0.029001280665397644,
-0.008028578013181686,
0.03479795902967453,
-0.017372142523527145,
-0.0340823195874691,
-0.004669546149671078,
0.0015934155089780688,
0.03091561608016491,
-0.02359820529818535,
-0.04054096341133118,
-0.04104191064834595,
0.04780470207333565,
-0.009509056806564331,
0.04655233398079872,
0.006776209454983473,
0.04433385282754898,
0.07342459261417389,
0.042580537497997284,
0.037642624229192734,
-0.0011919866083189845,
0.053064651787281036,
-0.008109087124466896,
-0.08795206248760223,
-0.006691227201372385,
-0.04172176867723465,
0.046194516122341156,
0.002386209787800908,
0.02554832212626934,
-0.0423300638794899,
-0.040040016174316406,
0.07728903740644455,
0.03311620652675629,
0.0130514707416296,
0.06820042431354523,
-0.0057295868173241615,
0.03978954255580902,
0.04243740811944008,
0.012031685560941696,
0.01640602946281433,
-0.05871820077300072,
0.03907390311360359,
-0.1031951829791069,
0.058932892978191376,
0.022972021251916885,
0.0023191184736788273,
0.028554007411003113,
-0.052170101553201675,
0.019465388730168343,
0.030951397493481636,
-0.04104191064834595,
0.04959380254149437,
-0.03036099672317505,
-0.046516552567481995,
-0.0019467624370008707,
-0.009339092299342155,
-0.036050327122211456,
0.03640814870595932,
-0.01285467017441988,
-0.04383290559053421,
0.028786590322852135,
-0.009580620564520359,
-0.003660942194983363,
0.009160182438790798,
-0.002873738994821906,
0.01820407435297966,
-0.0053583490662276745,
0.022077471017837524,
0.051060862839221954,
0.03878764808177948,
0.013641873374581337,
0.0013474145671352744,
-0.012425286695361137,
0.0009689084836281836,
-0.020646192133426666,
-0.02703327313065529,
0.00409479858353734,
-0.037821535021066666,
-0.031183980405330658,
-0.026442870497703552,
-0.007093774154782295,
0.03878764808177948,
-0.022703655064105988,
0.03334879130125046,
0.04139973223209381,
-0.028392987325787544,
0.017667343840003014,
-0.0027887567412108183,
-0.022238491103053093,
-0.0064854808151721954,
-0.0037548698019236326,
-0.08072411268949509,
-0.03075459785759449,
0.04415494203567505,
-0.0723511278629303,
0.013328781351447105,
-0.10376769304275513,
0.01823090948164463,
-0.062475308775901794,
0.006337880156934261,
-0.007116138003766537,
0.02426017075777054,
0.04168598726391792,
0.06168810650706291,
-0.09646817296743393,
-0.004023234359920025,
0.013087253086268902,
0.003092903411015868,
0.03928859531879425,
-0.06161653995513916,
0.012255322188138962,
-0.04930754378437996,
-0.01857083849608898,
0.03875186666846275,
0.0681646391749382,
0.0017823890084400773,
0.02975270338356495,
0.04333195835351944,
0.03739215061068535,
-0.07907813787460327,
0.01806989125907421,
-0.032615259289741516,
0.009213855490088463,
0.004110453184694052,
0.053064651787281036,
-0.054102327674627304,
0.041757550090551376,
-0.0565355010330677,
0.062475308775901794,
-0.028858153149485588,
-0.034780070185661316,
-0.08866770565509796,
0.030772488564252853,
0.02975270338356495,
0.00417530769482255,
-0.014008638449013233,
-0.012291104532778263,
-0.06032839044928551,
0.014473804272711277,
0.03209641948342323,
0.04952223598957062,
0.04615873098373413,
-0.0015240879729390144,
0.07210065424442291,
0.014312785118818283,
-0.011020844802260399,
0.024582209065556526,
0.045622002333402634,
-0.019197022542357445,
0.01867818459868431,
-0.02587036043405533,
-0.0020328627433627844,
0.046015605330467224,
-0.042186934500932693,
-0.0012624324299395084,
0.06061464548110962,
0.009339092299342155,
-0.010555678978562355,
-0.01934015192091465,
0.048842381685972214,
0.029573792591691017,
0.03728480637073517,
0.06734165549278259,
0.017747852951288223,
0.017926763743162155,
0.0052778394892811775,
0.009938440285623074,
-0.046910155564546585,
-0.001356360036879778,
0.1091349869966507,
-0.015225225128233433,
0.02869713492691517,
0.05048834905028343,
0.08666391670703888,
0.0014458149671554565,
0.004759001079946756,
-0.01743476092815399,
-0.01418754830956459,
0.009714802727103233,
-0.08852458000183105,
-0.02996739372611046,
0.031935401260852814,
0.012872561812400818,
-0.05675019323825836,
-0.020520955324172974,
-0.0380004458129406,
-0.0038219608832150698,
0.004372108727693558,
-0.007863086648285389,
0.035996656864881516,
0.02986004762351513,
-0.004130580462515354,
0.053780291229486465,
-0.04426229000091553,
0.060042135417461395,
-0.0012065230403095484,
0.09124400466680527,
-0.026013487949967384,
0.05524735152721405,
-0.027892040088772774,
-0.004211090039461851,
-0.03256158530712128,
0.001176332007162273,
-0.05886133015155792,
-0.022095361724495888,
0.016334466636180878,
-0.018105672672390938,
0.020359937101602554,
-0.017300579696893692,
0.026943817734718323,
-0.0057743145152926445,
-0.008337197825312614,
-0.0035245234612375498,
0.08752268552780151,
0.040040016174316406,
0.020467283204197884,
-0.02316882088780403,
-0.030021067708730698,
0.04687437042593956,
0.01196906715631485,
0.05810990929603577,
-0.01247001439332962,
-0.019697971642017365,
-0.05170493572950363,
0.059040240943431854,
0.01204957626760006,
-0.005371767096221447,
-0.03707011416554451,
-0.005953224375844002,
-0.021594414487481117,
0.053386688232421875,
0.004401181358844042,
0.022363727912306786,
0.008457961492240429,
0.06644710898399353,
-0.07041890174150467,
-0.00013900453632231802,
0.02715850993990898,
-0.026639671996235847,
-0.0046829646453261375,
-0.05757318064570427,
-0.07152814418077469,
0.015708282589912415,
-0.02238161861896515,
0.07685966044664383,
-0.030522014945745468,
-0.02996739372611046,
0.057537395507097244,
0.004211090039461851,
-0.039932671934366226,
-0.07320989668369293,
0.043797124177217484,
-0.0022464364301413298,
0.06061464548110962,
0.015609881840646267,
0.023133039474487305,
-0.035817746073007584,
0.001323932665400207,
-0.04376134276390076,
-0.08945491164922714,
0.015010533854365349,
0.023580314591526985,
-0.011799102649092674,
-0.054674841463565826,
-0.0688444972038269,
0.06229639798402786,
0.07628714293241501,
-0.006038206163793802,
-0.0319175124168396,
-0.0013462963979691267,
-0.01524311676621437,
-0.011047680862247944,
0.0035222871229052544,
-0.004937910940498114,
-0.05596299096941948,
0.012935180217027664,
0.0007704303716309369,
0.040040016174316406,
0.055497825145721436,
0.03950328752398491,
-0.001271377899684012,
-0.05900445953011513,
-0.0008783353841863573,
0.0934624895453453,
-0.03968219831585884,
-0.0435466505587101,
0.04966536536812782,
0.008730798959732056,
-0.011906448751688004,
-0.011262373067438602,
0.037320587784051895,
0.07414022833108902,
0.03075459785759449,
0.039252813905477524,
0.001533033442683518,
-0.04122082144021988,
-0.024564318358898163,
-0.02078932151198387,
0.04744688421487808,
-0.018427710980176926,
0.009374874643981457,
-0.009544839151203632,
0.06716274470090866,
0.007782577071338892,
-0.07177861779928207,
0.05997057259082794,
-0.05123976990580559,
-0.004358690232038498,
-0.004620346240699291,
0.03646181896328926,
-0.015216279774904251,
0.026067160069942474,
-0.0028826843481510878,
-0.009178074076771736,
0.012622087262570858,
-0.003788415342569351,
-0.03483374044299126,
-0.000896785466466099,
-0.001969126285985112,
0.0002500544360373169,
0.01410703919827938,
0.023866569623351097,
0.024188607931137085,
-0.06229639798402786,
-0.05900445953011513,
-0.03572829067707062,
-0.022542636841535568,
-0.07829093933105469,
0.00175890710670501,
-0.00469638267531991,
-0.040648311376571655,
-0.03535258024930954,
0.03968219831585884,
0.0064049712382256985,
-0.008520579896867275,
0.01498369686305523,
0.018857095390558243,
-0.044584326446056366,
-0.00745159387588501,
0.0202168095856905,
-0.003019103081896901,
-0.050345223397016525,
-0.07159970700740814,
0.016164502128958702,
0.0028088840190321207,
-0.028106732293963432,
-0.023580314591526985,
-0.004307253751903772,
0.0273195281624794,
-0.06623241305351257,
0.02404547855257988,
-0.046623896807432175,
0.05109664425253868,
-0.024403298273682594,
0.021594414487481117,
0.009732694365084171,
0.019036004319787025,
0.04880659654736519,
-0.01451853197067976,
0.02499370090663433,
-0.00012956984573975205,
-0.012103249318897724,
-0.007827304303646088,
-0.013400345109403133,
0.01257736049592495,
-0.05678597465157509,
-0.029734810814261436,
-0.002569592325016856,
-0.018535057082772255,
-0.0313807837665081,
0.00928541924804449,
0.05370872840285301,
0.05492531508207321,
-0.02980637550354004,
-0.027856258675456047,
-0.01174542959779501,
0.0527426153421402,
0.04343930259346962,
0.009043890982866287,
0.044298071414232254,
0.021039795130491257,
0.006910391617566347,
0.04225849732756615,
-0.00316446740180254,
-0.0006049388321116567,
-0.016629667952656746,
0.03932437673211098,
0.02018102817237377,
-0.041363950818777084,
0.01019785925745964,
-0.02388446033000946,
0.020091572776436806,
-0.0028088840190321207,
-0.04680280759930611,
0.05424545705318451,
0.099545419216156,
-0.030396778136491776,
0.010171023197472095,
0.0018271164735779166,
-0.005939805880188942,
0.0417933315038681,
-0.01781047321856022,
0.009034945629537106,
0.0057743145152926445,
0.007845195941627026,
0.003962852526456118,
-0.05968431383371353,
-0.018463492393493652,
-0.013946020044386387,
0.006167916115373373,
0.011655974201858044,
-0.006789627484977245,
0.02808884158730507,
-0.009813203476369381,
-0.00602478813380003,
0.024743227288126945,
-0.07671652734279633,
-0.01912545971572399,
-0.05861085653305054,
-0.023186711594462395,
-0.012953070923686028,
-0.040040016174316406,
-0.0018304710974916816,
0.06133028492331505,
0.009902657940983772,
-0.06387080252170563,
0.05299308896064758,
-0.007277156691998243,
0.02655021660029888,
-0.05392342060804367,
0.0067135910503566265,
0.03835826367139816,
-0.06107981130480766,
0.04887816309928894,
-0.03871608525514603,
-0.005179439205676317,
-0.053780291229486465,
0.02016313560307026,
0.02687225490808487,
0.055497825145721436,
0.032668933272361755,
0.04129238426685333,
0.010063677094876766,
0.001161795575171709,
0.03878764808177948,
0.05242057517170906,
0.04215115308761597,
0.012827834114432335,
-0.015940865501761436,
-0.017184287309646606,
-0.008627925999462605,
-0.006069515366107225,
0.03163125738501549,
-0.009518002159893513,
0.029573792591691017,
-0.05331512540578842,
-0.003343377262353897,
-0.015422026626765728,
-0.03270471468567848,
0.002690356457605958,
0.00703562842682004,
0.0845169946551323,
-0.0053583490662276745,
-0.0159587562084198,
0.0012814415385946631,
0.017980435863137245,
-0.010645134374499321,
-0.009455383755266666,
-0.01566355489194393,
-0.054889533668756485,
0.0785771906375885,
0.017828363925218582,
0.01706799678504467,
-0.010099459439516068,
-0.013704491779208183,
0.021701760590076447,
0.014965806156396866,
-0.023311948403716087,
-0.04193646088242531,
-0.028285641223192215,
0.029573792591691017,
-0.0076439217664301395,
-0.02520839311182499,
-0.04633764177560806,
-0.025798795744776726,
-0.00916912779211998,
0.010206804610788822,
-0.005237584933638573,
-0.018463492393493652,
0.027605785056948662,
-0.024456972256302834,
-0.06061464548110962,
-0.05471062287688255,
0.0054656947031617165,
0.05299308896064758,
-0.05202697589993477,
-0.059147585183382034,
-0.02200590819120407,
-0.0015766427386552095,
-0.0014737696619704366,
-0.012568414211273193,
-0.01202273927628994,
-0.025691449642181396,
0.02222059853374958,
-0.04547887668013573,
-0.03835826367139816,
0.0008895172504708171,
-0.02581668645143509,
-0.006114243064075708,
0.017050106078386307,
0.005340457893908024,
-0.033169880509376526,
-0.010788261890411377,
-0.026621781289577484,
-0.01851716637611389,
0.009339092299342155,
0.019626406952738762,
0.024134933948516846,
0.03767840936779976,
-0.012792051769793034,
-0.026228178292512894,
0.027069054543972015,
0.009294364601373672,
0.03331300616264343,
0.047124844044446945,
0.01174542959779501,
-0.04937911033630371,
0.034046538174152374,
-0.03474428504705429,
0.014590095728635788,
0.0011808048002421856,
-0.042866792529821396,
0.038322482258081436,
-0.058324601501226425,
-0.001225532265380025,
-0.0028200659435242414,
-0.043367739766836166,
0.02621028758585453,
-0.048627689480781555,
0.0037481607869267464,
-0.025745123624801636,
0.030629361048340797,
-0.02715850993990898,
-0.0417933315038681,
-0.09925916790962219,
0.022023798897862434,
0.014277003705501556,
0.03789309784770012,
-0.01672806777060032,
0.007174283731728792,
-0.0772174745798111,
0.006700172554701567,
-0.03147023543715477,
-0.010153132490813732,
0.05946962162852287,
-0.0028088840190321207,
-0.040755655616521835,
0.0006440753350034356,
0.05038100481033325,
0.04050518199801445,
-0.02504737488925457,
0.0091959647834301,
0.0007072528824210167,
0.016915922984480858,
-0.06404971331357956,
-0.007715485990047455,
-0.013257217593491077,
-0.0006558162858709693,
-0.06254687160253525,
0.0013317599659785628,
0.0160929374396801,
0.013239326886832714,
0.03025365062057972,
-0.03971797972917557,
-0.03535258024930954,
-0.06133028492331505,
0.013436127454042435,
-0.023956025019288063,
0.051168207079172134,
-0.011369719170033932,
-0.008337197825312614,
0.08143974840641022,
-0.0032628676854074,
-0.0017890981398522854,
-0.04100612923502922,
-0.008381924591958523,
-0.014509586617350578,
-0.07170705497264862,
-0.04587247595191002,
-0.037213243544101715,
0.02171965129673481,
-0.057322707027196884,
-0.03689120337367058,
0.000006486354322987609,
-0.02061041072010994,
-0.0006720300298184156,
-0.02089666575193405,
-0.002598665188997984,
-0.015896137803792953,
0.009339092299342155,
0.0589686743915081,
-0.015681445598602295,
0.023419294506311417,
0.02166597917675972,
0.012890452519059181,
-0.05614190176129341,
-0.0026210288051515818,
-0.057716306298971176,
-0.027856258675456047,
-0.005443331319838762,
-0.011888557113707066,
-0.021093467250466347,
-0.013722383417189121,
-0.001839416567236185,
-0.006946173496544361,
-0.010153132490813732,
0.019715862348675728,
-0.029287537559866905,
0.03889499604701996,
0.041149258613586426,
0.0064139170572161674,
-0.02903706394135952,
0.000031256804504664615,
0.015520426444709301,
-0.006351298652589321,
-0.022471072152256966,
-0.03674807772040367,
0.013480855152010918,
-0.04952223598957062,
-0.04673124477267265,
-0.046194516122341156,
0.02304358407855034,
-0.020681975409388542,
0.06820042431354523,
0.03839404508471489,
0.03567461669445038,
0.03749949857592583
]
|
30,603 | networkx.generators.random_graphs | dual_barabasi_albert_graph | Returns a random graph using dual Barabási–Albert preferential attachment
A graph of $n$ nodes is grown by attaching new nodes each with either $m_1$
edges (with probability $p$) or $m_2$ edges (with probability $1-p$) that
are preferentially attached to existing nodes with high degree.
Parameters
----------
n : int
Number of nodes
m1 : int
Number of edges to link each new node to existing nodes with probability $p$
m2 : int
Number of edges to link each new node to existing nodes with probability $1-p$
p : float
The probability of attaching $m_1$ edges (as opposed to $m_2$ edges)
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
initial_graph : Graph or None (default)
Initial network for Barabási–Albert algorithm.
A copy of `initial_graph` is used.
It should be connected for most use cases.
If None, starts from an star graph on max(m1, m2) + 1 nodes.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m1` and `m2` do not satisfy ``1 <= m1,m2 < n``, or
`p` does not satisfy ``0 <= p <= 1``, or
the initial graph number of nodes m0 does not satisfy m1, m2 <= m0 <= n.
References
----------
.. [1] N. Moshiri "The dual-Barabasi-Albert model", arXiv:1810.10538.
| def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None):
"""Returns a random graph using dual Barabási–Albert preferential attachment
A graph of $n$ nodes is grown by attaching new nodes each with either $m_1$
edges (with probability $p$) or $m_2$ edges (with probability $1-p$) that
are preferentially attached to existing nodes with high degree.
Parameters
----------
n : int
Number of nodes
m1 : int
Number of edges to link each new node to existing nodes with probability $p$
m2 : int
Number of edges to link each new node to existing nodes with probability $1-p$
p : float
The probability of attaching $m_1$ edges (as opposed to $m_2$ edges)
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
initial_graph : Graph or None (default)
Initial network for Barabási–Albert algorithm.
A copy of `initial_graph` is used.
It should be connected for most use cases.
If None, starts from an star graph on max(m1, m2) + 1 nodes.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m1` and `m2` do not satisfy ``1 <= m1,m2 < n``, or
`p` does not satisfy ``0 <= p <= 1``, or
the initial graph number of nodes m0 does not satisfy m1, m2 <= m0 <= n.
References
----------
.. [1] N. Moshiri "The dual-Barabasi-Albert model", arXiv:1810.10538.
"""
if m1 < 1 or m1 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m1 >= 1 and m1 < n, m1 = {m1}, n = {n}"
)
if m2 < 1 or m2 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m2 >= 1 and m2 < n, m2 = {m2}, n = {n}"
)
if p < 0 or p > 1:
raise nx.NetworkXError(
f"Dual Barabási–Albert network must have 0 <= p <= 1, p = {p}"
)
# For simplicity, if p == 0 or 1, just return BA
if p == 1:
return barabasi_albert_graph(n, m1, seed)
elif p == 0:
return barabasi_albert_graph(n, m2, seed)
if initial_graph is None:
# Default initial graph : empty graph on max(m1, m2) nodes
G = star_graph(max(m1, m2))
else:
if len(initial_graph) < max(m1, m2) or len(initial_graph) > n:
raise nx.NetworkXError(
f"Barabási–Albert initial graph must have between "
f"max(m1, m2) = {max(m1, m2)} and n = {n} nodes"
)
G = initial_graph.copy()
# Target nodes for new edges
targets = list(G)
# List of existing nodes, with nodes repeated once for each adjacent edge
repeated_nodes = [n for n, d in G.degree() for _ in range(d)]
# Start adding the remaining nodes.
source = len(G)
while source < n:
# Pick which m to use (m1 or m2)
if seed.random() < p:
m = m1
else:
m = m2
# Now choose m unique nodes from the existing nodes
# Pick uniformly from repeated_nodes (preferential attachment)
targets = _random_subset(repeated_nodes, m, seed)
# Add edges to m nodes from the source.
G.add_edges_from(zip([source] * m, targets))
# Add one node to the list for each new edge just created.
repeated_nodes.extend(targets)
# And the new node "source" has m edges to add to the list.
repeated_nodes.extend([source] * m)
source += 1
return G
| (n, m1, m2, p, seed=None, initial_graph=None, *, backend=None, **backend_kwargs) | [
0.003564037149772048,
0.0015281288651749492,
0.015348353423178196,
0.004924503155052662,
-0.024948259815573692,
-0.04092894122004509,
-0.06484248489141464,
-0.03631102293729782,
0.012090899981558323,
-0.02998773194849491,
0.006490954663604498,
0.04196366295218468,
-0.036828383803367615,
0.10722769796848297,
-0.04307502880692482,
0.013039394281804562,
0.034663137048482895,
0.04740552604198456,
-0.005954433232545853,
0.027305124327540398,
-0.04004751518368721,
0.002028722781687975,
0.00008188543142750859,
0.071012482047081,
-0.03454816713929176,
0.010749596171081066,
-0.03914692625403404,
0.010749596171081066,
-0.0156357754021883,
0.05928565189242363,
0.039281055331230164,
-0.12355329096317291,
0.021020155400037766,
0.03908944129943848,
-0.00014850155275780708,
0.010146008804440498,
0.02768835425376892,
0.06116347759962082,
-0.10960372537374496,
-0.03677089884877205,
0.07089751213788986,
-0.05541503056883812,
0.08339080214500427,
0.0130585553124547,
0.0246799997985363,
-0.023913539946079254,
0.030945805832743645,
0.01299149077385664,
-0.09657391160726547,
-0.00980589259415865,
0.016114812344312668,
-0.07051428407430649,
0.026232080534100533,
-0.0023951863404363394,
-0.02040698751807213,
0.01846209540963173,
-0.0031185324769467115,
0.04460794851183891,
0.01780102401971817,
0.025293167680501938,
0.06300298124551773,
-0.019583042711019516,
-0.014629798009991646,
-0.035218819975852966,
-0.024430900812149048,
0.0219782292842865,
-0.04855521768331528,
-0.026806924492120743,
-0.0014514828799292445,
0.0620449036359787,
0.050318073481321335,
0.0640760213136673,
-0.008086148649454117,
0.0551084466278553,
0.05472521483898163,
0.044301364570856094,
0.04863186180591583,
0.027056023478507996,
-0.052042607218027115,
0.019698012620210648,
0.004191576037555933,
-0.02582968957722187,
0.01184180099517107,
-0.03433739021420479,
0.005441863089799881,
-0.015482484363019466,
0.006055030971765518,
0.0031257180962711573,
0.0002603268076200038,
-0.10186248272657394,
-0.048593539744615555,
-0.04985819756984711,
0.055644966661930084,
0.01627768576145172,
0.03159729763865471,
-0.033245187252759933,
-0.006284968927502632,
-0.03234459459781647,
0.007453819736838341,
-0.02456502988934517,
-0.04506782442331314,
0.04368819668889046,
-0.038112204521894455,
0.000617958081420511,
0.006476583890616894,
0.0072334627620875835,
-0.052157577127218246,
0.015185480937361717,
0.02082853950560093,
-0.035372111946344376,
-0.11711502820253372,
0.0436115525662899,
0.0797884464263916,
0.01822257786989212,
-0.022936303168535233,
-0.013278912752866745,
0.014984285458922386,
0.011602282524108887,
0.031942203640937805,
0.03226795047521591,
0.016344750300049782,
0.02711350843310356,
-0.032938603311777115,
-0.00018562693730928004,
0.0007455017184838653,
-0.024066831916570663,
0.04824863374233246,
-0.008555605076253414,
-0.012914844788610935,
-0.03874453157186508,
0.010538819245994091,
0.014830993488430977,
-0.047022297978401184,
0.07024602591991425,
-0.012033415958285332,
-0.03441403806209564,
-0.04794204980134964,
0.005729285534471273,
0.0691346600651741,
0.003983194939792156,
-0.0008077765814960003,
-0.06683527678251266,
0.08906260877847672,
0.012895682826638222,
-0.03947266936302185,
-0.021499192342162132,
0.017235759645700455,
-0.05710124224424362,
0.0017664498882368207,
-0.012215450406074524,
0.04004751518368721,
-0.001282622222788632,
0.020886024460196495,
-0.03460565209388733,
-0.039549317210912704,
0.01771479845046997,
-0.04150378704071045,
-0.00041376843000762165,
-0.02324288710951805,
0.014639378525316715,
-0.03058173879981041,
-0.05468689277768135,
0.04878515377640724,
0.05430366471409798,
0.010136428289115429,
-0.030754191800951958,
0.04947496950626373,
0.0017975872615352273,
0.017475279048085213,
-0.035525403916835785,
-0.07434657961130142,
-0.0011413062456995249,
-0.06599216908216476,
-0.0616999976336956,
0.05269409716129303,
-0.0021748291328549385,
-0.026021303609013557,
-0.031041614711284637,
0.029317079111933708,
0.03433739021420479,
0.03832298144698143,
-0.047290556132793427,
0.0677933543920517,
-0.0591706819832325,
-0.030639221891760826,
-0.03541043400764465,
-0.0063664051704108715,
0.04296006262302399,
0.01808844693005085,
0.008565186522901058,
0.021365061402320862,
0.024794967845082283,
0.036100246012210846,
0.06089521571993828,
0.02525484375655651,
0.00524066761136055,
0.02513987571001053,
0.014601055532693863,
-0.012934005819261074,
0.011123244650661945,
0.04568099230527878,
0.0022275231312960386,
0.020464470610022545,
0.023185404017567635,
0.027899129316210747,
0.007645434699952602,
-0.032804470509290695,
-0.04196366295218468,
0.023166241124272346,
-0.02726680040359497,
0.004948454909026623,
-0.010433431714773178,
0.028608104214072227,
-0.027075186371803284,
-0.01536751538515091,
-0.06281136721372604,
0.01921897381544113,
0.01715911366045475,
-0.00011743897630367428,
-0.03491223603487015,
0.032095495611429214,
-0.058787450194358826,
0.010931630618870258,
0.02584885060787201,
0.0057484470307827,
0.04376484453678131,
-0.014591475017368793,
0.004045469686388969,
-0.015137577429413795,
0.028953012079000473,
0.03376254439353943,
-0.0007934054592624307,
0.03677089884877205,
-0.028339844197034836,
-0.03918524831533432,
-0.030198508873581886,
0.003037096234038472,
-0.03958763927221298,
-0.035831987857818604,
0.018979456275701523,
-0.0294128879904747,
0.01983214169740677,
-0.020311180502176285,
-0.008981948718428612,
0.02226565219461918,
0.015549548901617527,
0.02828235924243927,
-0.05813596025109291,
-0.06848316639661789,
-0.01983214169740677,
-0.09335478395223618,
-0.012474129907786846,
0.024775806814432144,
0.031501490622758865,
0.026155434548854828,
-0.02644285559654236,
-0.021499192342162132,
0.009734037332236767,
-0.004007146693766117,
0.058634158223867416,
0.007166397292166948,
-0.020349502563476562,
-0.11121328920125961,
0.031654782593250275,
-0.0014658540021628141,
-0.00599754648283124,
-0.0708208680152893,
0.06951788812875748,
-0.013480108231306076,
-0.031348198652267456,
0.06173831969499588,
0.0006676581688225269,
0.008838237263262272,
0.0004712528898380697,
0.02699854038655758,
0.023357857018709183,
-0.012387903407216072,
0.019496817141771317,
-0.019602203741669655,
-0.043573230504989624,
-0.04123552516102791,
-0.04338161274790764,
0.02471832185983658,
0.04541273042559624,
-0.005882577504962683,
0.004208342172205448,
-0.023338695988059044,
-0.0620449036359787,
0.024373415857553482,
-0.033513445407152176,
0.015463322401046753,
-0.028493136167526245,
0.0057723987847566605,
0.050049811601638794,
-0.0017317197052761912,
-0.004864623304456472,
0.05867248401045799,
0.023491986095905304,
0.020177049562335014,
-0.008957996964454651,
0.03799723461270332,
-0.009623858146369457,
0.09120869636535645,
0.003966428339481354,
-0.0166513342410326,
-0.032076336443424225,
0.013604657724499702,
-0.025350650772452354,
-0.019851304590702057,
0.02010040357708931,
-0.09051887691020966,
0.02513987571001053,
0.05756111815571785,
0.0308499988168478,
-0.009432243183255196,
-0.06725683063268661,
0.011592702008783817,
0.000736519752535969,
0.04046906903386116,
-0.003901758464053273,
-0.017331568524241447,
0.03749903663992882,
-0.001322142779827118,
0.04652410000562668,
-0.017590247094631195,
-0.0022430920507758856,
0.04637080803513527,
0.07499807327985764,
0.0013257355894893408,
0.022303974255919456,
-0.04207863286137581,
0.016622593626379967,
-0.010644207708537579,
0.018807003274559975,
-0.08752968907356262,
0.08086148649454117,
-0.027515899389982224,
-0.023300372064113617,
0.06672030687332153,
-0.08599676936864853,
0.021633323282003403,
-0.046715714037418365,
-0.005231086630374193,
-0.01063462719321251,
0.04633248224854469,
0.04407142847776413,
0.012090899981558323,
-0.004047864582389593,
-0.05694795027375221,
0.06924962252378464,
-0.013662142679095268,
0.04188701882958412,
-0.002752068918198347,
0.025733880698680878,
-0.019161490723490715,
0.033532608300447464,
-0.009858586825430393,
0.0044095381163060665,
0.01018433179706335,
0.07028434425592422,
-0.023338695988059044,
-0.005671801045536995,
-0.027803322300314903,
-0.01370046567171812,
0.027630869299173355,
0.0063232919201254845,
0.002373629482463002,
0.043841488659381866,
0.03845711052417755,
-0.05250248312950134,
0.06970950216054916,
-0.06714186072349548,
-0.04510614648461342,
0.04920670762658119,
0.010404689237475395,
-0.028761396184563637,
-0.03772897273302078,
0.020062079653143883,
0.032095495611429214,
0.03301524743437767,
-0.012387903407216072,
-0.03962596133351326,
0.009992716833949089,
0.03958763927221298,
-0.006222693715244532,
-0.012004673480987549,
0.07258372753858566,
0.0037867894861847162,
-0.006581971887499094,
-0.026960216462612152,
0.01283819880336523,
-0.029834439978003502,
0.07327353954315186,
0.006946040317416191,
-0.05495515465736389,
0.005101746879518032,
0.04115888103842735,
-0.026040464639663696,
-0.037115804851055145,
-0.0035352949053049088,
0.0025029696989804506,
0.016948338598012924,
-0.050586335361003876,
-0.02368360199034214,
-0.005686172284185886,
-0.033954162150621414,
0.027879968285560608,
0.02801409922540188,
0.011286118067800999,
0.01492680050432682,
-0.015195061452686787,
0.023012949153780937,
-0.019027359783649445,
-0.011640605516731739,
0.02370276302099228,
-0.001042504794895649,
-0.005901739001274109,
-0.020177049562335014,
0.010902888141572475,
0.015003446489572525,
0.03242124244570732,
-0.0077795651741325855,
0.006490954663604498,
-0.024890774860978127,
0.04410975053906441,
0.005810721777379513,
-0.051046211272478104,
0.01965968869626522,
-0.08155130594968796,
0.02213152125477791,
0.05399708077311516,
-0.03958763927221298,
0.03341763839125633,
-0.04296006262302399,
0.024641675874590874,
0.008546024560928345,
0.028953012079000473,
0.005374798085540533,
0.05675633251667023,
-0.0229937881231308,
0.012110061943531036,
0.022227328270673752,
0.011726832017302513,
-0.05740782618522644,
-0.029642825946211815,
-0.04568099230527878,
-0.021729130297899246,
-0.0012682511005550623,
0.01605732925236225,
-0.02052195556461811,
-0.005695752799510956,
-0.005250248126685619,
0.07108912616968155,
-0.006749635096639395,
-0.047443848103284836,
0.03579366207122803,
0.059783849865198135,
-0.028033260256052017,
-0.03462481126189232,
0.10063614696264267,
0.014811831526458263,
0.006998734083026648,
0.01235916092991829,
0.09580744802951813,
0.03427990525960922,
-0.019209394231438637,
0.054188694804906845,
-0.020042918622493744,
-0.015281288884580135,
0.0380355566740036,
-0.019008198752999306,
0.00020269263768568635,
0.01558787189424038,
-0.03305356949567795,
-0.016823789104819298,
-0.038706209510564804,
-0.009451405145227909,
-0.039702609181404114,
-0.011391505599021912,
-0.011219052597880363,
0.017331568524241447,
0.0040167272090911865,
0.010280139744281769,
0.03217214345932007,
0.022917142137885094,
-0.027803322300314903,
-0.03556372597813606,
0.02540813572704792,
0.012042996473610401,
0.002689794171601534,
-0.07315856963396072,
-0.08001838624477386,
0.022361459210515022,
0.036962512880563736,
-0.051467761397361755,
-0.012579518370330334,
-0.01715911366045475,
-0.048018693923950195,
-0.007540046237409115,
-0.07633937895298004,
0.019276458770036697,
-0.011219052597880363,
-0.014668121002614498,
-0.046600744128227234,
0.007396335247904062,
0.00042634314741007984,
-0.0021508773788809776,
-0.01744653657078743,
0.002228720812126994,
0.06346285343170166,
-0.00010673548968043178,
-0.02381773293018341,
0.03761400654911995,
0.0368475466966629,
-0.01457231305539608,
0.01629684679210186,
-0.008617879822850227,
0.004558039363473654,
0.05142943933606148,
-0.028742235153913498,
0.034816429018974304,
0.034663137048482895,
0.0314440056681633,
-0.04594925418496132,
0.027515899389982224,
-0.008881350979208946,
0.013968726620078087,
-0.011084921658039093,
0.021499192342162132,
-0.007075380068272352,
-0.02471832185983658,
0.036406829953193665,
0.04008583724498749,
0.02011956460773945,
-0.010854984633624554,
-0.014016630128026009,
0.010098105296492577,
0.005475395824760199,
-0.052310869097709656,
-0.05165937915444374,
0.008234650827944279,
0.01928604021668434,
-0.007554417476058006,
-0.012665744870901108,
-0.006428679917007685,
-0.01299149077385664,
-0.040699005126953125,
0.0008814285392872989,
-0.012751971371471882,
-0.019190233200788498,
-0.0024742274545133114,
0.015032188966870308,
-0.01850999891757965,
-0.022361459210515022,
0.006677779369056225,
-0.05652639642357826,
-0.07798726856708527,
0.04847856983542442,
0.06028204783797264,
0.024584192782640457,
-0.06718018651008606,
0.015013027936220169,
-0.022227328270673752,
0.0017832161393016577,
0.037805620580911636,
0.04307502880692482,
-0.02469916082918644,
-0.001341304276138544,
-0.019515978172421455,
-0.01098911464214325,
0.024028507992625237,
0.03422242030501366,
0.03014102391898632,
0.0176668930798769,
-0.04292173683643341,
-0.007214301265776157,
-0.0497049055993557,
-0.050011489540338516,
-0.00983942486345768,
0.008957996964454651,
0.00008076268568402156,
0.06185328960418701,
-0.022763850167393684,
0.01636391319334507,
0.04426304250955582,
0.028473975136876106,
-0.029393725097179413,
0.018787840381264687,
0.0020095612853765488,
-0.028665589168667793,
-0.0769142210483551,
-0.022457266226410866,
0.03232543542981148,
-0.04460794851183891,
0.004713726695626974,
0.04234689474105835,
0.047750432044267654,
-0.015195061452686787,
-0.05675633251667023,
-0.07549627125263214,
0.035659532994031906,
0.03249788656830788,
0.0019353105453774333,
-0.0015137577429413795,
0.05514676868915558,
0.016766304150223732,
-0.0036646348889917135,
-0.06315626949071884,
0.025293167680501938,
0.003547270782291889,
-0.036521799862384796,
-0.0017221389571204782,
-0.027190154418349266,
-0.06388440728187561,
-0.037978071719408035,
-0.053920432925224304,
-0.044991180300712585,
0.01861538738012314,
0.023319533094763756,
0.04717558994889259,
-0.03544875606894493,
0.019851304590702057,
0.018251318484544754,
0.051046211272478104,
-0.025369813665747643,
-0.0061364672146737576,
-0.0256955586373806,
-0.02571471966803074,
0.01574116386473179,
-0.0032406870741397142,
0.016680076718330383,
-0.057944346219301224,
0.029182950034737587,
-0.0018634549342095852,
0.02456502988934517,
-0.023798570036888123,
0.05165937915444374,
0.007913695648312569,
0.0020406986586749554,
0.08783627301454544,
-0.06656701862812042,
0.010768757201731205,
-0.06334788352251053,
-0.003712538629770279,
-0.037843942642211914,
0.005767608527094126,
-0.020177049562335014,
0.019247716292738914,
0.010969952680170536,
-0.026021303609013557,
-0.022323135286569595,
0.050739627331495285,
0.008110100403428078,
-0.0031185324769467115,
-0.03276614844799042,
-0.002462251577526331,
0.017743539065122604,
-0.005729285534471273,
-0.0029963781125843525,
-0.034107454121112823,
0.06591552495956421,
0.004670613445341587,
0.029029658064246178,
0.04422472044825554,
0.007798726670444012,
0.05813596025109291,
0.022629719227552414,
-0.03977925330400467,
-0.03657928481698036,
0.007856210693717003,
-0.028071582317352295,
-0.02742009237408638,
-0.006217903457581997,
-0.06511074304580688,
-0.048018693923950195,
0.029891924932599068,
-0.021307576447725296,
-0.004833485931158066,
0.011525636538863182,
0.012004673480987549,
0.07733577489852905,
-0.0029149416368454695,
-0.002919732127338648,
-0.0053843786008656025,
0.001637109788134694,
0.05066297948360443,
-0.01470644399523735,
0.018212996423244476,
-0.057216208428144455,
-0.002245487179607153,
0.021556677296757698,
-0.025159036740660667,
0.023453664034605026,
0.050318073481321335,
0.038687050342559814,
0.06392273306846619,
-0.025772204622626305,
-0.01729324460029602,
-0.05380546301603317,
-0.04752049595117569,
0.021211769431829453,
-0.03893614932894707,
-0.03604276478290558,
0.058212608098983765,
-0.07599446922540665,
0.03541043400764465,
-0.05112285539507866,
0.009005900472402573,
-0.032517049461603165,
0.010232235305011272,
-0.01808844693005085,
-0.045297764241695404,
0.04920670762658119,
-0.008565186522901058,
0.0043352870270609856,
-0.04016248509287834,
-0.005590364802628756,
0.03157813474535942,
-0.05453360080718994,
0.0015736373607069254,
-0.06196825951337814,
-0.013796272687613964,
0.0361768938601017,
0.007329269777983427,
0.02383689396083355,
-0.0083256671205163,
0.03159729763865471,
-0.05372881889343262,
-0.012110061943531036,
-0.03604276478290558,
0.01420824509114027,
0.03282363340258598,
0.001371244085021317,
0.015013027936220169,
-0.003853854723274708,
-0.033934999257326126,
0.011017857119441032,
0.009245418943464756,
0.023606956005096436,
0.008517282083630562,
0.01660343073308468,
0.0034466730430722237,
-0.052157577127218246,
0.04460794851183891,
-0.006146048195660114,
0.03602360188961029,
-0.030332639813423157,
0.008076568134129047,
0.008407103829085827,
0.0003224519605282694,
0.05453360080718994,
-0.017906412482261658,
-0.01864412985742092,
0.05495515465736389,
0.027669191360473633,
0.00491971243172884,
0.04798037186264992,
-0.029202111065387726,
-0.03205717355012894,
-0.07335018366575241,
-0.016335170716047287,
0.01371004618704319,
0.06189161166548729,
-0.0407373271882534,
-0.0023041691165417433,
0.020617762580513954,
0.01587529480457306,
0.04713726416230202
]
|
30,606 | networkx.algorithms.distance_measures | eccentricity | Returns the eccentricity of nodes in G.
The eccentricity of a node v is the maximum distance from v to
all other nodes in G.
Parameters
----------
G : NetworkX graph
A graph
v : node, optional
Return value of specified node
sp : dict of dicts, optional
All pairs shortest path lengths as a dictionary of dictionaries
weight : string, function, or None (default=None)
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number.
If this is None, every edge has weight/distance/cost 1.
Weights stored as floating point values can lead to small round-off
errors in distances. Use integer weights to avoid this.
Weights should be positive, since they are distances.
Returns
-------
ecc : dictionary
A dictionary of eccentricity values keyed by node.
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> dict(nx.eccentricity(G))
{1: 2, 2: 3, 3: 2, 4: 2, 5: 3}
>>> dict(nx.eccentricity(G, v=[1, 5])) # This returns the eccentricity of node 1 & 5
{1: 2, 5: 3}
| def effective_graph_resistance(G, weight=None, invert_weight=True):
"""Returns the Effective graph resistance of G.
Also known as the Kirchhoff index.
The effective graph resistance is defined as the sum
of the resistance distance of every node pair in G [1]_.
If weight is not provided, then a weight of 1 is used for all edges.
The effective graph resistance of a disconnected graph is infinite.
Parameters
----------
G : NetworkX graph
A graph
weight : string or None, optional (default=None)
The edge data key used to compute the effective graph resistance.
If None, then each edge has weight 1.
invert_weight : boolean (default=True)
Proper calculation of resistance distance requires building the
Laplacian matrix with the reciprocal of the weight. Not required
if the weight is already inverted. Weight cannot be zero.
Returns
-------
RG : float
The effective graph resistance of `G`.
Raises
------
NetworkXNotImplemented
If `G` is a directed graph.
NetworkXError
If `G` does not contain any nodes.
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> round(nx.effective_graph_resistance(G), 10)
10.25
Notes
-----
The implementation is based on Theorem 2.2 in [2]_. Self-loops are ignored.
Multi-edges are contracted in one edge with weight equal to the harmonic sum of the weights.
References
----------
.. [1] Wolfram
"Kirchhoff Index."
https://mathworld.wolfram.com/KirchhoffIndex.html
.. [2] W. Ellens, F. M. Spieksma, P. Van Mieghem, A. Jamakovic, R. E. Kooij.
Effective graph resistance.
Lin. Alg. Appl. 435:2491-2506, 2011.
"""
import numpy as np
if len(G) == 0:
raise nx.NetworkXError("Graph G must contain at least one node.")
# Disconnected graphs have infinite Effective graph resistance
if not nx.is_connected(G):
return float("inf")
# Invert weights
G = G.copy()
if invert_weight and weight is not None:
if G.is_multigraph():
for u, v, k, d in G.edges(keys=True, data=True):
d[weight] = 1 / d[weight]
else:
for u, v, d in G.edges(data=True):
d[weight] = 1 / d[weight]
# Get Laplacian eigenvalues
mu = np.sort(nx.laplacian_spectrum(G, weight=weight))
# Compute Effective graph resistance based on spectrum of the Laplacian
# Self-loops are ignored
return float(np.sum(1 / mu[1:]) * G.number_of_nodes())
| (G, v=None, sp=None, weight=None, *, backend=None, **backend_kwargs) | [
0.05050867050886154,
-0.014603428542613983,
0.0027054823003709316,
0.05921182036399841,
0.05624742805957794,
-0.009401491843163967,
-0.03190521150827408,
-0.04940652474761009,
0.10086531937122345,
-0.00876015704125166,
0.031848207116127014,
-0.00024257891345769167,
0.015183004550635815,
-0.004527347628027201,
-0.059743888676166534,
0.0450359471142292,
-0.057007528841495514,
0.00035867237602360547,
-0.005876525770872831,
0.04629011079668999,
0.005258944351226091,
-0.10413374751806259,
-0.0036318546626716852,
0.06061800569295883,
-0.027914686128497124,
0.007453734055161476,
0.020370690152049065,
0.01348228007555008,
-0.003510713577270508,
0.000527913449332118,
-0.006660379469394684,
-0.05028063803911209,
-0.023297077044844627,
-0.00654636463150382,
0.02282201312482357,
0.02388615347445011,
0.007035679183900356,
0.007724519819021225,
-0.09258022159337997,
-0.05354906991124153,
-0.011525021865963936,
0.03386247158050537,
0.03209523856639862,
-0.02666052058339119,
0.03329239785671234,
0.017767345532774925,
-0.003762496868148446,
0.01885048858821392,
-0.03029000014066696,
-0.03910716250538826,
0.025843413546681404,
-0.010878936387598515,
-0.04625210911035538,
0.009154458530247211,
0.0018859989941120148,
0.03342541307210922,
0.02609044499695301,
0.05415715277194977,
0.029206857085227966,
-0.07304564863443375,
0.011106966994702816,
-0.08057063817977905,
0.027667652815580368,
0.016931235790252686,
-0.061340101063251495,
0.015059488825500011,
-0.01972460374236107,
-0.005524979438632727,
0.008009557612240314,
0.013786320574581623,
-0.029111843556165695,
-0.0022791135124862194,
0.026033436879515648,
-0.06821900606155396,
0.018698468804359436,
0.026375483721494675,
0.023905156180262566,
-0.013254250399768353,
-0.026983562856912613,
-0.01409986149519682,
0.0317721962928772,
-0.013235247693955898,
0.04625210911035538,
-0.03646581619977951,
0.025463363155722618,
-0.037320926785469055,
0.011049958877265453,
-0.016598692163825035,
0.025976430624723434,
-0.03146815672516823,
-0.006769644096493721,
0.026071442291140556,
0.033786460757255554,
0.03749195113778114,
0.0732736736536026,
0.001000007032416761,
-0.049900587648153305,
-0.07342569530010223,
0.07080335170030594,
-0.022080915048718452,
-0.013406270183622837,
0.08627139031887054,
-0.01815689727663994,
0.005144929513335228,
0.028617778792977333,
-0.046024076640605927,
-0.015373029746115208,
-0.03435653820633888,
0.05354906991124153,
-0.03116411529481411,
-0.05632343888282776,
0.021643858402967453,
0.01661769486963749,
-0.013738813810050488,
-0.03610476851463318,
0.04514996334910393,
-0.016874227672815323,
0.015297019854187965,
0.05932583287358284,
0.027667652815580368,
0.013168739154934883,
0.03219025209546089,
-0.017738843336701393,
-0.001029698527418077,
0.010736417956650257,
0.021814880892634392,
0.009591516107320786,
0.001400247449055314,
-0.011905072256922722,
0.022004906088113785,
0.04914049059152603,
0.00004873104262514971,
0.02525433525443077,
0.048494402319192886,
0.0273636132478714,
0.009814796037971973,
-0.007738771848380566,
0.03756796196103096,
0.06715486943721771,
0.020769743248820305,
-0.010384871624410152,
-0.023297077044844627,
0.023202063515782356,
0.0511927604675293,
0.031848207116127014,
0.008332599885761738,
0.017406297847628593,
0.03956322371959686,
0.039753250777721405,
-0.002807620679959655,
0.026299472898244858,
-0.014061857014894485,
0.04381978511810303,
-0.011030957102775574,
0.009667526930570602,
0.017301784828305244,
-0.014337393455207348,
0.013909837231040001,
-0.04047534614801407,
-0.034850601106882095,
-0.07426180690526962,
-0.030746059492230415,
0.0401713028550148,
-0.021814880892634392,
0.013805323280394077,
-0.02723059616982937,
0.04952054098248482,
0.015639064833521843,
-0.0649125725030899,
0.028256731107831,
-0.0450359471142292,
-0.05157281085848808,
-0.03403349593281746,
-0.03874611482024193,
0.030480025336146355,
0.08535927534103394,
0.02662251517176628,
-0.014631932601332664,
0.012152104638516903,
0.023563111200928688,
-0.014964476227760315,
-0.058641742914915085,
-0.0018408680334687233,
-0.02145383320748806,
0.028921818360686302,
0.044959936290979385,
0.03460356965661049,
-0.004793383181095123,
0.004624735563993454,
0.00048426707508042455,
0.008270842023193836,
-0.041425470262765884,
0.0253873523324728,
0.028940821066498756,
0.029073840007185936,
-0.014964476227760315,
0.03589573875069618,
0.01835642382502556,
-0.03473658859729767,
0.07068933546543121,
0.029054837301373482,
-0.0009952564723789692,
0.037453945726156235,
0.032019227743148804,
0.005534480791538954,
0.011268488131463528,
-0.009282725863158703,
-0.029016831889748573,
-0.008266091346740723,
0.009976317174732685,
-0.06685082614421844,
0.00502141285687685,
0.005634244065731764,
-0.03496461734175682,
-0.02428520657122135,
0.030004961416125298,
-0.02648949809372425,
0.008897924795746803,
0.013662803918123245,
-0.06407646089792252,
-0.054803237318992615,
-0.010052327066659927,
-0.009881304576992989,
-0.013140235096216202,
0.0445798859000206,
-0.04925450310111046,
0.022403959184885025,
0.00006209218554431573,
0.014194874092936516,
0.007007175125181675,
0.05446119233965874,
0.0031544165685772896,
0.07905043661594391,
-0.0511927604675293,
0.014261383563280106,
-0.02118779718875885,
-0.059743888676166534,
0.07251357287168503,
0.05256094038486481,
0.041159436106681824,
-0.03570571541786194,
-0.06282229721546173,
-0.0428316555917263,
0.058869775384664536,
-0.03627578914165497,
-0.03707389533519745,
0.013824325054883957,
0.0018598706228658557,
0.02856077067553997,
0.008988186717033386,
-0.08794361352920532,
-0.0679909810423851,
-0.01409986149519682,
-0.023202063515782356,
0.027610646560788155,
-0.01085993368178606,
-0.08513124287128448,
0.01651317998766899,
-0.018099891021847725,
-0.027306605130434036,
0.01449891459196806,
-0.008327850140631199,
-0.07228554785251617,
-0.004586730618029833,
-0.048266373574733734,
0.01002382393926382,
0.0004590293683577329,
0.01024235226213932,
-0.025463363155722618,
0.050736699253320694,
0.0450359471142292,
0.010460881516337395,
0.013567791320383549,
-0.00951075553894043,
-0.0049121486954391,
0.020142659544944763,
0.02122580260038376,
0.04454188048839569,
-0.005083171185106039,
0.03633279725909233,
-0.08444715291261673,
0.0016175885684788227,
-0.007653260603547096,
0.024475231766700745,
-0.057007528841495514,
0.01738729514181614,
-0.009220968000590801,
-0.05632343888282776,
0.023107051849365234,
-0.009087949991226196,
0.09242820739746094,
0.007772026117891073,
0.003624728647992015,
0.003391947830095887,
0.07376774400472641,
0.010384871624410152,
-0.013957343064248562,
-0.04834238439798355,
0.016370661556720734,
0.06958718597888947,
0.04313569515943527,
-0.024399222806096077,
0.004655614960938692,
-0.049330513924360275,
0.05556333810091019,
0.04077938571572304,
0.034850601106882095,
-0.00010644374560797587,
0.0172162726521492,
0.057843636721372604,
-0.09615270048379898,
0.004921650048345327,
-0.043059684336185455,
0.022841015830636024,
-0.05256094038486481,
-0.029738927260041237,
0.05009061470627785,
-0.02723059616982937,
0.020066650584340096,
0.025634385645389557,
0.01604761928319931,
0.09698880463838577,
0.014432406052947044,
0.03874611482024193,
-0.07118339836597443,
-0.0023705631028860807,
0.019876625388860703,
0.07821432501077652,
0.07935447990894318,
-0.04948253557085991,
-0.042755644768476486,
0.018432434648275375,
-0.01024235226213932,
0.0047007459215819836,
-0.04146347567439079,
0.042223576456308365,
0.10953046381473541,
-0.033881474286317825,
-0.027933688834309578,
-0.029453888535499573,
0.027667652815580368,
0.004249436315149069,
-0.005334954708814621,
-0.0026437242049723864,
-0.005083171185106039,
0.019268544390797615,
0.01708325557410717,
-0.02742062136530876,
-0.03486960381269455,
-0.053169019520282745,
-0.01286469865590334,
0.003954897169023752,
-0.03200022503733635,
0.026869548484683037,
-0.0167792160063982,
0.045530013740062714,
-0.011667540296912193,
-0.04800033941864967,
0.021947897970676422,
0.02379114180803299,
-0.10352566838264465,
0.006380092352628708,
-0.028636781498789787,
-0.01939206011593342,
-0.006850404664874077,
0.012152104638516903,
-0.016494177281856537,
0.01718777045607567,
0.018308917060494423,
-0.04093140363693237,
-0.0022898023016750813,
-0.0820908397436142,
-0.07745422422885895,
0.004862267058342695,
0.01085993368178606,
0.037548959255218506,
-0.034052494913339615,
-0.021111788228154182,
-0.01574357971549034,
-0.006389593705534935,
0.009159209206700325,
0.019335053861141205,
-0.04454188048839569,
0.011163974180817604,
0.04473190754652023,
-0.0126936761662364,
0.049064479768276215,
0.004049909766763449,
0.02419019490480423,
-0.003251804504543543,
-0.04184352606534958,
-0.027572641149163246,
0.06764893233776093,
-0.01084093190729618,
-0.04340173304080963,
0.03473658859729767,
0.06172015145421028,
0.028313739225268364,
-0.045796047896146774,
-0.014194874092936516,
-0.04610008746385574,
-0.007819532416760921,
-0.021377822384238243,
0.00857488252222538,
-0.02662251517176628,
0.015059488825500011,
0.007715018931776285,
0.04347774013876915,
0.044655896723270416,
0.014460909180343151,
-0.04955854266881943,
0.01564856618642807,
0.0134632783010602,
0.004273189231753349,
-0.019705602899193764,
-0.02012365683913231,
-0.01309272926300764,
0.0023753135465085506,
0.03699788451194763,
0.02992895245552063,
0.02132081612944603,
-0.02970092184841633,
0.07509791851043701,
-0.005962037481367588,
0.022593984380364418,
-0.04670816659927368,
0.00014073733473196626,
-0.020028645172715187,
-0.06647077947854996,
0.05404313653707504,
-0.023867150768637657,
0.001703099929727614,
0.018907496705651283,
-0.031221123412251472,
0.00023471067834179848,
-0.002228044206276536,
0.018033381551504135,
0.01752031408250332,
-0.02012365683913231,
-0.03726392239332199,
0.0401713028550148,
0.012171107344329357,
0.027819674462080002,
-0.04830437898635864,
-0.0033610688988119364,
-0.06278429180383682,
-0.006931165233254433,
-0.0008848043507896364,
-0.0052399421110749245,
-0.03165818005800247,
0.005510727874934673,
-0.04431385174393654,
0.02675553224980831,
0.02886481210589409,
-0.11705546081066132,
0.029168851673603058,
-0.037149906158447266,
-0.014023851603269577,
-0.06806699186563492,
0.025539372116327286,
0.016199639067053795,
0.03160117194056511,
-0.009102202020585537,
-0.029947955161333084,
-0.01955358125269413,
-0.03283633664250374,
0.0078005301766097546,
-0.01567707024514675,
-0.02719259075820446,
-0.021130790933966637,
0.04914049059152603,
-0.020161662250757217,
-0.020009642466902733,
-0.04324971139431,
0.056513462215662,
0.01249414961785078,
-0.09121204167604446,
-0.011791056953370571,
0.00624707480892539,
-0.044161830097436905,
-0.02004764787852764,
0.020142659544944763,
0.05556333810091019,
0.023943161591887474,
0.02092176303267479,
-0.039259184151887894,
-0.0038883883971720934,
-0.005743508227169514,
0.019895628094673157,
-0.04188153147697449,
-0.015525050461292267,
0.03163917735219002,
0.025672389194369316,
0.012085596099495888,
0.0006490544765256345,
-0.0046888692304492,
0.012256618589162827,
0.004572478588670492,
0.03276032581925392,
0.014432406052947044,
-0.026451492682099342,
-0.031449154019355774,
-0.01543003786355257,
0.04845639690756798,
0.03694087639451027,
0.03165818005800247,
-0.03853708878159523,
0.007743522524833679,
0.08953982591629028,
0.035287659615278244,
-0.014052355661988258,
0.019173532724380493,
0.0741477906703949,
0.04750627279281616,
0.01182906236499548,
-0.02618545852601528,
-0.03656082972884178,
0.05438518151640892,
0.06529261916875839,
-0.02852276712656021,
-0.01882198452949524,
0.024247201159596443,
0.0005810611182823777,
-0.0018741225358098745,
-0.0167792160063982,
0.008988186717033386,
-0.00438007852062583,
-0.07749222964048386,
-0.0022126047406345606,
-0.015268515795469284,
-0.014460909180343151,
0.01995263434946537,
-0.01944906823337078,
0.04708821699023247,
-0.0003607507678680122,
-0.0078005301766097546,
-0.018660463392734528,
-0.04203354939818382,
-0.10230951011180878,
-0.01184806413948536,
-0.015525050461292267,
0.0029881445225328207,
0.014650934375822544,
0.01123048271983862,
0.08247089385986328,
0.02038969285786152,
0.0012517903232946992,
0.002406192710623145,
-0.02246096543967724,
-0.07072734087705612,
-0.04480791836977005,
0.028275733813643456,
-0.020864754915237427,
-0.033881474286317825,
0.06206219643354416,
0.03686486929655075,
-0.050166625529527664,
0.004520222079008818,
0.025406355038285255,
-0.017605824396014214,
-0.016627196222543716,
-0.08733553439378738,
-0.018128393217921257,
-0.06297431886196136,
0.006399095058441162,
-0.04043734073638916,
0.032285261899232864,
-0.024950293824076653,
-0.0450359471142292,
0.033919479697942734,
-0.03179119899868965,
0.03249429166316986,
0.07844235748052597,
0.004458463750779629,
-0.006522611249238253,
-0.01331125758588314,
0.025311341509222984,
-0.06316433846950531,
0.035116638988256454,
-0.0635443925857544,
-0.012703177519142628,
-0.06096005067229271,
0.016370661556720734,
0.04123544692993164,
0.01712126098573208,
0.04161549359560013,
-0.01672220788896084,
0.053397051990032196,
-0.038556091487407684,
-0.014622431248426437,
-0.02428520657122135,
-0.057235557585954666,
0.038252051919698715,
0.0035653458908200264,
-0.001921628718264401,
-0.033482421189546585,
-0.022061914205551147,
0.008019058965146542,
0.04598607122898102,
0.0032185500022023916,
-0.052066873759031296,
-0.009311229921877384,
0.019477572292089462,
-0.006926414556801319,
-0.04378177970647812,
0.04952054098248482,
0.005325453355908394,
-0.07034728676080704,
0.03616177663207054,
-0.05324503034353256,
0.0015890848590061069,
-0.024342214688658714,
-0.01624714583158493,
-0.0006086741341277957,
-0.0034157009795308113,
0.012722180224955082,
-0.002281488850712776,
0.01651317998766899,
-0.04229958727955818,
0.017662832513451576,
-0.004826637450605631,
-0.0047197481617331505,
0.03773898258805275,
-0.03276032581925392,
-0.01855595037341118,
0.057007528841495514,
0.040019284933805466,
0.006004793103784323,
-0.03325439244508743,
0.04184352606534958,
-0.0021425329614430666,
-0.04210956022143364,
-0.009843300096690655,
0.04226158186793327,
0.03165818005800247,
-0.07129741460084915,
0.040323324501514435,
-0.017491810023784637,
-0.02012365683913231,
0.041691504418849945,
-0.03570571541786194,
0.07601003348827362,
-0.05734957382082939,
-0.0006989360554143786,
-0.06392443925142288,
0.019306549802422523,
0.0489884689450264,
-0.01718777045607567,
-0.005216188728809357,
-0.005662747658789158,
-0.02012365683913231,
0.031848207116127014,
0.033387407660484314,
-0.01791936717927456,
-0.008570131845772266,
0.03602875769138336,
0.026451492682099342,
-0.024665256962180138,
0.009601017460227013,
-0.05145879462361336,
0.0011502456618472934,
0.03631379455327988,
0.03336840495467186,
0.011781555600464344,
0.02405717596411705,
0.017035748809576035,
0.03302635997533798,
-0.036218781024217606,
-0.0026057190261781216,
-0.06255625933408737,
-0.01978161185979843,
-0.01236113253980875,
0.022974032908678055,
0.031278129667043686,
-0.06875108182430267,
0.02308804914355278,
-0.003216174663975835,
0.03800501674413681,
-0.0006158000905998051,
-0.02092176303267479,
0.004755377769470215,
0.06726888567209244,
-0.025482365861535072,
-0.004363451153039932,
0.017577320337295532,
-0.021301813423633575,
-0.03072705678641796,
-0.021111788228154182,
0.02926386520266533,
-0.004800508730113506,
-0.03967723995447159,
-0.0428316555917263,
0.020674729719758034,
-0.0009204340167343616,
0.05799565836787224,
-0.0401713028550148,
-0.049938593059778214,
0.04819036275148392,
0.07023327797651291,
-0.05924982577562332,
0.07905043661594391,
0.025406355038285255,
-0.016655700281262398,
0.026774534955620766,
-0.023905156180262566,
-0.02582441084086895,
-0.07612404972314835,
-0.01121148094534874,
-0.045530013740062714,
0.03399549052119255,
-0.011952578090131283,
-0.023981167003512383,
0.01835642382502556,
-0.00409504072740674,
0.03990526869893074,
0.02379114180803299,
-0.003665108932182193,
-0.030955087393522263,
-0.043629761785268784,
-0.006299331784248352,
-0.01815689727663994,
-0.009339733049273491,
0.012722180224955082,
0.0304610226303339,
-0.03203823044896126,
0.012152104638516903,
0.07255157828330994,
-0.04473190754652023,
0.006883658934384584,
0.04788632318377495,
-0.027211593464016914,
0.00429456727579236,
0.015553553588688374,
0.037016887217760086,
0.02278400957584381,
0.020769743248820305,
-0.00583852082490921,
0.028332741931080818,
0.037548959255218506,
0.052104879170656204,
0.025976430624723434,
0.04153948649764061,
-0.04750627279281616,
-0.032513294368982315,
0.0012826693709939718,
-0.007097437046468258,
-0.0401713028550148,
0.023297077044844627,
0.019278045743703842,
-0.023069046437740326,
0.0507747046649456,
-0.0047007459215819836,
0.03169618546962738,
-0.008912176825106144,
0.05761560797691345,
-0.007786278147250414,
-0.015667568892240524,
-0.05168682709336281,
-0.002600968349725008,
-0.005249442998319864,
-0.0038242549635469913,
-0.06658479571342468,
-0.05176283419132233,
0.0141283655539155,
-0.029168851673603058,
0.008788660168647766,
0.006636626552790403,
0.05465121567249298
]
|
30,611 | networkx.algorithms.connectivity.connectivity | edge_connectivity | Returns the edge connectivity of the graph or digraph G.
The edge connectivity is equal to the minimum number of edges that
must be removed to disconnect G or render it trivial. If source
and target nodes are provided, this function returns the local edge
connectivity: the minimum number of edges that must be removed to
break all paths from source to target in G.
Parameters
----------
G : NetworkX graph
Undirected or directed graph
s : node
Source node. Optional. Default value: None.
t : node
Target node. Optional. Default value: None.
flow_func : function
A function for computing the maximum flow among a pair of nodes.
The function has to accept at least three parameters: a Digraph,
a source node, and a target node. And return a residual network
that follows NetworkX conventions (see :meth:`maximum_flow` for
details). If flow_func is None, the default maximum flow function
(:meth:`edmonds_karp`) is used. See below for details. The
choice of the default function may change from version
to version and should not be relied on. Default value: None.
cutoff : integer, float, or None (default: None)
If specified, the maximum flow algorithm will terminate when the
flow value reaches or exceeds the cutoff. This only works for flows
that support the cutoff parameter (most do) and is ignored otherwise.
Returns
-------
K : integer
Edge connectivity for G, or local edge connectivity if source
and target were provided
Examples
--------
>>> # Platonic icosahedral graph is 5-edge-connected
>>> G = nx.icosahedral_graph()
>>> nx.edge_connectivity(G)
5
You can use alternative flow algorithms for the underlying
maximum flow computation. In dense networks the algorithm
:meth:`shortest_augmenting_path` will usually perform better
than the default :meth:`edmonds_karp`, which is faster for
sparse networks with highly skewed degree distributions.
Alternative flow functions have to be explicitly imported
from the flow package.
>>> from networkx.algorithms.flow import shortest_augmenting_path
>>> nx.edge_connectivity(G, flow_func=shortest_augmenting_path)
5
If you specify a pair of nodes (source and target) as parameters,
this function returns the value of local edge connectivity.
>>> nx.edge_connectivity(G, 3, 7)
5
If you need to perform several local computations among different
pairs of nodes on the same graph, it is recommended that you reuse
the data structures used in the maximum flow computations. See
:meth:`local_edge_connectivity` for details.
Notes
-----
This is a flow based implementation of global edge connectivity.
For undirected graphs the algorithm works by finding a 'small'
dominating set of nodes of G (see algorithm 7 in [1]_ ) and
computing local maximum flow (see :meth:`local_edge_connectivity`)
between an arbitrary node in the dominating set and the rest of
nodes in it. This is an implementation of algorithm 6 in [1]_ .
For directed graphs, the algorithm does n calls to the maximum
flow function. This is an implementation of algorithm 8 in [1]_ .
See also
--------
:meth:`local_edge_connectivity`
:meth:`local_node_connectivity`
:meth:`node_connectivity`
:meth:`maximum_flow`
:meth:`edmonds_karp`
:meth:`preflow_push`
:meth:`shortest_augmenting_path`
:meth:`k_edge_components`
:meth:`k_edge_subgraphs`
References
----------
.. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf
| @nx._dispatchable
def edge_connectivity(G, s=None, t=None, flow_func=None, cutoff=None):
r"""Returns the edge connectivity of the graph or digraph G.
The edge connectivity is equal to the minimum number of edges that
must be removed to disconnect G or render it trivial. If source
and target nodes are provided, this function returns the local edge
connectivity: the minimum number of edges that must be removed to
break all paths from source to target in G.
Parameters
----------
G : NetworkX graph
Undirected or directed graph
s : node
Source node. Optional. Default value: None.
t : node
Target node. Optional. Default value: None.
flow_func : function
A function for computing the maximum flow among a pair of nodes.
The function has to accept at least three parameters: a Digraph,
a source node, and a target node. And return a residual network
that follows NetworkX conventions (see :meth:`maximum_flow` for
details). If flow_func is None, the default maximum flow function
(:meth:`edmonds_karp`) is used. See below for details. The
choice of the default function may change from version
to version and should not be relied on. Default value: None.
cutoff : integer, float, or None (default: None)
If specified, the maximum flow algorithm will terminate when the
flow value reaches or exceeds the cutoff. This only works for flows
that support the cutoff parameter (most do) and is ignored otherwise.
Returns
-------
K : integer
Edge connectivity for G, or local edge connectivity if source
and target were provided
Examples
--------
>>> # Platonic icosahedral graph is 5-edge-connected
>>> G = nx.icosahedral_graph()
>>> nx.edge_connectivity(G)
5
You can use alternative flow algorithms for the underlying
maximum flow computation. In dense networks the algorithm
:meth:`shortest_augmenting_path` will usually perform better
than the default :meth:`edmonds_karp`, which is faster for
sparse networks with highly skewed degree distributions.
Alternative flow functions have to be explicitly imported
from the flow package.
>>> from networkx.algorithms.flow import shortest_augmenting_path
>>> nx.edge_connectivity(G, flow_func=shortest_augmenting_path)
5
If you specify a pair of nodes (source and target) as parameters,
this function returns the value of local edge connectivity.
>>> nx.edge_connectivity(G, 3, 7)
5
If you need to perform several local computations among different
pairs of nodes on the same graph, it is recommended that you reuse
the data structures used in the maximum flow computations. See
:meth:`local_edge_connectivity` for details.
Notes
-----
This is a flow based implementation of global edge connectivity.
For undirected graphs the algorithm works by finding a 'small'
dominating set of nodes of G (see algorithm 7 in [1]_ ) and
computing local maximum flow (see :meth:`local_edge_connectivity`)
between an arbitrary node in the dominating set and the rest of
nodes in it. This is an implementation of algorithm 6 in [1]_ .
For directed graphs, the algorithm does n calls to the maximum
flow function. This is an implementation of algorithm 8 in [1]_ .
See also
--------
:meth:`local_edge_connectivity`
:meth:`local_node_connectivity`
:meth:`node_connectivity`
:meth:`maximum_flow`
:meth:`edmonds_karp`
:meth:`preflow_push`
:meth:`shortest_augmenting_path`
:meth:`k_edge_components`
:meth:`k_edge_subgraphs`
References
----------
.. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf
"""
if (s is not None and t is None) or (s is None and t is not None):
raise nx.NetworkXError("Both source and target must be specified.")
# Local edge connectivity
if s is not None and t is not None:
if s not in G:
raise nx.NetworkXError(f"node {s} not in graph")
if t not in G:
raise nx.NetworkXError(f"node {t} not in graph")
return local_edge_connectivity(G, s, t, flow_func=flow_func, cutoff=cutoff)
# Global edge connectivity
# reuse auxiliary digraph and residual network
H = build_auxiliary_edge_connectivity(G)
R = build_residual_network(H, "capacity")
kwargs = {"flow_func": flow_func, "auxiliary": H, "residual": R}
if G.is_directed():
# Algorithm 8 in [1]
if not nx.is_weakly_connected(G):
return 0
# initial value for \lambda is minimum degree
L = min(d for n, d in G.degree())
nodes = list(G)
n = len(nodes)
if cutoff is not None:
L = min(cutoff, L)
for i in range(n):
kwargs["cutoff"] = L
try:
L = min(L, local_edge_connectivity(G, nodes[i], nodes[i + 1], **kwargs))
except IndexError: # last node!
L = min(L, local_edge_connectivity(G, nodes[i], nodes[0], **kwargs))
return L
else: # undirected
# Algorithm 6 in [1]
if not nx.is_connected(G):
return 0
# initial value for \lambda is minimum degree
L = min(d for n, d in G.degree())
if cutoff is not None:
L = min(cutoff, L)
# A dominating set is \lambda-covering
# We need a dominating set with at least two nodes
for node in G:
D = nx.dominating_set(G, start_with=node)
v = D.pop()
if D:
break
else:
# in complete graphs the dominating sets will always be of one node
# thus we return min degree
return L
for w in D:
kwargs["cutoff"] = L
L = min(L, local_edge_connectivity(G, v, w, **kwargs))
return L
| (G, s=None, t=None, flow_func=None, cutoff=None, *, backend=None, **backend_kwargs) | [
-0.00657334690913558,
-0.03918026387691498,
0.02253125049173832,
0.039699897170066833,
0.012148999609053135,
0.011691723018884659,
-0.018259873613715172,
-0.020733322948217392,
0.0328199677169323,
-0.09511347115039825,
-0.03159363567829132,
0.019662881270051003,
0.034254152327775955,
0.0040687196888029575,
-0.012315281666815281,
0.029681388288736343,
-0.041466645896434784,
0.006869536824524403,
0.041695281863212585,
0.040843088179826736,
0.002257801592350006,
-0.06954756379127502,
0.02949432097375393,
-0.027207938954234123,
-0.00862069707363844,
0.029930811375379562,
0.03159363567829132,
0.00258127273991704,
-0.03999089077115059,
-0.008599911816418171,
-0.050175681710243225,
-0.013001196086406708,
-0.07520116120576859,
0.006656487938016653,
0.034129440784454346,
0.03878534212708473,
0.025150196626782417,
0.030845364555716515,
-0.0476398766040802,
-0.04884542152285576,
-0.07391247898340225,
0.0006625310052186251,
-0.002072033239528537,
0.0041336738504469395,
0.030138663947582245,
0.031219499185681343,
0.011535833589732647,
0.023071667179465294,
0.0013770251534879208,
-0.029286468401551247,
-0.002165566897019744,
-0.02618945948779583,
-0.008350488729774952,
-0.0008125747554004192,
0.03196777030825615,
0.028704479336738586,
0.010590103454887867,
0.012647846713662148,
-0.005643205251544714,
-0.026854589581489563,
-0.00005996067920932546,
0.006838358938694,
0.057783093303442,
0.037683721631765366,
-0.08222658932209015,
0.012959625571966171,
-0.06194015219807625,
0.0015744854463264346,
-0.013707895763218403,
0.021149028092622757,
-0.004071318078786135,
-0.014476951211690903,
0.013115515001118183,
-0.04088465869426727,
0.005757524166256189,
-0.03088693507015705,
0.04518721252679825,
-0.02914097160100937,
-0.04423108696937561,
-0.05229577794671059,
0.04938583821058273,
-0.02548276074230671,
0.035189490765333176,
-0.008267347700893879,
0.07345519959926605,
-0.02666752226650715,
-0.019288744777441025,
0.051256515085697174,
-0.026833804324269295,
-0.05021725222468376,
0.025378834456205368,
0.0012445190222933888,
-0.02121138386428356,
0.03175991773605347,
0.019953874871134758,
0.01280373614281416,
-0.03286153823137283,
-0.04107172414660454,
0.0719170868396759,
-0.03714330494403839,
0.022219469770789146,
0.02724950946867466,
-0.09802340716123581,
0.025295693427324295,
-0.008184206672012806,
-0.09544603526592255,
-0.03918026387691498,
0.038847699761390686,
-0.020546255633234978,
-0.04963526129722595,
-0.01735571399331093,
0.010070471093058586,
0.024027790874242783,
0.015776032581925392,
-0.006136855576187372,
0.03136499598622322,
0.027041656896471977,
-0.029681388288736343,
-0.012377637438476086,
-0.013427294790744781,
-0.004775419365614653,
0.04468836635351181,
-0.013479257933795452,
-0.0471826009452343,
0.047598306089639664,
-0.016430769115686417,
0.00785164162516594,
0.0028839583974331617,
0.010387446731328964,
-0.04385695233941078,
0.06397710740566254,
0.001213990617543459,
0.0008508976316079497,
0.0934506431221962,
-0.009285826236009598,
-0.03901398181915283,
-0.043690670281648636,
0.07096096873283386,
0.005136563908308744,
0.008386862464249134,
0.018925003707408905,
-0.04269297793507576,
-0.03277839720249176,
0.03479456901550293,
0.02251046523451805,
-0.004892336670309305,
0.013853393495082855,
-0.017948094755411148,
0.05711796507239342,
0.03419179469347,
-0.008610304445028305,
-0.05304405093193054,
-0.012689417228102684,
0.006620113737881184,
0.004858560394495726,
0.008662267588078976,
-0.020473506301641464,
0.016669798642396927,
-0.020837249234318733,
-0.0033022623974829912,
-0.043815381824970245,
-0.028267988935112953,
-0.023425016552209854,
0.004471434745937586,
-0.01873793452978134,
-0.021512771025300026,
0.04021952673792839,
0.012762165628373623,
-0.03776686638593674,
0.0036893882788717747,
-0.020546255633234978,
-0.017594745382666588,
-0.06430967152118683,
-0.01864440180361271,
0.025191767141222954,
0.02901626005768776,
0.022011617198586464,
0.006027732975780964,
-0.009155918844044209,
-0.003380207112058997,
0.0015861771535128355,
-0.024859201163053513,
0.0001890161947812885,
-0.024838415905833244,
0.042734548449516296,
0.04290083050727844,
0.06663762778043747,
-0.03302782028913498,
-0.004827382508665323,
-0.028704479336738586,
-0.031780701130628586,
-0.04984311759471893,
0.0017069915775209665,
0.05886393040418625,
0.004351919051259756,
-0.02429799921810627,
0.013427294790744781,
0.03595854341983795,
-0.016794510185718536,
0.07474388927221298,
0.026563595980405807,
0.03753822669386864,
0.05283619835972786,
0.01724139414727688,
0.01581760309636593,
0.004554575774818659,
0.042734548449516296,
-0.004791008308529854,
-0.029743744060397148,
0.024485066533088684,
-0.04431422799825668,
-0.04884542152285576,
0.03040887415409088,
0.011369551531970501,
-0.03040887415409088,
0.010933060199022293,
-0.013021981343626976,
0.0299723818898201,
0.005612027365714312,
-0.01923678256571293,
-0.03020101971924305,
0.007332009728997946,
0.027041656896471977,
0.009000028483569622,
0.045935481786727905,
-0.06734433025121689,
-0.007357991300523281,
0.0001094475228455849,
0.07050368934869766,
-0.06455909460783005,
0.06277156621217728,
-0.004341526422649622,
0.05495629459619522,
0.022822244092822075,
0.017002364620566368,
0.003858268726617098,
0.018207911401987076,
-0.0022149321157485247,
-0.03153127804398537,
-0.009659961797297001,
-0.04385695233941078,
-0.037455085664987564,
-0.019995445385575294,
0.00825175829231739,
0.019506990909576416,
-0.03124028444290161,
0.016430769115686417,
0.011660545133054256,
0.025191767141222954,
0.001660224748775363,
-0.06289627403020859,
-0.06900715082883835,
-0.03325645625591278,
-0.0825175866484642,
-0.0035153115168213844,
-0.06618034839630127,
-0.02311323769390583,
0.02172062359750271,
-0.019777199253439903,
-0.0030554370023310184,
-0.011369551531970501,
-0.007176119834184647,
-0.04032345488667488,
0.04788929969072342,
-0.030699867755174637,
-0.004333732184022665,
-0.015994276851415634,
-0.0012445190222933888,
-0.04897013306617737,
-0.04847128689289093,
0.051963213831186295,
0.0010035395389422774,
0.022676747292280197,
0.01038224995136261,
-0.043358106166124344,
-0.04423108696937561,
-0.0002442271215841174,
0.02571139857172966,
0.04175763949751854,
-0.03739272803068161,
-0.05283619835972786,
-0.00007213955541374162,
-0.04872070997953415,
-0.004837775137275457,
-0.04150821641087532,
0.024007005617022514,
-0.045935481786727905,
-0.12163549661636353,
-0.011951539665460587,
-0.04955212026834488,
0.04867913946509361,
-0.03785000741481781,
0.027561288326978683,
0.04265140742063522,
0.0863836482167244,
0.03843199461698532,
0.01149426307529211,
-0.048886992037296295,
0.029307253658771515,
0.024007005617022514,
0.07079468667507172,
-0.05009254068136215,
0.014258706010878086,
-0.036956239491701126,
0.019548561424016953,
-0.03926340490579605,
0.04046895354986191,
-0.010652459226548672,
0.026563595980405807,
0.004803999327123165,
-0.04265140742063522,
-0.022323397919535637,
0.008771390654146671,
-0.04348281770944595,
-0.02714558318257332,
-0.00968074705451727,
-0.032279547303915024,
-0.01829105243086815,
-0.0006294044433161616,
0.02841348573565483,
0.038993194699287415,
0.0806884765625,
-0.061607588082551956,
0.03244583308696747,
-0.05649440735578537,
0.01923678256571293,
0.059030212461948395,
0.030970076099038124,
0.026792233809828758,
-0.0071709235198795795,
-0.005715953651815653,
0.019652487710118294,
0.013354546390473843,
0.0058510578237473965,
-0.05803252011537552,
0.06734433025121689,
0.05932120606303215,
-0.011234447360038757,
-0.02781071327626705,
-0.0498015433549881,
0.0608593188226223,
0.0872981995344162,
0.009623587131500244,
0.019849948585033417,
0.010704422369599342,
0.04385695233941078,
0.025524331256747246,
-0.011837220750749111,
0.019184818491339684,
-0.021990831941366196,
0.048886992037296295,
0.09261923283338547,
-0.020494291558861732,
-0.036291107535362244,
-0.01781298965215683,
0.06327041238546371,
-0.0020668369252234697,
-0.0030164646450430155,
0.03369294852018356,
0.022718317806720734,
0.010257538408041,
0.004164851736277342,
-0.0026059551164507866,
-0.02984767034649849,
0.006599328480660915,
0.050050970166921616,
-0.005565260536968708,
0.06260528415441513,
0.00908836629241705,
-0.062438998371362686,
-0.03234190493822098,
-0.08247601240873337,
-0.003611443331465125,
-0.009566428139805794,
-0.019434241577982903,
0.05167222023010254,
0.0038063055835664272,
-0.0029489125590771437,
0.03953361511230469,
0.04140428826212883,
0.028455056250095367,
0.027852283790707588,
-0.025898465886712074,
0.011650152504444122,
0.030512800440192223,
-0.025565901771187782,
0.028829190880060196,
-0.0047598304226994514,
0.06526579707860947,
0.017854560166597366,
0.028704479336738586,
-0.036041684448719025,
0.05711796507239342,
-0.004190833307802677,
0.011327981017529964,
0.011816435493528843,
0.05848979577422142,
0.043233394622802734,
0.004359713755548,
-0.013167479075491428,
0.004487023688852787,
0.05271148681640625,
0.04435579851269722,
-0.011016201227903366,
0.007565843872725964,
0.0075554512441158295,
0.07748754322528839,
-0.008033513091504574,
0.02182454988360405,
0.0029229307547211647,
0.0002776784240268171,
0.06888243556022644,
-0.0445636548101902,
0.0068643405102193356,
0.005027440842241049,
-0.054083313792943954,
-0.026334958150982857,
0.04177842661738396,
0.05599556118249893,
-0.025420404970645905,
0.03770450875163078,
-0.041923921555280685,
0.03317331522703171,
-0.012107429094612598,
-0.012886877171695232,
-0.04161214083433151,
-0.017979271709918976,
0.01426909863948822,
-0.03678995743393898,
0.07274850457906723,
-0.026563595980405807,
-0.008885709568858147,
0.04772301763296127,
-0.041923921555280685,
-0.029037045314908028,
0.014300276525318623,
0.020130548626184464,
-0.008916887454688549,
0.044064804911613464,
-0.0023500362876802683,
0.028247203677892685,
-0.011608581990003586,
-0.029577462002635002,
-0.010366661474108696,
0.00431034853681922,
-0.051838502287864685,
-0.023445801809430122,
0.019506990909576416,
-0.03730958700180054,
0.00008419664663961157,
0.020837249234318733,
-0.03311096131801605,
0.001062647788785398,
0.02369522675871849,
-0.14158937335014343,
0.03751743957400322,
0.02110745757818222,
0.02970217354595661,
-0.1128225326538086,
-0.002409794135019183,
0.025378834456205368,
-0.001622551353648305,
-0.024588992819190025,
-0.007945175282657146,
-0.04726574197411537,
-0.005253481213003397,
0.021658267825841904,
-0.01396771240979433,
-0.02560747228562832,
-0.023778367787599564,
0.04055209457874298,
-0.04942740872502327,
-0.09627744555473328,
0.008334899321198463,
0.05636969581246376,
0.026127103716135025,
-0.030970076099038124,
0.015391504392027855,
0.0031541672069579363,
-0.014944620430469513,
0.022593606263399124,
-0.03146892413496971,
0.03429572284221649,
-0.030450444668531418,
0.008916887454688549,
0.0010866806842386723,
0.0010782367317005992,
0.037953931838274,
-0.019319923594594002,
-0.028226418420672417,
-0.02298852615058422,
-0.004590949974954128,
-0.0025228140875697136,
0.009753495454788208,
0.002964501501992345,
0.05366760864853859,
-0.01805202104151249,
-0.0412587933242321,
0.02182454988360405,
-0.002938519697636366,
0.0001890161947812885,
0.03913869336247444,
-0.06318727135658264,
0.03774607926607132,
0.01885225437581539,
0.03184305876493454,
-0.008350488729774952,
0.02251046523451805,
0.04668375104665756,
0.04154978692531586,
0.06410182267427444,
0.010418624617159367,
0.0833074226975441,
0.08355685323476791,
0.01055372878909111,
0.007186512462794781,
0.03101164661347866,
0.004237600136548281,
0.02452663704752922,
-0.0511733740568161,
-0.007607414852827787,
0.021637482568621635,
-0.007176119834184647,
0.04065601900219917,
-0.04248512536287308,
0.037808436900377274,
0.027561288326978683,
-0.010512158274650574,
-0.017875345423817635,
0.011452692560851574,
0.003437366569414735,
0.045353494584560394,
-0.039907749742269516,
0.04743202403187752,
-0.003691986436024308,
0.035667549818754196,
-0.05341818556189537,
-0.00337501079775393,
-0.06426810473203659,
0.005934199318289757,
-0.015609749592840672,
0.010127631016075611,
0.010091256350278854,
0.02028643898665905,
0.016940008848905563,
-0.0337345190346241,
0.05587084963917732,
0.01509011723101139,
0.001323113334365189,
-0.05400017276406288,
0.0000186133856914239,
0.04988468810915947,
0.005674383137375116,
-0.028330344706773758,
0.08339056372642517,
-0.025170981884002686,
-0.0018057216657325625,
0.03286153823137283,
-0.01450813002884388,
0.014206742867827415,
-0.06854987144470215,
-0.02855898253619671,
-0.019319923594594002,
-0.04236041381955147,
-0.006204407662153244,
-0.038411207497119904,
0.04414794594049454,
-0.06148287653923035,
-0.01699197106063366,
0.02500469982624054,
-0.03358902037143707,
0.012897269800305367,
-0.04078073054552078,
0.010439409874379635,
0.014466558583080769,
0.01640998385846615,
-0.02533726394176483,
-0.005419763270765543,
0.02724950946867466,
-0.01226331852376461,
-0.011473477818071842,
-0.029328038915991783,
0.06293784826993942,
0.04046895354986191,
0.014965405687689781,
0.05246206000447273,
-0.03807864338159561,
-0.00009808057075133547,
-0.09087327122688293,
-0.02230261266231537,
-0.020587826147675514,
-0.05612027272582054,
0.0076126111671328545,
-0.012970018200576305,
-0.024007005617022514,
0.02475527487695217,
0.008069886825978756,
0.05707639455795288,
0.07694713026285172,
-0.013998890295624733,
-0.05204635486006737,
-0.004775419365614653,
-0.03042965941131115,
-0.014196350239217281,
-0.035064779222011566,
-0.013240227475762367,
0.005310640670359135,
-0.03124028444290161,
0.033214885741472244,
-0.06036046892404556,
0.007664574310183525,
0.01944463513791561,
-0.04152899980545044,
-0.07798638939857483,
-0.04115486517548561,
-0.013219442218542099,
-0.010777170769870281,
0.0662219226360321,
-0.018436549231410027,
-0.0339631587266922,
0.022801458835601807,
0.028101706877350807,
-0.010267931036651134,
-0.00521710654720664,
0.02087881974875927,
0.09336750209331512,
-0.019143247976899147,
-0.010164004750549793,
-0.02336266078054905,
0.027415791526436806,
-0.033069390803575516,
-0.04614333435893059,
0.001348445424810052,
0.0903744250535965,
0.011722900904715061,
-0.09079013019800186,
0.06954756379127502,
0.018000056967139244,
-0.029930811375379562,
0.047348883002996445,
-0.08679935336112976,
0.06838358938694,
-0.02618945948779583,
-0.005617223680019379,
-0.029993167147040367,
0.021741408854722977,
0.03444121778011322,
-0.00657334690913558,
0.02490077167749405,
-0.016358019784092903,
-0.020172119140625,
0.026480454951524734,
0.0363534651696682,
-0.03930497542023659,
-0.01126562524586916,
0.028267988935112953,
0.03805785998702049,
0.008121850900352001,
0.030055522918701172,
-0.04244355484843254,
0.0023214565590023994,
0.02523333765566349,
0.06214800477027893,
0.009036403149366379,
0.009883403778076172,
-0.006724040023982525,
0.05952905863523483,
-0.0727069303393364,
-0.014840694144368172,
0.01503815408796072,
-0.0582403726875782,
-0.059986334294080734,
0.03471142798662186,
0.017054326832294464,
-0.03525184467434883,
-0.05449901893734932,
0.03718487545847893,
0.0013796233106404543,
-0.02018251270055771,
-0.03699781000614166,
0.048762280493974686,
0.05059138685464859,
-0.027644431218504906,
-0.03221719339489937,
0.018436549231410027,
-0.00936896726489067,
-0.04460522532463074,
-0.057866234332323074,
0.02169983834028244,
0.015744853764772415,
-0.010491373017430305,
-0.026709092780947685,
0.03419179469347,
0.015069331973791122,
0.005014450289309025,
-0.01238803006708622,
-0.05179693177342415,
0.035085562616586685,
0.013676717877388,
-0.040843088179826736,
0.047348883002996445,
0.014424988068640232,
-0.018613222986459732,
0.004364910069853067,
-0.00973271019756794,
-0.025170981884002686,
-0.0346490703523159,
0.021491985768079758,
-0.012616668827831745,
0.004577959422022104,
-0.032134052366018295,
-0.037953931838274,
-0.006937089376151562,
-0.019496597349643707,
0.0006690263980999589,
0.009270237758755684,
-0.0049053276889026165,
-0.03207169473171234,
-0.07877623289823532,
0.044397369027137756,
-0.008360881358385086,
-0.018207911401987076,
-0.014165172353386879,
0.03940890356898308,
-0.0032321119215339422,
0.04527035355567932,
0.04448051378130913,
0.003265887964516878,
-0.006245978642255068,
-0.017033541575074196,
-0.0024955333210527897,
0.09669315069913864,
0.018571652472019196,
0.07819424569606781,
-0.0040505328215658665,
-0.004874149337410927,
0.025877680629491806,
0.022261042147874832,
-0.033214885741472244,
0.02192847616970539,
0.023300305008888245,
-0.018020842224359512,
-0.06776003539562225,
-0.05512257665395737,
0.011774864047765732,
0.021970046684145927,
-0.022323397919535637,
0.029577462002635002,
-0.008381666615605354,
-0.025524331256747246,
0.01875871978700161,
0.004489621613174677,
0.04921955615282059,
-0.06958913803100586,
-0.037683721631765366,
0.0030658296309411526,
-0.059030212461948395,
-0.04188235104084015,
-0.02984767034649849,
-0.030138663947582245,
-0.04294240102171898,
-0.030034737661480904,
0.009919777512550354,
0.018800290301442146,
-0.013188264332711697,
0.045935481786727905,
0.016368413344025612,
0.05977848172187805
]
|
30,618 | networkx.classes.function | edge_subgraph | Returns a view of the subgraph induced by the specified edges.
The induced subgraph contains each edge in `edges` and each
node incident to any of those edges.
Parameters
----------
G : NetworkX Graph
edges : iterable
An iterable of edges. Edges not present in `G` are ignored.
Returns
-------
subgraph : SubGraph View
A read-only edge-induced subgraph of `G`.
Changes to `G` are reflected in the view.
Notes
-----
To create a mutable subgraph with its own copies of nodes
edges and attributes use `subgraph.copy()` or `Graph(subgraph)`
If you create a subgraph of a subgraph recursively you can end up
with a chain of subgraphs that becomes very slow with about 15
nested subgraph views. Luckily the edge_subgraph filter nests
nicely so you can use the original graph as G in this function
to avoid chains. We do not rule out chains programmatically so
that odd cases like an `edge_subgraph` of a `restricted_view`
can be created.
Examples
--------
>>> G = nx.path_graph(5)
>>> H = G.edge_subgraph([(0, 1), (3, 4)])
>>> list(H.nodes)
[0, 1, 3, 4]
>>> list(H.edges)
[(0, 1), (3, 4)]
| def edge_subgraph(G, edges):
"""Returns a view of the subgraph induced by the specified edges.
The induced subgraph contains each edge in `edges` and each
node incident to any of those edges.
Parameters
----------
G : NetworkX Graph
edges : iterable
An iterable of edges. Edges not present in `G` are ignored.
Returns
-------
subgraph : SubGraph View
A read-only edge-induced subgraph of `G`.
Changes to `G` are reflected in the view.
Notes
-----
To create a mutable subgraph with its own copies of nodes
edges and attributes use `subgraph.copy()` or `Graph(subgraph)`
If you create a subgraph of a subgraph recursively you can end up
with a chain of subgraphs that becomes very slow with about 15
nested subgraph views. Luckily the edge_subgraph filter nests
nicely so you can use the original graph as G in this function
to avoid chains. We do not rule out chains programmatically so
that odd cases like an `edge_subgraph` of a `restricted_view`
can be created.
Examples
--------
>>> G = nx.path_graph(5)
>>> H = G.edge_subgraph([(0, 1), (3, 4)])
>>> list(H.nodes)
[0, 1, 3, 4]
>>> list(H.edges)
[(0, 1), (3, 4)]
"""
nxf = nx.filters
edges = set(edges)
nodes = set()
for e in edges:
nodes.update(e[:2])
induced_nodes = nxf.show_nodes(nodes)
if G.is_multigraph():
if G.is_directed():
induced_edges = nxf.show_multidiedges(edges)
else:
induced_edges = nxf.show_multiedges(edges)
else:
if G.is_directed():
induced_edges = nxf.show_diedges(edges)
else:
induced_edges = nxf.show_edges(edges)
return nx.subgraph_view(G, filter_node=induced_nodes, filter_edge=induced_edges)
| (G, edges) | [
0.038835376501083374,
-0.04053673893213272,
-0.01652352884411812,
0.008072210475802422,
-0.054739389568567276,
-0.006074962671846151,
0.008733336813747883,
0.00047330616507679224,
0.10844317078590393,
-0.050522975623607635,
0.029034068807959557,
0.029496394097805023,
-0.020249875262379646,
0.030532004311680794,
-0.036967579275369644,
0.022616984322667122,
-0.020564258098602295,
-0.008964499458670616,
0.07249270379543304,
0.06731465458869934,
-0.03730045631527901,
-0.08210908621549606,
0.034434035420417786,
0.013805052265524864,
-0.024170398712158203,
0.04612163454294205,
0.007466563489288092,
-0.013065330684185028,
0.0346374586224556,
-0.03278815373778343,
-0.02614915370941162,
-0.05566404014825821,
-0.062247563153505325,
-0.003800319042056799,
0.000585131230764091,
0.04845175892114639,
-0.02344917133450508,
0.04967229813337326,
-0.04005591943860054,
0.034508008509874344,
-0.026629973202943802,
-0.04993119835853577,
0.0517435185611248,
-0.03802168369293213,
0.02507655881345272,
-0.0027092299424111843,
0.012926632538437843,
0.013425945304334164,
-0.018224887549877167,
-0.012612251564860344,
0.027240242809057236,
-0.02117452770471573,
-0.022265616804361343,
0.0016736198449507356,
-0.000179584720171988,
0.030384059995412827,
0.010633496567606926,
0.04020386189222336,
0.06465166062116623,
0.014840662479400635,
-0.02383752539753914,
-0.06657493114471436,
-0.007119819056242704,
0.020323848351836205,
-0.033916231244802475,
-0.0048914081417024136,
-0.05337090417742729,
-0.04068468138575554,
-0.06731465458869934,
0.026019703596830368,
-0.06054620444774628,
0.02439231611788273,
0.0060379765927791595,
-0.03524772822856903,
-0.002327810972929001,
-0.002349771559238434,
-0.02777654118835926,
0.024614231660962105,
-0.015247508883476257,
-0.023430677130818367,
0.061766743659973145,
-0.023856017738580704,
-0.0145447738468647,
0.0189923495054245,
0.09468434751033783,
-0.013037591241300106,
0.0004192718188278377,
-0.006162804551422596,
-0.011872529983520508,
-0.02228410914540291,
0.01947316713631153,
0.0011263415217399597,
-0.03119775280356407,
0.025206008926033974,
-0.017577631399035454,
-0.01414717361330986,
-0.038724418729543686,
-0.040906596928834915,
-0.004868291784077883,
-0.06516946107149124,
0.014692718163132668,
0.01696736179292202,
-0.061766743659973145,
0.016107434406876564,
0.0001389867247780785,
-0.05355583503842354,
-0.0132502606138587,
-0.00727238692343235,
-0.005307501647621393,
-0.0670187696814537,
0.0045654685236513615,
0.0618407167494297,
0.016236886382102966,
0.033158015459775925,
0.005228906404227018,
0.033398423343896866,
0.008733336813747883,
-0.0487106591463089,
0.022358082234859467,
-0.040869612246751785,
-0.010171170346438885,
0.04926545172929764,
-0.04545588418841362,
0.04105454310774803,
0.016088942065835,
0.010975617915391922,
0.003777202917262912,
0.005885409191250801,
0.01665298081934452,
-0.06332015991210938,
0.035266220569610596,
0.010494798421859741,
-0.015127304010093212,
0.021914249286055565,
0.03202994167804718,
-0.03223336488008499,
-0.005289008375257254,
0.01188177615404129,
0.04231206700205803,
0.03842853009700775,
-0.06620506942272186,
-0.019917000085115433,
0.0189923495054245,
0.08107347786426544,
-0.015404700301587582,
-0.02920050546526909,
0.033953215926885605,
0.010799933224916458,
0.047896966338157654,
0.008030601777136326,
-0.035025812685489655,
0.01027288194745779,
-0.005094831809401512,
-0.029145026579499245,
0.008978369645774364,
-0.02725873701274395,
-0.05296405777335167,
0.05877087265253067,
0.0019082502694800496,
0.01693037524819374,
-0.04760107770562172,
-0.0129358796402812,
-0.039907973259687424,
0.005071715451776981,
-0.00626913970336318,
-0.01309307012706995,
0.06920094788074493,
-0.01712455227971077,
-0.026796409860253334,
0.033195000141859055,
-0.00011818206257885322,
-0.014489294961094856,
-0.09290901571512222,
-0.0333799310028553,
-0.016024217009544373,
0.058548957109451294,
0.06025031581521034,
0.047786008566617966,
-0.01784578152000904,
0.04760107770562172,
0.03715251013636589,
-0.04312576353549957,
-0.026371071115136147,
0.010762947611510754,
0.041387416422367096,
0.01513655111193657,
0.012251636944711208,
-0.009681104682385921,
0.04053673893213272,
-0.04856271669268608,
-0.013555396348237991,
-0.02193274162709713,
0.013971489854156971,
0.03441554307937622,
0.009329737164080143,
-0.054739389568567276,
-0.06084209308028221,
0.004119324032217264,
-0.02404094859957695,
0.07419406622648239,
0.0021833342034369707,
0.0057975673116743565,
0.04712025821208954,
0.01285266038030386,
0.004634817596524954,
0.040906596928834915,
0.036338817328214645,
-0.059547580778598785,
-0.031142273917794228,
0.002968132495880127,
-0.054776374250650406,
-0.037374429404735565,
0.0927610769867897,
-0.02944091521203518,
-0.026315592229366302,
0.004301942884922028,
-0.03639429807662964,
0.014572513289749622,
-0.01866872049868107,
-0.006384721025824547,
0.02348615787923336,
-0.01573757454752922,
-0.023023830726742744,
-0.0018215641612187028,
0.03217788413167,
-0.08817479759454727,
0.029422422870993614,
-0.0294039286673069,
0.015460179187357426,
-0.057439371943473816,
0.037984699010849,
-0.0008073366479948163,
0.05725444108247757,
-0.04438328742980957,
-0.03147514909505844,
0.08173922449350357,
-0.01247355341911316,
-0.018335847184062004,
0.07981594651937485,
0.03487786650657654,
-0.03659772127866745,
-0.07312146574258804,
-0.03245528042316437,
0.0020400132052600384,
0.002977378899231553,
-0.009570146910846233,
-0.018150916323065758,
0.03607991710305214,
0.004052286967635155,
-0.009866035543382168,
-0.03667169436812401,
-0.02483614906668663,
-0.004919148050248623,
0.017697837203741074,
0.022838899865746498,
0.03722648322582245,
-0.07075435668230057,
-0.04312576353549957,
-0.0008662831969559193,
-0.004295007791370153,
0.00213132263161242,
0.020323848351836205,
-0.026075182482600212,
0.04131344333291054,
0.02725873701274395,
-0.0051919203251600266,
0.0033634211868047714,
0.006495679263025522,
-0.0401298888027668,
-0.008571522310376167,
0.014165665954351425,
0.06624206155538559,
0.023375198245048523,
0.0001086465927073732,
0.01350916363298893,
-0.0010922449873760343,
-0.002688425360247493,
0.0324367880821228,
-0.014988606795668602,
-0.012972865253686905,
-0.05562705546617508,
0.01509956456720829,
-0.05274214223027229,
0.05433254316449165,
-0.009251141920685768,
-0.04752710461616516,
0.03755935654044151,
-0.024503273889422417,
0.014470801688730717,
-0.02359711565077305,
0.07201188802719116,
-0.05840101093053818,
0.052631184458732605,
0.0290895476937294,
-0.0035992073826491833,
0.06402289122343063,
0.0049931202083826065,
-0.051040783524513245,
0.027480652555823326,
0.04064769670367241,
0.09128163009881973,
-0.001798447803594172,
0.012806428596377373,
0.007767075672745705,
0.04201618209481239,
-0.0197505634278059,
0.0031692441552877426,
-0.013583135791122913,
0.008173922076821327,
-0.006454070098698139,
-0.06842423975467682,
-0.015034839510917664,
-0.05510925129055977,
-0.020730694755911827,
-0.06132291257381439,
-0.020434806123375893,
-0.011511915363371372,
-0.0321224071085453,
0.0060379765927791595,
0.029311463236808777,
0.0000216534681385383,
0.0713091492652893,
-0.023504650220274925,
0.05333391949534416,
-0.021673839539289474,
0.06598315387964249,
0.01295437291264534,
0.06084209308028221,
0.030384059995412827,
0.007956629619002342,
-0.04501205310225487,
-0.0068146842531859875,
0.004611701238900423,
0.026814904063940048,
-0.03791072592139244,
0.034544993191957474,
0.062321536242961884,
0.013000604696571827,
-0.006648246664553881,
-0.022543013095855713,
0.052039407193660736,
0.03140117600560188,
-0.014711211435496807,
-0.008811932057142258,
0.0327511690557003,
0.03293609991669655,
0.009019979275763035,
-0.03140117600560188,
-0.0037656447384506464,
0.0062090372666716576,
0.014110187068581581,
0.03251075744628906,
-0.019565632566809654,
-0.01251978613436222,
-0.02196972817182541,
-0.007767075672745705,
-0.018012218177318573,
-0.006944135297089815,
-0.014443062245845795,
0.008608508855104446,
0.02836831845343113,
0.026019703596830368,
-0.005561781115829945,
-0.0642448142170906,
0.023578621447086334,
-0.024429302662611008,
-0.024891627952456474,
0.07981594651937485,
-0.020249875262379646,
-0.05655170604586601,
-0.014267378486692905,
-0.048858605325222015,
-0.0023070063907653093,
0.026925861835479736,
0.016588253900408745,
0.012103692628443241,
-0.04160933196544647,
0.00883967150002718,
0.029903240501880646,
0.07182695716619492,
0.01468347106128931,
-0.0004169601888861507,
0.028238868340849876,
0.012686223722994328,
0.08210908621549606,
-0.02452176809310913,
0.02320876158773899,
0.007665364071726799,
0.057291429489851,
-0.011225273832678795,
-0.06187770143151283,
0.005372227169573307,
0.03254774585366249,
0.016514282673597336,
-0.020471792668104172,
-0.05877087265253067,
0.058511968702077866,
0.00031784907332621515,
0.004156310111284256,
0.01070746872574091,
-0.035821013152599335,
0.0538887083530426,
-0.027369694784283638,
0.03726346790790558,
0.050485990941524506,
-0.011031096801161766,
0.0324922651052475,
0.03700456768274307,
0.0517435185611248,
-0.06235852092504501,
0.03151213377714157,
-0.014369090087711811,
-0.03171555697917938,
0.051003795117139816,
0.03759634494781494,
0.02356012910604477,
0.010661236010491848,
0.021784797310829163,
0.02988474816083908,
-0.0047087897546589375,
0.04068468138575554,
0.017180031165480614,
0.03791072592139244,
-0.02701832726597786,
0.0002782624214887619,
-0.05011612921953201,
-0.06002839654684067,
0.009158676490187645,
-0.01708756573498249,
0.08255291730165482,
-0.022672463208436966,
-0.0845501646399498,
-0.00800286140292883,
-0.02158137410879135,
-0.02065672166645527,
-0.012066707015037537,
0.0026005832478404045,
0.016431063413619995,
-0.001626231474801898,
0.044050414115190506,
0.009019979275763035,
0.01982453651726246,
-0.010356101207435131,
-0.07626528292894363,
0.04501205310225487,
-0.06339412927627563,
-0.025446418672800064,
0.0731954425573349,
0.03500732034444809,
-0.049487367272377014,
0.031179260462522507,
-0.004105454310774803,
0.01508107129484415,
-0.034914854913949966,
-0.09860487282276154,
-0.0028132533188909292,
0.03648676350712776,
0.045751772820949554,
-0.06494754552841187,
0.0692749172449112,
0.006537288427352905,
-0.017069073393940926,
-0.027869006618857384,
-0.006370851304382086,
0.017503660172224045,
-0.015423192642629147,
0.06772150099277496,
0.003758709877729416,
-0.0648735761642456,
-0.006934889126569033,
0.04963530972599983,
-0.03251075744628906,
-0.07023655623197556,
-0.02503957226872444,
0.08358852565288544,
0.024780670180916786,
-0.05806813761591911,
-0.01086465921252966,
-0.026001209393143654,
-0.04393945634365082,
-0.014655731618404388,
-0.009010732173919678,
0.010171170346438885,
0.01452628057450056,
0.0013488358817994595,
0.011160547845065594,
0.01812317594885826,
0.04061070829629898,
-0.05418459698557854,
-0.014664978720247746,
0.0164033230394125,
-0.028627220541238785,
-0.08980219066143036,
0.011974241584539413,
0.03012515790760517,
0.029625846073031425,
-0.036098409444093704,
-0.007545159198343754,
0.04068468138575554,
-0.03436006233096123,
0.00824327114969492,
-0.04231206700205803,
0.03241829574108124,
0.008118443191051483,
0.017771808430552483,
0.023153282701969147,
-0.016856404021382332,
0.04589971899986267,
0.05518322438001633,
-0.03509978577494621,
0.01452628057450056,
-0.009010732173919678,
-0.0064679398201406,
0.040388792753219604,
0.05840101093053818,
0.0116413664072752,
-0.008927513845264912,
0.028941603377461433,
0.05011612921953201,
-0.025797786191105843,
0.02117452770471573,
0.0076607405208051205,
0.009486927650868893,
0.032529253512620926,
0.01609818823635578,
0.025132037699222565,
-0.015090318396687508,
-0.0023786670062690973,
0.0049931202083826065,
0.01446155458688736,
-0.022321095690131187,
0.08218305557966232,
-0.0048775384202599525,
0.09120766073465347,
0.006158181466162205,
-0.03162309154868126,
-0.002228410914540291,
-0.02992173470556736,
-0.01660674810409546,
0.01875193975865841,
0.009681104682385921,
0.06062017381191254,
-0.0035298585426062346,
0.04190522059798241,
-0.013139302842319012,
-0.029348449781537056,
0.06605713069438934,
-0.005964004434645176,
0.039907973259687424,
-0.04545588418841362,
-0.03234432265162468,
0.02833133190870285,
0.03528471291065216,
-0.0020168968476355076,
0.018973855301737785,
-0.007619131356477737,
-0.03428608924150467,
0.04264494404196739,
-0.04549287259578705,
-0.011216026730835438,
-0.024706697091460228,
-0.0060102371498942375,
0.006578898057341576,
-0.004766580183058977,
0.027647091075778008,
0.021803291514515877,
0.041461389511823654,
0.005487808957695961,
-0.007998238317668438,
0.005547910928726196,
-0.04186823591589928,
-0.024743683636188507,
0.01005096547305584,
-0.0011985800229012966,
-0.024410808458924294,
0.01468347106128931,
0.006255269981920719,
0.01835433952510357,
0.02975529618561268,
-0.015016346238553524,
-0.04349562153220177,
-0.053703781217336655,
0.011807803995907307,
0.030772414058446884,
0.015266002155840397,
0.04982024058699608,
0.030975837260484695,
0.03095734491944313,
-0.03707854077219963,
-0.01110506895929575,
0.033638834953308105,
-0.045714788138866425,
0.058474984019994736,
0.0189923495054245,
0.0064679398201406,
-0.020453298464417458,
-0.029810775071382523,
-0.003777202917262912,
-0.01527524832636118,
-0.03730045631527901,
-0.07744883745908737,
0.020971104502677917,
0.07304749637842178,
0.008187792263925076,
-0.025279982015490532,
-0.02428135834634304,
0.04689834266901016,
-0.03846551850438118,
0.026851890608668327,
-0.04982024058699608,
-0.0286457147449255,
0.06820232421159744,
-0.00943607185035944,
-0.027240242809057236,
-0.02037932723760605,
-0.012186911888420582,
-0.06502151489257812,
0.07108723372220993,
-0.0465654656291008,
-0.012982112355530262,
-0.005788320675492287,
0.02992173470556736,
-0.03957509994506836,
-0.03269568830728531,
-0.019898507744073868,
0.05951059237122536,
0.025261487811803818,
-0.005390720441937447,
-0.03994496166706085,
0.010078704915940762,
0.02134096436202526,
-0.07641322910785675,
-0.0051919203251600266,
0.056440748274326324,
0.035580601543188095,
-0.12767592072486877,
-0.006417084019631147,
0.0033241233322769403,
-0.03702306002378464,
0.057439371943473816,
-0.058031149208545685,
0.012723209336400032,
-0.04604766145348549,
-0.0034674445632845163,
-0.03436006233096123,
0.00587153946980834,
-0.027647091075778008,
-0.05888183042407036,
0.02511354349553585,
-0.01110506895929575,
0.028479276224970818,
0.06254345178604126,
0.03946414217352867,
0.003116076812148094,
-0.021156033501029015,
0.06772150099277496,
0.056440748274326324,
-0.0422750823199749,
0.023190269246697426,
0.0016967362025752664,
0.06779547035694122,
-0.019140293821692467,
0.04286685958504677,
-0.01951015368103981,
0.04386548325419426,
0.016468049958348274,
0.008557653054594994,
-0.022117672488093376,
0.01772557571530342,
-0.015506411902606487,
-0.0011240298626944423,
-0.06964477896690369,
-0.042496997863054276,
-0.011308492161333561,
-0.05865991488099098,
-0.042533986270427704,
0.03075391985476017,
-0.032603222876787186,
-0.025686828419566154,
-0.011780064553022385,
-0.01919577270746231,
0.04586273059248924,
-0.0008368099224753678,
-0.04331069439649582,
-0.031604599207639694,
-0.023356705904006958,
-0.05973250791430473,
-0.02117452770471573,
0.015284495428204536,
-0.036819636821746826,
0.02034234069287777,
-0.07460091263055801,
0.018603995442390442,
-0.005446199327707291,
-0.007161428686231375,
0.009463811293244362,
0.01549716480076313,
0.014350596815347672,
-0.004426770843565464,
-0.030180636793375015,
0.02920050546526909,
0.0165327750146389,
0.009093951433897018,
0.04930243641138077,
-0.005460069049149752,
-0.031290218234062195,
-0.07959403097629547,
0.007105949334800243,
-0.0016967362025752664,
-0.021119048818945885,
-0.031456656754016876,
-0.05547911301255226,
0.05732841417193413,
0.007142935413867235,
0.05344487726688385,
-0.05089283734560013,
-0.022616984322667122,
0.00806758739054203,
-0.051521603018045425,
0.024614231660962105,
0.030328581109642982,
-0.006504925899207592,
0.01661599427461624,
0.05673663690686226,
-0.0395011268556118,
0.061692770570516586,
0.04186823591589928,
-0.022358082234859467,
0.011354724876582623,
-0.018446804955601692,
-0.027314215898513794,
0.06479959934949875,
0.01958412677049637,
0.04279288649559021,
-0.026629973202943802,
-0.020564258098602295,
-0.06254345178604126,
0.0007570587331429124,
-0.00506709236651659,
-0.017623864114284515,
0.035229235887527466,
-0.021303977817296982,
-0.04375452548265457,
-0.0008726401720196009,
-0.053629808127880096,
0.003546039806678891,
0.025853265076875687,
0.044013429433107376,
-0.004258021712303162,
-0.008557653054594994,
0.0113269854336977,
0.021784797310829163,
-0.023578621447086334,
-0.01923275925219059,
0.018816664814949036,
0.0075035495683550835,
-0.026445042341947556,
-0.06036127358675003,
-0.0545174740254879,
-0.05951059237122536,
-0.04319973289966583,
0.028164895251393318,
0.01915878616273403,
-0.00885816477239132,
-0.023338213562965393,
0.06417083740234375,
0.029533380642533302,
0.038687434047460556
]
|
30,622 | networkx.classes.function | edges | Returns an edge view of edges incident to nodes in nbunch.
Return all edges if nbunch is unspecified or nbunch=None.
For digraphs, edges=out_edges
This function wraps the :func:`G.edges <networkx.Graph.edges>` property.
| def edges(G, nbunch=None):
"""Returns an edge view of edges incident to nodes in nbunch.
Return all edges if nbunch is unspecified or nbunch=None.
For digraphs, edges=out_edges
This function wraps the :func:`G.edges <networkx.Graph.edges>` property.
"""
return G.edges(nbunch)
| (G, nbunch=None) | [
0.02328922040760517,
-0.04444832727313042,
-0.01364158932119608,
-0.03653141111135483,
-0.07945316284894943,
0.007109247148036957,
-0.0023564358707517385,
-0.0019625872373580933,
0.07363085448741913,
-0.021531878039240837,
0.011094330810010433,
-0.016082342714071274,
0.0050146374851465225,
0.012106133624911308,
0.028436988592147827,
0.02224191464483738,
-0.02950204536318779,
-0.052826765924692154,
0.03823550045490265,
0.05779702588915825,
-0.04267323389649391,
-0.0795951709151268,
0.018656227737665176,
-0.023040706291794777,
-0.057051487267017365,
0.04011709988117218,
0.008258620277047157,
-0.025188568979501724,
-0.0041892193257808685,
0.033140987157821655,
-0.056199442595243454,
-0.08733457326889038,
-0.04469684138894081,
-0.030797863379120827,
0.046968959271907806,
0.018159201368689537,
-0.0005846712156198919,
0.03713494539260864,
-0.06074368208646774,
0.05296877399086952,
-0.000370550638763234,
-0.02831273339688778,
0.02934228628873825,
-0.01104107778519392,
0.023697491735219955,
-0.012789544649422169,
0.06763104349374771,
-0.040188103914260864,
0.01920650526881218,
-0.03417053818702698,
0.016224348917603493,
-0.0019581494852900505,
-0.005143331829458475,
0.0009247124544344842,
0.011857620440423489,
-0.0027136732824146748,
-0.028010966256260872,
0.028916263952851295,
0.009141728281974792,
0.0364249087870121,
-0.06933513283729553,
-0.04334776848554611,
0.07519293576478958,
0.02396375499665737,
-0.010082527995109558,
0.04551338404417038,
-0.07061319798231125,
0.018407713621854782,
-0.0030930994544178247,
0.005964312236756086,
-0.005072328262031078,
0.012967053800821304,
-0.04125316068530083,
0.025827601552009583,
-0.015141543000936508,
-0.013153438456356525,
-0.046791449189186096,
0.06063717603683472,
-0.025011058896780014,
-0.018425464630126953,
0.0236087366938591,
0.02747843973338604,
-0.03418828919529915,
0.02442527934908867,
0.12198438495397568,
-0.006794168148189783,
-0.003756540361791849,
0.02561459131538868,
0.008742332458496094,
-0.005653670988976955,
0.02715892158448696,
-0.008915404789149761,
-0.0472174733877182,
0.013135687448084354,
-0.015647444874048233,
-0.00313969561830163,
-0.08087323606014252,
0.04132416471838951,
0.0033704577945172787,
-0.06202174723148346,
-0.030975371599197388,
-0.008258620277047157,
-0.005560478661209345,
0.047430481761693954,
-0.018993495032191277,
-0.060424163937568665,
-0.02644888497889042,
-0.023555483669042587,
-0.012949302792549133,
-0.03674442321062088,
-0.00880002323538065,
0.07448290288448334,
0.03386877477169037,
-0.0445193313062191,
-0.0007211315096355975,
0.05591542646288872,
0.024673791602253914,
-0.04853104054927826,
0.0007189126336015761,
0.0011649047955870628,
-0.04370278865098953,
0.03791598603129387,
-0.012239266186952591,
0.047607991844415665,
0.0033327369019389153,
0.006190636660903692,
-0.03218243643641472,
0.008254182524979115,
0.01853197067975998,
-0.06638847291469574,
0.09954721480607986,
0.0006667692796327174,
-0.038697026669979095,
0.01791956275701523,
-0.03837750852108002,
0.0002336743491468951,
-0.004828252829611301,
0.002218866255134344,
0.06507490575313568,
0.022383922711014748,
-0.06269628554582596,
-0.029377788305282593,
0.02289869822561741,
0.07008066773414612,
-0.04771449789404869,
-0.016534991562366486,
0.02123011089861393,
0.02123011089861393,
0.022863198071718216,
0.005888870917260647,
-0.01178661733865738,
0.015807202085852623,
0.0030065637547522783,
-0.040401116013526917,
0.006825232412666082,
0.00757964700460434,
-0.03424154222011566,
0.05449535325169563,
-0.0030598165467381477,
-0.012691915035247803,
-0.07391487061977386,
0.013845724985003471,
-0.03275046497583389,
-0.0026803903747349977,
-0.0024629414547234774,
0.020981598645448685,
0.07167825102806091,
0.013162313960492611,
0.01918875426054001,
0.022667936980724335,
-0.001134950085543096,
0.005214335396885872,
-0.06379684060811996,
-0.02561459131538868,
0.01670362427830696,
0.05051914602518082,
0.049809109419584274,
0.05769051983952522,
0.012833922170102596,
0.047785501927137375,
-0.004890380892902613,
-0.030975371599197388,
-0.004473234061151743,
-0.05044814199209213,
0.0508386604487896,
-0.03248419985175133,
-0.0016341949813067913,
-0.03149014711380005,
-0.03356700763106346,
-0.053181786090135574,
-0.03392202779650688,
-0.012878299690783024,
0.02817072533071041,
0.03287472203373909,
-0.0023630924988538027,
-0.0331764854490757,
-0.0678795576095581,
0.04842453449964523,
-0.054353345185518265,
-0.01869172789156437,
-0.005347467493265867,
0.0034148350823670626,
0.002041356870904565,
-0.014582389034330845,
0.025561338290572166,
0.02004079893231392,
-0.00904853641986847,
-0.08279033750295639,
0.016162220388650894,
-0.010854693129658699,
0.0030598165467381477,
-0.01938401535153389,
0.03560836613178253,
-0.0073932623490691185,
0.020182806998491287,
0.05548940598964691,
-0.01172448880970478,
-0.0020979379769414663,
-0.02225966565310955,
-0.016614869236946106,
-0.02376849390566349,
-0.06053066998720169,
0.010881319642066956,
-0.02059107832610607,
-0.00406718160957098,
-0.046436432749032974,
-0.006949489004909992,
-0.0273186806589365,
0.01153810415416956,
-0.03248419985175133,
-0.0038719214498996735,
0.0176000464707613,
-0.0030864428263157606,
-0.02678615227341652,
0.006097444333136082,
0.11033977568149567,
-0.025241822004318237,
-0.004182562697678804,
0.04522936791181564,
0.020963847637176514,
-0.02392825298011303,
-0.01761779747903347,
-0.053856320679187775,
0.01906449906527996,
0.04480334743857384,
0.021833643317222595,
0.0050323884934186935,
-0.020094051957130432,
0.01854972168803215,
0.030762361362576485,
-0.039513569325208664,
-0.04764349386096001,
0.021443122997879982,
-0.03392202779650688,
-0.0012869423953816295,
0.005085641518235207,
-0.07533494383096695,
0.009221607819199562,
0.0027425186708569527,
0.0044710151851177216,
0.05900409072637558,
0.004739498253911734,
-0.02007630094885826,
0.052152231335639954,
0.04107565060257912,
0.04547788202762604,
0.010348792187869549,
-0.04214070737361908,
-0.06550092995166779,
-0.009763010777533054,
0.030904367566108704,
-0.018620725721120834,
-0.025667844340205193,
-0.009399116970598698,
0.004093808121979237,
0.03221793845295906,
-0.020484572276473045,
0.059927139431238174,
-0.05946561321616173,
-0.026093866676092148,
-0.018443215638399124,
0.013925604522228241,
-0.017573419958353043,
0.029590798541903496,
-0.03491607680916786,
0.00013472678256221116,
-0.006337082013487816,
0.0009230483556166291,
0.02596960961818695,
-0.048637546598911285,
0.12887175381183624,
-0.016321979463100433,
-0.00024976112763397396,
-0.004575301893055439,
0.048992566764354706,
0.022472675889730453,
0.01097007468342781,
-0.02565009333193302,
0.02446078136563301,
0.06617546826601028,
0.09656505286693573,
-0.06649497896432877,
0.05577342212200165,
0.02646663598716259,
0.006394772324711084,
0.0331764854490757,
0.04015260189771652,
0.0033748955465853214,
0.02900501899421215,
-0.027886711061000824,
-0.09876617044210434,
-0.03594563156366348,
-0.024744795635342598,
-0.06312230229377747,
-0.07455390691757202,
-0.052152231335639954,
-0.0036788801662623882,
0.001719621242955327,
-0.011404972523450851,
-0.025224070996046066,
-0.011511477641761303,
0.07004516571760178,
-0.0002686214866116643,
0.003989521414041519,
-0.00762402405962348,
0.10593754798173904,
0.007570771500468254,
0.04604591056704521,
0.017511291429400444,
0.0026803903747349977,
0.002675952622666955,
-0.03990408778190613,
-0.019277509301900864,
0.09315688163042068,
-0.020094051957130432,
0.03976208344101906,
0.075547955930233,
0.03202267736196518,
-0.036637917160987854,
-0.058755576610565186,
0.01938401535153389,
0.06898011267185211,
-0.017910687252879143,
0.00762402405962348,
0.07384386658668518,
0.038342006504535675,
-0.010215659625828266,
-0.005165520589798689,
0.0031862917821854353,
0.0559864304959774,
-0.008192053996026516,
0.05186821520328522,
0.009754136204719543,
-0.020023047924041748,
0.02273894101381302,
0.04444832727313042,
-0.0018649570411071181,
-0.018478717654943466,
0.008902091532945633,
0.02412351407110691,
0.023147212341427803,
0.05460185930132866,
-0.005045701749622822,
-0.0242832712829113,
0.05005761981010437,
0.010233410634100437,
-0.009328113868832588,
0.03891003876924515,
0.029892565682530403,
-0.013819098472595215,
-0.025188568979501724,
-0.0030465032905340195,
-0.04388029873371124,
-0.007215752732008696,
0.01138722151517868,
-0.011058828793466091,
0.01559419184923172,
0.012940427288413048,
0.049631599336862564,
0.061098698526620865,
-0.04689795523881912,
0.026608644053339958,
0.016810130327939987,
0.01002039946615696,
0.06088568642735481,
-0.012629786506295204,
-0.0044044493697583675,
0.03812899813055992,
0.047785501927137375,
-0.03983308747410774,
-0.011236337944865227,
0.00012078952568117529,
-0.00021148569067008793,
0.03486282378435135,
-0.03922955319285393,
-0.057726021856069565,
0.056412454694509506,
0.011378346011042595,
-0.006026440765708685,
-0.011830994859337807,
-0.03356700763106346,
0.061276208609342575,
-0.015745073556900024,
0.03583912551403046,
-0.012860548682510853,
-0.03788048401474953,
0.015026161447167397,
-0.05169070512056351,
0.08335836231708527,
-0.0809442400932312,
0.02227741666138172,
0.028383735567331314,
-0.05662546679377556,
0.0242832712829113,
0.050341635942459106,
0.004632992669939995,
0.019437268376350403,
0.03349600359797478,
0.054637361317873,
0.015727324411273003,
0.03544860705733299,
-0.004961384925991297,
0.036815427243709564,
0.028703253716230392,
0.030265334993600845,
-0.0039384872652590275,
-0.0377739779651165,
0.0003278374788351357,
-0.011156459338963032,
0.023235967382788658,
-0.002156737959012389,
-0.021957900375127792,
-0.011937499977648258,
-0.03354925662279129,
0.007810409180819988,
-0.027851209044456482,
0.008391751907765865,
-0.0559864304959774,
0.008835525251924992,
0.015611942857503891,
-0.017431411892175674,
-0.011777741834521294,
-0.0008115503005683422,
-0.030904367566108704,
0.06866059452295303,
-0.0778200775384903,
-0.0014023234834894538,
0.007371073588728905,
0.07384386658668518,
-0.05708698928356171,
0.004080494865775108,
-0.06116970255970955,
0.0018372212070971727,
-0.03101087361574173,
-0.056199442595243454,
0.01752016693353653,
0.02092834562063217,
0.01280729565769434,
-0.05747751146554947,
0.04668494313955307,
0.015132667496800423,
-0.022206412628293037,
-0.04217620939016342,
-0.009159479290246964,
-0.027567192912101746,
0.009399116970598698,
0.04757248982787132,
-0.02849024161696434,
-0.04831802845001221,
-0.0050501395016908646,
0.030283086001873016,
-0.05374981462955475,
-0.047785501927137375,
-0.05946561321616173,
0.06280279159545898,
0.0424957238137722,
-0.033442750573158264,
-0.025543587282299995,
-0.0012636443134397268,
-0.0352000929415226,
0.011981877498328686,
-0.008294121362268925,
0.02073308639228344,
-0.0127096651121974,
-0.03727695345878601,
0.026502138003706932,
-0.03383327275514603,
0.00852044578641653,
-0.07803308963775635,
-0.031241636723279953,
0.04011709988117218,
-0.01095232367515564,
-0.052365243434906006,
-0.018744980916380882,
0.07448290288448334,
0.07774907350540161,
0.0323776938021183,
-0.01936626434326172,
0.014049860648810863,
-0.005560478661209345,
-0.016162220388650894,
0.021176859736442566,
0.02999907173216343,
-0.008152114227414131,
-0.044235315173864365,
-0.03560836613178253,
0.014724396169185638,
0.04050762206315994,
0.04810502007603645,
0.034809574484825134,
0.059075094759464264,
0.002511756494641304,
0.04214070737361908,
0.03525334596633911,
0.021283363923430443,
0.02108810469508171,
-0.003993959166109562,
-0.003361582290381193,
0.029058272019028664,
0.05950111523270607,
0.02004079893231392,
0.023324720561504364,
0.02479804866015911,
0.048992566764354706,
-0.00586224440485239,
0.03891003876924515,
0.02160288207232952,
0.007899163290858269,
0.013508457690477371,
0.0019259758992120624,
0.020023047924041748,
0.05339479446411133,
0.02442527934908867,
0.09152378886938095,
-0.031241636723279953,
-0.028046468272805214,
0.010765939019620419,
0.021017100661993027,
-0.004504298325628042,
0.04210520535707474,
-0.025561338290572166,
-0.00045680906623601913,
0.00703824358060956,
0.07625799626111984,
-0.0613827146589756,
-0.006341519765555859,
0.025082062929868698,
0.041395168751478195,
0.05793903395533562,
-0.05747751146554947,
-0.016854507848620415,
0.021549629047513008,
0.029573049396276474,
-0.003082005074247718,
0.008942030370235443,
-0.019419517368078232,
-0.021815892308950424,
0.04785650596022606,
-0.0028934015426784754,
-0.018079321831464767,
-0.07434089481830597,
-0.03926505520939827,
-0.05793903395533562,
-0.01097007468342781,
0.025827601552009583,
0.015647444874048233,
-0.0023497792426496744,
-0.017245028167963028,
0.006856296677142382,
0.03253745287656784,
-0.020857341587543488,
-0.018123699352145195,
0.0202360600233078,
-0.04082713648676872,
0.009141728281974792,
0.010561803355813026,
-0.05339479446411133,
0.025685595348477364,
0.009692007675766945,
-0.052826765924692154,
-0.020644331350922585,
-0.04107565060257912,
-0.026910409331321716,
0.0014833119930699468,
-0.03049609623849392,
0.02662639506161213,
-0.03180966526269913,
-0.017191775143146515,
-0.059927139431238174,
0.01087244413793087,
0.04799851402640343,
-0.03477407246828079,
0.03866152465343475,
-0.008560385555028915,
-0.005680297501385212,
-0.0039251744747161865,
-0.0609566904604435,
0.005187709350138903,
-0.041714683175086975,
-0.04732397943735123,
0.013570585288107395,
0.056554462760686874,
0.0692286267876625,
-0.05424683913588524,
0.0014977346872910857,
0.00056664296425879,
0.02172713726758957,
-0.020946096628904343,
0.018026068806648254,
-0.04487435147166252,
-0.02209990657866001,
0.04483884945511818,
-0.045619890093803406,
0.010694934986531734,
-0.05967862531542778,
0.014138615690171719,
-0.007091496139764786,
0.0764710009098053,
-0.07853011041879654,
0.01853197067975998,
0.022011153399944305,
-0.024869052693247795,
-0.009363614954054356,
0.003916298970580101,
0.00808554794639349,
-0.022330669686198235,
-0.014919656328856945,
0.008675767108798027,
0.003723257454112172,
0.0015099383890628815,
0.006097444333136082,
-0.013543958775699139,
0.001624210039153695,
0.018105948343873024,
0.011884246952831745,
-0.12255241721868515,
0.014032109640538692,
-0.029448792338371277,
-0.0279932152479887,
0.006896235980093479,
-0.05019962787628174,
0.052471745759248734,
-0.03138364478945732,
-0.021265612915158272,
-0.038874536752700806,
0.05822305008769035,
0.0045841773971915245,
0.004027242306619883,
0.009612128138542175,
-0.04753698781132698,
0.03944256529211998,
0.01767992600798607,
0.010277788154780865,
-0.02531282603740692,
-0.06361933052539825,
0.067453533411026,
0.02627137489616871,
0.008271933533251286,
0.005320840980857611,
-0.010854693129658699,
0.02934228628873825,
0.022792194038629532,
-0.01434275135397911,
-0.00918610580265522,
0.022312918677926064,
0.0832163542509079,
0.004222502466291189,
-0.0026271375827491283,
-0.008200929500162601,
0.008387314155697823,
-0.06266078352928162,
0.0058400556445121765,
0.02140762098133564,
-0.031081877648830414,
-0.08236431330442429,
-0.018460966646671295,
-0.016437361016869545,
0.0014045422431081533,
0.012008504010736942,
-0.041395168751478195,
-0.026910409331321716,
0.030602602288126945,
-0.03677992522716522,
-0.024904554709792137,
-0.019330762326717377,
0.010091403499245644,
-0.06287379562854767,
-0.012132760137319565,
0.0384485125541687,
-0.008072235621511936,
0.01507941447198391,
-0.03573261946439743,
0.03118838369846344,
0.043418772518634796,
0.023022955283522606,
0.03047834523022175,
-0.004956947173923254,
-0.007109247148036957,
-0.003709944197908044,
-0.010375418700277805,
0.039868589490652084,
0.022809945046901703,
-0.03539535403251648,
0.001343523501418531,
0.030229832977056503,
-0.00611075758934021,
-0.005382969509810209,
0.011742239817976952,
-0.03266170993447304,
0.06031765788793564,
-0.06148922070860863,
0.011431599035859108,
-0.008378438651561737,
-0.014298373833298683,
0.03880353271961212,
-0.016321979463100433,
0.04203420132398605,
-0.019171003252267838,
-0.08122825622558594,
0.029786059632897377,
0.010552927851676941,
-0.005471724085509777,
-0.004877068102359772,
0.008706831373274326,
-0.01666812226176262,
0.033975280821323395,
0.005329716484993696,
-0.002259915228933096,
-0.006878484971821308,
0.011431599035859108,
-0.0032240126747637987,
0.010490799322724342,
0.065003901720047,
0.06582044810056686,
-0.03443680331110954,
-0.052365243434906006,
-0.011422723531723022,
0.006177323404699564,
-0.023537732660770416,
-0.03450780734419823,
0.0033970840740948915,
-0.04061412811279297,
-0.006882922723889351,
-0.0017662175232544541,
0.021176859736442566,
-0.05094516649842262,
0.014768773689866066,
0.018336709588766098,
-0.013890102505683899,
-0.0001625319418963045,
0.013898978009819984,
0.044093307107686996,
0.07292082160711288,
-0.036318402737379074,
0.0026626393664628267,
-0.02595185860991478,
0.0027913337107747793,
-0.053004276007413864,
-0.02291644923388958,
-0.030922118574380875,
-0.053856320679187775,
0.027851209044456482,
-0.05229423940181732,
-0.03756096586585045,
-0.02529507502913475,
0.03724145144224167,
0.07196226716041565,
-0.02194014936685562
]
|
30,623 | networkx.algorithms.distance_measures | effective_graph_resistance | Returns the Effective graph resistance of G.
Also known as the Kirchhoff index.
The effective graph resistance is defined as the sum
of the resistance distance of every node pair in G [1]_.
If weight is not provided, then a weight of 1 is used for all edges.
The effective graph resistance of a disconnected graph is infinite.
Parameters
----------
G : NetworkX graph
A graph
weight : string or None, optional (default=None)
The edge data key used to compute the effective graph resistance.
If None, then each edge has weight 1.
invert_weight : boolean (default=True)
Proper calculation of resistance distance requires building the
Laplacian matrix with the reciprocal of the weight. Not required
if the weight is already inverted. Weight cannot be zero.
Returns
-------
RG : float
The effective graph resistance of `G`.
Raises
------
NetworkXNotImplemented
If `G` is a directed graph.
NetworkXError
If `G` does not contain any nodes.
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> round(nx.effective_graph_resistance(G), 10)
10.25
Notes
-----
The implementation is based on Theorem 2.2 in [2]_. Self-loops are ignored.
Multi-edges are contracted in one edge with weight equal to the harmonic sum of the weights.
References
----------
.. [1] Wolfram
"Kirchhoff Index."
https://mathworld.wolfram.com/KirchhoffIndex.html
.. [2] W. Ellens, F. M. Spieksma, P. Van Mieghem, A. Jamakovic, R. E. Kooij.
Effective graph resistance.
Lin. Alg. Appl. 435:2491-2506, 2011.
| def effective_graph_resistance(G, weight=None, invert_weight=True):
"""Returns the Effective graph resistance of G.
Also known as the Kirchhoff index.
The effective graph resistance is defined as the sum
of the resistance distance of every node pair in G [1]_.
If weight is not provided, then a weight of 1 is used for all edges.
The effective graph resistance of a disconnected graph is infinite.
Parameters
----------
G : NetworkX graph
A graph
weight : string or None, optional (default=None)
The edge data key used to compute the effective graph resistance.
If None, then each edge has weight 1.
invert_weight : boolean (default=True)
Proper calculation of resistance distance requires building the
Laplacian matrix with the reciprocal of the weight. Not required
if the weight is already inverted. Weight cannot be zero.
Returns
-------
RG : float
The effective graph resistance of `G`.
Raises
------
NetworkXNotImplemented
If `G` is a directed graph.
NetworkXError
If `G` does not contain any nodes.
Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
>>> round(nx.effective_graph_resistance(G), 10)
10.25
Notes
-----
The implementation is based on Theorem 2.2 in [2]_. Self-loops are ignored.
Multi-edges are contracted in one edge with weight equal to the harmonic sum of the weights.
References
----------
.. [1] Wolfram
"Kirchhoff Index."
https://mathworld.wolfram.com/KirchhoffIndex.html
.. [2] W. Ellens, F. M. Spieksma, P. Van Mieghem, A. Jamakovic, R. E. Kooij.
Effective graph resistance.
Lin. Alg. Appl. 435:2491-2506, 2011.
"""
import numpy as np
if len(G) == 0:
raise nx.NetworkXError("Graph G must contain at least one node.")
# Disconnected graphs have infinite Effective graph resistance
if not nx.is_connected(G):
return float("inf")
# Invert weights
G = G.copy()
if invert_weight and weight is not None:
if G.is_multigraph():
for u, v, k, d in G.edges(keys=True, data=True):
d[weight] = 1 / d[weight]
else:
for u, v, d in G.edges(data=True):
d[weight] = 1 / d[weight]
# Get Laplacian eigenvalues
mu = np.sort(nx.laplacian_spectrum(G, weight=weight))
# Compute Effective graph resistance based on spectrum of the Laplacian
# Self-loops are ignored
return float(np.sum(1 / mu[1:]) * G.number_of_nodes())
| (G, weight=None, invert_weight=True, *, backend=None, **backend_kwargs) | [
0.05046522617340088,
-0.014601854607462883,
0.002726566279307008,
0.05912943556904793,
0.056241367012262344,
-0.009371977299451828,
-0.03188277408480644,
-0.0494391992688179,
0.10085444897413254,
-0.00877346284687519,
0.031825773417949677,
-0.00024804507847875357,
0.015209869481623173,
-0.004524484742432833,
-0.05973745137453079,
0.045107096433639526,
-0.05700138583779335,
0.00032627355540171266,
-0.005833141505718231,
0.04632312431931496,
0.005258377641439438,
-0.10412252694368362,
-0.003640963463112712,
0.06057346984744072,
-0.02796867862343788,
0.007414930034428835,
0.020387494936585426,
0.013442826457321644,
-0.0035388360265642405,
0.0005121218273416162,
-0.006635911297053099,
-0.05031322315335274,
-0.02331356704235077,
-0.006512408144772053,
0.022895555943250656,
0.023845579475164413,
0.007053921464830637,
0.007709437049925327,
-0.0925702452659607,
-0.05346729978919029,
-0.011542780324816704,
0.03385882079601288,
0.03209177777171135,
-0.02667664736509323,
0.033288806676864624,
0.01778443157672882,
-0.003785841865465045,
0.018895959481596947,
-0.030343737453222275,
-0.03906494751572609,
0.025840627029538155,
-0.010896764695644379,
-0.046171121299266815,
0.009139222092926502,
0.0018964835908263922,
0.03342181071639061,
0.026106633245944977,
0.05407531186938286,
0.02918470837175846,
-0.07299977540969849,
0.011115269735455513,
-0.08056195825338364,
0.027683671563863754,
0.016834408044815063,
-0.061295486986637115,
0.014962863177061081,
-0.019722478464245796,
-0.0055576348677277565,
0.00797069352120161,
0.013813335448503494,
-0.029051706194877625,
-0.0022741176653653383,
0.026030631735920906,
-0.0682496577501297,
0.018753455951809883,
0.026429641991853714,
0.02390258014202118,
-0.01322432141751051,
-0.026923654600977898,
-0.014107842929661274,
0.031787771731615067,
-0.013214820995926857,
0.046247124671936035,
-0.03644288331270218,
0.025441618636250496,
-0.03725990653038025,
0.01102976780384779,
-0.016558902338147163,
0.025992631912231445,
-0.031483765691518784,
-0.006754664238542318,
0.026030631735920906,
0.03378282114863396,
0.037449911236763,
0.07326577603816986,
0.0010022743372246623,
-0.049895212054252625,
-0.07349378615617752,
0.07071971893310547,
-0.02205953560769558,
-0.013385824859142303,
0.0863380953669548,
-0.018069438636302948,
0.00518237566575408,
0.02867169678211212,
-0.046095117926597595,
-0.015361873432993889,
-0.03435283526778221,
0.053581301122903824,
-0.031198756769299507,
-0.056279364973306656,
0.021679526194930077,
0.016644403338432312,
-0.013699332252144814,
-0.03608187660574913,
0.045145098119974136,
-0.016862910240888596,
0.015323871746659279,
0.05931944027543068,
0.02762667089700699,
0.013167319819331169,
0.03224378451704979,
-0.017698930576443672,
-0.0010200872784480453,
0.010754261165857315,
0.021793529391288757,
0.009585732594132423,
0.0013763458700850606,
-0.011875288560986519,
0.0219455324113369,
0.04921119660139084,
0.0000939632227527909,
0.02519461140036583,
0.04845117777585983,
0.027398664504289627,
0.009804237633943558,
-0.0077379378490149975,
0.037544913589954376,
0.06722363084554672,
0.02072950266301632,
-0.010412252508103848,
-0.02335156686604023,
0.02316156215965748,
0.051187243312597275,
0.031825773417949677,
0.008374453522264957,
0.01739492267370224,
0.03952096030116081,
0.039824966341257095,
-0.002864319598302245,
0.026258638128638268,
-0.014031840488314629,
0.043815065175294876,
-0.010982266627252102,
0.009623733349144459,
0.01723341830074787,
-0.014345348812639713,
0.013889336958527565,
-0.04043298214673996,
-0.03478984534740448,
-0.07425380498170853,
-0.030704746022820473,
0.04016697406768799,
-0.021755527704954147,
0.013784835115075111,
-0.02722766064107418,
0.04951520264148712,
0.015608878806233406,
-0.0649055764079094,
0.028215685859322548,
-0.045031093060970306,
-0.05156725272536278,
-0.033991824835538864,
-0.03874194249510765,
0.030457738786935806,
0.08535007387399673,
0.02663864754140377,
-0.01459235418587923,
0.012131794355809689,
0.02354157157242298,
-0.014924862422049046,
-0.058711424469947815,
-0.0018347320146858692,
-0.02147052064538002,
0.02891870215535164,
0.044993091374635696,
0.03456183895468712,
-0.004802366718649864,
0.0046717384830117226,
0.0004569017328321934,
0.008255700580775738,
-0.04149700701236725,
0.02534661628305912,
0.028937702998518944,
0.02910870686173439,
-0.014924862422049046,
0.03589187189936638,
0.01837344653904438,
-0.034770842641592026,
0.07064371556043625,
0.02907070517539978,
-0.0009987117955461144,
0.037392906844615936,
0.03201577812433243,
0.005514883901923895,
0.011305274441838264,
-0.00918672326952219,
-0.029013704508543015,
-0.008307951502501965,
0.009946741163730621,
-0.06684362143278122,
0.005068372935056686,
0.005619386676698923,
-0.034922849386930466,
-0.024282589554786682,
0.029982728883624077,
-0.02648664265871048,
0.008911216631531715,
0.013718333095312119,
-0.06403155624866486,
-0.054835330694913864,
-0.01005124393850565,
-0.00981373805552721,
-0.013062817044556141,
0.044613081961870193,
-0.04928719624876976,
0.022401543334126472,
0.00003250860027037561,
0.014231345616281033,
0.007039670832455158,
0.05453132465481758,
0.003180202329531312,
0.07904192060232162,
-0.051187243312597275,
0.014259845949709415,
-0.021128512918949127,
-0.059813451021909714,
0.07242976129055023,
0.052441272884607315,
0.041193000972270966,
-0.03570186719298363,
-0.06289152801036835,
-0.04290304332971573,
0.058901429176330566,
-0.03625287860631943,
-0.03705089911818504,
0.013822835870087147,
0.0018596701556816697,
0.02855769358575344,
0.009006218984723091,
-0.08801013976335526,
-0.06794565171003342,
-0.014041340909898281,
-0.023218564689159393,
0.02758866921067238,
-0.010944265872240067,
-0.0851980671286583,
0.01653040200471878,
-0.01809793896973133,
-0.02726566232740879,
0.014506852254271507,
-0.008331702090799809,
-0.07227775454521179,
-0.004550610668957233,
-0.04829917475581169,
0.010089244693517685,
0.00044651085045188665,
0.010250749066472054,
-0.025517620146274567,
0.05076923221349716,
0.044955093413591385,
0.01040275301784277,
0.01361383032053709,
-0.009495480917394161,
-0.004906869027763605,
0.020121488720178604,
0.021166514605283737,
0.04457508400082588,
-0.005077873356640339,
0.03630988299846649,
-0.08443804830312729,
0.0015996013535186648,
-0.007647685706615448,
0.02449159510433674,
-0.05700138583779335,
0.0174329224973917,
-0.009191473014652729,
-0.056393370032310486,
0.02316156215965748,
-0.00906797032803297,
0.0925702452659607,
0.007756938226521015,
0.003593462286517024,
0.003422458190470934,
0.07375979423522949,
0.0104217529296875,
-0.013927338644862175,
-0.04829917475581169,
0.016349896788597107,
0.06957969069480896,
0.04324505105614662,
-0.024339590221643448,
0.0045957365073263645,
-0.04928719624876976,
0.05555734783411026,
0.04073698818683624,
0.03490384668111801,
-0.00009567029337631539,
0.01720491796731949,
0.05783740431070328,
-0.09621834009885788,
0.004935369826853275,
-0.04313104599714279,
0.02283855527639389,
-0.05259327590465546,
-0.029678720980882645,
0.050047215074300766,
-0.027322662994265556,
0.020083487033843994,
0.025612622499465942,
0.01606488972902298,
0.09705435484647751,
0.014430850744247437,
0.038798943161964417,
-0.0712137296795845,
-0.0023501196410506964,
0.019874483346939087,
0.0782058984041214,
0.07934592664241791,
-0.04947720095515251,
-0.0427890382707119,
0.018382946029305458,
-0.010203247889876366,
0.00471923965960741,
-0.04145900532603264,
0.042257025837898254,
0.10951866209506989,
-0.03382082283496857,
-0.02793067879974842,
-0.029507717117667198,
0.0276646725833416,
0.00432022986933589,
-0.005315379239618778,
-0.002633939031511545,
-0.005158625077456236,
0.019294967874884605,
0.017062414437532425,
-0.027436666190624237,
-0.034808844327926636,
-0.0531252883374691,
-0.012863312847912312,
0.003973471466451883,
-0.031996775418519974,
0.026809651404619217,
-0.016720406711101532,
0.04552510380744934,
-0.01169478427618742,
-0.04799516499042511,
0.021964533254504204,
0.023807577788829803,
-0.10359051823616028,
0.006407905835658312,
-0.02867169678211212,
-0.01938997022807598,
-0.006920917890965939,
0.012122293934226036,
-0.016444899141788483,
0.017261918634176254,
0.0182594433426857,
-0.040964994579553604,
-0.0023406194522976875,
-0.08208199590444565,
-0.0774458795785904,
0.004842742811888456,
0.010858763940632343,
0.037544913589954376,
-0.03397282585501671,
-0.021147513762116432,
-0.015722882002592087,
-0.006365154404193163,
0.009158222004771233,
0.019304469227790833,
-0.04453708231449127,
0.011153270490467548,
0.04476508870720863,
-0.012720809318125248,
0.04902119189500809,
0.004049473442137241,
0.024244587868452072,
-0.0032657042611390352,
-0.04180101677775383,
-0.027569670230150223,
0.06760364025831223,
-0.010801762342453003,
-0.04343505576252937,
0.034770842641592026,
0.06178950145840645,
0.028310688212513924,
-0.04579111188650131,
-0.014193344861268997,
-0.046095117926597595,
-0.007761688437312841,
-0.021375518292188644,
0.008592958562076092,
-0.02660064585506916,
0.015019864775240421,
0.0076619358733296394,
0.04343505576252937,
0.04472708702087402,
0.014440350234508514,
-0.04959120601415634,
0.015646880492568016,
0.013461827300488949,
0.004296479281038046,
-0.01966547779738903,
-0.02014048956334591,
-0.013091318309307098,
0.002377432771027088,
0.03699389845132828,
0.029906725510954857,
0.021337518468499184,
-0.02965972013771534,
0.07508982717990875,
-0.005951894447207451,
0.022667551413178444,
-0.04670313373208046,
0.00008231059473473579,
-0.02006448805332184,
-0.0663876086473465,
0.05407531186938286,
-0.02382657863199711,
0.0016518526244908571,
0.01884845830500126,
-0.031236758455634117,
0.0001677384425420314,
-0.0021969282533973455,
0.018002936616539955,
0.01754692569375038,
-0.020159490406513214,
-0.03725990653038025,
0.04012897610664368,
0.012217296287417412,
0.027721673250198364,
-0.04822317138314247,
-0.003363081719726324,
-0.06281552463769913,
-0.006892417557537556,
-0.0009138034656643867,
-0.00523937726393342,
-0.031635768711566925,
0.005491133313626051,
-0.04442307725548744,
0.026752648875117302,
0.028861701488494873,
-0.11719484627246857,
0.029127707704901695,
-0.03714590147137642,
-0.014050841331481934,
-0.06809765100479126,
0.02553662098944187,
0.01621689461171627,
0.031597767025232315,
-0.009143971838057041,
-0.029944727197289467,
-0.01958947628736496,
-0.0328327976167202,
0.007851940579712391,
-0.015580378472805023,
-0.02722766064107418,
-0.021147513762116432,
0.04913519322872162,
-0.020121488720178604,
-0.02002648636698723,
-0.04324505105614662,
0.05654537305235863,
0.012568805366754532,
-0.09127821773290634,
-0.011884788982570171,
0.006208400707691908,
-0.04419507458806038,
-0.01998848468065262,
0.020121488720178604,
0.05563335120677948,
0.02394058182835579,
0.02091950736939907,
-0.03925495222210884,
-0.003873719135299325,
-0.0057333894073963165,
0.019874483346939087,
-0.04183901473879814,
-0.01555187813937664,
0.031635768711566925,
0.025612622499465942,
0.012093793600797653,
0.0006952981348149478,
-0.004712114576250315,
0.012274297885596752,
0.0045957365073263645,
0.03275679424405098,
0.014402349479496479,
-0.02641064114868641,
-0.03138876333832741,
-0.015428374521434307,
0.048489175736904144,
0.03695589676499367,
0.031597767025232315,
-0.03858993574976921,
0.007742688059806824,
0.08960617333650589,
0.03534085676074028,
-0.014031840488314629,
0.019180966541171074,
0.07410179823637009,
0.047577153891325,
0.011846787296235561,
-0.026239637285470963,
-0.03646188601851463,
0.05434131994843483,
0.0652855858206749,
-0.028500692918896675,
-0.018838956952095032,
0.024244587868452072,
0.0005649668164551258,
-0.0018774830969050527,
-0.01680590771138668,
0.008977717719972134,
-0.004400982055813074,
-0.0774838849902153,
-0.0021814904175698757,
-0.015276370570063591,
-0.014383349567651749,
0.020045487210154533,
-0.019446972757577896,
0.04712114483118057,
-0.0004070255090482533,
-0.0078376904129982,
-0.018629953265190125,
-0.04199102148413658,
-0.10222247987985611,
-0.011865788139402866,
-0.0154948765411973,
0.0030376987997442484,
0.014677856117486954,
0.011276774108409882,
0.08246200531721115,
0.02036849409341812,
0.0012730308808386326,
0.002430871594697237,
-0.022515546530485153,
-0.07071971893310547,
-0.044841088354587555,
0.02825368568301201,
-0.020843505859375,
-0.03385882079601288,
0.0619795061647892,
0.036803893744945526,
-0.0501612164080143,
0.0045316098257899284,
0.025403616949915886,
-0.01763242855668068,
-0.01661590300500393,
-0.08725012093782425,
-0.018107440322637558,
-0.06296753138303757,
0.006431656423956156,
-0.04043298214673996,
0.03231978416442871,
-0.025004606693983078,
-0.045031093060970306,
0.0339348241686821,
-0.031825773417949677,
0.0324527882039547,
0.07835790514945984,
0.004469858482480049,
-0.006545659154653549,
-0.013319323770701885,
0.025251613929867744,
-0.06315753608942032,
0.03509385138750076,
-0.06353754550218582,
-0.012711308896541595,
-0.06106748431921005,
0.016349896788597107,
0.041231002658605576,
0.017176417633891106,
0.04164901003241539,
-0.016777407377958298,
0.05339129641652107,
-0.038608938455581665,
-0.014620855450630188,
-0.024282589554786682,
-0.05726739019155502,
0.038304928690195084,
0.003531710710376501,
-0.0019083588849753141,
-0.03349781408905983,
-0.02205953560769558,
0.007999193854629993,
0.045981116592884064,
0.003180202329531312,
-0.05206126347184181,
-0.009281725622713566,
0.019570475444197655,
-0.006949418690055609,
-0.043739061802625656,
0.04947720095515251,
0.005291628651320934,
-0.07030170410871506,
0.03615787625312805,
-0.05331529304385185,
0.0015556628350168467,
-0.024301590397953987,
-0.01621689461171627,
-0.0006228588754311204,
-0.0034604589454829693,
0.012720809318125248,
-0.002271742559969425,
0.016511401161551476,
-0.042333029210567474,
0.01758492738008499,
-0.004792866297066212,
-0.004754865542054176,
0.03775391727685928,
-0.032813798636198044,
-0.01852544955909252,
0.05703938379883766,
0.04001497104763985,
0.005951894447207451,
-0.03323180601000786,
0.04191501811146736,
-0.002132801804691553,
-0.04214302450418472,
-0.009832738898694515,
0.042257025837898254,
0.03176877275109291,
-0.07132773101329803,
0.04024297744035721,
-0.01750892587006092,
-0.02014048956334591,
0.04164901003241539,
-0.03577787056565285,
0.0760018453001976,
-0.05738139525055885,
-0.0006228588754311204,
-0.06399355083703995,
0.019304469227790833,
0.04898319020867348,
-0.01720491796731949,
-0.005158625077456236,
-0.00572863919660449,
-0.02002648636698723,
0.03184477239847183,
0.03342181071639061,
-0.017879433929920197,
-0.008512206375598907,
0.03600587323307991,
0.026505643501877785,
-0.024700600653886795,
0.009571482427418232,
-0.051415249705314636,
0.0011851537274196744,
0.03625287860631943,
0.033326808363199234,
0.011818286962807178,
0.023959582671523094,
0.017014913260936737,
0.03306080400943756,
-0.03625287860631943,
-0.002681440208107233,
-0.06258752197027206,
-0.019798479974269867,
-0.012274297885596752,
0.022952556610107422,
0.03127475827932358,
-0.06874366849660873,
0.023028559982776642,
-0.003192077623680234,
0.03792491927742958,
-0.0006068272632546723,
-0.020862506702542305,
0.004740614909678698,
0.06726163625717163,
-0.025517620146274567,
-0.00437723146751523,
0.017537426203489304,
-0.02135651931166649,
-0.030723746865987778,
-0.021052511408925056,
0.029260709881782532,
-0.004849867895245552,
-0.039672963321208954,
-0.04282703995704651,
0.02076750434935093,
-0.0009316163486801088,
0.0579134076833725,
-0.04012897610664368,
-0.049819208681583405,
0.04818516969680786,
0.07022570818662643,
-0.05924343690276146,
0.0789659172296524,
0.02546061761677265,
-0.016682405024766922,
0.026790650561451912,
-0.023921580985188484,
-0.02578362636268139,
-0.07611584663391113,
-0.011181771755218506,
-0.04552510380744934,
0.033991824835538864,
-0.011998791247606277,
-0.024035584181547165,
0.018344946205615997,
-0.004115974996238947,
0.039938971400260925,
0.023845579475164413,
-0.003619587980210781,
-0.030970752239227295,
-0.043739061802625656,
-0.006260652095079422,
-0.01822144165635109,
-0.009338727220892906,
0.012739809229969978,
0.030419738963246346,
-0.032034777104854584,
0.012122293934226036,
0.07261976599693298,
-0.04472708702087402,
0.006821165792644024,
0.04791916534304619,
-0.027170659974217415,
0.004279853776097298,
0.01557087805122137,
0.03701289743185043,
0.02280055359005928,
0.02080550603568554,
-0.005823641549795866,
0.02832968719303608,
0.037506911903619766,
0.05206126347184181,
0.02597363106906414,
0.04157301038503647,
-0.047501154243946075,
-0.03252879157662392,
0.001303906668908894,
-0.007068171631544828,
-0.04016697406768799,
0.023294566199183464,
0.01927596889436245,
-0.023047558963298798,
0.05076923221349716,
-0.004702614154666662,
0.03165476769208908,
-0.008911216631531715,
0.057609397917985916,
-0.007799689192324877,
-0.015703881159424782,
-0.05175725743174553,
-0.002657689619809389,
-0.005353379994630814,
-0.00391647033393383,
-0.06650161743164062,
-0.05175725743174553,
0.014155344106256962,
-0.029241710901260376,
0.008792463690042496,
0.0065836599096655846,
0.05464532598853111
]
|
30,632 | networkx.generators.classic | empty_graph | Returns the empty graph with n nodes and zero edges.
.. plot::
>>> nx.draw(nx.empty_graph(5))
Parameters
----------
n : int or iterable container of nodes (default = 0)
If n is an integer, nodes are from `range(n)`.
If n is a container of nodes, those nodes appear in the graph.
create_using : Graph Instance, Constructor or None
Indicator of type of graph to return.
If a Graph-type instance, then clear and use it.
If None, use the `default` constructor.
If a constructor, call it to create an empty graph.
default : Graph constructor (optional, default = nx.Graph)
The constructor to use if create_using is None.
If None, then nx.Graph is used.
This is used when passing an unknown `create_using` value
through your home-grown function to `empty_graph` and
you want a default constructor other than nx.Graph.
Examples
--------
>>> G = nx.empty_graph(10)
>>> G.number_of_nodes()
10
>>> G.number_of_edges()
0
>>> G = nx.empty_graph("ABC")
>>> G.number_of_nodes()
3
>>> sorted(G)
['A', 'B', 'C']
Notes
-----
The variable create_using should be a Graph Constructor or a
"graph"-like object. Constructors, e.g. `nx.Graph` or `nx.MultiGraph`
will be used to create the returned graph. "graph"-like objects
will be cleared (nodes and edges will be removed) and refitted as
an empty "graph" with nodes specified in n. This capability
is useful for specifying the class-nature of the resulting empty
"graph" (i.e. Graph, DiGraph, MyWeirdGraphClass, etc.).
The variable create_using has three main uses:
Firstly, the variable create_using can be used to create an
empty digraph, multigraph, etc. For example,
>>> n = 10
>>> G = nx.empty_graph(n, create_using=nx.DiGraph)
will create an empty digraph on n nodes.
Secondly, one can pass an existing graph (digraph, multigraph,
etc.) via create_using. For example, if G is an existing graph
(resp. digraph, multigraph, etc.), then empty_graph(n, create_using=G)
will empty G (i.e. delete all nodes and edges using G.clear())
and then add n nodes and zero edges, and return the modified graph.
Thirdly, when constructing your home-grown graph creation function
you can use empty_graph to construct the graph by passing a user
defined create_using to empty_graph. In this case, if you want the
default constructor to be other than nx.Graph, specify `default`.
>>> def mygraph(n, create_using=None):
... G = nx.empty_graph(n, create_using, nx.MultiGraph)
... G.add_edges_from([(0, 1), (0, 1)])
... return G
>>> G = mygraph(3)
>>> G.is_multigraph()
True
>>> G = mygraph(3, nx.Graph)
>>> G.is_multigraph()
False
See also create_empty_copy(G).
| def star_graph(n, create_using=None):
"""Return the star graph
The star graph consists of one center node connected to n outer nodes.
.. plot::
>>> nx.draw(nx.star_graph(6))
Parameters
----------
n : int or iterable
If an integer, node labels are 0 to n with center 0.
If an iterable of nodes, the center is the first.
Warning: n is not checked for duplicates and if present the
resulting graph may not be as desired. Make sure you have no duplicates.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
The graph has n+1 nodes for integer n.
So star_graph(3) is the same as star_graph(range(4)).
"""
n, nodes = n
if isinstance(n, numbers.Integral):
nodes.append(int(n)) # there should be n+1 nodes
G = empty_graph(nodes, create_using)
if G.is_directed():
raise NetworkXError("Directed Graph not supported")
if len(nodes) > 1:
hub, *spokes = nodes
G.add_edges_from((hub, node) for node in spokes)
return G
| (n=0, create_using=None, default=<class 'networkx.classes.graph.Graph'>, *, backend=None, **backend_kwargs) | [
0.02223445102572441,
-0.006899428088217974,
0.0217194352298975,
-0.05025838315486908,
-0.012742186896502972,
0.06673886626958847,
-0.047558993101119995,
0.007494359277188778,
-0.000560523010790348,
0.005070236045867205,
0.004144540522247553,
0.062441155314445496,
0.016933344304561615,
0.07615121454000473,
0.027011660858988762,
-0.007583155296742916,
0.01480224821716547,
0.011827590875327587,
-0.022909298539161682,
0.038004569709300995,
-0.019801447167992592,
0.01510415319353342,
0.03425739333033562,
0.013905410654842854,
-0.02086699567735195,
0.012022941373288631,
0.02223445102572441,
0.032445959746837616,
-0.03736524283885956,
0.027313565835356712,
0.03315632417798042,
-0.01214725524187088,
0.0010649937903508544,
0.018327437341213226,
0.020671645179390907,
0.04244435951113701,
-0.021453047171235085,
0.053099844604730606,
-0.10442377626895905,
-0.015752362087368965,
0.046422407031059265,
-0.00590047612786293,
0.014775608666241169,
-0.03294321522116661,
0.012129496783018112,
0.028450151905417442,
0.0834679827094078,
0.004493063781410456,
-0.06869237124919891,
-0.017599312588572502,
0.0428350605070591,
0.004262194968760014,
-0.04326127842068672,
-0.0583210326731205,
-0.001881359494291246,
0.010087194852530956,
-0.0075121186673641205,
-0.01229820866137743,
0.05942210182547569,
-0.0399225577712059,
0.03361806273460388,
0.03209077566862106,
0.0061757429502904415,
-0.02353086695075035,
-0.05618993565440178,
-0.021843748167157173,
-0.038821492344141006,
-0.06141112372279167,
-0.014225075952708721,
-0.01896676793694496,
0.054023321717977524,
0.04144984483718872,
0.03013727068901062,
-0.009634336456656456,
0.012902019545435905,
0.02633681334555149,
0.036477286368608475,
0.010877477005124092,
-0.010513413697481155,
-0.009039404802024364,
-0.02278498373925686,
-0.036246415227651596,
0.021897027269005775,
-0.048020727932453156,
0.04631585255265236,
0.0982435941696167,
-0.019712651148438454,
0.021009068936109543,
-0.044610973447561264,
-0.023939328268170357,
-0.02443658374249935,
-0.027846340090036392,
-0.026088185608386993,
0.005514214746654034,
-0.012671150267124176,
0.01594771258533001,
0.050293900072574615,
-0.09248962998390198,
0.012431401759386063,
-0.0009184808004647493,
-0.03757835179567337,
-0.03331615775823593,
-0.08858262002468109,
-0.021897027269005775,
-0.056687191128730774,
-0.03143368661403656,
-0.025324542075395584,
0.056829266250133514,
-0.013141768053174019,
0.02853894606232643,
-0.019037803635001183,
0.017448360100388527,
0.06613505631685257,
-0.01358574628829956,
0.029711050912737846,
0.04269298538565636,
-0.018203124403953552,
0.03864390030503273,
0.06528262048959732,
-0.02299809269607067,
-0.058569662272930145,
0.044220272451639175,
-0.04031325876712799,
0.029746567830443382,
0.026851827278733253,
-0.0004220572009216994,
0.04457545652985573,
-0.05320639908313751,
0.03020830638706684,
0.02111562341451645,
-0.0015616948949173093,
0.01896676793694496,
-0.0010217058006674051,
0.06815960258245468,
-0.03532294183969498,
0.013203924521803856,
-0.07885060459375381,
-0.02839687280356884,
-0.0012253810418769717,
-0.014180677942931652,
0.033831171691417694,
-0.03407980129122734,
0.038750454783439636,
0.049548014998435974,
-0.0607362762093544,
0.015503734350204468,
0.018753657117486,
0.01921539567410946,
0.013328238390386105,
-0.014500342309474945,
0.023708458989858627,
0.002048961352556944,
0.0953310951590538,
0.030776599422097206,
-0.022110136225819588,
-0.018416233360767365,
0.027064938098192215,
-0.02225220948457718,
-0.01211173739284277,
0.02983536384999752,
-0.007432202342897654,
0.011889748275279999,
0.03999359533190727,
-0.016658078879117966,
-0.0762222558259964,
-0.0033631380647420883,
-0.006286737509071827,
-0.004331011790782213,
0.00652648601680994,
-0.027082696557044983,
-0.04166295379400253,
-0.000924585503526032,
0.0012298207730054855,
-0.0560123436152935,
-0.004550781100988388,
-0.002064500702545047,
-0.03081211820244789,
-0.011170502752065659,
-0.017217490822076797,
-0.025839556008577347,
0.029746567830443382,
-0.07064588367938995,
0.02907172031700611,
-0.04169847443699837,
-0.012014062143862247,
0.01766147091984749,
0.009900723583996296,
0.01408300269395113,
0.02914275787770748,
0.033582545816898346,
0.04667103290557861,
0.025093672797083855,
-0.01286650076508522,
0.0560123436152935,
0.022873779758810997,
-0.05835655331611633,
0.06986448168754578,
0.03619313985109329,
-0.07231523841619492,
0.05519542470574379,
0.07735883444547653,
0.07128521054983139,
0.020458536222577095,
-0.01040685921907425,
0.048482466489076614,
-0.0006132454727776349,
-0.05125289410352707,
-0.04819831997156143,
-0.051821187138557434,
0.02869877964258194,
-0.008075971156358719,
0.01967713236808777,
0.03796905279159546,
0.044539935886859894,
-0.06489191949367523,
0.06975792348384857,
0.03896356374025345,
0.03171783313155174,
0.010078314691781998,
-0.06109146028757095,
-0.0351453498005867,
-0.015690205618739128,
0.003138928906992078,
0.03422187268733978,
-0.008471112698316574,
-0.005780601873993874,
-0.008382316678762436,
-0.016773512586951256,
-0.004599618725478649,
-0.06268978118896484,
0.026549922302365303,
-0.026514403522014618,
0.04425578936934471,
-0.015308383852243423,
0.012537957169115543,
-0.015219587832689285,
0.03345822915434837,
-0.011596721597015858,
-0.042337801307439804,
0.03235716372728348,
-0.05512438714504242,
-0.019481781870126724,
0.0073878043331205845,
-0.009323551319539547,
-0.013807735405862331,
0.07977408170700073,
-0.010442377999424934,
0.03141592815518379,
0.002557317027822137,
-0.011667758226394653,
-0.004504163283854723,
-0.019073322415351868,
0.012857621535658836,
-0.030936431139707565,
0.01889573037624359,
0.030563488602638245,
-0.056971337646245956,
-0.007410003338009119,
0.015157430432736874,
0.04276402294635773,
-0.027579952031373978,
-0.008701981045305729,
-0.05800136923789978,
-0.028361355885863304,
0.061695270240306854,
0.018096569925546646,
-0.06869237124919891,
0.052886735647916794,
-0.0595286563038826,
-0.02862774208188057,
0.056971337646245956,
0.08140791952610016,
0.1052762120962143,
0.004497503396123648,
0.012795464135706425,
-0.05611889809370041,
0.002475180895999074,
0.039887040853500366,
-0.04290609434247017,
-0.031629037111997604,
-0.05388124659657478,
-0.037081096321344376,
-0.011729915626347065,
0.0428350605070591,
0.025342300534248352,
0.032303884625434875,
0.0499742366373539,
-0.0040379855781793594,
0.025644205510616302,
-0.028894130140542984,
0.01967713236808777,
-0.01483776606619358,
-0.03679694980382919,
-0.0030567930079996586,
0.030545730143785477,
0.02026318572461605,
-0.026461126282811165,
0.015219587832689285,
0.00234420713968575,
0.052567072212696075,
0.09419450908899307,
-0.053099844604730606,
0.03665487468242645,
0.02253635600209236,
0.04539237543940544,
0.027011660858988762,
0.00040624046232551336,
0.010415738448500633,
0.012777704745531082,
0.014704572036862373,
-0.054485056549310684,
0.014367148280143738,
0.005074675660580397,
0.009367949329316616,
-0.010575571097433567,
-0.05853414162993431,
-0.020405258983373642,
-0.021506324410438538,
0.038004569709300995,
0.03818216174840927,
0.01912659965455532,
0.00527446623891592,
-0.05263810604810715,
0.02125769667327404,
-0.05253155156970024,
0.053419508039951324,
-0.010069435462355614,
0.05714892968535423,
-0.049157314002513885,
0.02102682739496231,
0.019002284854650497,
-0.019535059109330177,
-0.031096262857317924,
0.03544725477695465,
-0.07206661254167557,
0.03551829233765602,
0.01389653142541647,
-0.032605789601802826,
-0.015521492809057236,
-0.05111081898212433,
0.0297643281519413,
0.010557811707258224,
-0.015548131428658962,
0.00705926027148962,
-0.030101751908659935,
0.03864390030503273,
0.04699070006608963,
-0.09348414093255997,
-0.03789801523089409,
-0.0267985500395298,
0.031540241092443466,
0.07870852947235107,
-0.026283536106348038,
-0.029782086610794067,
0.04024222493171692,
0.06641920655965805,
0.005354382563382387,
0.012369244359433651,
-0.06403947621583939,
-0.010611089877784252,
-0.0037383001763373613,
0.0035695882979780436,
0.06219252571463585,
-0.0098296869546175,
-0.005789481569081545,
0.021080106496810913,
-0.013567986898124218,
0.08701981604099274,
0.011667758226394653,
-0.006579763256013393,
-0.024116920307278633,
-0.07366493344306946,
-0.07679054141044617,
0.05043597146868706,
-0.005873837508261204,
0.054236430674791336,
-0.015423817560076714,
-0.03180662915110588,
0.027207011356949806,
-0.001864710240624845,
-0.04191158339381218,
-0.01973041146993637,
0.042479876428842545,
0.006899428088217974,
0.026443367823958397,
-0.00005601761586149223,
0.041130181401968,
0.019268672913312912,
-0.04269298538565636,
-0.027544435113668442,
-0.053632620722055435,
-0.0464579239487648,
0.06240563839673996,
-0.004879325162619352,
-0.029338108375668526,
0.002209903672337532,
0.09561523795127869,
0.04905075952410698,
-0.052886735647916794,
0.017377324402332306,
0.051821187138557434,
-0.04564100503921509,
0.025555409491062164,
0.002635013312101364,
-0.004746131598949432,
-0.037010058760643005,
0.010557811707258224,
-0.009882964193820953,
-0.02612370252609253,
-0.026603199541568756,
0.02005007490515709,
-0.07870852947235107,
-0.03043917566537857,
-0.0004514707834459841,
0.07153383642435074,
0.006242339499294758,
0.010486775077879429,
0.0009223656379617751,
0.029515700414776802,
0.004639576654881239,
0.02390380948781967,
-0.09383932501077652,
-0.01514855120331049,
0.09682285785675049,
0.05313536152243614,
-0.050684601068496704,
0.0279528945684433,
-0.016302894800901413,
-0.012005181983113289,
0.07267042249441147,
0.03409755975008011,
-0.023868290707468987,
0.03599778935313225,
0.006744035519659519,
0.007356726098805666,
-0.06155319884419441,
0.025448855012655258,
0.006171302869915962,
-0.0017281868495047092,
0.0013607945293188095,
0.03098970837891102,
-0.005345502868294716,
0.018629344180226326,
-0.02111562341451645,
-0.0026949504390358925,
-0.015814518555998802,
0.03818216174840927,
0.034648094326257706,
-0.0023464271798729897,
-0.03391996771097183,
-0.006712956819683313,
-0.03143368661403656,
0.05221188813447952,
0.0003610101412050426,
-0.038821492344141006,
-0.00772522808983922,
0.01898452639579773,
-0.04578307643532753,
-0.05967072769999504,
0.04713277146220207,
-0.010948513634502888,
0.02688734605908394,
-0.0208137184381485,
0.021897027269005775,
-0.016702476888895035,
-0.042408838868141174,
0.028112728148698807,
-0.0058693974278867245,
-0.04120121896266937,
-0.07046829164028168,
0.024472102522850037,
0.013141768053174019,
-0.03896356374025345,
-0.031078504398465157,
0.0381111279129982,
-0.034807924181222916,
-0.026372330263257027,
-0.04656447842717171,
-0.00030939761199988425,
-0.030865395441651344,
-0.06084283068776131,
0.015352780930697918,
-0.01017598994076252,
0.039602894335985184,
-0.04713277146220207,
-0.023708458989858627,
0.023211203515529633,
-0.047558993101119995,
0.0018902390729635954,
-0.03542949631810188,
-0.0030767719727009535,
-0.022660668939352036,
-0.015281744301319122,
0.01599211059510708,
-0.030652284622192383,
0.0708945095539093,
-0.017439480870962143,
-0.03843079134821892,
-0.0020167729817330837,
-0.009279153309762478,
0.019268672913312912,
-0.002179935108870268,
-0.022039098665118217,
0.01488216407597065,
0.006943826097995043,
0.05807240679860115,
-0.006610841955989599,
-0.012884260155260563,
0.008280201815068722,
0.04276402294635773,
0.039141155779361725,
0.038537345826625824,
0.024560898542404175,
0.041947100311517715,
-0.022607391700148582,
0.008036013692617416,
-0.021701674908399582,
-0.007720788475126028,
0.043225761502981186,
-0.05739755928516388,
0.04120121896266937,
0.038217682391405106,
0.009838566184043884,
0.04191158339381218,
-0.0252890232950449,
-0.005887156818062067,
0.03843079134821892,
-0.026674237102270126,
0.01627625711262226,
-0.0005452612531371415,
0.022376522421836853,
0.061766307801008224,
-0.03946082293987274,
0.01081531960517168,
-0.041343290358781815,
-0.08091066777706146,
0.03468361124396324,
0.04663551598787308,
0.008107050321996212,
-0.020298702642321587,
0.0026327932719141245,
-0.0022676209919154644,
-0.011108345352113247,
0.0019856945145875216,
0.001187642803415656,
0.029657773673534393,
0.006122465245425701,
-0.06748475134372711,
0.026301294565200806,
-0.05967072769999504,
0.03425739333033562,
-0.0038870328571647406,
0.007472160272300243,
0.006508726626634598,
0.08368109166622162,
-0.006113586015999317,
0.007942778058350086,
-0.0267985500395298,
0.004124561324715614,
0.03242820128798485,
-0.06219252571463585,
0.006517606321722269,
-0.001732626580633223,
-0.029640013352036476,
0.018664861097931862,
-0.0000353622053808067,
0.008617625571787357,
-0.023033611476421356,
0.02468521147966385,
0.0075653959065675735,
-0.00563408900052309,
0.06421706825494766,
0.0897902399301529,
-0.009234755299985409,
-0.01610754430294037,
-0.0072501711547374725,
-0.04265746846795082,
-0.0047106132842600346,
-0.039673931896686554,
-0.017865700647234917,
-0.02035197988152504,
-0.019659373909235,
0.002575076185166836,
0.0005624654586426914,
-0.0026128143072128296,
0.06393292546272278,
-0.09426554292440414,
-0.004599618725478649,
-0.017847940325737,
0.015610288828611374,
0.04507271200418472,
-0.056829266250133514,
0.06428810954093933,
0.03349374979734421,
-0.04375853389501572,
0.010726523585617542,
-0.020156629383563995,
-0.04564100503921509,
0.026549922302365303,
0.005975952371954918,
-0.046813108026981354,
0.08872468769550323,
-0.02086699567735195,
0.03285441920161247,
0.06222804635763168,
0.042941614985466,
0.03155800327658653,
-0.01604538783431053,
-0.016258496791124344,
-0.08453353494405746,
-0.006055868696421385,
0.05377469211816788,
-0.020938033238053322,
-0.04869557544589043,
-0.05015182867646217,
0.012706669047474861,
-0.028681019321084023,
0.05192774161696434,
-0.06531813740730286,
-0.029959678649902344,
-0.01587667688727379,
0.03535845875740051,
-0.015219587832689285,
-0.007742987480014563,
-0.028947407379746437,
0.0012020721333101392,
0.018469510599970818,
-0.02907172031700611,
0.0013308259658515453,
0.004164519719779491,
0.01067324634641409,
-0.05491127818822861,
-0.02299809269607067,
-0.034648094326257706,
-0.011499046348035336,
-0.007507678586989641,
0.009367949329316616,
-0.02756219357252121,
0.003969169221818447,
0.09625456482172012,
-0.043083686381578445,
0.00829796027392149,
-0.02907172031700611,
-0.02633681334555149,
-0.003831535577774048,
-0.03120281919836998,
0.018718140199780464,
-0.03651280328631401,
-0.006517606321722269,
-0.028148245066404343,
-0.03910563886165619,
-0.002948018256574869,
0.017696987837553024,
0.018860211595892906,
0.04269298538565636,
0.037329722195863724,
-0.03484344482421875,
-0.06240563839673996,
0.005474256817251444,
-0.06173079088330269,
0.05381020903587341,
-0.015592529438436031,
0.029817605391144753,
0.06158871576189995,
0.001169883762486279,
0.06109146028757095,
-0.003711661323904991,
-0.06155319884419441,
0.0060425493866205215,
-0.0004769995575770736,
0.004644016735255718,
0.008111489936709404,
0.03825319930911064,
-0.016933344304561615,
-0.05512438714504242,
-0.015050875954329967,
-0.014908802695572376,
0.028219282627105713,
-0.0446464903652668,
-0.009856325574219227,
0.009456745348870754,
-0.00911044143140316,
0.0327833816409111,
-0.02445434406399727,
-0.019908001646399498,
-0.01780354417860508,
-0.041023626923561096,
-0.051963258534669876,
0.018735898658633232,
0.011063947342336178,
-0.017483878880739212,
0.028201522305607796,
0.010762042365968227,
0.016258496791124344,
-0.019552819430828094,
0.014926562085747719,
-0.016009869053959846,
0.027135973796248436,
0.0042177969589829445,
-0.050826676189899445,
0.03665487468242645,
-0.0013496950268745422,
-0.009367949329316616,
0.037684906274080276,
0.017510516569018364,
0.02278498373925686,
-0.03425739333033562,
0.012182774022221565,
-0.04137880727648735,
0.03573140129446983,
-0.07132072746753693,
-0.0232289619743824,
0.004302152898162603,
0.0217194352298975,
-0.08723292499780655,
0.005198989994823933,
0.029728809371590614,
0.005203429609537125,
-0.05185670405626297,
-0.0015394958900287747,
0.03365357965230942,
-0.04731036350131035,
-0.02582179754972458,
0.05111081898212433,
-0.03598002716898918,
0.009021646343171597,
-0.032144054770469666,
-0.03711661323904991,
-0.04212469235062599,
-0.029480181634426117,
-0.02102682739496231,
0.030421415343880653,
0.011818711645901203,
-0.016054267063736916,
0.01889573037624359,
-0.0016882288036867976,
0.02095579169690609,
0.027597712352871895,
-0.016516005620360374,
-0.016658078879117966,
0.0029435784090310335,
-0.021541843190789223,
-0.06663231551647186,
-0.02088475599884987,
-0.01666695810854435,
-0.014535860158503056,
0.008342358283698559,
-0.018469510599970818,
0.001189862727187574,
0.029284831136465073,
0.041343290358781815,
-0.0027837459929287434,
0.008995006792247295,
0.026514403522014618,
-0.04478856548666954,
-0.024045882746577263,
0.015343901701271534,
-0.005527534056454897,
-0.017865700647234917,
-0.043545424938201904,
-0.022802742198109627,
0.02839687280356884,
0.06403947621583939,
-0.011019549332559109,
-0.04510822892189026,
0.003316520480439067,
0.045676521956920624,
-0.0030634526629000902
]
|
30,635 | networkx.algorithms.minors.contraction | equivalence_classes | Returns equivalence classes of `relation` when applied to `iterable`.
The equivalence classes, or blocks, consist of objects from `iterable`
which are all equivalent. They are defined to be equivalent if the
`relation` function returns `True` when passed any two objects from that
class, and `False` otherwise. To define an equivalence relation the
function must be reflexive, symmetric and transitive.
Parameters
----------
iterable : list, tuple, or set
An iterable of elements/nodes.
relation : function
A Boolean-valued function that implements an equivalence relation
(reflexive, symmetric, transitive binary relation) on the elements
of `iterable` - it must take two elements and return `True` if
they are related, or `False` if not.
Returns
-------
set of frozensets
A set of frozensets representing the partition induced by the equivalence
relation function `relation` on the elements of `iterable`. Each
member set in the return set represents an equivalence class, or
block, of the partition.
Duplicate elements will be ignored so it makes the most sense for
`iterable` to be a :class:`set`.
Notes
-----
This function does not check that `relation` represents an equivalence
relation. You can check that your equivalence classes provide a partition
using `is_partition`.
Examples
--------
Let `X` be the set of integers from `0` to `9`, and consider an equivalence
relation `R` on `X` of congruence modulo `3`: this means that two integers
`x` and `y` in `X` are equivalent under `R` if they leave the same
remainder when divided by `3`, i.e. `(x - y) mod 3 = 0`.
The equivalence classes of this relation are `{0, 3, 6, 9}`, `{1, 4, 7}`,
`{2, 5, 8}`: `0`, `3`, `6`, `9` are all divisible by `3` and leave zero
remainder; `1`, `4`, `7` leave remainder `1`; while `2`, `5` and `8` leave
remainder `2`. We can see this by calling `equivalence_classes` with
`X` and a function implementation of `R`.
>>> X = set(range(10))
>>> def mod3(x, y):
... return (x - y) % 3 == 0
>>> equivalence_classes(X, mod3) # doctest: +SKIP
{frozenset({1, 4, 7}), frozenset({8, 2, 5}), frozenset({0, 9, 3, 6})}
| def equivalence_classes(iterable, relation):
"""Returns equivalence classes of `relation` when applied to `iterable`.
The equivalence classes, or blocks, consist of objects from `iterable`
which are all equivalent. They are defined to be equivalent if the
`relation` function returns `True` when passed any two objects from that
class, and `False` otherwise. To define an equivalence relation the
function must be reflexive, symmetric and transitive.
Parameters
----------
iterable : list, tuple, or set
An iterable of elements/nodes.
relation : function
A Boolean-valued function that implements an equivalence relation
(reflexive, symmetric, transitive binary relation) on the elements
of `iterable` - it must take two elements and return `True` if
they are related, or `False` if not.
Returns
-------
set of frozensets
A set of frozensets representing the partition induced by the equivalence
relation function `relation` on the elements of `iterable`. Each
member set in the return set represents an equivalence class, or
block, of the partition.
Duplicate elements will be ignored so it makes the most sense for
`iterable` to be a :class:`set`.
Notes
-----
This function does not check that `relation` represents an equivalence
relation. You can check that your equivalence classes provide a partition
using `is_partition`.
Examples
--------
Let `X` be the set of integers from `0` to `9`, and consider an equivalence
relation `R` on `X` of congruence modulo `3`: this means that two integers
`x` and `y` in `X` are equivalent under `R` if they leave the same
remainder when divided by `3`, i.e. `(x - y) mod 3 = 0`.
The equivalence classes of this relation are `{0, 3, 6, 9}`, `{1, 4, 7}`,
`{2, 5, 8}`: `0`, `3`, `6`, `9` are all divisible by `3` and leave zero
remainder; `1`, `4`, `7` leave remainder `1`; while `2`, `5` and `8` leave
remainder `2`. We can see this by calling `equivalence_classes` with
`X` and a function implementation of `R`.
>>> X = set(range(10))
>>> def mod3(x, y):
... return (x - y) % 3 == 0
>>> equivalence_classes(X, mod3) # doctest: +SKIP
{frozenset({1, 4, 7}), frozenset({8, 2, 5}), frozenset({0, 9, 3, 6})}
"""
# For simplicity of implementation, we initialize the return value as a
# list of lists, then convert it to a set of sets at the end of the
# function.
blocks = []
# Determine the equivalence class for each element of the iterable.
for y in iterable:
# Each element y must be in *exactly one* equivalence class.
#
# Each block is guaranteed to be non-empty
for block in blocks:
x = arbitrary_element(block)
if relation(x, y):
block.append(y)
break
else:
# If the element y is not part of any known equivalence class, it
# must be in its own, so we create a new singleton equivalence
# class for it.
blocks.append([y])
return {frozenset(block) for block in blocks}
| (iterable, relation) | [
0.02504185400903225,
-0.024086786434054375,
-0.024965448305010796,
-0.00748772406950593,
-0.004541343078017235,
-0.012186652980744839,
-0.03145990148186684,
0.012988909147679806,
0.011021471582353115,
0.018003011122345924,
0.011976538226008415,
-0.03384757041931152,
0.04469712823629379,
0.004663113970309496,
-0.04794435575604439,
-0.03147900477051735,
-0.04229035973548889,
0.007229856215417385,
-0.04553758725523949,
0.028441891074180603,
0.03132619336247444,
-0.013409138657152653,
-0.0012559129390865564,
0.05608152598142624,
-0.005730401258915663,
0.016408048570156097,
0.007038842886686325,
0.04752412810921669,
-0.04080045595765114,
0.047103896737098694,
0.002162032527849078,
-0.017382217571139336,
-0.07010190933942795,
-0.010878211818635464,
0.04358925297856331,
-0.00027219406911171973,
0.02995089627802372,
0.09015831351280212,
0.008390262722969055,
-0.005520286504179239,
-0.06651085615158081,
-0.022463172674179077,
-0.009063584730029106,
-0.022520476952195168,
0.027792446315288544,
0.03520376607775688,
0.06142989918589592,
0.02792615443468094,
-0.05948156490921974,
-0.038756612688302994,
0.050389327108860016,
-0.03953976929187775,
0.04947246238589287,
0.0019471425330266356,
0.009197293780744076,
0.021183382719755173,
-0.010410228744149208,
0.013284980319440365,
-0.0331026166677475,
0.0064132739789783955,
-0.0001277401897823438,
-0.01781199686229229,
0.018003011122345924,
-0.01675187237560749,
-0.030619444325566292,
0.007893627509474754,
-0.07445701211690903,
-0.04267238825559616,
-0.012826547957956791,
0.018127169460058212,
-0.049243248999118805,
0.020705848932266235,
0.021049674600362778,
-0.020323822274804115,
-0.022845199331641197,
0.02842278964817524,
0.012473173439502716,
0.028900323435664177,
-0.0000928951776586473,
-0.04141169786453247,
-0.0312688909471035,
0.011718670837581158,
0.007396992761641741,
-0.046569060534238815,
0.0066377148032188416,
-0.028728410601615906,
0.023666556924581528,
0.011021471582353115,
-0.03333183377981186,
-0.016331642866134644,
-0.03780154511332512,
0.01666591688990593,
0.032701488584280014,
0.031173381954431534,
0.01091641467064619,
0.06750412285327911,
-0.02891942486166954,
-0.0659378170967102,
-0.006718895398080349,
-0.05833548307418823,
-0.01789795234799385,
0.058297280222177505,
0.014698479324579239,
0.04775334149599075,
-0.019769884645938873,
-0.014622073620557785,
-0.04740951955318451,
-0.005243317224085331,
-0.016560859978199005,
-0.0800728052854538,
-0.09245046973228455,
0.05310171842575073,
-0.02995089627802372,
0.0016809176886454225,
0.02536657638847828,
-0.035872310400009155,
0.004844576586037874,
-0.033198125660419464,
0.007907954044640064,
-0.0611242800951004,
0.029530666768550873,
0.0577242411673069,
-0.024526117369532585,
0.03547118231654167,
0.02689468301832676,
-0.036961086094379425,
0.06330183148384094,
0.063951276242733,
-0.033026210963726044,
0.01792660541832447,
0.039195943623781204,
-0.021909233182668686,
-0.050274718552827835,
0.07392217218875885,
0.010954616591334343,
0.02324632741510868,
-0.08664366602897644,
0.03808806836605072,
-0.03189923241734505,
0.010410228744149208,
0.025844110175967216,
-0.03770603984594345,
0.01963617466390133,
0.08267058432102203,
-0.03507005423307419,
-0.02187103033065796,
-0.011222035624086857,
-0.02133619412779808,
0.004113950300961733,
0.026818277314305305,
-0.0013084416277706623,
-0.03911953791975975,
0.028518296778202057,
-0.0006097505101934075,
-0.062537781894207,
0.0012159195030108094,
-0.05046573281288147,
-0.0038107167929410934,
0.010486634448170662,
-0.001301278593018651,
-0.06800076365470886,
0.026493554934859276,
-0.014335554093122482,
0.07476263493299484,
0.02301711216568947,
-0.0187479630112648,
-0.024755332618951797,
-0.051917433738708496,
-0.015118708834052086,
-0.033045314252376556,
0.006685467902570963,
-0.040456634014844894,
-0.015615343116223812,
-0.016589511185884476,
0.004013668280094862,
0.019788986071944237,
0.07678737491369247,
0.0012833711225539446,
0.0143260033801198,
0.020476633682847023,
0.009393082931637764,
-0.06811536848545074,
-0.016522657126188278,
-0.0024569095112383366,
0.025939615443348885,
0.02471712976694107,
0.08595601469278336,
-0.012186652980744839,
0.04462072253227234,
0.006155406124889851,
-0.05100056901574135,
-0.03709479793906212,
-0.028231777250766754,
0.057800646871328354,
0.04637804627418518,
-0.022577781230211258,
-0.029778985306620598,
-0.004634461831301451,
-0.05547028407454491,
0.028823917731642723,
-0.013351834379136562,
-0.013590601272881031,
0.07151540368795395,
0.02231036126613617,
0.04611063003540039,
0.010219215415418148,
-0.02318902313709259,
-0.0374959260225296,
0.04087686166167259,
-0.010734951123595238,
-0.004190356004983187,
-0.058908525854349136,
-0.004068584647029638,
0.020209215581417084,
-0.003820267505943775,
-0.0021429313346743584,
0.030294720083475113,
-0.002607332542538643,
0.014879941940307617,
-0.01877661421895027,
-0.024373305961489677,
-0.004980673547834158,
0.015911413356661797,
0.039043132215738297,
0.023723861202597618,
-0.042252156883478165,
-0.014411958865821362,
-0.011155180633068085,
-0.006862155627459288,
-0.014736682176589966,
0.004070972558110952,
0.01230126153677702,
0.017143450677394867,
-0.040189214050769806,
0.000002420311147943721,
0.000005568114374909783,
0.021909233182668686,
0.031230686232447624,
0.0006601899513043463,
0.03747682273387909,
-0.043512847274541855,
0.016627714037895203,
0.027028393000364304,
0.003643580013886094,
-0.0052862949669361115,
-0.01880526728928089,
0.0217182207852602,
0.009278474375605583,
-0.01795525662600994,
-0.04053303599357605,
-0.05233766511082649,
-0.06127709150314331,
0.01156585942953825,
-0.11071135103702545,
0.10750232636928558,
-0.03449701517820358,
-0.08144810050725937,
0.0052862949669361115,
0.05474443361163139,
0.010028202086687088,
0.017716489732265472,
-0.008275654166936874,
0.06051303818821907,
0.004063809290528297,
-0.010028202086687088,
-0.031192483380436897,
-0.011451251804828644,
0.027505924925208092,
-0.03231946378946304,
0.01816537231206894,
0.027047494426369667,
0.01243497058749199,
0.011594511568546295,
0.05363655462861061,
-0.06830637902021408,
0.03060034289956093,
0.005014101043343544,
-0.020553039386868477,
-0.012320362962782383,
-0.037075694650411606,
-0.04030382260680199,
0.005778154358267784,
-0.01807941496372223,
-0.016121529042720795,
0.00878661498427391,
0.0319756381213665,
-0.06574680656194687,
-0.02139349840581417,
0.06406588852405548,
0.006303441245108843,
0.06971988081932068,
0.0005055885412730277,
-0.0024521341547369957,
-0.05004550516605377,
0.020151911303400993,
0.046263437718153,
-0.019321002066135406,
-0.034611623734235764,
0.05340733751654625,
0.0038942850660532713,
0.031020572409033775,
-0.029702579602599144,
0.041106078773736954,
0.006169731728732586,
-0.03258688002824783,
-0.024908144026994705,
0.03953976929187775,
-0.008982404135167599,
-0.007014966104179621,
0.023991279304027557,
0.03938695788383484,
0.021565409377217293,
-0.010429330170154572,
0.023055315017700195,
0.04041843116283417,
0.0017764243530109525,
0.010945065878331661,
0.005720850545912981,
0.002850874559953809,
0.048861220479011536,
-0.0255384873598814,
0.048211775720119476,
0.008433240465819836,
0.08580321073532104,
-0.030027301982045174,
-0.029989099130034447,
0.03717120364308357,
0.01816537231206894,
0.05176462233066559,
0.023265428841114044,
-0.012320362962782383,
-0.015825457870960236,
0.01810806803405285,
0.09420779347419739,
-0.0016701731365174055,
0.08091326802968979,
0.0782390758395195,
-0.020973268896341324,
0.05279609560966492,
-0.06654906272888184,
0.056883782148361206,
0.03577680513262749,
-0.0009108950034715235,
-0.07346374541521072,
-0.03644535318017006,
0.029836289584636688,
-0.0548972450196743,
0.041717320680618286,
-0.014918144792318344,
0.061620913445949554,
0.0012033842504024506,
0.014660276472568512,
0.03209024667739868,
-0.004491202067583799,
-0.022023841738700867,
-0.00006510123785119504,
-0.0315554104745388,
-0.010448431596159935,
-0.01887212134897709,
0.001518556266091764,
0.04507915675640106,
-0.04622523486614227,
0.03673187270760536,
-0.0021321866661310196,
0.018127169460058212,
0.004706092178821564,
-0.03646445274353027,
0.008519196882843971,
0.015653545036911964,
-0.04488814249634743,
0.018891222774982452,
0.025576690211892128,
-0.015672646462917328,
-0.0705985426902771,
0.003760575782507658,
-0.004025606904178858,
-0.031498104333877563,
0.03873751312494278,
-0.0006834696978330612,
0.028136270120739937,
0.05126798897981644,
-0.02301711216568947,
0.016217036172747612,
0.009426509961485863,
-0.02662726491689682,
-0.019139539450407028,
0.08320542424917221,
-0.007225080858916044,
0.04408588632941246,
0.06761873513460159,
-0.004011280834674835,
-0.021240686997771263,
0.018910324200987816,
-0.003574337810277939,
-0.0414499007165432,
-0.023418240249156952,
0.005023651756346226,
-0.010018651373684406,
-0.030791355296969414,
-0.017535027116537094,
0.03617793321609497,
-0.010648995637893677,
0.05543208122253418,
-0.008781840093433857,
-0.0157777052372694,
0.027964357286691666,
-0.009646175429224968,
0.005902313161641359,
0.03980718553066254,
-0.05287250131368637,
-0.04320722445845604,
-0.010142809711396694,
0.013628804124891758,
-0.007210754789412022,
-0.041488103568553925,
0.03231946378946304,
0.002528539625927806,
0.007630984298884869,
0.061086077243089676,
0.010868661105632782,
0.0800728052854538,
-0.022959807887673378,
0.01319902390241623,
0.021737322211265564,
-0.019139539450407028,
-0.028002560138702393,
0.04022741690278053,
0.018232226371765137,
-0.02274969220161438,
-0.018385037779808044,
0.0008744830847717822,
-0.02830818109214306,
-0.00018265654216520488,
-0.0973404124379158,
0.015204664319753647,
-0.04076225310564041,
-0.0062222606502473354,
0.002826998010277748,
-0.01915864087641239,
0.012033842504024506,
0.011021471582353115,
0.003352284664288163,
-0.028613803908228874,
-0.06177372485399246,
0.024182293564081192,
0.00605512410402298,
-0.04336003586649895,
0.03591051325201988,
-0.01745862141251564,
0.038431890308856964,
0.03491724282503128,
-0.03317902237176895,
-0.002585843438282609,
0.0030299497302621603,
-0.02580590732395649,
0.037572331726551056,
0.054706230759620667,
-0.02422049641609192,
-0.03130709007382393,
0.025232866406440735,
0.05138259753584862,
-0.020495735108852386,
0.012234406545758247,
0.015433880500495434,
-0.05187923088669777,
-0.01028607040643692,
-0.00010468428081367165,
0.004873228725045919,
0.006475353147834539,
-0.02263508550822735,
0.04954886808991432,
-0.051535408943891525,
-0.014803536236286163,
0.012568679638206959,
0.013724311254918575,
0.06234676390886307,
-0.007554579060524702,
-0.02639804780483246,
-0.049243248999118805,
-0.02215755172073841,
-0.015968717634677887,
0.009502915665507317,
0.030084606260061264,
-0.09061674773693085,
0.02930145151913166,
-0.05646355450153351,
0.015051853843033314,
-0.003953977022320032,
-0.03356105089187622,
0.022558679804205894,
-0.015195113606750965,
0.006838278844952583,
-0.03677007555961609,
0.04519376531243324,
0.04179372638463974,
0.020037302747368813,
0.022883402183651924,
0.0236283540725708,
0.02962617389857769,
-0.052566878497600555,
0.04595781862735748,
0.033962178975343704,
0.02821267582476139,
0.02154630795121193,
0.05543208122253418,
0.07109517604112625,
0.006585185881704092,
-0.06246137246489525,
-0.020438430830836296,
0.011145629920065403,
0.011527657508850098,
-0.03911953791975975,
0.035050954669713974,
-0.0046869907528162,
-0.013762513175606728,
0.0021095038391649723,
0.03858470171689987,
-0.03398127853870392,
0.014908594079315662,
-0.00011953258945140988,
0.010018651373684406,
0.011775974184274673,
0.020935066044330597,
0.07235586643218994,
-0.047867950052022934,
-0.006012145895510912,
0.012396767735481262,
-0.05684557929635048,
-0.00619360851123929,
-0.056005120277404785,
-0.008409364148974419,
-0.007578455377370119,
-0.039310552179813385,
0.025672197341918945,
-0.01578725501894951,
0.07319632172584534,
-0.03421049565076828,
0.028518296778202057,
0.08190653473138809,
0.017716489732265472,
0.015004100278019905,
0.050389327108860016,
-0.01339003723114729,
0.0286520067602396,
0.03831728175282478,
0.015882762148976326,
-0.011193383485078812,
0.00006692929309792817,
-0.016685018315911293,
0.03365655615925789,
-0.02307441458106041,
0.0030036852695047855,
0.020323822274804115,
0.022845199331641197,
0.011231586337089539,
-0.09214485436677933,
0.03671276941895485,
0.006647265516221523,
0.014421509578824043,
0.028575601056218147,
-0.02748682349920273,
-0.008648130111396313,
-0.03654085844755173,
-0.04740951955318451,
0.09329093247652054,
-0.011995639652013779,
0.08656726032495499,
0.0012499437434598804,
0.03782064840197563,
0.02177552506327629,
0.023819368332624435,
0.13210484385490417,
-0.01745862141251564,
-0.003400037996470928,
0.01721985638141632,
0.0420229434967041,
-0.03233856335282326,
-0.028078965842723846,
-0.009560219012200832,
-0.06822997331619263,
-0.05990179255604744,
-0.020935066044330597,
0.01760188303887844,
-0.013399587944149971,
0.0018767063738778234,
-0.008624253794550896,
-0.01047708373516798,
0.051917433738708496,
-0.06727491319179535,
0.04099147021770477,
-0.030619444325566292,
-0.05615793168544769,
0.04026561975479126,
0.00426914868876338,
-0.015051853843033314,
-0.048097167164087296,
0.023666556924581528,
-0.026035122573375702,
-0.036368947476148605,
-0.04740951955318451,
-0.02678007446229458,
0.03889032453298569,
-0.007755143102258444,
0.015242867171764374,
0.008848694153130054,
-0.062384966760873795,
-0.03873751312494278,
-0.022673286497592926,
0.047218505293130875,
0.010181012563407421,
-0.0410296730697155,
0.018260877579450607,
0.02357104979455471,
-0.06689288467168808,
-0.0072155301459133625,
-0.0077312663197517395,
-0.06223215535283089,
0.053598351776599884,
-0.06952887028455734,
0.0007873332360759377,
0.0078888526186347,
-0.010820907540619373,
0.010677647776901722,
0.03312171995639801,
-0.060207415372133255,
0.024564320221543312,
0.028193574398756027,
-0.004371818620711565,
0.04676007479429245,
-0.03818357363343239,
-0.011575410142540932,
0.006881256587803364,
0.05184102803468704,
0.0012678512139245868,
0.05413319170475006,
-0.07476263493299484,
0.009636624716222286,
0.023704759776592255,
-0.02771604061126709,
-0.007950931787490845,
-0.039310552179813385,
0.010314722545444965,
0.02651265636086464,
-0.0000721523174433969,
-0.027964357286691666,
-0.007673962041735649,
0.042252156883478165,
0.004913819022476673,
0.03732401132583618,
-0.03170821815729141,
-0.007807671558111906,
0.05004550516605377,
0.009288025088608265,
-0.026589062064886093,
-0.004293025471270084,
-0.007368341088294983,
-0.007244182284921408,
-0.043780263513326645,
-0.010333823040127754,
0.005854560062289238,
0.04805896431207657,
0.015233316458761692,
-0.03165091574192047,
0.040838658809661865,
0.058908525854349136,
0.06666366755962372,
0.00802256166934967,
0.005849784705787897,
-0.03356105089187622,
0.02019011415541172,
-0.06192653626203537,
0.044009480625391006,
0.014182742685079575,
-0.0567309707403183,
-0.066205233335495,
-0.03654085844755173,
-0.0357959046959877,
0.03529927134513855,
-0.04549938440322876,
-0.01421139482408762,
0.004221395589411259,
0.01257823035120964,
-0.02821267582476139,
-0.026111528277397156,
-0.00489471759647131,
-0.024468813091516495,
-0.0212215855717659,
-0.054859042167663574,
-0.011193383485078812,
-0.0792323499917984,
0.002347076777368784,
0.010954616591334343,
-0.0000036654421364801237,
-0.033580150455236435,
-0.01843279041349888,
0.0041999067179858685,
-0.05596691742539406,
0.009775109589099884,
0.05195563659071922,
-0.004870840813964605,
0.048746611922979355,
-0.043398238718509674,
-0.016885582357645035,
0.05520286411046982,
0.03375206142663956,
-0.024736231192946434,
-0.09558308869600296,
0.006203159224241972,
0.040724050253629684,
0.04790615290403366,
-0.032816097140312195,
0.011222035624086857,
-0.005214665085077286,
-0.043245427310466766,
0.010601242072880268,
-0.04622523486614227,
0.04519376531243324,
0.018767064437270164,
-0.02580590732395649,
0.028728410601615906,
-0.017620984464883804,
-0.03654085844755173,
0.06452431529760361,
-0.010247867554426193,
-0.037725139409303665,
0.04462072253227234,
0.10887762159109116,
0.02821267582476139,
-0.038985829800367355,
-0.0032543903216719627,
0.000711524800863117,
0.048479195684194565,
-0.048975829035043716,
0.0887066125869751,
0.022081146016716957,
-0.047600533813238144,
-0.03774424269795418,
-0.03201384097337723,
-0.06971988081932068,
0.022195754572749138,
-0.006862155627459288,
-0.07529747486114502,
0.001992508303374052,
-0.03356105089187622,
-0.02548118308186531,
-0.051535408943891525,
0.011584960855543613,
0.03459252044558525,
-0.0039062234573066235,
-0.031192483380436897,
-0.04290160536766052,
-0.001992508303374052,
0.046569060534238815,
-0.014918144792318344,
0.05264328420162201,
0.009469487704336643,
-0.003691333346068859,
-0.026971088722348213,
-0.03602512180805206,
-0.05749502405524254,
-0.035547588020563126,
0.010066404938697815,
0.02101147174835205,
-0.037725139409303665,
0.018003011122345924,
0.023055315017700195,
0.06761873513460159,
0.022062044590711594
]
|
30,644 | networkx.generators.degree_seq | expected_degree_graph | Returns a random graph with given expected degrees.
Given a sequence of expected degrees $W=(w_0,w_1,\ldots,w_{n-1})$
of length $n$ this algorithm assigns an edge between node $u$ and
node $v$ with probability
.. math::
p_{uv} = \frac{w_u w_v}{\sum_k w_k} .
Parameters
----------
w : list
The list of expected degrees.
selfloops: bool (default=True)
Set to False to remove the possibility of self-loop edges.
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
Returns
-------
Graph
Examples
--------
>>> z = [10 for i in range(100)]
>>> G = nx.expected_degree_graph(z)
Notes
-----
The nodes have integer labels corresponding to index of expected degrees
input sequence.
The complexity of this algorithm is $\mathcal{O}(n+m)$ where $n$ is the
number of nodes and $m$ is the expected number of edges.
The model in [1]_ includes the possibility of self-loop edges.
Set selfloops=False to produce a graph without self loops.
For finite graphs this model doesn't produce exactly the given
expected degree sequence. Instead the expected degrees are as
follows.
For the case without self loops (selfloops=False),
.. math::
E[deg(u)] = \sum_{v \ne u} p_{uv}
= w_u \left( 1 - \frac{w_u}{\sum_k w_k} \right) .
NetworkX uses the standard convention that a self-loop edge counts 2
in the degree of a node, so with self loops (selfloops=True),
.. math::
E[deg(u)] = \sum_{v \ne u} p_{uv} + 2 p_{uu}
= w_u \left( 1 + \frac{w_u}{\sum_k w_k} \right) .
References
----------
.. [1] Fan Chung and L. Lu, Connected components in random graphs with
given expected degree sequences, Ann. Combinatorics, 6,
pp. 125-145, 2002.
.. [2] Joel Miller and Aric Hagberg,
Efficient generation of networks with given expected degrees,
in Algorithms and Models for the Web-Graph (WAW 2011),
Alan Frieze, Paul Horn, and Paweł Prałat (Eds), LNCS 6732,
pp. 115-126, 2011.
| def generate(self):
# remaining_degree is mapping from int->remaining degree
self.remaining_degree = dict(enumerate(self.degree))
# add all nodes to make sure we get isolated nodes
self.graph = nx.Graph()
self.graph.add_nodes_from(self.remaining_degree)
# remove zero degree nodes
for n, d in list(self.remaining_degree.items()):
if d == 0:
del self.remaining_degree[n]
if len(self.remaining_degree) > 0:
# build graph in three phases according to how many unmatched edges
self.phase1()
self.phase2()
self.phase3()
return self.graph
| (w, seed=None, selfloops=True, *, backend=None, **backend_kwargs) | [
-0.022558242082595825,
0.0036686493549495935,
-0.030360613018274307,
-0.02120366320014,
-0.01599305309355259,
0.04858420416712761,
-0.07152172923088074,
-0.0393008291721344,
0.03427986055612564,
-0.03131784871220589,
0.03241956979036331,
0.0804077610373497,
-0.03399088233709335,
0.04027612507343292,
-0.013672209344804287,
0.005084183532744646,
0.02389475889503956,
0.013645118102431297,
-0.014412712305784225,
0.0017417618073523045,
-0.01918082684278488,
-0.015424130484461784,
-0.006976077798753977,
0.03344905003905296,
-0.03397282212972641,
-0.004989363253116608,
-0.01683289185166359,
0.013446446508169174,
-0.028951851651072502,
-0.018070073798298836,
-0.05851777642965317,
0.0013071679277345538,
-0.027181869372725487,
0.004366257227957249,
0.013455476611852646,
0.04645300284028053,
-0.01869317889213562,
0.026820648461580276,
-0.05183519423007965,
0.029493682086467743,
0.0969516783952713,
-0.02929501049220562,
-0.03576086461544037,
0.015559588558971882,
-0.023985065519809723,
-0.030902443453669548,
0.03984266147017479,
0.037530846893787384,
-0.0005742846988141537,
-0.07845716923475266,
0.021293969824910164,
-0.017997829243540764,
0.0094368951395154,
0.015397039242088795,
0.010764381848275661,
0.015080970712006092,
-0.010863716714084148,
0.016968348994851112,
0.08329752832651138,
0.021492641419172287,
-0.020878564566373825,
-0.012751095928251743,
0.0003665827389340848,
-0.000632700917776674,
-0.02942143939435482,
0.020950809121131897,
-0.04883705824613571,
-0.024418529123067856,
0.009563322179019451,
0.05667555332183838,
0.05100438371300697,
-0.012850431725382805,
0.051257237792015076,
-0.0021063690073788166,
0.053532931953668594,
-0.019632352516055107,
0.009572352282702923,
-0.027651457116007805,
0.020589588209986687,
-0.03001745231449604,
-0.03194998577237129,
-0.0034315981902182102,
-0.021077236160635948,
-0.0015193852595984936,
0.053171709179878235,
0.038542263209819794,
0.0027385056018829346,
-0.04219059646129608,
-0.03803655505180359,
-0.05064316466450691,
-0.019126644358038902,
-0.02719992958009243,
-0.004831328988075256,
0.012633698992431164,
0.038253288716077805,
-0.01702253334224224,
-0.03821716457605362,
-0.05194355919957161,
0.039698172360658646,
-0.022991707548499107,
-0.017347631976008415,
0.02541188709437847,
-0.1437658965587616,
0.034117311239242554,
0.022377632558345795,
-0.06570607423782349,
-0.004070507362484932,
-0.04493587464094162,
0.03565249964594841,
-0.010195458307862282,
-0.049884598702192307,
0.04685034602880478,
0.07206355780363083,
0.040167760103940964,
-0.010683107189834118,
0.020716015249490738,
-0.0010187557199969888,
-0.02078825980424881,
0.025917597115039825,
0.020986931398510933,
-0.033701904118061066,
0.023515477776527405,
-0.018729301169514656,
0.05703677237033844,
0.003020709380507469,
0.022666608914732933,
0.015586679801344872,
-0.03055928461253643,
0.06899318099021912,
-0.052268657833337784,
0.05494169145822525,
0.0055266791023314,
0.025953717529773712,
-0.007946859113872051,
-0.06613954156637192,
-0.012724004685878754,
-0.016968348994851112,
-0.04204610735177994,
0.022504059597849846,
0.05147397145628929,
-0.012769157066941261,
-0.0395536832511425,
0.009924543090164661,
0.048078496009111404,
0.010150305926799774,
0.04432179778814316,
-0.0072469934821128845,
0.009007944725453854,
-0.015776321291923523,
-0.03474944457411766,
0.028590630739927292,
-0.010159336030483246,
0.009256284683942795,
-0.0027678548358380795,
-0.006858680862933397,
0.02389475889503956,
-0.002160552190616727,
0.0330878309905529,
-0.05096826329827309,
-0.0022790778893977404,
-0.0374947227537632,
0.0028062344063073397,
0.008863456547260284,
0.017419876530766487,
0.0017203142633661628,
-0.02978265844285488,
0.09666270017623901,
-0.05674779787659645,
-0.025538314133882523,
-0.008402899838984013,
-0.038433898240327835,
-0.04255181550979614,
-0.044610776007175446,
-0.02510484866797924,
-0.033882517367601395,
0.007224417291581631,
0.02024642936885357,
0.006569704040884972,
-0.004474623128771782,
0.051184993237257004,
0.0038605479057878256,
-0.03408118709921837,
-0.03720574826002121,
-0.02983684279024601,
0.039156340062618256,
-0.014223070815205574,
0.06285242736339569,
0.0055808620527386665,
0.054905571043491364,
-0.05064316466450691,
-0.03991490602493286,
0.007486302405595779,
0.0527382455766201,
0.08575382828712463,
0.08011878281831741,
-0.017347631976008415,
0.028969911858439445,
0.0656699538230896,
-0.06765666604042053,
0.051076628267765045,
0.03231120482087135,
-0.01045734342187643,
0.024129552766680717,
-0.038144923746585846,
-0.025086788460612297,
0.020643772557377815,
-0.029403377324342728,
-0.00931949820369482,
0.011766768991947174,
0.033756088465452194,
-0.015207397751510143,
-0.0025104850064963102,
0.07101602107286453,
0.009816176258027554,
-0.0537857860326767,
0.0011739677283912897,
0.020336734130978584,
0.01401536911725998,
0.013789606280624866,
-0.041251420974731445,
-0.04659748822450638,
0.003300655633211136,
-0.006569704040884972,
-0.07701228559017181,
-0.012778188101947308,
-0.032564058899879456,
-0.03418955206871033,
-0.04403282329440117,
-0.10562098026275635,
0.0009815047960728407,
0.06913767009973526,
-0.034171491861343384,
-0.03599565848708153,
-0.012362783774733543,
0.024400468915700912,
0.02983684279024601,
-0.017754005268216133,
-0.005391221027821302,
-0.01336517184972763,
0.03204029053449631,
-0.04331038147211075,
-0.05674779787659645,
0.009355620481073856,
0.03373802825808525,
0.04692259058356285,
0.06480301916599274,
0.021601006388664246,
-0.0363207571208477,
0.007183779496699572,
0.03702513873577118,
-0.04840359464287758,
-0.051618460565805435,
-0.02654973231256008,
-0.022088654339313507,
0.006438761483877897,
-0.05270212143659592,
-0.022197021171450615,
-0.03901185095310211,
0.03541770577430725,
0.01327486615628004,
0.021239785477519035,
0.05169070512056351,
-0.0866207629442215,
0.026278816163539886,
0.034713324159383774,
-0.002618851140141487,
-0.003944080322980881,
0.014719749800860882,
-0.05320783331990242,
-0.007910736836493015,
0.010637953877449036,
0.05284661054611206,
0.016462640836834908,
-0.009716841392219067,
0.03617626801133156,
-0.01804298162460327,
0.012010592967271805,
0.04854808375239372,
-0.04284079372882843,
0.02192610502243042,
-0.046164024621248245,
0.011667433194816113,
-0.0011773542501032352,
-0.000709460349753499,
-0.06577831506729126,
0.04829522967338562,
0.009870359674096107,
-0.03839777782559395,
0.029439499601721764,
-0.06122693419456482,
0.0012146051740273833,
0.008213259279727936,
-0.014530109241604805,
0.04005939140915871,
0.0943508893251419,
-0.014150827191770077,
-0.0038131375331431627,
-0.004867450799793005,
0.0010560066439211369,
0.06404446065425873,
0.062455084174871445,
-0.02084244415163994,
0.0017338601173833013,
-0.03523709252476692,
-0.0029033126775175333,
-0.005865323822945356,
0.025845352560281754,
0.0011649372754618526,
0.044610776007175446,
0.011369426734745502,
-0.06310528516769409,
-0.014096643775701523,
0.09297824651002884,
0.020264489576220512,
0.02109529823064804,
-0.04359935596585274,
-0.013518690131604671,
-0.044068943709135056,
0.06729544699192047,
0.05483332648873329,
0.0017993313958868384,
0.05302722007036209,
-0.06451404094696045,
0.013997307978570461,
-0.08683749288320541,
0.04746441915631294,
0.037711456418037415,
0.037061259150505066,
-0.0017688533989712596,
-0.04750054329633713,
-0.056169841438531876,
-0.0014234358677640557,
-0.01618269458413124,
0.031227542087435722,
-0.07014908641576767,
0.02055346593260765,
0.0910276547074318,
-0.04854808375239372,
0.003740893444046378,
-0.01605626754462719,
0.09868554025888443,
0.007242477964609861,
-0.050896018743515015,
0.029493682086467743,
0.006772891152650118,
-0.009165978990495205,
0.030396735295653343,
-0.04200998693704605,
-0.02217896096408367,
0.010854686610400677,
-0.020390916615724564,
0.09160561114549637,
-0.006086571607738733,
0.06520036607980728,
0.047356054186820984,
0.044430166482925415,
0.011631311848759651,
0.009743932634592056,
-0.05082377418875694,
0.030161941424012184,
-0.010800503194332123,
0.01642651855945587,
-0.029493682086467743,
0.04804237186908722,
-0.011261059902608395,
-0.04793400689959526,
0.04204610735177994,
0.0589512437582016,
0.033828333020210266,
-0.021944167092442513,
0.001812877133488655,
-0.04273242875933647,
-0.04338262602686882,
0.022865280508995056,
-0.011134632863104343,
0.025899535045027733,
0.007973950356245041,
0.004332392476499081,
0.06780115514993668,
-0.03590535372495651,
-0.02618851140141487,
-0.004858420696109533,
-0.0041698431596159935,
0.024779750034213066,
0.016760647296905518,
-0.033033646643161774,
0.06653688102960587,
0.00627621216699481,
0.06014327332377434,
-0.01599305309355259,
0.0008957148529589176,
-0.0359414741396904,
0.025863412767648697,
-0.0155144352465868,
0.02311813458800316,
0.03079407848417759,
0.06931827962398529,
0.02270273119211197,
-0.04049285873770714,
-0.008547388017177582,
-0.01791655458509922,
-0.0656699538230896,
0.008700907230377197,
0.05548352375626564,
-0.0076262750662863255,
-0.0822138637304306,
0.07802370190620422,
0.039156340062618256,
0.05978205054998398,
-0.037350237369537354,
-0.028590630739927292,
0.011649372056126595,
-0.00877315178513527,
0.002244084607809782,
0.034171491861343384,
-0.05320783331990242,
0.013762514106929302,
-0.018909912556409836,
0.06082959100604057,
0.01642651855945587,
0.06003490462899208,
0.03655555099248886,
0.06538097560405731,
0.010358007624745369,
0.012696913443505764,
0.027037380263209343,
-0.021185602992773056,
0.01362705696374178,
-0.05085989460349083,
0.07242478430271149,
-0.010954022407531738,
-0.014936482533812523,
0.009861329570412636,
-0.05049867555499077,
0.012362783774733543,
-0.02409343048930168,
0.01605626754462719,
-0.018133286386728287,
-0.021293969824910164,
0.005472496151924133,
0.03570668026804924,
0.0028152649756520987,
0.02409343048930168,
-0.019794901832938194,
0.036700040102005005,
-0.011071419343352318,
-0.02031867206096649,
-0.015324794687330723,
-0.027651457116007805,
0.02618851140141487,
0.01666131243109703,
0.007233447395265102,
0.031426213681697845,
-0.020625710487365723,
-0.037603091448545456,
0.08214162290096283,
0.014412712305784225,
-0.040348369628190994,
-0.05512230098247528,
0.005287370178848505,
0.05595311149954796,
0.022431815043091774,
-0.03527321666479111,
0.0643695592880249,
-0.03332262486219406,
-0.014466894790530205,
-0.0008166977786459029,
0.006822559051215649,
-0.04247957095503807,
0.003494811709970236,
0.0046868403442204,
0.0009843268198892474,
-0.019271131604909897,
-0.08965501934289932,
-0.008642208762466908,
-0.04154039919376373,
-0.0253396425396204,
-0.019126644358038902,
0.00823583547025919,
-0.05450822785496712,
-0.0442134328186512,
-0.007802370470017195,
0.003472235519438982,
0.03455077484250069,
-0.03890348598361015,
0.040240004658699036,
-0.017537271603941917,
-0.02671228162944317,
-0.03552607074379921,
-0.04450240731239319,
-0.06082959100604057,
-0.08163591474294662,
-0.03265436366200447,
0.01387088093906641,
0.014186949469149113,
0.0442134328186512,
-0.009789085015654564,
-0.035562191158533096,
-0.0021865149028599262,
-0.023948943242430687,
-0.0016582295065745711,
0.0017553075449541211,
0.006908348761498928,
0.022504059597849846,
0.01724829524755478,
0.006894803140312433,
-0.03061346709728241,
-0.037603091448545456,
0.011017235927283764,
0.03977041691541672,
0.03485781326889992,
0.0072379629127681255,
-0.0014324664371088147,
0.0478256419301033,
0.003539964323863387,
0.010014847852289677,
0.007341813761740923,
0.0003423132002353668,
-0.024833934381604195,
-0.009454956278204918,
0.010917900130152702,
0.0277959443628788,
0.0066509791649878025,
0.031787436455488205,
-0.005034515634179115,
0.037603091448545456,
-0.04374384507536888,
-0.07018521428108215,
0.014078582637012005,
-0.010827595368027687,
0.039156340062618256,
0.004217253532260656,
0.00546798063442111,
0.09218356013298035,
-0.016372336074709892,
-0.06332201510667801,
0.06321364641189575,
-0.04482750967144966,
-0.06585056334733963,
-0.05064316466450691,
-0.00209056562744081,
0.007554030977189541,
-0.009473016485571861,
-0.020174184814095497,
0.0010215777438133955,
0.009337559342384338,
0.08373099565505981,
-0.016128510236740112,
0.03498423844575882,
-0.030035514384508133,
-0.030035514384508133,
0.045802805572748184,
-0.01760951615869999,
-0.0509321391582489,
0.12433221936225891,
-0.013608995825052261,
-0.02181774005293846,
0.003578344127163291,
0.028735117986798286,
0.019433682784438133,
0.004777145572006702,
-0.03868675231933594,
-0.06397221237421036,
-0.026766465976834297,
-0.0038244258612394333,
-0.006506490521132946,
-0.01411470491439104,
-0.006158815696835518,
0.003752181539312005,
0.04775339737534523,
0.008768635801970959,
-0.0342617966234684,
0.011179785244166851,
-0.01952398754656315,
0.006488429382443428,
-0.03984266147017479,
-0.009400772862136364,
0.02252211980521679,
0.0179707370698452,
-0.025556376203894615,
0.003779273247346282,
0.00453557912260294,
-0.014195979572832584,
-0.014530109241604805,
0.004124690778553486,
0.024490773677825928,
-0.045875050127506256,
0.023443233221769333,
0.08163591474294662,
0.0020013893954455853,
-0.003910215571522713,
-0.04392445459961891,
0.0020375114399939775,
-0.002426952589303255,
-0.07433924823999405,
0.04692259058356285,
-0.03084826096892357,
-0.005156427621841431,
-0.04435792192816734,
-0.01670646481215954,
-0.05039031058549881,
0.0786016583442688,
0.017871402204036713,
0.09088316559791565,
-0.020716015249490738,
0.04258793964982033,
-0.016498763114213943,
0.010312855243682861,
-0.017302479594945908,
-0.018015889450907707,
0.0005474753561429679,
-0.004962271545082331,
-0.0013534494210034609,
-0.04027612507343292,
-0.040709588676691055,
-0.043238136917352676,
-0.014078582637012005,
0.007314722053706646,
-0.036880649626255035,
-0.0037341206334531307,
-0.021059175953269005,
-0.012949767522513866,
-0.06408058106899261,
0.006939955521374941,
-0.004605565685778856,
0.02241375483572483,
0.055447399616241455,
-0.007206356152892113,
0.024888116866350174,
0.02420179732143879,
0.009563322179019451,
-0.05909573286771774,
-0.07506169378757477,
-0.01972265914082527,
-0.00003651011502370238,
-0.015252550132572651,
0.015713106840848923,
0.027398601174354553,
0.025393826887011528,
-0.02732635661959648,
-0.07527842372655869,
0.04045673459768295,
-0.05266600102186203,
-0.04746441915631294,
-0.05750636011362076,
-0.02461720071732998,
0.015135154128074646,
0.03397282212972641,
-0.01785334013402462,
-0.02337098866701126,
-0.0187473613768816,
0.009843268431723118,
0.06241896376013756,
-0.027886249125003815,
0.01489132922142744,
-0.007653366774320602,
0.015017757192254066,
0.006926409900188446,
0.04013163596391678,
-0.04045673459768295,
0.006384578533470631,
0.026676159352064133,
0.08777666836977005,
-0.005955628585070372,
0.018133286386728287,
0.04020388051867485,
0.044899750500917435,
-0.031426213681697845,
-0.04219059646129608,
-0.013717361725866795,
-0.027886249125003815,
-0.04237120598554611,
0.06765666604042053,
0.01303104218095541,
-0.056531064212322235,
0.01658906787633896,
-0.011902227066457272,
0.004980332683771849,
0.03617626801133156,
0.030541222542524338,
0.01725732535123825,
0.032329265028238297,
-0.022485997527837753,
-0.07285824418067932,
-0.010005817748606205,
-0.012407936155796051,
-0.04258793964982033,
-0.03839777782559395,
0.003955368418246508,
-0.002177484566345811,
-0.02952980436384678,
0.0023050406016409397,
0.05747023597359657,
0.006073025520890951,
0.009545261040329933,
0.02109529823064804,
-0.031733252108097076,
-0.017094776034355164,
0.024960361421108246,
-0.030125819146633148,
0.037169624119997025,
-0.01856675185263157,
-0.014484955929219723,
0.030216123908758163,
-0.006483914330601692,
-0.008664784952998161,
0.011315243318676949,
0.006158815696835518,
-0.03536352142691612,
0.017356662079691887,
-0.014521078206598759,
0.002311813412234187,
-0.006894803140312433,
0.048259105533361435,
-0.011848043650388718,
-0.005901445634663105,
0.0033074284438043833,
0.07657881826162338,
-0.03030642867088318,
-0.024707505479454994,
-0.0019088264089077711,
0.016516823321580887,
-0.013157469220459461,
0.045983415096998215,
-0.025538314133882523,
0.04435792192816734,
0.0006462466553784907,
-0.04630851373076439,
-0.018476447090506554,
-0.019849086180329323,
-0.026333000510931015,
0.040709588676691055,
0.0037837885320186615,
-0.029042156413197517,
0.003790561342611909,
-0.008068771101534367,
0.02019224502146244,
0.05833716690540314,
-0.022034471854567528,
0.0330878309905529,
-0.017943646758794785,
0.008317110128700733,
-0.025448009371757507,
0.03731411322951317,
0.007684973534196615,
-0.010412191040813923,
0.03193192183971405,
0.017284417524933815,
0.0032871097791939974,
0.01043025217950344,
0.028861546888947487,
-0.0036325273104012012,
0.031606823205947876,
0.025538314133882523,
-0.04482750967144966,
-0.02300976775586605,
-0.012742065824568272,
-0.02523127570748329,
-0.027109624817967415,
-0.08604280650615692,
-0.03288915753364563,
-0.032690487802028656,
0.04450240731239319,
0.011875135824084282,
-0.012236356735229492,
0.04027612507343292,
0.06942664831876755,
-0.004709417000412941
]
|
30,645 | networkx.generators.random_graphs | extended_barabasi_albert_graph | Returns an extended Barabási–Albert model graph.
An extended Barabási–Albert model graph is a random graph constructed
using preferential attachment. The extended model allows new edges,
rewired edges or new nodes. Based on the probabilities $p$ and $q$
with $p + q < 1$, the growing behavior of the graph is determined as:
1) With $p$ probability, $m$ new edges are added to the graph,
starting from randomly chosen existing nodes and attached preferentially at the other end.
2) With $q$ probability, $m$ existing edges are rewired
by randomly choosing an edge and rewiring one end to a preferentially chosen node.
3) With $(1 - p - q)$ probability, $m$ new nodes are added to the graph
with edges attached preferentially.
When $p = q = 0$, the model behaves just like the Barabási–Alber model.
Parameters
----------
n : int
Number of nodes
m : int
Number of edges with which a new node attaches to existing nodes
p : float
Probability value for adding an edge between existing nodes. p + q < 1
q : float
Probability value of rewiring of existing edges. p + q < 1
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m` does not satisfy ``1 <= m < n`` or ``1 >= p + q``
References
----------
.. [1] Albert, R., & Barabási, A. L. (2000)
Topology of evolving networks: local events and universality
Physical review letters, 85(24), 5234.
| def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None):
"""Returns a random graph using dual Barabási–Albert preferential attachment
A graph of $n$ nodes is grown by attaching new nodes each with either $m_1$
edges (with probability $p$) or $m_2$ edges (with probability $1-p$) that
are preferentially attached to existing nodes with high degree.
Parameters
----------
n : int
Number of nodes
m1 : int
Number of edges to link each new node to existing nodes with probability $p$
m2 : int
Number of edges to link each new node to existing nodes with probability $1-p$
p : float
The probability of attaching $m_1$ edges (as opposed to $m_2$ edges)
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
initial_graph : Graph or None (default)
Initial network for Barabási–Albert algorithm.
A copy of `initial_graph` is used.
It should be connected for most use cases.
If None, starts from an star graph on max(m1, m2) + 1 nodes.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m1` and `m2` do not satisfy ``1 <= m1,m2 < n``, or
`p` does not satisfy ``0 <= p <= 1``, or
the initial graph number of nodes m0 does not satisfy m1, m2 <= m0 <= n.
References
----------
.. [1] N. Moshiri "The dual-Barabasi-Albert model", arXiv:1810.10538.
"""
if m1 < 1 or m1 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m1 >= 1 and m1 < n, m1 = {m1}, n = {n}"
)
if m2 < 1 or m2 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m2 >= 1 and m2 < n, m2 = {m2}, n = {n}"
)
if p < 0 or p > 1:
raise nx.NetworkXError(
f"Dual Barabási–Albert network must have 0 <= p <= 1, p = {p}"
)
# For simplicity, if p == 0 or 1, just return BA
if p == 1:
return barabasi_albert_graph(n, m1, seed)
elif p == 0:
return barabasi_albert_graph(n, m2, seed)
if initial_graph is None:
# Default initial graph : empty graph on max(m1, m2) nodes
G = star_graph(max(m1, m2))
else:
if len(initial_graph) < max(m1, m2) or len(initial_graph) > n:
raise nx.NetworkXError(
f"Barabási–Albert initial graph must have between "
f"max(m1, m2) = {max(m1, m2)} and n = {n} nodes"
)
G = initial_graph.copy()
# Target nodes for new edges
targets = list(G)
# List of existing nodes, with nodes repeated once for each adjacent edge
repeated_nodes = [n for n, d in G.degree() for _ in range(d)]
# Start adding the remaining nodes.
source = len(G)
while source < n:
# Pick which m to use (m1 or m2)
if seed.random() < p:
m = m1
else:
m = m2
# Now choose m unique nodes from the existing nodes
# Pick uniformly from repeated_nodes (preferential attachment)
targets = _random_subset(repeated_nodes, m, seed)
# Add edges to m nodes from the source.
G.add_edges_from(zip([source] * m, targets))
# Add one node to the list for each new edge just created.
repeated_nodes.extend(targets)
# And the new node "source" has m edges to add to the list.
repeated_nodes.extend([source] * m)
source += 1
return G
| (n, m, p, q, seed=None, *, backend=None, **backend_kwargs) | [
0.0035330478567630053,
0.0015030424110591412,
0.015339415520429611,
0.004939081147313118,
-0.024930143728852272,
-0.04081568494439125,
-0.06480687856674194,
-0.03633170947432518,
0.012043501250445843,
-0.03002731315791607,
0.006491227075457573,
0.04196542128920555,
-0.036868251860141754,
0.10723219066858292,
-0.043038509786129,
0.013011197559535503,
0.034664589911699295,
0.04740751534700394,
-0.005897196009755135,
0.027287105098366737,
-0.04004919156432152,
0.0020264126360416412,
0.00006875221151858568,
0.07101546227931976,
-0.034492127597332,
0.010740465484559536,
-0.03911023959517479,
0.01075004693120718,
-0.015617269091308117,
0.05932645872235298,
0.03920605406165123,
-0.12348181754350662,
0.020982710644602776,
0.039052754640579224,
-0.000130992237245664,
0.010136852972209454,
0.02770867571234703,
0.06116604059934616,
-0.10960831493139267,
-0.03681076690554619,
0.07097713649272919,
-0.05541735142469406,
0.08339430391788483,
0.013078264892101288,
0.024681033566594124,
-0.02391454204916954,
0.03092794120311737,
0.012992034666240215,
-0.09650131314992905,
-0.009839837439358234,
0.016125069931149483,
-0.07051724195480347,
0.026252342388033867,
-0.002377321943640709,
-0.02046532928943634,
0.018501194193959236,
-0.003140220884233713,
0.04460981860756874,
0.017878420650959015,
0.02531339041888714,
0.06300561875104904,
-0.01954553835093975,
-0.014620830304920673,
-0.035239458084106445,
-0.024431923404335976,
0.02195998840034008,
-0.048595577478408813,
-0.02678888663649559,
-0.0014802871737629175,
0.06200918182730675,
0.05035850778222084,
0.06407871097326279,
-0.008052953518927097,
0.05514908209443092,
0.05472750961780548,
0.044341545552015305,
0.048595577478408813,
0.02701883390545845,
-0.052044790238142014,
0.019698837772011757,
0.0041654035449028015,
-0.02584993466734886,
0.011832715943455696,
-0.034338828176259995,
0.0055139497853815556,
-0.015492714010179043,
0.006074447184801102,
0.0031306396704167128,
0.0003173754957970232,
-0.10186675190925598,
-0.048595577478408813,
-0.04982196167111397,
0.05564729869365692,
0.01627836748957634,
0.031560298055410385,
-0.03324658051133156,
-0.006275651045143604,
-0.032365113496780396,
0.00747808488085866,
-0.024566059932112694,
-0.04506971314549446,
0.0436900295317173,
-0.03813296556472778,
0.0006335533107630908,
0.006472064647823572,
0.007200231775641441,
-0.05219808593392372,
0.015138211660087109,
0.020848575979471207,
-0.03533526882529259,
-0.1171199381351471,
0.04357505589723587,
0.07979179173707962,
0.018204178661108017,
-0.022860616445541382,
-0.013317793607711792,
0.014965751208364964,
0.01162193063646555,
0.03194354474544525,
0.03223097696900368,
0.016364598646759987,
0.027076320722699165,
-0.032959144562482834,
-0.00023264222545549273,
0.0007874504663050175,
-0.02402951568365097,
0.04825065657496452,
-0.008623031899333,
-0.012877061031758785,
-0.03874615579843521,
0.010520098730921745,
0.014831614680588245,
-0.04706259444355965,
0.07021064311265945,
-0.012053082697093487,
-0.034434642642736435,
-0.04786740988492966,
0.005729525815695524,
0.06913755089044571,
0.003978571388870478,
-0.0008503267890773714,
-0.06687640398740768,
0.08906634151935577,
0.01288664247840643,
-0.039512649178504944,
-0.021480930969119072,
0.017236482352018356,
-0.057103633880615234,
0.0017617333214730024,
-0.012215961702167988,
0.040087517350912094,
-0.0013257911195978522,
0.020867737010121346,
-0.034664589911699295,
-0.03955097496509552,
0.01768679730594158,
-0.04154385253787041,
-0.000426959857577458,
-0.0232438612729311,
0.014601667411625385,
-0.030621344223618507,
-0.05465086176991463,
0.0487871989607811,
0.05430594086647034,
0.010098529048264027,
-0.03069799393415451,
0.049515366554260254,
0.0018515565898269415,
0.01745685003697872,
-0.03545024245977402,
-0.07434970140457153,
-0.0011694987770169973,
-0.0660332664847374,
-0.061702582985162735,
0.05269630625844002,
-0.0021868967451155186,
-0.026022395119071007,
-0.0310429148375988,
0.029260821640491486,
0.03435799106955528,
0.0382670983672142,
-0.04729254171252251,
0.06779619306325912,
-0.05924981087446213,
-0.030640507116913795,
-0.03543107956647873,
-0.006357091013342142,
0.042961861938238144,
0.018060460686683655,
0.008560754358768463,
0.021327633410692215,
0.024776846170425415,
0.03612092137336731,
0.0609360933303833,
0.025217577815055847,
0.005255259107798338,
0.025140928104519844,
0.014592085964977741,
-0.012915385887026787,
0.011104549281299114,
0.04568290710449219,
0.0022635459899902344,
0.020503653213381767,
0.023148050531744957,
0.02793862298130989,
0.00764575507491827,
-0.032844170928001404,
-0.04196542128920555,
0.0232438612729311,
-0.027210457250475883,
0.004929500166326761,
-0.010500936768949032,
0.028570979833602905,
-0.027076320722699165,
-0.0153585784137249,
-0.06289064884185791,
0.01924852281808853,
0.017159834504127502,
-0.0001020990966935642,
-0.03487537428736687,
0.03209684044122696,
-0.058828242123126984,
0.01093208882957697,
0.025792445987462997,
0.005758269224315882,
0.043766677379608154,
-0.014572924003005028,
0.004060010891407728,
-0.015166955068707466,
0.028954224660992622,
0.033763960003852844,
-0.0008096069213934243,
0.03677244111895561,
-0.02830270677804947,
-0.03918689116835594,
-0.030161449685692787,
0.003053990425541997,
-0.03955097496509552,
-0.035833489149808884,
0.018951507285237312,
-0.029394958168268204,
0.019852135330438614,
-0.020312031731009483,
-0.008963163010776043,
0.02230490930378437,
0.015569363720715046,
0.02828354574739933,
-0.058138396590948105,
-0.06852436065673828,
-0.019813811406493187,
-0.09335869550704956,
-0.012522558681666851,
0.024776846170425415,
0.03148364648222923,
0.026137368753552437,
-0.026482289656996727,
-0.021480930969119072,
0.009753607213497162,
-0.00399533798918128,
0.058598294854164124,
0.007185860071331263,
-0.020407842472195625,
-0.11121795326471329,
0.03163694590330124,
-0.0014742990024387836,
-0.005988216493278742,
-0.0707855150103569,
0.06952080130577087,
-0.013499835506081581,
-0.031330350786447525,
0.061932533979415894,
0.0006814590306021273,
0.008833817206323147,
0.00045091271749697626,
0.026961347088217735,
0.02335883490741253,
-0.012417166493833065,
0.019468890503048897,
-0.019641350954771042,
-0.043536730110645294,
-0.04127557948231697,
-0.043421756476163864,
0.02473852038383484,
0.04541463404893875,
-0.005897196009755135,
0.004232471343129873,
-0.02335883490741253,
-0.06200918182730675,
0.024336112663149834,
-0.033495690673589706,
0.01547355204820633,
-0.028570979833602905,
0.005748688243329525,
0.05001358687877655,
-0.0017198158893734217,
-0.004850455559790134,
0.058713268488645554,
0.023492971435189247,
0.020139571279287338,
-0.008972743526101112,
0.03801799193024635,
-0.00966737698763609,
0.09121251851320267,
0.003942641895264387,
-0.016661614179611206,
-0.03205851837992668,
0.013605228625237942,
-0.025351714342832565,
-0.019832974299788475,
0.020043758675456047,
-0.09052267670631409,
0.025160090997815132,
0.057563528418540955,
0.030870454385876656,
-0.009447010233998299,
-0.0673362985253334,
0.011554863303899765,
0.0006736743962392211,
0.04047076404094696,
-0.003894736059010029,
-0.01734187640249729,
0.03750060871243477,
-0.0013174077030271292,
0.04656437411904335,
-0.01759098470211029,
-0.0022407907526940107,
0.046411074697971344,
0.07500121742486954,
0.0013808828080073,
0.02230490930378437,
-0.04208039492368698,
0.016594545915722847,
-0.01063507329672575,
0.018817372620105743,
-0.08753335475921631,
0.08086487650871277,
-0.02747872844338417,
-0.02333967387676239,
0.06664645671844482,
-0.08592372387647629,
0.021672554314136505,
-0.04671766981482506,
-0.005303164478391409,
-0.01064465381205082,
0.04637274891138077,
0.04407327622175217,
0.01213931292295456,
-0.004071987234055996,
-0.056988660246133804,
0.06932917982339859,
-0.013595647178590298,
0.04192709922790527,
-0.002723440993577242,
0.02577328495681286,
-0.019095225259661674,
0.03357233852148056,
-0.009868580847978592,
0.004416908603161573,
0.010175177827477455,
0.0702872946858406,
-0.02333967387676239,
-0.005734316073358059,
-0.027747001498937607,
-0.013672295957803726,
0.027632027864456177,
0.006304394453763962,
0.0023533692583441734,
0.04384332895278931,
0.03851620852947235,
-0.052504684776067734,
0.06971242278814316,
-0.0671830028295517,
-0.04510803893208504,
0.04920876771211624,
0.010424287989735603,
-0.02876260317862034,
-0.03773055598139763,
0.02012040838599205,
0.03207767754793167,
0.033054955303668976,
-0.01235967967659235,
-0.0395892970263958,
0.009973973967134953,
0.0395892970263958,
-0.00618463009595871,
-0.0120722446590662,
0.07258676737546921,
0.0037893434055149555,
-0.006558294873684645,
-0.026999671012163162,
0.012867479585111141,
-0.02979736588895321,
0.07327660918235779,
0.006984655745327473,
-0.05499578267335892,
0.0050827981904149055,
0.04116060584783554,
-0.026022395119071007,
-0.0371173620223999,
-0.0035570007748901844,
0.002562956651672721,
0.016929885372519493,
-0.050550129264593124,
-0.023627107962965965,
-0.005676829256117344,
-0.03393642231822014,
0.02784281224012375,
0.027976948767900467,
0.01131533458828926,
0.015004076063632965,
-0.015147793106734753,
0.023033076897263527,
-0.019008995965123177,
-0.011688998900353909,
0.023665431886911392,
-0.0010718908160924911,
-0.005901986267417669,
-0.020177895203232765,
0.010893763974308968,
0.014975332655012608,
0.03242260217666626,
-0.007851749658584595,
0.006486436352133751,
-0.02483433298766613,
0.044111598283052444,
0.0057678502053022385,
-0.05104834958910942,
0.019622188061475754,
-0.08155471831560135,
0.022132448852062225,
0.053999342024326324,
-0.0395892970263958,
0.03343820199370384,
-0.04300018772482872,
0.024642709642648697,
0.008536801673471928,
0.028915900737047195,
0.005365442018955946,
0.05672038719058037,
-0.022975590080022812,
0.012129731476306915,
0.02220909856259823,
0.011688998900353909,
-0.05741023272275925,
-0.029586581513285637,
-0.04564458131790161,
-0.021710878238081932,
-0.0012862689327448606,
0.01614423282444477,
-0.020503653213381767,
-0.005691200960427523,
-0.005245677661150694,
0.07116875797510147,
-0.00673075532540679,
-0.047445837408304214,
0.03577600046992302,
0.059748031198978424,
-0.02795778587460518,
-0.034664589911699295,
0.10064036399126053,
0.014869939535856247,
0.006975074764341116,
0.01230219192802906,
0.09581146389245987,
0.03426218032836914,
-0.019162293523550034,
0.05419096723198891,
-0.02002459578216076,
-0.01529151014983654,
0.03797966614365578,
-0.018980251625180244,
0.00016737065743654966,
0.015550200827419758,
-0.033054955303668976,
-0.016814911738038063,
-0.038707833737134933,
-0.009442220441997051,
-0.03966594859957695,
-0.011305753141641617,
-0.011229104362428188,
0.01736103743314743,
0.004014500416815281,
0.010309313423931599,
0.03221181407570839,
0.022860616445541382,
-0.027804488316178322,
-0.035584378987550735,
0.025370877236127853,
0.011986014433205128,
0.0026731400284916162,
-0.07312331348657608,
-0.08009838312864304,
0.022381559014320374,
0.03700238838791847,
-0.051469918340444565,
-0.012618370354175568,
-0.01717899553477764,
-0.04798238351941109,
-0.007521199993789196,
-0.07634257525205612,
0.01924852281808853,
-0.011152454651892185,
-0.014678317122161388,
-0.04656437411904335,
0.007391854654997587,
0.00042666043736971915,
-0.002123421523720026,
-0.017466429620981216,
0.0022312095388770103,
0.06346551328897476,
-0.00010831186955329031,
-0.023857055231928825,
0.0376155823469162,
0.03688741475343704,
-0.014601667411625385,
0.016287948936223984,
-0.008613450452685356,
0.00457499735057354,
0.05139327049255371,
-0.02876260317862034,
0.03487537428736687,
0.03468375280499458,
0.031445324420928955,
-0.045951180160045624,
0.027517054229974747,
-0.008824235759675503,
0.014007636345922947,
-0.011114129796624184,
0.02150009386241436,
-0.007027771323919296,
-0.024700196459889412,
0.03637003153562546,
0.040087517350912094,
0.02012040838599205,
-0.010845857672393322,
-0.01402679830789566,
0.010079366154968739,
0.005442091263830662,
-0.05231305956840515,
-0.05169986933469772,
0.00828769151121378,
0.019229361787438393,
-0.007578686811029911,
-0.012695019133388996,
-0.006438530515879393,
-0.01300161611288786,
-0.040662385523319244,
0.0009185924427583814,
-0.01270460058003664,
-0.01921978034079075,
-0.0024443899746984243,
0.01506156288087368,
-0.01851077564060688,
-0.022343233227729797,
0.006706802640110254,
-0.05649043992161751,
-0.07795220613479614,
0.04840395227074623,
0.060322899371385574,
0.024566059932112694,
-0.0671830028295517,
0.01495616976171732,
-0.02218993566930294,
0.0018060461152344942,
0.037768881767988205,
0.043076835572719574,
-0.024681033566594124,
-0.0013497440377250314,
-0.019583864137530327,
-0.0110470624640584,
0.023991191759705544,
0.034223854541778564,
0.0301422867923975,
0.01765805296599865,
-0.04292353615164757,
-0.007209812756627798,
-0.049745313823223114,
-0.05005190894007683,
-0.009806303307414055,
0.008915256708860397,
0.00004528588760877028,
0.061817560344934464,
-0.022745642811059952,
0.0163454357534647,
0.04426489770412445,
0.02851349301636219,
-0.029394958168268204,
0.018769467249512672,
0.001994076184928417,
-0.028609303757548332,
-0.07691744714975357,
-0.022477369755506516,
0.03230762481689453,
-0.044571492820978165,
0.004704343155026436,
0.04234866797924042,
0.04775243625044823,
-0.015234023332595825,
-0.05672038719058037,
-0.07542278617620468,
0.0356418639421463,
0.03253757581114769,
0.00194856571033597,
-0.0015305881388485432,
0.05511075630784035,
0.01678616926074028,
-0.003621673444285989,
-0.06315892189741135,
0.02529422752559185,
0.0034971185959875584,
-0.036523330956697464,
-0.0017341875936836004,
-0.027191294357180595,
-0.06384876370429993,
-0.03801799193024635,
-0.05392269417643547,
-0.04503139108419418,
0.0186449121683836,
0.02333967387676239,
0.047215890139341354,
-0.03545024245977402,
0.019832974299788475,
0.018290409818291664,
0.05104834958910942,
-0.02531339041888714,
-0.0061415149830281734,
-0.025696635246276855,
-0.02575412206351757,
0.015722662210464478,
-0.0032647757325321436,
0.016680777072906494,
-0.05794677510857582,
0.029241660609841347,
-0.0018838929245248437,
0.024546897038817406,
-0.0238187313079834,
0.05169986933469772,
0.007952352054417133,
0.001982099609449506,
0.08776330202817917,
-0.06664645671844482,
0.010769208893179893,
-0.06335054337978363,
-0.0037342519499361515,
-0.03782636672258377,
0.005815756041556597,
-0.020216219127178192,
0.01920061744749546,
0.010989575646817684,
-0.026022395119071007,
-0.022285746410489082,
0.05070342868566513,
0.008096069097518921,
-0.0031234538182616234,
-0.03274836018681526,
-0.002467145211994648,
0.01775386556982994,
-0.005700782407075167,
-0.00301806116476655,
-0.03414720669388771,
0.06587996333837509,
0.004637274891138077,
0.02897338755428791,
0.04414992406964302,
0.007813424803316593,
0.058138396590948105,
0.02263066917657852,
-0.039742596447467804,
-0.03659997880458832,
0.007899655029177666,
-0.028091922402381897,
-0.027402078732848167,
-0.006179839838296175,
-0.06515179574489594,
-0.04798238351941109,
0.02991233952343464,
-0.021327633410692215,
-0.004816921427845955,
0.011516538448631763,
0.011995595879852772,
0.07733901590108871,
-0.002864762907847762,
-0.0029318309389054775,
-0.0053414893336594105,
0.0016228067688643932,
0.05070342868566513,
-0.014735803939402103,
0.018223341554403305,
-0.057218607515096664,
-0.0021785132121294737,
0.02150009386241436,
-0.025160090997815132,
0.023435484617948532,
0.05035850778222084,
0.038707833737134933,
0.06384876370429993,
-0.02577328495681286,
-0.017322713509202003,
-0.05380772054195404,
-0.04752248898148537,
0.02117433398962021,
-0.038937781006097794,
-0.036044273525476456,
0.058253370225429535,
-0.07599765807390213,
0.03541191667318344,
-0.0510866753757,
0.00902544055134058,
-0.03253757581114769,
0.010261408053338528,
-0.018089205026626587,
-0.04526133835315704,
0.04920876771211624,
-0.008584707044064999,
0.004359421785920858,
-0.04012584313750267,
-0.005533112213015556,
0.03157946094870567,
-0.054574210196733475,
0.0015521458117291331,
-0.061932533979415894,
-0.013739364221692085,
0.036159247159957886,
0.007319996133446693,
0.023780405521392822,
-0.008373922668397427,
0.031560298055410385,
-0.053769394755363464,
-0.01218721829354763,
-0.036044273525476456,
0.014218421652913094,
0.032825008034706116,
0.0014120214618742466,
0.015013656578958035,
-0.0038492255844175816,
-0.03395558521151543,
0.011037481017410755,
0.009264969266951084,
0.023550458252429962,
0.008484105579555035,
0.016642451286315918,
0.0034348410554230213,
-0.05219808593392372,
0.044571492820978165,
-0.006045703776180744,
0.035948462784290314,
-0.030276423320174217,
0.0081296032294631,
0.008383503183722496,
0.00030450080521404743,
0.0545358881354332,
-0.017916744574904442,
-0.01867365464568138,
0.05495745688676834,
0.027651188895106316,
0.004898361396044493,
0.04798238351941109,
-0.029241660609841347,
-0.03207767754793167,
-0.0734299048781395,
-0.016335854306817055,
0.013710620813071728,
0.06185588240623474,
-0.0407390370965004,
-0.002257557585835457,
0.020618626847863197,
0.015904704108834267,
0.047100916504859924
]
|
30,647 | networkx.generators.random_graphs | fast_gnp_random_graph | Returns a $G_{n,p}$ random graph, also known as an Erdős-Rényi graph or
a binomial graph.
Parameters
----------
n : int
The number of nodes.
p : float
Probability for edge creation.
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
directed : bool, optional (default=False)
If True, this function returns a directed graph.
Notes
-----
The $G_{n,p}$ graph algorithm chooses each of the $[n (n - 1)] / 2$
(undirected) or $n (n - 1)$ (directed) possible edges with probability $p$.
This algorithm [1]_ runs in $O(n + m)$ time, where `m` is the expected number of
edges, which equals $p n (n - 1) / 2$. This should be faster than
:func:`gnp_random_graph` when $p$ is small and the expected number of edges
is small (that is, the graph is sparse).
See Also
--------
gnp_random_graph
References
----------
.. [1] Vladimir Batagelj and Ulrik Brandes,
"Efficient generation of large random networks",
Phys. Rev. E, 71, 036113, 2005.
| def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None):
"""Returns a random graph using dual Barabási–Albert preferential attachment
A graph of $n$ nodes is grown by attaching new nodes each with either $m_1$
edges (with probability $p$) or $m_2$ edges (with probability $1-p$) that
are preferentially attached to existing nodes with high degree.
Parameters
----------
n : int
Number of nodes
m1 : int
Number of edges to link each new node to existing nodes with probability $p$
m2 : int
Number of edges to link each new node to existing nodes with probability $1-p$
p : float
The probability of attaching $m_1$ edges (as opposed to $m_2$ edges)
seed : integer, random_state, or None (default)
Indicator of random number generation state.
See :ref:`Randomness<randomness>`.
initial_graph : Graph or None (default)
Initial network for Barabási–Albert algorithm.
A copy of `initial_graph` is used.
It should be connected for most use cases.
If None, starts from an star graph on max(m1, m2) + 1 nodes.
Returns
-------
G : Graph
Raises
------
NetworkXError
If `m1` and `m2` do not satisfy ``1 <= m1,m2 < n``, or
`p` does not satisfy ``0 <= p <= 1``, or
the initial graph number of nodes m0 does not satisfy m1, m2 <= m0 <= n.
References
----------
.. [1] N. Moshiri "The dual-Barabasi-Albert model", arXiv:1810.10538.
"""
if m1 < 1 or m1 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m1 >= 1 and m1 < n, m1 = {m1}, n = {n}"
)
if m2 < 1 or m2 >= n:
raise nx.NetworkXError(
f"Dual Barabási–Albert must have m2 >= 1 and m2 < n, m2 = {m2}, n = {n}"
)
if p < 0 or p > 1:
raise nx.NetworkXError(
f"Dual Barabási–Albert network must have 0 <= p <= 1, p = {p}"
)
# For simplicity, if p == 0 or 1, just return BA
if p == 1:
return barabasi_albert_graph(n, m1, seed)
elif p == 0:
return barabasi_albert_graph(n, m2, seed)
if initial_graph is None:
# Default initial graph : empty graph on max(m1, m2) nodes
G = star_graph(max(m1, m2))
else:
if len(initial_graph) < max(m1, m2) or len(initial_graph) > n:
raise nx.NetworkXError(
f"Barabási–Albert initial graph must have between "
f"max(m1, m2) = {max(m1, m2)} and n = {n} nodes"
)
G = initial_graph.copy()
# Target nodes for new edges
targets = list(G)
# List of existing nodes, with nodes repeated once for each adjacent edge
repeated_nodes = [n for n, d in G.degree() for _ in range(d)]
# Start adding the remaining nodes.
source = len(G)
while source < n:
# Pick which m to use (m1 or m2)
if seed.random() < p:
m = m1
else:
m = m2
# Now choose m unique nodes from the existing nodes
# Pick uniformly from repeated_nodes (preferential attachment)
targets = _random_subset(repeated_nodes, m, seed)
# Add edges to m nodes from the source.
G.add_edges_from(zip([source] * m, targets))
# Add one node to the list for each new edge just created.
repeated_nodes.extend(targets)
# And the new node "source" has m edges to add to the list.
repeated_nodes.extend([source] * m)
source += 1
return G
| (n, p, seed=None, directed=False, *, backend=None, **backend_kwargs) | [
0.0035330478567630053,
0.0015030424110591412,
0.015339415520429611,
0.004939081147313118,
-0.024930143728852272,
-0.04081568494439125,
-0.06480687856674194,
-0.03633170947432518,
0.012043501250445843,
-0.03002731315791607,
0.006491227075457573,
0.04196542128920555,
-0.036868251860141754,
0.10723219066858292,
-0.043038509786129,
0.013011197559535503,
0.034664589911699295,
0.04740751534700394,
-0.005897196009755135,
0.027287105098366737,
-0.04004919156432152,
0.0020264126360416412,
0.00006875221151858568,
0.07101546227931976,
-0.034492127597332,
0.010740465484559536,
-0.03911023959517479,
0.01075004693120718,
-0.015617269091308117,
0.05932645872235298,
0.03920605406165123,
-0.12348181754350662,
0.020982710644602776,
0.039052754640579224,
-0.000130992237245664,
0.010136852972209454,
0.02770867571234703,
0.06116604059934616,
-0.10960831493139267,
-0.03681076690554619,
0.07097713649272919,
-0.05541735142469406,
0.08339430391788483,
0.013078264892101288,
0.024681033566594124,
-0.02391454204916954,
0.03092794120311737,
0.012992034666240215,
-0.09650131314992905,
-0.009839837439358234,
0.016125069931149483,
-0.07051724195480347,
0.026252342388033867,
-0.002377321943640709,
-0.02046532928943634,
0.018501194193959236,
-0.003140220884233713,
0.04460981860756874,
0.017878420650959015,
0.02531339041888714,
0.06300561875104904,
-0.01954553835093975,
-0.014620830304920673,
-0.035239458084106445,
-0.024431923404335976,
0.02195998840034008,
-0.048595577478408813,
-0.02678888663649559,
-0.0014802871737629175,
0.06200918182730675,
0.05035850778222084,
0.06407871097326279,
-0.008052953518927097,
0.05514908209443092,
0.05472750961780548,
0.044341545552015305,
0.048595577478408813,
0.02701883390545845,
-0.052044790238142014,
0.019698837772011757,
0.0041654035449028015,
-0.02584993466734886,
0.011832715943455696,
-0.034338828176259995,
0.0055139497853815556,
-0.015492714010179043,
0.006074447184801102,
0.0031306396704167128,
0.0003173754957970232,
-0.10186675190925598,
-0.048595577478408813,
-0.04982196167111397,
0.05564729869365692,
0.01627836748957634,
0.031560298055410385,
-0.03324658051133156,
-0.006275651045143604,
-0.032365113496780396,
0.00747808488085866,
-0.024566059932112694,
-0.04506971314549446,
0.0436900295317173,
-0.03813296556472778,
0.0006335533107630908,
0.006472064647823572,
0.007200231775641441,
-0.05219808593392372,
0.015138211660087109,
0.020848575979471207,
-0.03533526882529259,
-0.1171199381351471,
0.04357505589723587,
0.07979179173707962,
0.018204178661108017,
-0.022860616445541382,
-0.013317793607711792,
0.014965751208364964,
0.01162193063646555,
0.03194354474544525,
0.03223097696900368,
0.016364598646759987,
0.027076320722699165,
-0.032959144562482834,
-0.00023264222545549273,
0.0007874504663050175,
-0.02402951568365097,
0.04825065657496452,
-0.008623031899333,
-0.012877061031758785,
-0.03874615579843521,
0.010520098730921745,
0.014831614680588245,
-0.04706259444355965,
0.07021064311265945,
-0.012053082697093487,
-0.034434642642736435,
-0.04786740988492966,
0.005729525815695524,
0.06913755089044571,
0.003978571388870478,
-0.0008503267890773714,
-0.06687640398740768,
0.08906634151935577,
0.01288664247840643,
-0.039512649178504944,
-0.021480930969119072,
0.017236482352018356,
-0.057103633880615234,
0.0017617333214730024,
-0.012215961702167988,
0.040087517350912094,
-0.0013257911195978522,
0.020867737010121346,
-0.034664589911699295,
-0.03955097496509552,
0.01768679730594158,
-0.04154385253787041,
-0.000426959857577458,
-0.0232438612729311,
0.014601667411625385,
-0.030621344223618507,
-0.05465086176991463,
0.0487871989607811,
0.05430594086647034,
0.010098529048264027,
-0.03069799393415451,
0.049515366554260254,
0.0018515565898269415,
0.01745685003697872,
-0.03545024245977402,
-0.07434970140457153,
-0.0011694987770169973,
-0.0660332664847374,
-0.061702582985162735,
0.05269630625844002,
-0.0021868967451155186,
-0.026022395119071007,
-0.0310429148375988,
0.029260821640491486,
0.03435799106955528,
0.0382670983672142,
-0.04729254171252251,
0.06779619306325912,
-0.05924981087446213,
-0.030640507116913795,
-0.03543107956647873,
-0.006357091013342142,
0.042961861938238144,
0.018060460686683655,
0.008560754358768463,
0.021327633410692215,
0.024776846170425415,
0.03612092137336731,
0.0609360933303833,
0.025217577815055847,
0.005255259107798338,
0.025140928104519844,
0.014592085964977741,
-0.012915385887026787,
0.011104549281299114,
0.04568290710449219,
0.0022635459899902344,
0.020503653213381767,
0.023148050531744957,
0.02793862298130989,
0.00764575507491827,
-0.032844170928001404,
-0.04196542128920555,
0.0232438612729311,
-0.027210457250475883,
0.004929500166326761,
-0.010500936768949032,
0.028570979833602905,
-0.027076320722699165,
-0.0153585784137249,
-0.06289064884185791,
0.01924852281808853,
0.017159834504127502,
-0.0001020990966935642,
-0.03487537428736687,
0.03209684044122696,
-0.058828242123126984,
0.01093208882957697,
0.025792445987462997,
0.005758269224315882,
0.043766677379608154,
-0.014572924003005028,
0.004060010891407728,
-0.015166955068707466,
0.028954224660992622,
0.033763960003852844,
-0.0008096069213934243,
0.03677244111895561,
-0.02830270677804947,
-0.03918689116835594,
-0.030161449685692787,
0.003053990425541997,
-0.03955097496509552,
-0.035833489149808884,
0.018951507285237312,
-0.029394958168268204,
0.019852135330438614,
-0.020312031731009483,
-0.008963163010776043,
0.02230490930378437,
0.015569363720715046,
0.02828354574739933,
-0.058138396590948105,
-0.06852436065673828,
-0.019813811406493187,
-0.09335869550704956,
-0.012522558681666851,
0.024776846170425415,
0.03148364648222923,
0.026137368753552437,
-0.026482289656996727,
-0.021480930969119072,
0.009753607213497162,
-0.00399533798918128,
0.058598294854164124,
0.007185860071331263,
-0.020407842472195625,
-0.11121795326471329,
0.03163694590330124,
-0.0014742990024387836,
-0.005988216493278742,
-0.0707855150103569,
0.06952080130577087,
-0.013499835506081581,
-0.031330350786447525,
0.061932533979415894,
0.0006814590306021273,
0.008833817206323147,
0.00045091271749697626,
0.026961347088217735,
0.02335883490741253,
-0.012417166493833065,
0.019468890503048897,
-0.019641350954771042,
-0.043536730110645294,
-0.04127557948231697,
-0.043421756476163864,
0.02473852038383484,
0.04541463404893875,
-0.005897196009755135,
0.004232471343129873,
-0.02335883490741253,
-0.06200918182730675,
0.024336112663149834,
-0.033495690673589706,
0.01547355204820633,
-0.028570979833602905,
0.005748688243329525,
0.05001358687877655,
-0.0017198158893734217,
-0.004850455559790134,
0.058713268488645554,
0.023492971435189247,
0.020139571279287338,
-0.008972743526101112,
0.03801799193024635,
-0.00966737698763609,
0.09121251851320267,
0.003942641895264387,
-0.016661614179611206,
-0.03205851837992668,
0.013605228625237942,
-0.025351714342832565,
-0.019832974299788475,
0.020043758675456047,
-0.09052267670631409,
0.025160090997815132,
0.057563528418540955,
0.030870454385876656,
-0.009447010233998299,
-0.0673362985253334,
0.011554863303899765,
0.0006736743962392211,
0.04047076404094696,
-0.003894736059010029,
-0.01734187640249729,
0.03750060871243477,
-0.0013174077030271292,
0.04656437411904335,
-0.01759098470211029,
-0.0022407907526940107,
0.046411074697971344,
0.07500121742486954,
0.0013808828080073,
0.02230490930378437,
-0.04208039492368698,
0.016594545915722847,
-0.01063507329672575,
0.018817372620105743,
-0.08753335475921631,
0.08086487650871277,
-0.02747872844338417,
-0.02333967387676239,
0.06664645671844482,
-0.08592372387647629,
0.021672554314136505,
-0.04671766981482506,
-0.005303164478391409,
-0.01064465381205082,
0.04637274891138077,
0.04407327622175217,
0.01213931292295456,
-0.004071987234055996,
-0.056988660246133804,
0.06932917982339859,
-0.013595647178590298,
0.04192709922790527,
-0.002723440993577242,
0.02577328495681286,
-0.019095225259661674,
0.03357233852148056,
-0.009868580847978592,
0.004416908603161573,
0.010175177827477455,
0.0702872946858406,
-0.02333967387676239,
-0.005734316073358059,
-0.027747001498937607,
-0.013672295957803726,
0.027632027864456177,
0.006304394453763962,
0.0023533692583441734,
0.04384332895278931,
0.03851620852947235,
-0.052504684776067734,
0.06971242278814316,
-0.0671830028295517,
-0.04510803893208504,
0.04920876771211624,
0.010424287989735603,
-0.02876260317862034,
-0.03773055598139763,
0.02012040838599205,
0.03207767754793167,
0.033054955303668976,
-0.01235967967659235,
-0.0395892970263958,
0.009973973967134953,
0.0395892970263958,
-0.00618463009595871,
-0.0120722446590662,
0.07258676737546921,
0.0037893434055149555,
-0.006558294873684645,
-0.026999671012163162,
0.012867479585111141,
-0.02979736588895321,
0.07327660918235779,
0.006984655745327473,
-0.05499578267335892,
0.0050827981904149055,
0.04116060584783554,
-0.026022395119071007,
-0.0371173620223999,
-0.0035570007748901844,
0.002562956651672721,
0.016929885372519493,
-0.050550129264593124,
-0.023627107962965965,
-0.005676829256117344,
-0.03393642231822014,
0.02784281224012375,
0.027976948767900467,
0.01131533458828926,
0.015004076063632965,
-0.015147793106734753,
0.023033076897263527,
-0.019008995965123177,
-0.011688998900353909,
0.023665431886911392,
-0.0010718908160924911,
-0.005901986267417669,
-0.020177895203232765,
0.010893763974308968,
0.014975332655012608,
0.03242260217666626,
-0.007851749658584595,
0.006486436352133751,
-0.02483433298766613,
0.044111598283052444,
0.0057678502053022385,
-0.05104834958910942,
0.019622188061475754,
-0.08155471831560135,
0.022132448852062225,
0.053999342024326324,
-0.0395892970263958,
0.03343820199370384,
-0.04300018772482872,
0.024642709642648697,
0.008536801673471928,
0.028915900737047195,
0.005365442018955946,
0.05672038719058037,
-0.022975590080022812,
0.012129731476306915,
0.02220909856259823,
0.011688998900353909,
-0.05741023272275925,
-0.029586581513285637,
-0.04564458131790161,
-0.021710878238081932,
-0.0012862689327448606,
0.01614423282444477,
-0.020503653213381767,
-0.005691200960427523,
-0.005245677661150694,
0.07116875797510147,
-0.00673075532540679,
-0.047445837408304214,
0.03577600046992302,
0.059748031198978424,
-0.02795778587460518,
-0.034664589911699295,
0.10064036399126053,
0.014869939535856247,
0.006975074764341116,
0.01230219192802906,
0.09581146389245987,
0.03426218032836914,
-0.019162293523550034,
0.05419096723198891,
-0.02002459578216076,
-0.01529151014983654,
0.03797966614365578,
-0.018980251625180244,
0.00016737065743654966,
0.015550200827419758,
-0.033054955303668976,
-0.016814911738038063,
-0.038707833737134933,
-0.009442220441997051,
-0.03966594859957695,
-0.011305753141641617,
-0.011229104362428188,
0.01736103743314743,
0.004014500416815281,
0.010309313423931599,
0.03221181407570839,
0.022860616445541382,
-0.027804488316178322,
-0.035584378987550735,
0.025370877236127853,
0.011986014433205128,
0.0026731400284916162,
-0.07312331348657608,
-0.08009838312864304,
0.022381559014320374,
0.03700238838791847,
-0.051469918340444565,
-0.012618370354175568,
-0.01717899553477764,
-0.04798238351941109,
-0.007521199993789196,
-0.07634257525205612,
0.01924852281808853,
-0.011152454651892185,
-0.014678317122161388,
-0.04656437411904335,
0.007391854654997587,
0.00042666043736971915,
-0.002123421523720026,
-0.017466429620981216,
0.0022312095388770103,
0.06346551328897476,
-0.00010831186955329031,
-0.023857055231928825,
0.0376155823469162,
0.03688741475343704,
-0.014601667411625385,
0.016287948936223984,
-0.008613450452685356,
0.00457499735057354,
0.05139327049255371,
-0.02876260317862034,
0.03487537428736687,
0.03468375280499458,
0.031445324420928955,
-0.045951180160045624,
0.027517054229974747,
-0.008824235759675503,
0.014007636345922947,
-0.011114129796624184,
0.02150009386241436,
-0.007027771323919296,
-0.024700196459889412,
0.03637003153562546,
0.040087517350912094,
0.02012040838599205,
-0.010845857672393322,
-0.01402679830789566,
0.010079366154968739,
0.005442091263830662,
-0.05231305956840515,
-0.05169986933469772,
0.00828769151121378,
0.019229361787438393,
-0.007578686811029911,
-0.012695019133388996,
-0.006438530515879393,
-0.01300161611288786,
-0.040662385523319244,
0.0009185924427583814,
-0.01270460058003664,
-0.01921978034079075,
-0.0024443899746984243,
0.01506156288087368,
-0.01851077564060688,
-0.022343233227729797,
0.006706802640110254,
-0.05649043992161751,
-0.07795220613479614,
0.04840395227074623,
0.060322899371385574,
0.024566059932112694,
-0.0671830028295517,
0.01495616976171732,
-0.02218993566930294,
0.0018060461152344942,
0.037768881767988205,
0.043076835572719574,
-0.024681033566594124,
-0.0013497440377250314,
-0.019583864137530327,
-0.0110470624640584,
0.023991191759705544,
0.034223854541778564,
0.0301422867923975,
0.01765805296599865,
-0.04292353615164757,
-0.007209812756627798,
-0.049745313823223114,
-0.05005190894007683,
-0.009806303307414055,
0.008915256708860397,
0.00004528588760877028,
0.061817560344934464,
-0.022745642811059952,
0.0163454357534647,
0.04426489770412445,
0.02851349301636219,
-0.029394958168268204,
0.018769467249512672,
0.001994076184928417,
-0.028609303757548332,
-0.07691744714975357,
-0.022477369755506516,
0.03230762481689453,
-0.044571492820978165,
0.004704343155026436,
0.04234866797924042,
0.04775243625044823,
-0.015234023332595825,
-0.05672038719058037,
-0.07542278617620468,
0.0356418639421463,
0.03253757581114769,
0.00194856571033597,
-0.0015305881388485432,
0.05511075630784035,
0.01678616926074028,
-0.003621673444285989,
-0.06315892189741135,
0.02529422752559185,
0.0034971185959875584,
-0.036523330956697464,
-0.0017341875936836004,
-0.027191294357180595,
-0.06384876370429993,
-0.03801799193024635,
-0.05392269417643547,
-0.04503139108419418,
0.0186449121683836,
0.02333967387676239,
0.047215890139341354,
-0.03545024245977402,
0.019832974299788475,
0.018290409818291664,
0.05104834958910942,
-0.02531339041888714,
-0.0061415149830281734,
-0.025696635246276855,
-0.02575412206351757,
0.015722662210464478,
-0.0032647757325321436,
0.016680777072906494,
-0.05794677510857582,
0.029241660609841347,
-0.0018838929245248437,
0.024546897038817406,
-0.0238187313079834,
0.05169986933469772,
0.007952352054417133,
0.001982099609449506,
0.08776330202817917,
-0.06664645671844482,
0.010769208893179893,
-0.06335054337978363,
-0.0037342519499361515,
-0.03782636672258377,
0.005815756041556597,
-0.020216219127178192,
0.01920061744749546,
0.010989575646817684,
-0.026022395119071007,
-0.022285746410489082,
0.05070342868566513,
0.008096069097518921,
-0.0031234538182616234,
-0.03274836018681526,
-0.002467145211994648,
0.01775386556982994,
-0.005700782407075167,
-0.00301806116476655,
-0.03414720669388771,
0.06587996333837509,
0.004637274891138077,
0.02897338755428791,
0.04414992406964302,
0.007813424803316593,
0.058138396590948105,
0.02263066917657852,
-0.039742596447467804,
-0.03659997880458832,
0.007899655029177666,
-0.028091922402381897,
-0.027402078732848167,
-0.006179839838296175,
-0.06515179574489594,
-0.04798238351941109,
0.02991233952343464,
-0.021327633410692215,
-0.004816921427845955,
0.011516538448631763,
0.011995595879852772,
0.07733901590108871,
-0.002864762907847762,
-0.0029318309389054775,
-0.0053414893336594105,
0.0016228067688643932,
0.05070342868566513,
-0.014735803939402103,
0.018223341554403305,
-0.057218607515096664,
-0.0021785132121294737,
0.02150009386241436,
-0.025160090997815132,
0.023435484617948532,
0.05035850778222084,
0.038707833737134933,
0.06384876370429993,
-0.02577328495681286,
-0.017322713509202003,
-0.05380772054195404,
-0.04752248898148537,
0.02117433398962021,
-0.038937781006097794,
-0.036044273525476456,
0.058253370225429535,
-0.07599765807390213,
0.03541191667318344,
-0.0510866753757,
0.00902544055134058,
-0.03253757581114769,
0.010261408053338528,
-0.018089205026626587,
-0.04526133835315704,
0.04920876771211624,
-0.008584707044064999,
0.004359421785920858,
-0.04012584313750267,
-0.005533112213015556,
0.03157946094870567,
-0.054574210196733475,
0.0015521458117291331,
-0.061932533979415894,
-0.013739364221692085,
0.036159247159957886,
0.007319996133446693,
0.023780405521392822,
-0.008373922668397427,
0.031560298055410385,
-0.053769394755363464,
-0.01218721829354763,
-0.036044273525476456,
0.014218421652913094,
0.032825008034706116,
0.0014120214618742466,
0.015013656578958035,
-0.0038492255844175816,
-0.03395558521151543,
0.011037481017410755,
0.009264969266951084,
0.023550458252429962,
0.008484105579555035,
0.016642451286315918,
0.0034348410554230213,
-0.05219808593392372,
0.044571492820978165,
-0.006045703776180744,
0.035948462784290314,
-0.030276423320174217,
0.0081296032294631,
0.008383503183722496,
0.00030450080521404743,
0.0545358881354332,
-0.017916744574904442,
-0.01867365464568138,
0.05495745688676834,
0.027651188895106316,
0.004898361396044493,
0.04798238351941109,
-0.029241660609841347,
-0.03207767754793167,
-0.0734299048781395,
-0.016335854306817055,
0.013710620813071728,
0.06185588240623474,
-0.0407390370965004,
-0.002257557585835457,
0.020618626847863197,
0.015904704108834267,
0.047100916504859924
]
|
30,654 | networkx.algorithms.cycles | find_cycle | Returns a cycle found via depth-first traversal.
The cycle is a list of edges indicating the cyclic path.
Orientation of directed edges is controlled by `orientation`.
Parameters
----------
G : graph
A directed/undirected graph/multigraph.
source : node, list of nodes
The node from which the traversal begins. If None, then a source
is chosen arbitrarily and repeatedly until all edges from each node in
the graph are searched.
orientation : None | 'original' | 'reverse' | 'ignore' (default: None)
For directed graphs and directed multigraphs, edge traversals need not
respect the original orientation of the edges.
When set to 'reverse' every edge is traversed in the reverse direction.
When set to 'ignore', every edge is treated as undirected.
When set to 'original', every edge is treated as directed.
In all three cases, the yielded edge tuples add a last entry to
indicate the direction in which that edge was traversed.
If orientation is None, the yielded edge has no direction indicated.
The direction is respected, but not reported.
Returns
-------
edges : directed edges
A list of directed edges indicating the path taken for the loop.
If no cycle is found, then an exception is raised.
For graphs, an edge is of the form `(u, v)` where `u` and `v`
are the tail and head of the edge as determined by the traversal.
For multigraphs, an edge is of the form `(u, v, key)`, where `key` is
the key of the edge. When the graph is directed, then `u` and `v`
are always in the order of the actual directed edge.
If orientation is not None then the edge tuple is extended to include
the direction of traversal ('forward' or 'reverse') on that edge.
Raises
------
NetworkXNoCycle
If no cycle was found.
Examples
--------
In this example, we construct a DAG and find, in the first call, that there
are no directed cycles, and so an exception is raised. In the second call,
we ignore edge orientations and find that there is an undirected cycle.
Note that the second call finds a directed cycle while effectively
traversing an undirected graph, and so, we found an "undirected cycle".
This means that this DAG structure does not form a directed tree (which
is also known as a polytree).
>>> G = nx.DiGraph([(0, 1), (0, 2), (1, 2)])
>>> nx.find_cycle(G, orientation="original")
Traceback (most recent call last):
...
networkx.exception.NetworkXNoCycle: No cycle found.
>>> list(nx.find_cycle(G, orientation="ignore"))
[(0, 1, 'forward'), (1, 2, 'forward'), (0, 2, 'reverse')]
See Also
--------
simple_cycles
| def recursive_simple_cycles(G):
"""Find simple cycles (elementary circuits) of a directed graph.
A `simple cycle`, or `elementary circuit`, is a closed path where
no node appears twice. Two elementary circuits are distinct if they
are not cyclic permutations of each other.
This version uses a recursive algorithm to build a list of cycles.
You should probably use the iterator version called simple_cycles().
Warning: This recursive version uses lots of RAM!
It appears in NetworkX for pedagogical value.
Parameters
----------
G : NetworkX DiGraph
A directed graph
Returns
-------
A list of cycles, where each cycle is represented by a list of nodes
along the cycle.
Example:
>>> edges = [(0, 0), (0, 1), (0, 2), (1, 2), (2, 0), (2, 1), (2, 2)]
>>> G = nx.DiGraph(edges)
>>> nx.recursive_simple_cycles(G)
[[0], [2], [0, 1, 2], [0, 2], [1, 2]]
Notes
-----
The implementation follows pp. 79-80 in [1]_.
The time complexity is $O((n+e)(c+1))$ for $n$ nodes, $e$ edges and $c$
elementary circuits.
References
----------
.. [1] Finding all the elementary circuits of a directed graph.
D. B. Johnson, SIAM Journal on Computing 4, no. 1, 77-84, 1975.
https://doi.org/10.1137/0204007
See Also
--------
simple_cycles, cycle_basis
"""
# Jon Olav Vik, 2010-08-09
def _unblock(thisnode):
"""Recursively unblock and remove nodes from B[thisnode]."""
if blocked[thisnode]:
blocked[thisnode] = False
while B[thisnode]:
_unblock(B[thisnode].pop())
def circuit(thisnode, startnode, component):
closed = False # set to True if elementary path is closed
path.append(thisnode)
blocked[thisnode] = True
for nextnode in component[thisnode]: # direct successors of thisnode
if nextnode == startnode:
result.append(path[:])
closed = True
elif not blocked[nextnode]:
if circuit(nextnode, startnode, component):
closed = True
if closed:
_unblock(thisnode)
else:
for nextnode in component[thisnode]:
if thisnode not in B[nextnode]: # TODO: use set for speedup?
B[nextnode].append(thisnode)
path.pop() # remove thisnode from path
return closed
path = [] # stack of nodes in current path
blocked = defaultdict(bool) # vertex: blocked from search?
B = defaultdict(list) # graph portions that yield no elementary circuit
result = [] # list to accumulate the circuits found
# Johnson's algorithm exclude self cycle edges like (v, v)
# To be backward compatible, we record those cycles in advance
# and then remove from subG
for v in G:
if G.has_edge(v, v):
result.append([v])
G.remove_edge(v, v)
# Johnson's algorithm requires some ordering of the nodes.
# They might not be sortable so we assign an arbitrary ordering.
ordering = dict(zip(G, range(len(G))))
for s in ordering:
# Build the subgraph induced by s and following nodes in the ordering
subgraph = G.subgraph(node for node in G if ordering[node] >= ordering[s])
# Find the strongly connected component in the subgraph
# that contains the least node according to the ordering
strongcomp = nx.strongly_connected_components(subgraph)
mincomp = min(strongcomp, key=lambda ns: min(ordering[n] for n in ns))
component = G.subgraph(mincomp)
if len(component) > 1:
# smallest node in the component according to the ordering
startnode = min(component, key=ordering.__getitem__)
for node in component:
blocked[node] = False
B[node][:] = []
dummy = circuit(startnode, startnode, component)
return result
| (G, source=None, orientation=None, *, backend=None, **backend_kwargs) | [
0.021086517721414566,
-0.03180550038814545,
-0.041313957422971725,
0.02907206118106842,
-0.03901005908846855,
-0.0010500549105927348,
-0.03861956670880318,
-0.014575080014765263,
0.0755990743637085,
-0.0590813010931015,
-0.025030478835105896,
0.03914673253893852,
0.00014147674664855003,
0.0024771778844296932,
-0.029950665310025215,
-0.028408225625753403,
0.0031507748644798994,
0.003004340687766671,
-0.03617899864912033,
0.0388343371450901,
-0.01596132293343544,
-0.04217303544282913,
0.04107966274023056,
0.047639913856983185,
-0.018850957974791527,
0.05915939807891846,
-0.0024283663369715214,
0.024249495938420296,
-0.09793516248464584,
-0.020598404109477997,
0.012895967811346054,
0.002019571140408516,
-0.07954303175210953,
-0.04998285695910454,
0.02434711903333664,
0.06618823856115341,
0.015102243050932884,
0.052364856004714966,
-0.07841061055660248,
0.009113085456192493,
0.03194217011332512,
-0.010006333701312542,
0.011265668086707592,
-0.050334300845861435,
0.043266411870718,
-0.014672702178359032,
0.029755420982837677,
0.08582994341850281,
-0.014331023208796978,
-0.0543954074382782,
0.05154482275247574,
-0.005764624569565058,
-0.04147015139460564,
0.0011775746243074536,
0.04455503448843956,
0.011177807115018368,
0.010221104137599468,
0.04357880353927612,
0.0726313441991806,
-0.02495237998664379,
-0.01398934330791235,
-0.02180892787873745,
0.024444742128252983,
0.05216960981488228,
-0.05865176022052765,
-0.014897234737873077,
-0.013432892970740795,
-0.04736656695604324,
-0.008351627737283707,
0.002242883201688528,
0.0036852597258985043,
-0.004822564776986837,
0.01771853305399418,
-0.04775705933570862,
-0.014760563150048256,
-0.052208658307790756,
-0.00852734874933958,
-0.008083165623247623,
-0.00513495784252882,
-0.022257991135120392,
0.02448379062116146,
-0.011236380785703659,
0.002489380771294236,
-0.04728846997022629,
0.02909158542752266,
-0.00035967890289612114,
0.015375586226582527,
0.03649139031767845,
-0.04025962948799133,
-0.023780906572937965,
-0.00722896633669734,
-0.024718085303902626,
0.0066139427945017815,
0.09004724770784378,
0.027431998401880264,
0.0034119158517569304,
-0.035651836544275284,
-0.05533258616924286,
0.030751172453165054,
0.0014680024469271302,
0.007111818995326757,
0.003907351288944483,
-0.11691302806138992,
-0.013393844477832317,
-0.024249495938420296,
-0.026280049234628677,
-0.03362128138542175,
0.0233708918094635,
0.008244243450462818,
-0.08645472675561905,
-0.05185721442103386,
0.05642596259713173,
0.01596132293343544,
-0.03463656082749367,
-0.010865414515137672,
0.0594327412545681,
0.028330128639936447,
-0.027236752212047577,
0.007121581118553877,
-0.014272449538111687,
-0.014496981166303158,
-0.021594157442450523,
-0.041626349091529846,
0.044515982270240784,
0.02087174914777279,
-0.001635181368328631,
0.009059392847120762,
0.02132081240415573,
0.008717713877558708,
-0.008200312964618206,
0.06189283728599548,
0.03807288035750389,
0.023448988795280457,
0.07032744586467743,
-0.000648581306450069,
-0.022824203595519066,
-0.05181816592812538,
-0.01975884847342968,
-0.019075488671660423,
0.016488486900925636,
-0.01609799452126026,
-0.1049640029668808,
0.012261420488357544,
0.06646158546209335,
0.03955674543976784,
-0.01547320932149887,
0.03572993353009224,
-0.024600937962532043,
0.002818857552483678,
0.030243534594774246,
0.014428645372390747,
0.0024259258061647415,
0.025694312527775764,
0.0019536756444722414,
0.02194559946656227,
-0.003343579825013876,
-0.040532976388931274,
0.045453161001205444,
-0.04619509354233742,
0.02434711903333664,
-0.03192264586687088,
-0.0063991728238761425,
-0.024679036810994148,
0.006950741168111563,
-0.0279786866158247,
0.019046202301979065,
0.02356613613665104,
-0.00853222981095314,
-0.05216960981488228,
0.025499068200588226,
0.007282658945769072,
0.006438221782445908,
-0.07173321396112442,
0.01114852074533701,
0.003756036050617695,
0.03569088503718376,
0.013208361342549324,
0.03719427436590195,
0.010679931379854679,
-0.01879238337278366,
-0.02167225442826748,
-0.009357142262160778,
-0.026280049234628677,
-0.015365824103355408,
0.014428645372390747,
0.028701094910502434,
0.06833594292402267,
-0.051154330372810364,
0.05818317085504532,
0.009220470674335957,
-0.06318145990371704,
0.010289439931511879,
0.044945523142814636,
0.05763648450374603,
0.06997600197792053,
-0.037838585674762726,
-0.020305536687374115,
0.02987256832420826,
-0.05865176022052765,
0.08145643770694733,
0.014126014895737171,
0.030712123960256577,
0.0536925233900547,
-0.0022843729238957167,
0.04521886631846428,
0.03270362690091133,
0.014662940055131912,
-0.005520567763596773,
0.016390863806009293,
0.01359885185956955,
-0.056152619421482086,
-0.05107623338699341,
0.03194217011332512,
-0.016566583886742592,
-0.041196808218955994,
0.026319099590182304,
-0.0032850061543285847,
0.01930978335440159,
0.017738057300448418,
-0.06872642785310745,
-0.03321126848459244,
0.01026015356183052,
-0.00892272125929594,
-0.022785155102610588,
-0.009981928393244743,
-0.02514762617647648,
0.03916625678539276,
0.012544525787234306,
0.02684626169502735,
-0.021691780537366867,
0.02782248891890049,
0.004729823209345341,
0.0436178557574749,
-0.011343766003847122,
0.010416349396109581,
-0.05345822870731354,
-0.03676473721861839,
0.004651724826544523,
0.020305536687374115,
-0.0024247055407613516,
-0.048772335052490234,
-0.06966360658407211,
-0.0008285732474178076,
-0.012817869894206524,
0.014487219043076038,
-0.015678217634558678,
0.0404939241707325,
-0.0001376633590552956,
-0.013921007513999939,
-0.0012947219656780362,
-0.080987848341465,
-0.051896266639232635,
-0.0007260693819262087,
-0.06544630229473114,
0.008517586626112461,
-0.04029868170619011,
-0.04529696702957153,
-0.026963409036397934,
-0.00047469072160311043,
0.011412101797759533,
0.011441389098763466,
0.016781354323029518,
-0.04724942147731781,
0.021906549111008644,
-0.0024356881622225046,
0.008595684543251991,
0.01122661866247654,
0.017347566783428192,
-0.03362128138542175,
0.026924360543489456,
0.07606766372919083,
-0.05869080871343613,
0.011343766003847122,
0.008615209721028805,
-0.04724942147731781,
0.027080556377768517,
-0.005569379311054945,
0.031239286065101624,
-0.02276563085615635,
-0.05259915068745613,
-0.07876205444335938,
0.027412474155426025,
0.0006626145332120359,
-0.00446136062964797,
-0.047015126794576645,
-0.014721513725817204,
0.0048030405305325985,
-0.042446382343769073,
0.0006296669016592205,
-0.00560842826962471,
0.07442759722471237,
-0.033718906342983246,
0.05123243108391762,
0.028564423322677612,
0.04467217996716499,
0.0063991728238761425,
-0.020949846133589745,
-0.07844965904951096,
0.0022831526584923267,
0.026299575343728065,
0.010943512432277203,
-0.050178103148937225,
0.0018121226457878947,
-0.0262410007417202,
0.007311945781111717,
-0.04471122846007347,
0.00930833164602518,
-0.02368328347802162,
-0.00001654057632549666,
-0.01170497015118599,
-0.0490066297352314,
0.024054251611232758,
0.011480437591671944,
0.022082271054387093,
-0.004783515818417072,
-0.060135625302791595,
-0.028369177132844925,
-0.021633205935359,
0.0679454505443573,
0.052403904497623444,
0.01565869338810444,
0.04350070655345917,
-0.04311021417379379,
0.04088441655039787,
-0.059510841965675354,
0.0448283776640892,
0.0637671947479248,
0.05259915068745613,
0.037038080394268036,
0.005383895710110664,
-0.005623071454465389,
0.022882778197526932,
-0.014126014895737171,
0.043071165680885315,
0.0037169870920479298,
0.011421863920986652,
0.06263477355241776,
-0.05470779910683632,
-0.02210179530084133,
-0.07985542714595795,
0.07618480920791626,
0.0540439672768116,
-0.013921007513999939,
-0.01878262124955654,
0.0026846262626349926,
-0.009152134880423546,
0.04931902512907982,
0.01168544590473175,
-0.020637454465031624,
0.026026230305433273,
0.03289887309074402,
0.06817974150180817,
-0.03602280095219612,
0.019485505297780037,
-0.025030478835105896,
0.029911616817116737,
0.010660406202077866,
-0.005315559916198254,
-0.010650644078850746,
-0.0052081746980547905,
0.026201952248811722,
0.036881882697343826,
-0.008092927746474743,
-0.013891720212996006,
0.04849899187684059,
-0.006013562902808189,
-0.017630672082304955,
0.04346165806055069,
0.002008588518947363,
-0.05502019450068474,
-0.0341484434902668,
-0.00020088936435058713,
0.006135591305792332,
-0.0031971456483006477,
0.002235561376437545,
0.03522229567170143,
0.024913331493735313,
-0.016195617616176605,
0.05275534465909004,
0.02704150788486004,
-0.0010939851636067033,
-0.006775020156055689,
0.0010787316132336855,
0.011529249139130116,
0.030224010348320007,
-0.0028115357272326946,
0.04459408298134804,
0.02700245939195156,
0.08278410881757736,
-0.011382815428078175,
-0.04611699655652046,
-0.05076384171843529,
0.02383948117494583,
0.009078918024897575,
-0.045765556395053864,
-0.01257381308823824,
0.14377881586551666,
0.035476114600896835,
-0.00799042358994484,
-0.013950293883681297,
-0.0002571749791968614,
0.013755048625171185,
0.030263058841228485,
0.028954913839697838,
0.005530329886823893,
-0.028310604393482208,
0.047952305525541306,
0.0001777039433363825,
0.002721234690397978,
-0.007526715751737356,
-0.031239286065101624,
0.009825731627643108,
0.004722501616925001,
-0.016966838389635086,
0.013247409835457802,
-0.05584022402763367,
-0.037877634167671204,
-0.000935958290938288,
0.07345137000083923,
0.024718085303902626,
0.04287591949105263,
-0.00845413189381361,
0.04572650417685509,
-0.008205194026231766,
0.009576793760061264,
0.020910797640681267,
0.026943884789943695,
0.03338698670268059,
-0.04642938822507858,
0.06825783848762512,
-0.003219110891222954,
-0.029150160029530525,
-0.028954913839697838,
-0.049240924417972565,
-0.01974908635020256,
-0.024620462208986282,
0.04365690425038338,
-0.02053983137011528,
0.05736314132809639,
0.026338623836636543,
-0.021633205935359,
0.06478247046470642,
-0.009366905316710472,
-0.03559326380491257,
0.051622919738292694,
-0.01848975196480751,
0.004141645971685648,
0.033133167773485184,
0.011968552134931087,
-0.017025411128997803,
0.02132081240415573,
-0.028818242251873016,
0.03096594288945198,
-0.05150577425956726,
-0.12277039885520935,
0.031375959515571594,
0.01800163835287094,
0.018684998154640198,
-0.05041239783167839,
0.025245249271392822,
0.06681302189826965,
0.022238466888666153,
0.016966838389635086,
0.013833146542310715,
-0.053497277200222015,
-0.04279782250523567,
0.011353528127074242,
0.01492652203887701,
-0.021847976371645927,
0.004007414914667606,
0.03446083888411522,
-0.022843727841973305,
-0.08051925897598267,
-0.03266457840800285,
0.030380206182599068,
-0.02118414081633091,
-0.07161606848239899,
-0.0131205003708601,
-0.0017755141016095877,
-0.08122214674949646,
-0.07544288039207458,
-0.014653177931904793,
0.022179894149303436,
-0.017611147835850716,
-0.0037804418243467808,
-0.030868319794535637,
0.03908815607428551,
-0.005461994092911482,
-0.02292182669043541,
-0.05974513664841652,
-0.052208658307790756,
-0.020481256768107414,
-0.021613681688904762,
0.01020157989114523,
0.025538116693496704,
0.06892167776823044,
-0.04428168758749962,
-0.018440941348671913,
0.08871957659721375,
-0.024425217881798744,
0.012417616322636604,
-0.004517493769526482,
-0.0007468141848221421,
0.008620090782642365,
0.04541411250829697,
0.031102614477276802,
0.015307250432670116,
-0.0072143226861953735,
0.025401445105671883,
0.006770139094442129,
0.02811535820364952,
-0.006130710244178772,
0.01930978335440159,
0.044984571635723114,
0.010953274555504322,
0.0017303635831922293,
-0.013803860172629356,
-0.004153849091380835,
0.03639376908540726,
-0.0270219836384058,
0.012964303605258465,
0.02022743783891201,
0.0049079847522079945,
0.05357537791132927,
-0.008478538133203983,
0.019866233691573143,
-0.0006253958563320339,
-0.05060764402151108,
-0.026768164709210396,
-0.008341865614056587,
0.006042849738150835,
0.020325060933828354,
-0.025674788281321526,
0.09606080502271652,
0.010230866260826588,
-0.016869215294718742,
0.04721037298440933,
0.01836284250020981,
-0.05869080871343613,
0.0008950787596404552,
0.022980399429798126,
0.03901005908846855,
0.07067888975143433,
0.009176540188491344,
0.006731090135872364,
0.020500781014561653,
0.05642596259713173,
0.016781354323029518,
-0.03297697380185127,
-0.036745209246873856,
-0.004078191239386797,
0.006745733320713043,
-0.007448617368936539,
-0.0279786866158247,
0.06279096752405167,
-0.08512705564498901,
-0.0206765029579401,
0.014487219043076038,
0.0028969557024538517,
0.0245033148676157,
-0.03303554654121399,
0.0034216782078146935,
-0.06575869768857956,
-0.08247171342372894,
0.04107966274023056,
-0.022316565737128258,
0.07532572746276855,
-0.02954065054655075,
0.018597137182950974,
0.03328936547040939,
0.012964303605258465,
-0.0020781448110938072,
0.03297697380185127,
-0.026768164709210396,
-0.0010213782079517841,
0.03711617738008499,
-0.02052030712366104,
-0.021535582840442657,
0.001021988340653479,
-0.0695074126124382,
-0.007604813668876886,
-0.044320739805698395,
-0.007121581118553877,
0.012495714239776134,
0.059354644268751144,
-0.008088046684861183,
-0.022550860419869423,
0.004124562256038189,
-0.030399730429053307,
-0.007282658945769072,
0.030067812651395798,
-0.05923749879002571,
0.03065354935824871,
-0.00568652618676424,
-0.02055935561656952,
0.032176464796066284,
-0.002796892309561372,
0.02731485106050968,
-0.003531503723934293,
-0.014096728526055813,
-0.03205931931734085,
0.015756314620375633,
0.04041582718491554,
0.04998285695910454,
-0.034656085073947906,
0.023468514904379845,
0.019788134843111038,
-0.06306430697441101,
0.04408644512295723,
-0.018860720098018646,
0.0019732003565877676,
0.05263819918036461,
-0.0033240553457289934,
0.006482151802629232,
-0.06696922332048416,
0.011822117492556572,
-0.04342260956764221,
0.015209627337753773,
-0.024229971691966057,
-0.008039235137403011,
0.0068677617236971855,
0.0013142465613782406,
0.013286459259688854,
-0.028056783601641655,
-0.07095222920179367,
0.02559669129550457,
0.023468514904379845,
0.009513339027762413,
0.029325880110263824,
0.06997600197792053,
0.013696474954485893,
-0.004859173204749823,
-0.012261420488357544,
0.058222219347953796,
0.007219203747808933,
-0.06942931562662125,
0.00199760589748621,
-0.002643136540427804,
-0.013208361342549324,
0.08747000247240067,
-0.06646158546209335,
-0.015512258745729923,
-0.05244295299053192,
0.01819688454270363,
-0.07821536064147949,
-0.04549220949411392,
0.031161189079284668,
-0.04475027695298195,
0.019075488671660423,
0.04127490893006325,
-0.03098546713590622,
0.023312317207455635,
0.029950665310025215,
-0.014496981166303158,
-0.0058378418907523155,
0.05338013172149658,
0.03981056436896324,
-0.0318835973739624,
0.017738057300448418,
-0.04045487567782402,
0.05642596259713173,
0.005349727813154459,
0.015346299856901169,
-0.012964303605258465,
-0.02098889648914337,
-0.003016543574631214,
0.07349041849374771,
-0.02132081240415573,
-0.03463656082749367,
0.01540487352758646,
-0.022257991135120392,
-0.06786735355854034,
0.0022892539855092764,
-0.024151872843503952,
-0.07770772278308868,
-0.004075750708580017,
-0.038014307618141174,
0.04076727107167244,
-0.007492547854781151,
-0.017171844840049744,
0.016664206981658936,
0.012271182611584663,
-0.029755420982837677,
-0.0334455631673336,
-0.0006211248692125082,
-0.002493041567504406,
-0.0021623442880809307,
-0.05341918021440506,
0.03748714551329613,
-0.07860585302114487,
0.001820664736442268,
0.013179074041545391,
0.03364080563187599,
0.018265221267938614,
-0.014487219043076038,
0.024737609550356865,
0.01658610813319683,
0.010055145248770714,
0.04439883679151535,
-0.053184885531663895,
0.05431731045246124,
-0.013149787671864033,
0.02052030712366104,
0.028876814991235733,
-0.0026114091742783785,
0.00008618260471848771,
-0.05146672576665878,
0.004973880015313625,
0.029970191419124603,
0.04381309822201729,
-0.0016046742675825953,
0.009571912698447704,
-0.003389950841665268,
-0.0037340710405260324,
0.017777105793356895,
-0.06743781268596649,
-0.014584842137992382,
-0.02368328347802162,
-0.04611699655652046,
0.029267307370901108,
-0.0051447199657559395,
0.009147253818809986,
-0.026748638600111008,
0.03082927130162716,
-0.022531336173415184,
0.09020344167947769,
0.051115281879901886,
-0.02321469411253929,
0.01500461995601654,
-0.020617928355932236,
-0.04127490893006325,
0.06279096752405167,
-0.010982561856508255,
0.03125881031155586,
0.02530382201075554,
-0.04443788528442383,
-0.020656978711485863,
0.0033240553457289934,
-0.010103956796228886,
0.029755420982837677,
-0.00609166081994772,
-0.035964228212833405,
-0.06283001601696014,
0.029618749395012856,
-0.01830426976084709,
-0.022004172205924988,
0.011002086102962494,
0.062205228954553604,
0.01800163835287094,
-0.09746657311916351,
-0.005691407714039087,
-0.031668826937675476,
-0.027900587767362595,
-0.0395372211933136,
-0.008751881308853626,
0.010113718919456005,
-0.05970608815550804,
-0.010016096755862236,
-0.05138862505555153,
-0.05353632941842079,
-0.013940531760454178,
0.007770772557705641,
0.022082271054387093,
0.0233708918094635,
-0.03426559269428253,
0.029345404356718063,
0.00032368049141950905,
0.05599642172455788
]
|
30,657 | networkx.algorithms.shortest_paths.weighted | find_negative_cycle | Returns a cycle with negative total weight if it exists.
Bellman-Ford is used to find shortest_paths. That algorithm
stops if there exists a negative cycle. This algorithm
picks up from there and returns the found negative cycle.
The cycle consists of a list of nodes in the cycle order. The last
node equals the first to make it a cycle.
You can look up the edge weights in the original graph. In the case
of multigraphs the relevant edge is the minimal weight edge between
the nodes in the 2-tuple.
If the graph has no negative cycle, a NetworkXError is raised.
Parameters
----------
G : NetworkX graph
source: node label
The search for the negative cycle will start from this node.
weight : string or function
If this is a string, then edge weights will be accessed via the
edge attribute with this key (that is, the weight of the edge
joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
such edge attribute exists, the weight of the edge is assumed to
be one.
If this is a function, the weight of an edge is the value
returned by the function. The function must accept exactly three
positional arguments: the two endpoints of an edge and the
dictionary of edge attributes for that edge. The function must
return a number.
Examples
--------
>>> G = nx.DiGraph()
>>> G.add_weighted_edges_from([(0, 1, 2), (1, 2, 2), (2, 0, 1), (1, 4, 2), (4, 0, -5)])
>>> nx.find_negative_cycle(G, 0)
[4, 0, 1, 4]
Returns
-------
cycle : list
A list of nodes in the order of the cycle found. The last node
equals the first to indicate a cycle.
Raises
------
NetworkXError
If no negative cycle is found.
| def _dijkstra_multisource(
G, sources, weight, pred=None, paths=None, cutoff=None, target=None
):
"""Uses Dijkstra's algorithm to find shortest weighted paths
Parameters
----------
G : NetworkX graph
sources : non-empty iterable of nodes
Starting nodes for paths. If this is just an iterable containing
a single node, then all paths computed by this function will
start from that node. If there are two or more nodes in this
iterable, the computed paths may begin from any one of the start
nodes.
weight: function
Function with (u, v, data) input that returns that edge's weight
or None to indicate a hidden edge
pred: dict of lists, optional(default=None)
dict to store a list of predecessors keyed by that node
If None, predecessors are not stored.
paths: dict, optional (default=None)
dict to store the path list from source to each node, keyed by node.
If None, paths are not stored.
target : node label, optional
Ending node for path. Search is halted when target is found.
cutoff : integer or float, optional
Length (sum of edge weights) at which the search is stopped.
If cutoff is provided, only return paths with summed weight <= cutoff.
Returns
-------
distance : dictionary
A mapping from node to shortest distance to that node from one
of the source nodes.
Raises
------
NodeNotFound
If any of `sources` is not in `G`.
Notes
-----
The optional predecessor and path dictionaries can be accessed by
the caller through the original pred and paths objects passed
as arguments. No need to explicitly return pred or paths.
"""
G_succ = G._adj # For speed-up (and works for both directed and undirected graphs)
push = heappush
pop = heappop
dist = {} # dictionary of final distances
seen = {}
# fringe is heapq with 3-tuples (distance,c,node)
# use the count c to avoid comparing nodes (may not be able to)
c = count()
fringe = []
for source in sources:
seen[source] = 0
push(fringe, (0, next(c), source))
while fringe:
(d, _, v) = pop(fringe)
if v in dist:
continue # already searched this node.
dist[v] = d
if v == target:
break
for u, e in G_succ[v].items():
cost = weight(v, u, e)
if cost is None:
continue
vu_dist = dist[v] + cost
if cutoff is not None:
if vu_dist > cutoff:
continue
if u in dist:
u_dist = dist[u]
if vu_dist < u_dist:
raise ValueError("Contradictory paths found:", "negative weights?")
elif pred is not None and vu_dist == u_dist:
pred[u].append(v)
elif u not in seen or vu_dist < seen[u]:
seen[u] = vu_dist
push(fringe, (vu_dist, next(c), u))
if paths is not None:
paths[u] = paths[v] + [u]
if pred is not None:
pred[u] = [v]
elif vu_dist == seen[u]:
if pred is not None:
pred[u].append(v)
# The optional predecessor and path dictionaries can be accessed
# by the caller via the pred and paths objects passed as arguments.
return dist
| (G, source, weight='weight', *, backend=None, **backend_kwargs) | [
0.00868748314678669,
-0.0040619331412017345,
-0.034225184470415115,
-0.04419538378715515,
-0.038967348635196686,
-0.021786730736494064,
-0.010757319629192352,
0.04058045893907547,
0.07362010329961777,
-0.010543533600866795,
-0.052863433957099915,
0.029735680669546127,
0.028666751459240913,
0.0255182683467865,
-0.027247989550232887,
0.035896603018045425,
0.00011251092655584216,
0.03593547269701958,
-0.0012693540193140507,
0.013672582805156708,
-0.015033039264380932,
-0.0565560981631279,
0.05550660565495491,
0.049598339945077896,
-0.02098989300429821,
-0.009280253201723099,
0.014858122915029526,
-0.04003627598285675,
-0.02579035796225071,
-0.016296319663524628,
0.017744233831763268,
-0.018745141103863716,
-0.006330979056656361,
-0.005538999568670988,
0.016578128561377525,
0.05853847786784172,
0.007871209643781185,
-0.0030440203845500946,
-0.023360973224043846,
-0.044039905071258545,
-0.03018268756568432,
-0.03045477904379368,
0.005704197566956282,
-0.03782067820429802,
0.0800725519657135,
0.08388183265924454,
-0.01746242493391037,
0.008672907017171383,
-0.019396215677261353,
-0.018832597881555557,
0.015169084072113037,
0.0014722077175974846,
-0.00927539449185133,
0.009528051130473614,
-0.007817762903869152,
0.03945322334766388,
-0.03325343132019043,
0.05418501794338226,
0.027286861091852188,
-0.038248248398303986,
0.03949209302663803,
0.010572686791419983,
0.07086032629013062,
0.04003627598285675,
-0.06378595530986786,
-0.023555323481559753,
-0.04656646400690079,
-0.037529151886701584,
-0.0399974063038826,
0.02135915867984295,
0.001062248949892819,
-0.009537768550217152,
-0.01345879677683115,
-0.03552733734250069,
-0.0018937061540782452,
0.03795672208070755,
-0.00001619906834093854,
-0.03482767194509506,
0.011097433976829052,
-0.03984192758798599,
0.04388442263007164,
-0.056478358805179596,
-0.025809794664382935,
-0.07105467468500137,
0.0730370506644249,
0.025071261450648308,
-0.004120238125324249,
0.002691759495064616,
-0.009110196493566036,
-0.03410857543349266,
-0.036712877452373505,
0.03076574020087719,
-0.0033209703397005796,
0.0004876991733908653,
0.05678931996226311,
0.02678154781460762,
0.009037314914166927,
-0.05706141144037247,
0.04998704046010971,
0.031096138060092926,
0.06845036894083023,
0.0048903534188866615,
-0.01456659659743309,
0.036129824817180634,
0.02647058665752411,
-0.06724539399147034,
-0.0110585642978549,
0.015849312767386436,
-0.01391552109271288,
-0.05566208437085152,
-0.022641874849796295,
0.012380149215459824,
0.025945840403437614,
-0.026800982654094696,
0.023497018963098526,
0.0032699531875550747,
0.006797421257942915,
0.04400103539228439,
-0.0005387162673287094,
-0.02108706720173359,
-0.025226742029190063,
0.0525524728000164,
-0.08310442417860031,
-0.003947751596570015,
0.040424980223178864,
-0.05640061944723129,
0.02470199391245842,
-0.019920963793992996,
0.06627364456653595,
0.017938584089279175,
0.026159625500440598,
0.004798037000000477,
-0.02786991372704506,
0.06561285257339478,
0.03199015185236931,
-0.024546513333916664,
-0.0566338412463665,
0.04691629856824875,
0.06506866961717606,
0.010446358472108841,
0.04256283864378929,
-0.07548587024211884,
0.0077157290652394295,
0.02876392751932144,
0.005932559724897146,
-0.028472401201725006,
0.011136304587125778,
0.014061284251511097,
0.03130992501974106,
0.059743452817201614,
0.015460610389709473,
0.0028715338557958603,
0.006928608287125826,
0.011661051772534847,
0.0016568410210311413,
-0.06817828118801117,
-0.04197978600859642,
0.02044571004807949,
0.005801373161375523,
-0.0004734265385195613,
0.016616998240351677,
-0.044622957706451416,
0.005718774162232876,
0.014887276105582714,
-0.049831561744213104,
0.03496371954679489,
0.022194867953658104,
0.05216376855969429,
-0.027170250192284584,
0.012370431795716286,
-0.005893689580261707,
-0.06413578242063522,
-0.04777144268155098,
-0.02917206473648548,
-0.02446877397596836,
0.0032796708401292562,
0.02511013112962246,
-0.0023237073328346014,
0.011835967190563679,
-0.019444802775979042,
0.009911893866956234,
-0.026626067236065865,
0.023147188127040863,
-0.013633713126182556,
0.030066078528761864,
0.02917206473648548,
0.02225317247211933,
-0.02163125015795231,
0.002961421152576804,
0.03482767194509506,
-0.04827675223350525,
-0.09328841418027878,
-0.060559727251529694,
0.08318217098712921,
-0.009085902944207191,
0.006709963548928499,
-0.037257060408592224,
-0.022175433114171028,
-0.027286861091852188,
0.06370820850133896,
-0.009115055203437805,
-0.029327545315027237,
0.039919666945934296,
-0.008867258206009865,
0.009251100942492485,
-0.028841666877269745,
-0.032456591725349426,
0.008566014468669891,
0.0010033362777903676,
0.01850220188498497,
-0.03506089374423027,
-0.045361489057540894,
0.02998833730816841,
-0.02971624583005905,
0.001164283137768507,
0.013779476284980774,
-0.03169862553477287,
0.04003627598285675,
0.014012697152793407,
-0.05908266082406044,
-0.004423911217600107,
-0.015266260132193565,
-0.009571779519319534,
0.02116480842232704,
0.06184244155883789,
-0.05029800161719322,
0.047032907605171204,
0.030649131163954735,
0.025848664343357086,
-0.07330914586782455,
0.07723502814769745,
-0.03278699144721031,
0.09632028639316559,
-0.01477066520601511,
0.07377558946609497,
-0.047888051718473434,
0.003481309860944748,
0.040697067975997925,
0.0455947108566761,
0.027928218245506287,
-0.021689556539058685,
-0.023458149284124374,
-0.014654054306447506,
-0.058110907673835754,
0.005859678145498037,
-0.0001001362397801131,
0.03148483857512474,
-0.012321844696998596,
0.026159625500440598,
-0.0064670247957110405,
0.005023969803005457,
0.027714433148503304,
-0.042368486523628235,
-0.05752785503864288,
-0.012953484430909157,
-0.043223630636930466,
-0.02098989300429821,
-0.03749028220772743,
-0.03651852533221245,
-0.06592381000518799,
-0.03222337365150452,
-0.027850478887557983,
-0.06098730117082596,
0.10152889043092728,
-0.0038797289598733187,
0.03261207416653633,
0.03121274709701538,
-0.014333375729620457,
-0.08022803068161011,
0.006617646664381027,
0.0427183173596859,
0.04306815192103386,
-0.006875161547213793,
-0.00362950237467885,
-0.02511013112962246,
0.0051940265111625195,
-0.03220393881201744,
0.034847110509872437,
0.012836874462664127,
-0.023011142387986183,
-0.04369007423520088,
-0.008391098119318485,
-0.041241250932216644,
-0.0064961775206029415,
0.017938584089279175,
0.029774552211165428,
0.0120983412489295,
-0.03482767194509506,
0.01646151766180992,
0.006695386953651905,
0.07019952684640884,
-0.012176081538200378,
0.010592121630907059,
-0.03774293512105942,
0.062270015478134155,
0.047654829919338226,
-0.003481309860944748,
-0.07284270226955414,
0.016403213143348694,
0.05364083871245384,
0.015460610389709473,
-0.02569318376481533,
0.025673748925328255,
-0.005694480147212744,
-0.042640578001737595,
0.008245334960520267,
0.031232183799147606,
-0.016821065917611122,
-0.0025897251907736063,
-0.030960092321038246,
-0.021417465060949326,
-0.025168435648083687,
0.00179774546995759,
0.007331886328756809,
0.003678089939057827,
-0.03721819072961807,
-0.03515807166695595,
0.007331886328756809,
-0.006748833693563938,
0.03220393881201744,
-0.038928475230932236,
0.07645762711763382,
-0.06833375990390778,
0.02923036925494671,
-0.030551955103874207,
0.02926923893392086,
0.03179579973220825,
0.025673748925328255,
0.03509976342320442,
0.022505829110741615,
0.03789841756224632,
0.022505829110741615,
0.02623736672103405,
0.030862916260957718,
-0.019794635474681854,
0.08979009836912155,
0.074397511780262,
-0.005407812539488077,
0.00005898852396057919,
-0.003167918883264065,
0.04738273844122887,
0.02170899137854576,
-0.022019952535629272,
0.02374967560172081,
0.006107475608587265,
-0.04384555295109749,
0.033991966396570206,
-0.038889605551958084,
0.007448496762663126,
-0.04738273844122887,
0.02184503711760044,
0.06790619343519211,
0.0183175690472126,
0.02647058665752411,
0.05049235373735428,
0.0030998962465673685,
-0.010932235978543758,
-0.040697067975997925,
0.022311478853225708,
-0.0048952121287584305,
0.008405674248933792,
0.018162088468670845,
0.009149067103862762,
-0.002898257225751877,
-0.046294376254081726,
0.013653147965669632,
0.019386498257517815,
-0.013361621648073196,
-0.018210675567388535,
-0.05060896277427673,
-0.008425110019743443,
-0.060598596930503845,
-0.025071261450648308,
0.05546773597598076,
0.01203031837940216,
0.0005007571307942271,
0.016412930563092232,
-0.007404767908155918,
-0.003508032998070121,
0.0440787747502327,
-0.022019952535629272,
0.05741124227643013,
0.005208603106439114,
0.045944541692733765,
0.024915780872106552,
-0.04120238125324249,
0.06646799296140671,
0.007409626618027687,
0.033719874918460846,
0.006326120346784592,
-0.024682559072971344,
-0.017812255769968033,
0.044350866228342056,
0.028627881780266762,
-0.0026820418424904346,
-0.04162995517253876,
0.07179320603609085,
0.03026042878627777,
-0.05057009309530258,
-0.025051824748516083,
0.015781288966536522,
-0.02126198448240757,
-0.0552733838558197,
0.06907229870557785,
0.0096786729991436,
-0.047615960240364075,
0.04590567201375961,
0.02786991372704506,
0.025984710082411766,
0.04854884371161461,
-0.041824303567409515,
-0.002395374234765768,
-0.014605467207729816,
0.01715146377682686,
-0.04388442263007164,
-0.05881056934595108,
-0.06856698542833328,
0.04217413440346718,
0.05678931996226311,
0.0029930032324045897,
0.0366351380944252,
-0.02940528467297554,
0.06398030370473862,
-0.0828712061047554,
0.01221495121717453,
-0.043184760957956314,
-0.013040942139923573,
-0.028025394305586815,
-0.0009158783941529691,
0.05080331489443779,
-0.0248380396515131,
-0.02357475832104683,
0.0393560491502285,
-0.055117905139923096,
-0.007127817720174789,
-0.0051940265111625195,
0.016169991344213486,
0.002457323716953397,
0.07198755443096161,
-0.034089140594005585,
-0.009445452131330967,
-0.02777273766696453,
-0.026256801560521126,
-0.02701476961374283,
-0.05196942016482353,
-0.07906193286180496,
0.02054288610816002,
-0.022855661809444427,
0.030862916260957718,
-0.03587716817855835,
0.007006348576396704,
-0.03875356167554855,
0.021203678101301193,
0.023147188127040863,
-0.026081884279847145,
0.02497408539056778,
0.015985358506441116,
0.010242289863526821,
-0.11987560987472534,
0.027034204453229904,
0.05080331489443779,
-0.031873539090156555,
0.028491836041212082,
-0.011933142319321632,
-0.047926921397447586,
0.0592770129442215,
0.034361232072114944,
0.0010300595313310623,
-0.0007033071597106755,
-0.025906968861818314,
0.045361489057540894,
-0.010825342498719692,
-0.0855143740773201,
-0.005927701015025377,
0.022311478853225708,
-0.004173684865236282,
-0.0635138601064682,
0.014760947786271572,
0.002158509334549308,
-0.01669473946094513,
0.040735941380262375,
-0.0400751456618309,
0.06689556688070297,
-0.007866350933909416,
0.005466117989271879,
-0.05500129237771034,
0.03904508799314499,
-0.019619720056653023,
0.014488856308162212,
0.0029225510079413652,
0.040697067975997925,
-0.06285306811332703,
0.06946099549531937,
-0.031193312257528305,
-0.003928316757082939,
0.0427183173596859,
0.033175691962242126,
-0.016539258882403374,
0.08077221363782883,
-0.013439361937344074,
0.002604301553219557,
-0.010388053022325039,
-0.054806940257549286,
0.059471361339092255,
0.033914223313331604,
0.015237106941640377,
0.014547161757946014,
0.04897641763091087,
-0.025712618604302406,
0.026451151818037033,
0.017336096614599228,
0.0029759975150227547,
0.047071777284145355,
0.055117905139923096,
0.04578906297683716,
-0.0077788932248950005,
-0.006695386953651905,
0.06891681253910065,
0.0022192439064383507,
-0.02238921821117401,
0.04337911307811737,
0.06219227612018585,
-0.015557786449790001,
0.027714433148503304,
-0.07435863465070724,
0.03533298522233963,
0.004346170928329229,
-0.04749935120344162,
0.023108316585421562,
0.004088656045496464,
0.010932235978543758,
0.03373930975794792,
-0.00041663963929750025,
0.0269175935536623,
0.018424460664391518,
0.014469421468675137,
0.05612852796912193,
-0.018657682463526726,
-0.014722077175974846,
-0.017034852877259254,
0.059471361339092255,
0.00023580224660690874,
-0.004640126600861549,
-0.005650751292705536,
0.06992743909358978,
-0.005121144931763411,
-0.002141503617167473,
-0.008075278252363205,
-0.00027725365362130105,
-0.050997667014598846,
-0.022000517696142197,
-0.0023589334450662136,
0.007239569444209337,
0.05212489888072014,
0.06957760453224182,
-0.009693249128758907,
0.014148742891848087,
0.009372570551931858,
0.006641940679401159,
0.08504793792963028,
-0.02542109228670597,
-0.08535889536142349,
-0.046216633170843124,
-0.01691824197769165,
-0.015431458130478859,
-0.030551955103874207,
0.01570354960858822,
-0.012807721272110939,
0.0013628853484988213,
-0.006374708376824856,
-0.029774552211165428,
0.04058045893907547,
-0.005713915452361107,
0.026315106078982353,
-0.028375225141644478,
-0.007910080254077911,
-0.02637341059744358,
-0.045167140662670135,
0.023244362324476242,
-0.051036536693573,
-0.017851125448942184,
0.021242549642920494,
0.06300854682922363,
0.05196942016482353,
0.02538222260773182,
-0.0021548650693148375,
-0.05228038132190704,
0.00411537941545248,
-0.04800466075539589,
0.010504663921892643,
0.010728167369961739,
-0.05332987383008003,
0.014352810569107533,
0.03785954788327217,
0.011291785165667534,
-0.05585643649101257,
-0.019697459414601326,
0.01728750951588154,
0.03148483857512474,
-0.003073172876611352,
-0.09313292801380157,
-0.009853588417172432,
0.006977195851504803,
-0.006194933783262968,
0.03121274709701538,
-0.014867840334773064,
-0.006311544217169285,
-0.08714692294597626,
-0.015071908943355083,
-0.05107540637254715,
0.019959833472967148,
0.013546254485845566,
0.025945840403437614,
-0.02474086359143257,
-0.02963850647211075,
-0.00761369476094842,
-0.009873023256659508,
0.016160273924469948,
-0.029910597950220108,
-0.035896603018045425,
0.015217672102153301,
-0.03978361934423447,
0.019979268312454224,
-0.012603653594851494,
0.0028618164360523224,
0.0385592095553875,
-0.0024621824268251657,
0.019376780837774277,
-0.06048198789358139,
0.033000774681568146,
-0.021786730736494064,
-0.049015287309885025,
0.044622957706451416,
0.0538351871073246,
-0.022505829110741615,
-0.01592705212533474,
0.06930551677942276,
-0.010504663921892643,
-0.015217672102153301,
-0.011952578090131283,
-0.03488598018884659,
0.0440787747502327,
-0.021320289000868797,
-0.03335060551762581,
-0.03593547269701958,
-0.004389899782836437,
-0.003908881451934576,
-0.02248639427125454,
0.009552344679832458,
0.0007834769203327596,
-0.005728491581976414,
-0.015324565581977367,
-0.03053252026438713,
0.006729398388415575,
0.020367970690131187,
0.07272609323263168,
-0.018793728202581406,
-0.034089140594005585,
0.012137210927903652,
0.012535630725324154,
0.03253433480858803,
0.05402953922748566,
0.06934438645839691,
-0.04384555295109749,
-0.03747084364295006,
-0.012982637621462345,
0.01764705777168274,
-0.0621534027159214,
-0.017928866669535637,
0.007662282790988684,
-0.06409691274166107,
-0.011505571193993092,
0.00855143740773201,
0.016296319663524628,
-0.03288416564464569,
-0.06048198789358139,
0.026839854195713997,
-0.004122667480260134,
-0.07579683512449265,
-0.06771183758974075,
0.04302927851676941,
0.04610002413392067,
0.024935215711593628,
-0.013128400780260563,
-0.011554158292710781,
0.053679708391427994,
-0.05189168080687523,
-0.08395957201719284,
0.03492484986782074,
0.014148742891848087,
0.019920963793992996,
-0.03457501903176308,
0.04038610681891441,
0.008808952756226063,
-0.03809276968240738,
-0.05138636752963066,
-0.0024719000793993473,
-0.019920963793992996,
0.030843481421470642,
-0.035993777215480804,
0.02040684036910534,
0.05329100415110588,
0.00805098470300436,
-0.030066078528761864,
-0.011146022006869316,
-0.03140709921717644,
-0.08038351684808731,
0.0387146919965744,
0.02303057722747326,
0.009805000387132168,
-0.03622699901461601,
-0.03026042878627777,
-0.013964109122753143,
0.026800982654094696,
0.01151528861373663,
-0.01490671094506979,
0.02071780152618885,
-0.01307009533047676,
-0.012506477534770966,
-0.0026601774152368307,
0.014479138888418674,
-0.02361362986266613,
-0.003226224333047867,
0.028608446940779686,
-0.0884685143828392,
-0.0008581805159337819,
0.023419277742505074,
-0.08349312841892242,
0.002066192450001836,
-0.017928866669535637,
-0.026256801560521126,
0.0881575495004654,
0.009839012287557125,
0.032048456370830536,
0.004761596210300922,
-0.014605467207729816,
0.02524617686867714,
-0.015003886073827744,
-0.009873023256659508,
0.05993780493736267,
-0.02654832787811756,
0.0183175690472126,
-0.039880797266960144,
-0.017715081572532654,
-0.0013142976677045226,
-0.010961388237774372,
0.010125679895281792,
0.012535630725324154,
-0.02750064618885517,
-0.01092251855880022,
0.03103783167898655,
-0.0007300304132513702,
0.024099506437778473,
-0.018405025824904442,
0.011690204031765461,
-0.01182624977082014,
-0.040152888745069504,
-0.05196942016482353,
-0.026081884279847145,
-0.048199012875556946,
-0.06125938892364502,
-0.008716636337339878,
-0.018764575943350792,
0.0227584857493639,
0.0220782570540905,
0.04660533741116524,
0.02569318376481533,
0.08504793792963028
]
|
30,665 | networkx.readwrite.text | forest_str | Creates a nice utf8 representation of a forest
This function has been superseded by
:func:`nx.readwrite.text.generate_network_text`, which should be used
instead.
Parameters
----------
graph : nx.DiGraph | nx.Graph
Graph to represent (must be a tree, forest, or the empty graph)
with_labels : bool
If True will use the "label" attribute of a node to display if it
exists otherwise it will use the node value itself. Defaults to True.
sources : List
Mainly relevant for undirected forests, specifies which nodes to list
first. If unspecified the root nodes of each tree will be used for
directed forests; for undirected forests this defaults to the nodes
with the smallest degree.
write : callable
Function to use to write to, if None new lines are appended to
a list and returned. If set to the `print` function, lines will
be written to stdout as they are generated. If specified,
this function will return None. Defaults to None.
ascii_only : Boolean
If True only ASCII characters are used to construct the visualization
Returns
-------
str | None :
utf8 representation of the tree / forest
Examples
--------
>>> graph = nx.balanced_tree(r=2, h=3, create_using=nx.DiGraph)
>>> print(nx.forest_str(graph))
╙── 0
├─╼ 1
│ ├─╼ 3
│ │ ├─╼ 7
│ │ └─╼ 8
│ └─╼ 4
│ ├─╼ 9
│ └─╼ 10
└─╼ 2
├─╼ 5
│ ├─╼ 11
│ └─╼ 12
└─╼ 6
├─╼ 13
└─╼ 14
>>> graph = nx.balanced_tree(r=1, h=2, create_using=nx.Graph)
>>> print(nx.forest_str(graph))
╙── 0
└── 1
└── 2
>>> print(nx.forest_str(graph, ascii_only=True))
+-- 0
L-- 1
L-- 2
| def forest_str(graph, with_labels=True, sources=None, write=None, ascii_only=False):
"""Creates a nice utf8 representation of a forest
This function has been superseded by
:func:`nx.readwrite.text.generate_network_text`, which should be used
instead.
Parameters
----------
graph : nx.DiGraph | nx.Graph
Graph to represent (must be a tree, forest, or the empty graph)
with_labels : bool
If True will use the "label" attribute of a node to display if it
exists otherwise it will use the node value itself. Defaults to True.
sources : List
Mainly relevant for undirected forests, specifies which nodes to list
first. If unspecified the root nodes of each tree will be used for
directed forests; for undirected forests this defaults to the nodes
with the smallest degree.
write : callable
Function to use to write to, if None new lines are appended to
a list and returned. If set to the `print` function, lines will
be written to stdout as they are generated. If specified,
this function will return None. Defaults to None.
ascii_only : Boolean
If True only ASCII characters are used to construct the visualization
Returns
-------
str | None :
utf8 representation of the tree / forest
Examples
--------
>>> graph = nx.balanced_tree(r=2, h=3, create_using=nx.DiGraph)
>>> print(nx.forest_str(graph))
╙── 0
├─╼ 1
│ ├─╼ 3
│ │ ├─╼ 7
│ │ └─╼ 8
│ └─╼ 4
│ ├─╼ 9
│ └─╼ 10
└─╼ 2
├─╼ 5
│ ├─╼ 11
│ └─╼ 12
└─╼ 6
├─╼ 13
└─╼ 14
>>> graph = nx.balanced_tree(r=1, h=2, create_using=nx.Graph)
>>> print(nx.forest_str(graph))
╙── 0
└── 1
└── 2
>>> print(nx.forest_str(graph, ascii_only=True))
+-- 0
L-- 1
L-- 2
"""
msg = (
"\nforest_str is deprecated as of version 3.1 and will be removed "
"in version 3.3. Use generate_network_text or write_network_text "
"instead.\n"
)
warnings.warn(msg, DeprecationWarning)
if len(graph.nodes) > 0:
if not nx.is_forest(graph):
raise nx.NetworkXNotImplemented("input must be a forest or the empty graph")
printbuf = []
if write is None:
_write = printbuf.append
else:
_write = write
write_network_text(
graph,
_write,
with_labels=with_labels,
sources=sources,
ascii_only=ascii_only,
end="",
)
if write is None:
# Only return a string if the custom write function was not specified
return "\n".join(printbuf)
| (graph, with_labels=True, sources=None, write=None, ascii_only=False) | [
-0.018872039392590523,
-0.03196445852518082,
-0.00020355272863525897,
-0.030998090282082558,
0.009110799990594387,
-0.03071933053433895,
-0.040067076683044434,
-0.0036006474401801825,
0.11588974297046661,
-0.06664218008518219,
0.008497527800500393,
0.02744854986667633,
-0.036145854741334915,
0.0158056803047657,
0.012618527747690678,
0.01975477859377861,
-0.04790952056646347,
-0.04408121854066849,
0.06824040412902832,
0.01469064224511385,
-0.04385821148753166,
-0.027727309614419937,
0.00752186868339777,
-0.06928110122680664,
0.02579457499086857,
-0.0017631558002904058,
-0.03040340356528759,
-0.028563588857650757,
-0.04385821148753166,
0.03125826641917229,
0.021631760522723198,
-0.07493063807487488,
-0.009877389296889305,
-0.04452723264694214,
0.0060583800077438354,
-0.0023276444990187883,
-0.052444010972976685,
0.02179901674389839,
-0.010713668540120125,
-0.02624059095978737,
-0.035941433161497116,
-0.022114945575594902,
-0.02930694818496704,
-0.04567944258451462,
-0.029139691963791847,
0.03432462364435196,
0.013687106780707836,
0.011243312619626522,
-0.05106879770755768,
0.019791945815086365,
0.025292806327342987,
0.009951725602149963,
-0.03103525936603546,
-0.002263762056827545,
-0.029994554817676544,
-0.045456431806087494,
-0.009305931627750397,
-0.024995462968945503,
0.012674279510974884,
-0.03406444936990738,
0.061736006289720535,
0.01469064224511385,
0.04092194139957428,
0.009635797701776028,
-0.02880517952144146,
0.03209454566240311,
-0.02739279717206955,
-0.04021574929356575,
0.016809215769171715,
-0.018007883802056313,
0.03019898012280464,
0.014309669844806194,
-0.0037121514324098825,
0.03151844069361687,
0.04631129652261734,
0.03406444936990738,
-0.02835916541516781,
-0.017496824264526367,
-0.009756593033671379,
0.0005014772759750485,
0.01873265951871872,
-0.04835553467273712,
0.020888401195406914,
-0.04623696208000183,
0.042557332664728165,
-0.06247936561703682,
-0.04385821148753166,
-0.014616305939853191,
0.06036078929901123,
-0.056532490998506546,
-0.010341988876461983,
0.0017062423285096884,
0.019513186067342758,
0.024345023557543755,
-0.01773841679096222,
-0.02988305129110813,
0.018072927370667458,
-0.04311485216021538,
-0.0000030398612125281943,
-0.022356536239385605,
-0.02532997541129589,
0.06515546143054962,
-0.06552714109420776,
0.0042975470423698425,
-0.042891841381788254,
-0.006095547694712877,
-0.03200162574648857,
0.030868003144860268,
0.010295528918504715,
-0.04757500812411308,
-0.04125645011663437,
-0.04515909031033516,
0.10213759541511536,
-0.026965364813804626,
0.05508293956518173,
-0.06935544312000275,
-0.0397697314620018,
-0.010035352781414986,
0.01020260900259018,
-0.0751536414027214,
0.010546412318944931,
-0.003298657713457942,
-0.045642271637916565,
-0.022375119850039482,
0.013584895059466362,
0.02765297330915928,
0.014541969634592533,
0.004007172305136919,
0.06207051873207092,
-0.04675731062889099,
0.05586346611380577,
0.04831836745142937,
-0.053856395184993744,
0.040178582072257996,
0.051551979035139084,
0.00344036053866148,
-0.08950047940015793,
0.03413878381252289,
0.042371492832899094,
0.04040158912539482,
0.028879515826702118,
-0.06731120496988297,
0.0271883737295866,
0.03649895265698433,
-0.01577780582010746,
-0.004130291286855936,
-0.01949460245668888,
-0.09128454327583313,
0.03425028920173645,
0.005802850238978863,
0.10927384346723557,
0.012934454716742039,
-0.03642461448907852,
-0.006657713558524847,
-0.005119888577610254,
-0.0366847924888134,
0.0006092063267715275,
-0.01917867548763752,
0.016967181116342545,
0.005798203870654106,
-0.01917867548763752,
0.03495648130774498,
0.040513090789318085,
0.014634889550507069,
0.006894659250974655,
0.0406617633998394,
0.020609641447663307,
-0.015396833419799805,
0.02250520884990692,
-0.006783155258744955,
-0.023304320871829987,
-0.03649895265698433,
-0.12265431880950928,
0.05541744828224182,
-0.005092012695968151,
-0.03302374482154846,
-0.016307448968291283,
0.053150203078985214,
-0.03631311282515526,
0.0018340072128921747,
-0.04062459617853165,
-0.07180852442979813,
-0.013854362070560455,
-0.0574616901576519,
0.029214028269052505,
-0.08243856579065323,
-0.012376935221254826,
0.03302374482154846,
0.05761035904288292,
0.0046785189770162106,
-0.012228263542056084,
-0.007591558620333672,
0.00434865290299058,
0.05868823081254959,
0.06430059671401978,
-0.0813235267996788,
-0.0054079401306807995,
-0.04311485216021538,
-0.016679128631949425,
-0.03631311282515526,
0.009905265644192696,
0.013027374632656574,
0.10578005760908127,
-0.040067076683044434,
0.007052623201161623,
0.0375768207013607,
-0.05073428526520729,
-0.0010621909750625491,
-0.042557332664728165,
0.036852046847343445,
0.008167662657797337,
-0.0006881883018650115,
-0.05426524206995964,
0.010574288666248322,
0.006025857757776976,
0.006620545405894518,
-0.0077262925915420055,
0.017236648127436638,
-0.015350373461842537,
-0.008176954463124275,
-0.026593685150146484,
0.008023636415600777,
0.0127021549269557,
-0.006903951056301594,
-0.03281932324171066,
0.00005433638580143452,
0.006866783369332552,
0.019197259098291397,
0.0769377052783966,
-0.030050307512283325,
0.026222005486488342,
0.03824584558606148,
-0.02841491624712944,
-0.006197759881615639,
0.02265387959778309,
-0.030329067260026932,
0.02309989556670189,
-0.04664580896496773,
0.05188649147748947,
-0.0027852749917656183,
-0.026853861287236214,
-0.014541969634592533,
-0.04266883432865143,
-0.0728863999247551,
0.06441210210323334,
-0.04549359902739525,
0.0024437943939119577,
-0.005723868031054735,
-0.005816787946969271,
-0.004188366234302521,
0.0011423344258219004,
-0.007071207277476788,
-0.02733704447746277,
0.0052221002988517284,
0.007317444775253534,
-0.0009617213509045541,
-0.004731947556138039,
-0.06385458260774612,
-0.0025854972191154957,
0.03718655928969383,
0.0004553076869342476,
0.01100172009319067,
-0.05958026275038719,
0.03898920491337776,
-0.01648399606347084,
-0.03924938291311264,
-0.030998090282082558,
-0.030031723901629448,
0.016446828842163086,
-0.044936079531908035,
-0.01551762968301773,
0.05459975451231003,
-0.03765115886926651,
0.01128977257758379,
-0.06578731536865234,
-0.042185649275779724,
-0.04225998744368553,
0.018100803717970848,
0.0164561215788126,
-0.012971622869372368,
-0.04880154877901077,
-0.02244945615530014,
-0.03378568962216377,
-0.0006876075058244169,
0.04456439986824989,
-0.011921627447009087,
-0.034231703728437424,
-0.0724775493144989,
0.03501223027706146,
-0.04850420728325844,
0.06716252863407135,
0.004803960677236319,
-0.029344115406274796,
-0.027058284729719162,
0.00902717188000679,
-0.04623696208000183,
0.018751243129372597,
-0.025125550106167793,
0.013399055227637291,
-0.001024442259222269,
0.02930694818496704,
-0.0015993843553587794,
0.029845884069800377,
0.0008647361537441611,
0.03616444021463394,
-0.021947689354419708,
-0.0026435721665620804,
-0.03644319996237755,
-0.004069893155246973,
0.022914055734872818,
-0.06359440088272095,
-0.04062459617853165,
0.08058016747236252,
0.04400688037276268,
0.014179582707583904,
0.016437536105513573,
-0.008841332048177719,
-0.06114131957292557,
0.042631667107343674,
-0.028526419773697853,
-0.011791540309786797,
-0.008715890347957611,
0.027114037424325943,
0.0370936393737793,
0.0035146966110914946,
-0.01865832321345806,
-0.04586528241634369,
0.02265387959778309,
0.02822907641530037,
0.010035352781414986,
0.011986671946942806,
-0.0019524801755324006,
0.049990925937891006,
0.014439757913351059,
-0.03406444936990738,
0.07574833184480667,
0.05627231299877167,
0.0034914666321128607,
-0.04348653182387352,
-0.02438219077885151,
0.025701655074954033,
0.04850420728325844,
0.007419656962156296,
0.02964146062731743,
-0.0005624559707939625,
0.05199799686670303,
-0.020442385226488113,
0.0003693567414302379,
0.022077776491642,
0.07351825386285782,
-0.05805637687444687,
-0.013956574723124504,
-0.008683367632329464,
-0.002945561893284321,
-0.04136795550584793,
0.03534674271941185,
0.02218928001821041,
0.039026372134685516,
0.013250382617115974,
0.03872903063893318,
0.03540249541401863,
-0.049098894000053406,
0.0011963441502302885,
0.039286550134420395,
-0.007201294880360365,
0.016864968463778496,
0.02425210364162922,
0.04727766290307045,
-0.0033404717687517405,
0.0012764876009896398,
0.02731846086680889,
-0.029028188437223434,
-0.028396332636475563,
0.012609235011041164,
-0.016233112663030624,
0.05612364038825035,
-0.01899283565580845,
-0.03553258255124092,
0.011429152451455593,
-0.0419626422226429,
-0.006448643747717142,
0.0450475849211216,
-0.028563588857650757,
0.008478944189846516,
0.023062728345394135,
0.023322904482483864,
-0.007456825114786625,
0.022542376071214676,
0.011354816146194935,
-0.02393617480993271,
-0.03891487047076225,
-0.023044144734740257,
-0.005765682086348534,
-0.010741544887423515,
-0.05842805653810501,
-0.0271883737295866,
0.027857396751642227,
0.004724978934973478,
0.06236786022782326,
0.04924756661057472,
-0.020107874646782875,
0.006286033894866705,
-0.03713080659508705,
-0.03562550246715546,
-0.023192815482616425,
0.08243856579065323,
-0.019345929846167564,
-0.0028735490050166845,
0.043783873319625854,
-0.011410567909479141,
0.049730751663446426,
0.028266245499253273,
-0.06021212041378021,
0.029158275574445724,
0.027114037424325943,
0.015285329893231392,
-0.02098132111132145,
0.061810340732336044,
0.013417638838291168,
-0.012423395179212093,
-0.03534674271941185,
0.03542108088731766,
0.001230027643032372,
0.032168883830308914,
0.026909613981842995,
0.046274129301309586,
-0.024921126663684845,
0.013584895059466362,
0.052258171141147614,
0.08377661556005478,
0.02315564826130867,
-0.09121020883321762,
-0.05998910963535309,
-0.0031732157804071903,
0.0006324363057501614,
0.021966272965073586,
-0.011745080351829529,
0.002065145643427968,
0.004799314774572849,
0.00012602267088368535,
0.005380064249038696,
-0.028526419773697853,
0.01828664354979992,
-0.00016812700778245926,
0.007317444775253534,
0.0015262099914252758,
-0.03534674271941185,
-0.014737102203071117,
-0.005240684375166893,
0.016233112663030624,
-0.02956712432205677,
-0.030124643817543983,
-0.036926381289958954,
0.07043331116437912,
-0.023899007588624954,
-0.018872039392590523,
0.08518899977207184,
0.01758045144379139,
-0.00393051328137517,
0.08407396078109741,
-0.016855675727128983,
0.012460563331842422,
0.03924938291311264,
0.06132715940475464,
0.05337321013212204,
-0.01378931850194931,
0.05857672914862633,
0.016864968463778496,
-0.03657328709959984,
-0.005909707862883806,
0.0320202112197876,
0.004587921779602766,
-0.06430059671401978,
-0.006643775384873152,
0.07708638161420822,
0.059691768139600754,
-0.012479147873818874,
-0.03560692071914673,
-0.030254730954766273,
-0.047054655849933624,
-0.03335825726389885,
-0.014133122749626637,
0.003136047860607505,
0.006114131771028042,
0.0008200184674933553,
-0.02514413557946682,
0.011828707531094551,
0.025683069601655006,
0.042371492832899094,
0.010760128498077393,
0.01982911489903927,
-0.04835553467273712,
-0.03785558044910431,
0.00880416389554739,
-0.025943245738744736,
0.045196257531642914,
-0.046534303575754166,
-0.026965364813804626,
-0.058985576033592224,
-0.011614992283284664,
0.014616305939853191,
0.02835916541516781,
-0.04393254593014717,
0.031406939029693604,
-0.010221192613244057,
-0.006216343957930803,
0.05805637687444687,
0.03726089373230934,
0.041144948452711105,
-0.031202513724565506,
0.016242405399680138,
-0.00794000830501318,
0.058205049484968185,
-0.026593685150146484,
-0.029492788016796112,
0.01635390892624855,
0.04136795550584793,
0.029158275574445724,
0.006741341203451157,
0.0486157089471817,
-0.04021574929356575,
-0.006936473306268454,
-0.012395519763231277,
0.060063447803258896,
-0.02142733708024025,
0.010304820723831654,
0.05467408895492554,
0.06207051873207092,
-0.02559014968574047,
0.0464228019118309,
-0.009501063264906406,
0.057052839547395706,
0.05400506779551506,
0.011020304635167122,
-0.0009837897960096598,
0.024103431031107903,
0.006732049398124218,
0.0035936785861849785,
0.021631760522723198,
-0.002713262103497982,
0.016307448968291283,
-0.027504300698637962,
-0.030775083228945732,
-0.00019992304441984743,
0.0015517629217356443,
-0.0742616131901741,
0.08147220313549042,
-0.06441210210323334,
0.06972712278366089,
-0.010890216566622257,
-0.014607014134526253,
0.013659230433404446,
0.053596220910549164,
0.025255639106035233,
0.07013596594333649,
0.01910433918237686,
-0.00914332177489996,
0.07478196173906326,
-0.015025153756141663,
-0.000642889819573611,
-0.04501041769981384,
0.008525404147803783,
0.004980508703738451,
-0.013547726906836033,
0.06705102324485779,
0.042185649275779724,
-0.025813158601522446,
0.0067645711824297905,
0.032689232379198074,
-0.05980326980352402,
0.0327078178524971,
0.021836185827851295,
0.06705102324485779,
0.010462785139679909,
-0.06961561739444733,
0.019550355151295662,
-0.01868619956076145,
-0.014895065687596798,
0.050697118043899536,
0.010945968329906464,
-0.0357927605509758,
0.003066357923671603,
-0.00941743515431881,
0.03622019290924072,
0.01805434376001358,
0.04757500812411308,
-0.01212605182081461,
0.03200162574648857,
-0.04571660980582237,
-0.013891530223190784,
0.03194587305188179,
-0.008492882363498211,
0.07314657419919968,
-0.02213352918624878,
0.07106516510248184,
-0.06827756762504578,
-0.003298657713457942,
-0.007057269103825092,
0.008990003727376461,
-0.0384688526391983,
0.02815474011003971,
0.01824018359184265,
0.014114538207650185,
0.000983209116384387,
0.04534493014216423,
0.05998910963535309,
0.010918092913925648,
-0.005942230112850666,
-0.00008544278534827754,
0.012878702953457832,
-0.0050734286196529865,
0.030031723901629448,
-0.019290179014205933,
-0.08295892179012299,
-0.014541969634592533,
-0.009036463685333729,
0.022914055734872818,
-0.042631667107343674,
-0.06010061502456665,
-0.032875072211027145,
0.10801013559103012,
0.0022173020988702774,
-0.05709001049399376,
-0.0024670243728905916,
-0.01168003585189581,
0.03817151114344597,
-0.00649510370567441,
-0.05887407064437866,
-0.06221918761730194,
-0.0450475849211216,
-0.013008791022002697,
-0.04605112224817276,
-0.012191095389425755,
-0.01841673068702221,
-0.04943340644240379,
-0.030031723901629448,
0.029845884069800377,
0.041590962558984756,
-0.0424458272755146,
-0.0433378592133522,
-0.045828111469745636,
0.023768920451402664,
-0.0289352685213089,
-0.03097950667142868,
0.00819089263677597,
-0.036406032741069794,
-0.01776629127562046,
-0.016474705189466476,
-0.015368957072496414,
-0.05381922796368599,
-0.04144228994846344,
0.05025110021233559,
0.010081812739372253,
-0.015350373461842537,
0.04984225332736969,
0.06905809789896011,
0.06876075267791748,
-0.032298970967531204,
0.005695992149412632,
0.006179175805300474,
-0.007763460744172335,
-0.00022736347455065697,
0.04798385500907898,
0.05441391468048096,
-0.014365422539412975,
0.03365560248494148,
0.012209679931402206,
0.053782060742378235,
-0.0044322810135781765,
-0.0437467060983181,
0.010564996860921383,
0.0016597823705524206,
-0.004841128829866648,
-0.08050583302974701,
0.00858115591108799,
0.021185746416449547,
0.029975971207022667,
0.08013415336608887,
0.02995738759636879,
-0.0640404224395752,
0.11209861189126968,
0.0254043098539114,
-0.015053030103445053,
-0.06389174610376358,
0.044750239700078964,
0.01590789295732975,
-0.07533948123455048,
0.011466320604085922,
-0.01742248795926571,
-0.00122654321603477,
0.00045356544433161616,
-0.05902274325489998,
0.022207865491509438,
0.003686598502099514,
0.03480780869722366,
0.03995557129383087,
0.029214028269052505,
-0.03739098086953163,
-0.010314112529158592,
-0.030998090282082558,
0.04965641349554062,
-0.008070096373558044,
-0.013863654807209969,
-0.02598041482269764,
0.012581359595060349,
-0.004474095068871975,
-0.010983136482536793,
0.02508838288486004,
-0.036721959710121155,
0.00313372490927577,
-0.011717204004526138,
0.014170289970934391,
0.004648319911211729,
0.009886681102216244,
-0.03451046347618103,
-0.03151844069361687,
-0.010016769170761108,
0.01703222468495369,
-0.05816787853837013,
-0.024419359862804413,
0.02213352918624878,
0.013752150349318981,
0.0034380375873297453,
0.007164127193391323,
0.009463895112276077,
0.03616444021463394,
0.04248299449682236,
0.0029246550984680653,
-0.015657009556889534,
-0.043709538877010345,
0.048838719725608826,
0.06950411200523376,
0.000927457120269537,
0.005036260467022657,
-0.02592466212809086,
-0.005157056264579296,
-0.0028735490050166845,
-0.030124643817543983,
0.01811009645462036,
0.026649437844753265,
0.028656508773565292,
0.007949300110340118,
-0.04181396961212158,
-0.02731846086680889,
0.029214028269052505,
-0.010221192613244057,
0.022226449102163315,
0.00012856344983447343,
-0.01740390434861183,
0.04173963516950607,
0.03581134229898453,
0.04709182307124138,
-0.0135941868647933,
-0.020033538341522217,
0.02943703532218933,
-0.00044601570698432624,
-0.016418952494859695,
0.014300378039479256,
-0.029548538848757744,
-0.0005252879927866161,
-0.0011446574935689569,
-0.019457435235381126,
0.008855270221829414,
-0.006100193597376347,
-0.016920721158385277,
0.02886093221604824,
-0.01228401530534029,
0.007289568893611431
]
|
30,666 | networkx.classes.function | freeze | Modify graph to prevent further change by adding or removing
nodes or edges.
Node and edge data can still be modified.
Parameters
----------
G : graph
A NetworkX graph
Examples
--------
>>> G = nx.path_graph(4)
>>> G = nx.freeze(G)
>>> try:
... G.add_edge(4, 5)
... except nx.NetworkXError as err:
... print(str(err))
Frozen graph can't be modified
Notes
-----
To "unfreeze" a graph you must make a copy by creating a new graph object:
>>> graph = nx.path_graph(4)
>>> frozen_graph = nx.freeze(graph)
>>> unfrozen_graph = nx.Graph(frozen_graph)
>>> nx.is_frozen(unfrozen_graph)
False
See Also
--------
is_frozen
| def freeze(G):
"""Modify graph to prevent further change by adding or removing
nodes or edges.
Node and edge data can still be modified.
Parameters
----------
G : graph
A NetworkX graph
Examples
--------
>>> G = nx.path_graph(4)
>>> G = nx.freeze(G)
>>> try:
... G.add_edge(4, 5)
... except nx.NetworkXError as err:
... print(str(err))
Frozen graph can't be modified
Notes
-----
To "unfreeze" a graph you must make a copy by creating a new graph object:
>>> graph = nx.path_graph(4)
>>> frozen_graph = nx.freeze(graph)
>>> unfrozen_graph = nx.Graph(frozen_graph)
>>> nx.is_frozen(unfrozen_graph)
False
See Also
--------
is_frozen
"""
G.add_node = frozen
G.add_nodes_from = frozen
G.remove_node = frozen
G.remove_nodes_from = frozen
G.add_edge = frozen
G.add_edges_from = frozen
G.add_weighted_edges_from = frozen
G.remove_edge = frozen
G.remove_edges_from = frozen
G.clear = frozen
G.clear_edges = frozen
G.frozen = True
return G
| (G) | [
0.10198608040809631,
0.018166489899158478,
-0.024386443197727203,
0.00884096696972847,
-0.042852479964494705,
-0.042711514979600906,
-0.06554737687110901,
0.011735094711184502,
0.06741512566804886,
-0.023857835680246353,
0.019347047433257103,
-0.037213996052742004,
-0.02993682585656643,
0.04944245517253876,
-0.05747729539871216,
-0.02838624268770218,
-0.007836611941456795,
0.008087700232863426,
0.012624918483197689,
0.02669469825923443,
0.020421884953975677,
-0.048279520124197006,
-0.02630705200135708,
0.05987365171313286,
-0.009937828406691551,
0.012492765672504902,
-0.001343545038253069,
0.034535713493824005,
0.06396155059337616,
0.019893275573849678,
0.033584218472242355,
-0.02715282514691353,
-0.025690343230962753,
-0.02271251752972603,
0.04796235263347626,
0.02207818813621998,
-0.0013226208975538611,
0.05885167792439461,
-0.029989685863256454,
-0.07851588726043701,
-0.019241327419877052,
-0.03275606781244278,
-0.009893777780234814,
-0.020721428096294403,
0.06515973061323166,
-0.0027994192205369473,
0.041231412440538406,
0.08126465231180191,
-0.015373678877949715,
-0.024315962567925453,
0.047151822596788406,
0.018800819292664528,
0.02782239392399788,
0.019505631178617477,
-0.031434547156095505,
0.02725854516029358,
0.040420882403850555,
0.044473543763160706,
-0.0059424336068332195,
-0.034253790974617004,
-0.012827550992369652,
-0.018941782414913177,
0.004519597161561251,
-0.050464432686567307,
-0.030342092737555504,
0.0045416224747896194,
-0.05976793169975281,
-0.05106351897120476,
-0.013576412573456764,
0.002025228925049305,
-0.06523021310567856,
0.02419262006878853,
-0.01620183140039444,
0.022342491894960403,
-0.037813082337379456,
-0.024791710078716278,
0.0012642538640648127,
0.015558691695332527,
-0.042182907462120056,
-0.05994413420557976,
0.020175199955701828,
-0.018712718039751053,
-0.05444661155343056,
-0.0019679630640894175,
-0.011470790952444077,
0.01662471704185009,
0.017135705798864365,
0.013038993813097477,
0.024967912584543228,
-0.047539468854665756,
-0.009699954651296139,
0.030377332121133804,
-0.006101015955209732,
0.028932470828294754,
0.039046499878168106,
0.006827851757407188,
-0.005823496729135513,
-0.046306051313877106,
-0.01452790666371584,
-0.014175500720739365,
-0.026818038895726204,
0.037002552300691605,
-0.08168753981590271,
-0.004810331854969263,
0.009673523716628551,
-0.036614906042814255,
-0.0037641285452991724,
-0.05913360044360161,
-0.02976062335073948,
-0.06780277192592621,
-0.043275363743305206,
0.025760823860764503,
-0.013268057256937027,
0.002969014225527644,
0.050112027674913406,
0.07146778702735901,
-0.038024526089429855,
-0.021020973101258278,
0.07189066708087921,
-0.014968412928283215,
-0.00009395179222337902,
0.07266595959663391,
-0.033302295953035355,
0.011867246590554714,
0.031082142144441605,
0.05035870894789696,
0.038200728595256805,
0.044579263776540756,
0.005704559851437807,
-0.032245080918073654,
-0.03413044661283493,
0.020087098702788353,
-0.02236011251807213,
0.07858636975288391,
-0.02803383767604828,
0.009418030269443989,
-0.02916153520345688,
0.013585221953690052,
0.017496921122074127,
0.026324672624468803,
-0.036473944783210754,
-0.03536386787891388,
0.036156777292490005,
0.07830444723367691,
0.043803971260786057,
-0.037531159818172455,
-0.014994842931628227,
-0.023875456303358078,
0.016704007983207703,
0.031223105266690254,
0.05617339536547661,
0.01315352600067854,
-0.003367672674357891,
-0.01785813644528389,
-0.033090852200984955,
0.05980316922068596,
-0.06360914558172226,
0.001775241456925869,
-0.005471091251820326,
-0.0008722029742784798,
-0.07252500206232071,
0.020968113094568253,
0.039539869874715805,
-0.009100865572690964,
0.0014690894167870283,
-0.023064924404025078,
0.08542302995920181,
-0.019399909302592278,
-0.03335515782237053,
0.020598087459802628,
0.010818840935826302,
-0.049019571393728256,
-0.011682233773171902,
0.030201129615306854,
-0.011876056902110577,
0.041619058698415756,
0.0016574059845879674,
-0.0038720527663826942,
-0.004792711231857538,
0.0049733188934624195,
-0.007585523184388876,
-0.030165888369083405,
-0.03272082656621933,
0.040808528661727905,
0.048631925135850906,
-0.013241627253592014,
-0.05099304020404816,
-0.010440005920827389,
0.036579664796590805,
0.022166289389133453,
-0.035733893513679504,
0.008792511187493801,
0.020069478079676628,
0.05575051158666611,
-0.017673123627901077,
-0.03441237285733223,
-0.008677978999912739,
0.0009140511392615736,
-0.05109876021742821,
0.05638483911752701,
0.021179554983973503,
-0.04577744007110596,
0.07893877476453781,
-0.002896330552175641,
0.020316163077950478,
-0.015030084177851677,
0.017206186428666115,
-0.09627711027860641,
0.01505651418119669,
0.012792310677468777,
-0.01551464106887579,
-0.006162686739116907,
0.015012463554739952,
0.004722230136394501,
-0.02711758390069008,
0.009303499013185501,
-0.008955498225986958,
0.029531558975577354,
0.041795261204242706,
-0.009937828406691551,
-0.04951293766498566,
-0.013849526643753052,
-0.037073031067848206,
0.0015825198497623205,
0.006664864253252745,
-0.05374180153012276,
-0.011285778135061264,
-0.032773688435554504,
0.002418380929157138,
-0.07915022224187851,
0.048808127641677856,
0.037954043596982956,
0.028262900188565254,
-0.06308054178953171,
0.03539910539984703,
-0.004460128955543041,
0.008096510544419289,
-0.003063723212108016,
0.007294788490980864,
0.02997206710278988,
-0.002726735547184944,
-0.05775922164320946,
-0.001849026302807033,
0.039257943630218506,
0.046094607561826706,
-0.012845171615481377,
0.0008804624667391181,
-0.02475646883249283,
0.023664012551307678,
-0.012281322851777077,
-0.08612783998250961,
-0.004065875429660082,
-0.033478498458862305,
-0.01274826005101204,
0.026148470118641853,
0.02493267133831978,
-0.0061714970506727695,
-0.026923760771751404,
-0.013461880385875702,
0.07245451956987381,
-0.0009256143821403384,
-0.05328367277979851,
-0.037354957312345505,
0.018836060538887978,
0.09994212538003922,
-0.010448815301060677,
0.00723752286285162,
0.033302295953035355,
-0.030342092737555504,
0.017725983634591103,
0.005374180153012276,
-0.023681633174419403,
0.050852078944444656,
0.020880011841654778,
-0.004576863255351782,
-0.028932470828294754,
-0.017091654241085052,
0.040209438651800156,
0.040667567402124405,
-0.010501676239073277,
-0.014739349484443665,
-0.0016794312978163362,
-0.007907092571258545,
0.004889622796326876,
-0.07675386220216751,
-0.0021441655699163675,
-0.036403462290763855,
-0.004594483412802219,
0.0028654951602220535,
-0.021443858742713928,
0.07344125211238861,
0.045178353786468506,
0.040526602417230606,
-0.008554637432098389,
0.05145116522908211,
0.014307653531432152,
-0.010801221244037151,
-0.03398948535323143,
0.07358221709728241,
0.043874453753232956,
0.10114030539989471,
-0.024386443197727203,
-0.03106452338397503,
0.022589176893234253,
0.06078990548849106,
-0.036403462290763855,
0.018166489899158478,
0.044614505022764206,
-0.0033236220479011536,
0.07146778702735901,
-0.036579664796590805,
-0.039610348641872406,
-0.027417128905653954,
0.041160933673381805,
0.014660058543086052,
-0.039363667368888855,
0.042993441224098206,
-0.02976062335073948,
0.0009157030144706368,
-0.0011926714796572924,
0.013823095709085464,
0.001423937501385808,
-0.03243890404701233,
0.010404764674603939,
-0.11058476567268372,
0.003979976754635572,
0.035346247255802155,
0.06614646315574646,
-0.021479099988937378,
0.015312007628381252,
0.004242078401148319,
0.02567272260785103,
0.018430793657898903,
0.05687820538878441,
-0.05127496272325516,
0.09987165033817291,
0.05398848280310631,
-0.023646391928195953,
0.007541472092270851,
-0.017831705510616302,
0.03106452338397503,
0.04708134010434151,
-0.016016818583011627,
-0.018219351768493652,
-0.004581268411129713,
0.016289932653307915,
0.009858536534011364,
0.043944936245679855,
0.019628971815109253,
0.039081741124391556,
0.006109825801104307,
0.07597856968641281,
-0.028650546446442604,
0.009506131522357464,
0.0001957501081051305,
-0.038870297372341156,
-0.020263301208615303,
-0.05976793169975281,
-0.012175600975751877,
-0.00030284826061688364,
-0.040949489921331406,
-0.004374230280518532,
0.0028434698469936848,
-0.009664714336395264,
0.031082142144441605,
-0.031540270894765854,
-0.043486807495355606,
0.027276165783405304,
0.004495369270443916,
-0.037989284843206406,
0.020351402461528778,
-0.040843769907951355,
-0.042852479964494705,
0.00009126745135290548,
0.02461550571024418,
0.02507363259792328,
-0.02355829067528248,
0.019153226166963577,
0.024386443197727203,
0.04398017376661301,
0.024509785696864128,
-0.039962753653526306,
0.016289932653307915,
0.010721929371356964,
0.030377332121133804,
0.02775191329419613,
0.07710626721382141,
-0.034852877259254456,
0.05606767535209656,
-0.006563547533005476,
-0.027487609535455704,
-0.052684586495161057,
0.013109475374221802,
0.046411771327257156,
-0.06188236176967621,
0.04376873001456261,
0.05349511653184891,
0.017241427674889565,
-0.021020973101258278,
-0.021267656236886978,
-0.00683225691318512,
0.039152223616838455,
-0.03444761410355568,
0.005409420467913151,
0.03007778711616993,
-0.010281423106789589,
0.036967311054468155,
0.033795662224292755,
0.036368221044540405,
0.011206487193703651,
0.024509785696864128,
-0.00407688831910491,
-0.036297742277383804,
0.007814586162567139,
0.07023436576128006,
-0.017135705798864365,
0.07647193968296051,
-0.036650147289037704,
0.07731771469116211,
0.004389647860080004,
0.037425436079502106,
-0.03194553405046463,
0.0026298242155462503,
-0.026888519525527954,
-0.0056869396939873695,
-0.03335515782237053,
-0.003030685242265463,
0.005189167335629463,
-0.036192018538713455,
0.05183881148695946,
0.016219452023506165,
-0.010175701230764389,
0.010827651247382164,
-0.003455773927271366,
-0.005224407650530338,
-0.040526602417230606,
0.03272082656621933,
-0.07576712965965271,
-0.028544824570417404,
0.05032346770167351,
0.03057115525007248,
-0.000051725106459343806,
0.024386443197727203,
-0.07199639081954956,
-0.001262051286175847,
0.015787754207849503,
0.0009024878381751478,
0.08063031733036041,
0.07682434469461441,
0.020104719325900078,
0.02676517888903618,
0.022131050005555153,
0.02958442084491253,
-0.004568052943795919,
-0.11777383089065552,
-0.004378635436296463,
-0.013805476017296314,
-0.07449846714735031,
-0.044367820024490356,
0.05913360044360161,
0.014836261048913002,
-0.007770535536110401,
-0.029143914580345154,
-0.013056614436209202,
0.012387044727802277,
-0.010748360306024551,
0.016563046723604202,
-0.012624918483197689,
0.006070180330425501,
-0.02873864769935608,
0.047504227608442307,
-0.08225138485431671,
-0.009673523716628551,
-0.06568834185600281,
0.047222305089235306,
0.01338258944451809,
-0.039821792393922806,
0.037707362323999405,
0.0013215197250247002,
-0.05994413420557976,
-0.030800219625234604,
-0.01535605825483799,
-0.006246382836252451,
0.05779445916414261,
0.0004149021115154028,
-0.019910896196961403,
0.007845422253012657,
0.02609560824930668,
-0.008021624758839607,
0.016157779842615128,
-0.011470790952444077,
-0.040138956159353256,
-0.038095008581876755,
0.03152265027165413,
0.03099404089152813,
0.06367962807416916,
-0.06826089322566986,
-0.008316763676702976,
0.014096209779381752,
-0.05025298893451691,
-0.017479300498962402,
-0.013056614436209202,
-0.015576312318444252,
0.008136156015098095,
0.02327636629343033,
-0.004292736295610666,
-0.0014008108992129564,
-0.005955648608505726,
0.026818038895726204,
-0.024527404457330704,
0.012906841933727264,
0.01581418514251709,
0.004380837548524141,
0.06663983315229416,
0.029883965849876404,
0.012898032553493977,
-0.025760823860764503,
0.015197476372122765,
0.03603343665599823,
-0.06663983315229416,
0.014034539461135864,
0.04686989635229111,
0.049583420157432556,
-0.04250007122755051,
-0.036332979798316956,
-0.02905581332743168,
0.04968914017081261,
-0.06230524927377701,
0.040491364896297455,
-0.009585422463715076,
0.039434146136045456,
0.07034008949995041,
0.021972468122839928,
0.07100965827703476,
0.041689541190862656,
-0.020457124337553978,
0.008021624758839607,
0.002726735547184944,
-0.031399305909872055,
-0.011488410644233227,
-0.015012463554739952,
-0.005638483911752701,
0.05286078900098801,
0.02725854516029358,
0.0013622664846479893,
0.02905581332743168,
0.017523350194096565,
0.0000037899051221756963,
-0.02507363259792328,
-0.06808469444513321,
-0.10818841308355331,
-0.008532611653208733,
-0.006999649107456207,
-0.08302667737007141,
0.004054863005876541,
-0.042993441224098206,
0.00822425726801157,
0.05271982401609421,
0.024280721321702003,
-0.004898433107882738,
-0.06160043925046921,
-0.015699652954936028,
-0.0033874954096972942,
-0.04983010143041611,
0.03307323157787323,
-0.04909005016088486,
0.020016618072986603,
0.01676568016409874,
0.05219121649861336,
-0.008426890708506107,
0.048455722630023956,
0.05088731646537781,
0.07689482718706131,
-0.01310066506266594,
0.05060539394617081,
0.02327636629343033,
-0.017629072070121765,
0.03138168901205063,
-0.041372377425432205,
-0.06103659048676491,
-0.001133203157223761,
-0.022606797516345978,
-0.036086298525333405,
-0.012827550992369652,
-0.033866144716739655,
-0.002016418846324086,
-0.022694898769259453,
0.04704609885811806,
-0.037707362323999405,
-0.0023280770983546972,
0.011840816587209702,
-0.0031209890730679035,
0.06339770555496216,
-0.018747959285974503,
-0.0019591529853641987,
0.019505631178617477,
-0.017840515822172165,
-0.010008309036493301,
-0.012545626610517502,
0.008598688058555126,
-0.028086697682738304,
0.01658947765827179,
0.05818210542201996,
-0.009744005277752876,
-0.05222645774483681,
0.013144715689122677,
-0.031082142144441605,
-0.026430394500494003,
0.05078159645199776,
-0.05790018290281296,
-0.007986383512616158,
0.046129848808050156,
-0.04877288639545441,
-0.045143112540245056,
0.00046225657570175827,
-0.004506382159888744,
-0.06043750047683716,
-0.013179956004023552,
-0.050464432686567307,
0.012845171615481377,
-0.027064723894000053,
-0.024844570085406303,
-0.016897831112146378,
-0.045178353786468506,
-0.000856785278301686,
-0.017338337376713753,
-0.008849776349961758,
0.008907042443752289,
-0.033090852200984955,
-0.01322400663048029,
-0.02961966022849083,
-0.09352835267782211,
-0.031892675906419754,
0.019628971815109253,
0.032386042177677155,
-0.043063919991254807,
-0.016651147976517677,
-0.0012146967928856611,
-0.00692916801199317,
0.038940779864788055,
-0.03381328284740448,
0.004255293402820826,
-0.013356158509850502,
-0.030306851491332054,
-0.06494829058647156,
-0.027276165783405304,
0.011585322208702564,
-0.05895739793777466,
0.006246382836252451,
-0.06015557423233986,
-0.05078159645199776,
0.013373779132962227,
0.017910996451973915,
-0.036438703536987305,
-0.008096510544419289,
0.06004985421895981,
0.008633928373456001,
-0.039434146136045456,
0.018606998026371002,
-0.030060168355703354,
0.010748360306024551,
0.002383140381425619,
0.013144715689122677,
0.025831304490566254,
0.07051628828048706,
0.06769704818725586,
-0.02461550571024418,
-0.018765579909086227,
0.024227861315011978,
-0.022871101275086403,
-0.05423516780138016,
0.00012802222045138478,
0.0070304847322404385,
-0.032985132187604904,
-0.05300175026059151,
0.004731040447950363,
-0.02761095203459263,
0.049935825169086456,
-0.026148470118641853,
0.008255093358457088,
-0.0010704309679567814,
0.02796335704624653,
0.0028831155505031347,
-0.015963958576321602,
-0.0058543323539197445,
0.03067687712609768,
-0.023769734427332878,
-0.01495079230517149,
0.008396054618060589,
0.021831505000591278,
0.020968113094568253,
-0.033443257212638855,
0.039363667368888855,
0.003510837210342288,
0.02299444191157818,
-0.039962753653526306,
0.010792410932481289,
0.041125692427158356,
0.01662471704185009,
-0.011814385652542114,
0.041760023683309555,
0.032068878412246704,
-0.0015781148103997111,
0.03596295416355133,
0.004713420290499926,
-0.008462131023406982,
-0.08415437489748001,
0.009858536534011364,
-0.08168753981590271,
-0.008827751502394676,
0.016853781417012215,
0.007541472092270851,
0.01551464106887579,
0.03480001911520958,
0.05871071293950081,
-0.02577844448387623,
-0.00649747159332037,
-0.07886829227209091,
-0.03007778711616993,
0.021390998736023903,
-0.021884365007281303,
0.015188666060566902,
-0.007823396474123001,
0.010175701230764389,
-0.010501676239073277,
0.023364467546343803,
-0.042006704956293106,
-0.044050656259059906,
0.007021674420684576,
-0.0005338388727977872,
0.035487208515405655,
0.05952124670147896,
-0.016386844217777252,
0.06561785936355591,
0.06114231050014496,
-0.01683616079390049,
-0.023258745670318604,
0.06149471551179886,
0.005246432963758707,
0.06470160186290741,
-0.0011497221421450377,
-0.009118486195802689,
-0.006264003459364176,
-0.023223506286740303,
-0.017426438629627228,
-0.014404564164578915,
-0.06470160186290741,
0.043698251247406006,
-0.022571556270122528,
0.009585422463715076,
0.033302295953035355,
-0.016651147976517677,
-0.0026011911686509848,
-0.044121138751506805,
0.08478870242834091,
0.008598688058555126,
-0.021813884377479553,
-0.013585221953690052,
-0.036156777292490005,
-0.06649886816740036,
-0.005924813449382782,
0.009303499013185501,
-0.016316363587975502,
-0.01292446255683899,
-0.0005820192745886743,
0.0051407115533947945,
0.024950291961431503,
0.020827149972319603
]
|
30,672 | networkx.convert_matrix | from_numpy_array | Returns a graph from a 2D NumPy array.
The 2D NumPy array is interpreted as an adjacency matrix for the graph.
Parameters
----------
A : a 2D numpy.ndarray
An adjacency matrix representation of a graph
parallel_edges : Boolean
If this is True, `create_using` is a multigraph, and `A` is an
integer array, then entry *(i, j)* in the array is interpreted as the
number of parallel edges joining vertices *i* and *j* in the graph.
If it is False, then the entries in the array are interpreted as
the weight of a single edge joining the vertices.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
edge_attr : String, optional (default="weight")
The attribute to which the array values are assigned on each edge. If
it is None, edge attributes will not be assigned.
Notes
-----
For directed graphs, explicitly mention create_using=nx.DiGraph,
and entry i,j of A corresponds to an edge from i to j.
If `create_using` is :class:`networkx.MultiGraph` or
:class:`networkx.MultiDiGraph`, `parallel_edges` is True, and the
entries of `A` are of type :class:`int`, then this function returns a
multigraph (of the same type as `create_using`) with parallel edges.
If `create_using` indicates an undirected multigraph, then only the edges
indicated by the upper triangle of the array `A` will be added to the
graph.
If `edge_attr` is Falsy (False or None), edge attributes will not be
assigned, and the array data will be treated like a binary mask of
edge presence or absence. Otherwise, the attributes will be assigned
as follows:
If the NumPy array has a single data type for each array entry it
will be converted to an appropriate Python data type.
If the NumPy array has a user-specified compound data type the names
of the data fields will be used as attribute keys in the resulting
NetworkX graph.
See Also
--------
to_numpy_array
Examples
--------
Simple integer weights on edges:
>>> import numpy as np
>>> A = np.array([[1, 1], [2, 1]])
>>> G = nx.from_numpy_array(A)
>>> G.edges(data=True)
EdgeDataView([(0, 0, {'weight': 1}), (0, 1, {'weight': 2}), (1, 1, {'weight': 1})])
If `create_using` indicates a multigraph and the array has only integer
entries and `parallel_edges` is False, then the entries will be treated
as weights for edges joining the nodes (without creating parallel edges):
>>> A = np.array([[1, 1], [1, 2]])
>>> G = nx.from_numpy_array(A, create_using=nx.MultiGraph)
>>> G[1][1]
AtlasView({0: {'weight': 2}})
If `create_using` indicates a multigraph and the array has only integer
entries and `parallel_edges` is True, then the entries will be treated
as the number of parallel edges joining those two vertices:
>>> A = np.array([[1, 1], [1, 2]])
>>> temp = nx.MultiGraph()
>>> G = nx.from_numpy_array(A, parallel_edges=True, create_using=temp)
>>> G[1][1]
AtlasView({0: {'weight': 1}, 1: {'weight': 1}})
User defined compound data type on edges:
>>> dt = [("weight", float), ("cost", int)]
>>> A = np.array([[(1.0, 2)]], dtype=dt)
>>> G = nx.from_numpy_array(A)
>>> G.edges()
EdgeView([(0, 0)])
>>> G[0][0]["cost"]
2
>>> G[0][0]["weight"]
1.0
| def to_numpy_array(
G,
nodelist=None,
dtype=None,
order=None,
multigraph_weight=sum,
weight="weight",
nonedge=0.0,
):
"""Returns the graph adjacency matrix as a NumPy array.
Parameters
----------
G : graph
The NetworkX graph used to construct the NumPy array.
nodelist : list, optional
The rows and columns are ordered according to the nodes in `nodelist`.
If `nodelist` is ``None``, then the ordering is produced by ``G.nodes()``.
dtype : NumPy data type, optional
A NumPy data type used to initialize the array. If None, then the NumPy
default is used. The dtype can be structured if `weight=None`, in which
case the dtype field names are used to look up edge attributes. The
result is a structured array where each named field in the dtype
corresponds to the adjacency for that edge attribute. See examples for
details.
order : {'C', 'F'}, optional
Whether to store multidimensional data in C- or Fortran-contiguous
(row- or column-wise) order in memory. If None, then the NumPy default
is used.
multigraph_weight : callable, optional
An function that determines how weights in multigraphs are handled.
The function should accept a sequence of weights and return a single
value. The default is to sum the weights of the multiple edges.
weight : string or None optional (default = 'weight')
The edge attribute that holds the numerical value used for
the edge weight. If an edge does not have that attribute, then the
value 1 is used instead. `weight` must be ``None`` if a structured
dtype is used.
nonedge : array_like (default = 0.0)
The value used to represent non-edges in the adjacency matrix.
The array values corresponding to nonedges are typically set to zero.
However, this could be undesirable if there are array values
corresponding to actual edges that also have the value zero. If so,
one might prefer nonedges to have some other value, such as ``nan``.
Returns
-------
A : NumPy ndarray
Graph adjacency matrix
Raises
------
NetworkXError
If `dtype` is a structured dtype and `G` is a multigraph
ValueError
If `dtype` is a structured dtype and `weight` is not `None`
See Also
--------
from_numpy_array
Notes
-----
For directed graphs, entry ``i, j`` corresponds to an edge from ``i`` to ``j``.
Entries in the adjacency matrix are given by the `weight` edge attribute.
When an edge does not have a weight attribute, the value of the entry is
set to the number 1. For multiple (parallel) edges, the values of the
entries are determined by the `multigraph_weight` parameter. The default is
to sum the weight attributes for each of the parallel edges.
When `nodelist` does not contain every node in `G`, the adjacency matrix is
built from the subgraph of `G` that is induced by the nodes in `nodelist`.
The convention used for self-loop edges in graphs is to assign the
diagonal array entry value to the weight attribute of the edge
(or the number 1 if the edge has no weight attribute). If the
alternate convention of doubling the edge weight is desired the
resulting NumPy array can be modified as follows:
>>> import numpy as np
>>> G = nx.Graph([(1, 1)])
>>> A = nx.to_numpy_array(G)
>>> A
array([[1.]])
>>> A[np.diag_indices_from(A)] *= 2
>>> A
array([[2.]])
Examples
--------
>>> G = nx.MultiDiGraph()
>>> G.add_edge(0, 1, weight=2)
0
>>> G.add_edge(1, 0)
0
>>> G.add_edge(2, 2, weight=3)
0
>>> G.add_edge(2, 2)
1
>>> nx.to_numpy_array(G, nodelist=[0, 1, 2])
array([[0., 2., 0.],
[1., 0., 0.],
[0., 0., 4.]])
When `nodelist` argument is used, nodes of `G` which do not appear in the `nodelist`
and their edges are not included in the adjacency matrix. Here is an example:
>>> G = nx.Graph()
>>> G.add_edge(3, 1)
>>> G.add_edge(2, 0)
>>> G.add_edge(2, 1)
>>> G.add_edge(3, 0)
>>> nx.to_numpy_array(G, nodelist=[1, 2, 3])
array([[0., 1., 1.],
[1., 0., 0.],
[1., 0., 0.]])
This function can also be used to create adjacency matrices for multiple
edge attributes with structured dtypes:
>>> G = nx.Graph()
>>> G.add_edge(0, 1, weight=10)
>>> G.add_edge(1, 2, cost=5)
>>> G.add_edge(2, 3, weight=3, cost=-4.0)
>>> dtype = np.dtype([("weight", int), ("cost", float)])
>>> A = nx.to_numpy_array(G, dtype=dtype, weight=None)
>>> A["weight"]
array([[ 0, 10, 0, 0],
[10, 0, 1, 0],
[ 0, 1, 0, 3],
[ 0, 0, 3, 0]])
>>> A["cost"]
array([[ 0., 1., 0., 0.],
[ 1., 0., 5., 0.],
[ 0., 5., 0., -4.],
[ 0., 0., -4., 0.]])
As stated above, the argument "nonedge" is useful especially when there are
actually edges with weight 0 in the graph. Setting a nonedge value different than 0,
makes it much clearer to differentiate such 0-weighted edges and actual nonedge values.
>>> G = nx.Graph()
>>> G.add_edge(3, 1, weight=2)
>>> G.add_edge(2, 0, weight=0)
>>> G.add_edge(2, 1, weight=0)
>>> G.add_edge(3, 0, weight=1)
>>> nx.to_numpy_array(G, nonedge=-1.0)
array([[-1., 2., -1., 1.],
[ 2., -1., 0., -1.],
[-1., 0., -1., 0.],
[ 1., -1., 0., -1.]])
"""
import numpy as np
if nodelist is None:
nodelist = list(G)
nlen = len(nodelist)
# Input validation
nodeset = set(nodelist)
if nodeset - set(G):
raise nx.NetworkXError(f"Nodes {nodeset - set(G)} in nodelist is not in G")
if len(nodeset) < nlen:
raise nx.NetworkXError("nodelist contains duplicates.")
A = np.full((nlen, nlen), fill_value=nonedge, dtype=dtype, order=order)
# Corner cases: empty nodelist or graph without any edges
if nlen == 0 or G.number_of_edges() == 0:
return A
# If dtype is structured and weight is None, use dtype field names as
# edge attributes
edge_attrs = None # Only single edge attribute by default
if A.dtype.names:
if weight is None:
edge_attrs = dtype.names
else:
raise ValueError(
"Specifying `weight` not supported for structured dtypes\n."
"To create adjacency matrices from structured dtypes, use `weight=None`."
)
# Map nodes to row/col in matrix
idx = dict(zip(nodelist, range(nlen)))
if len(nodelist) < len(G):
G = G.subgraph(nodelist).copy()
# Collect all edge weights and reduce with `multigraph_weights`
if G.is_multigraph():
if edge_attrs:
raise nx.NetworkXError(
"Structured arrays are not supported for MultiGraphs"
)
d = defaultdict(list)
for u, v, wt in G.edges(data=weight, default=1.0):
d[(idx[u], idx[v])].append(wt)
i, j = np.array(list(d.keys())).T # indices
wts = [multigraph_weight(ws) for ws in d.values()] # reduced weights
else:
i, j, wts = [], [], []
# Special branch: multi-attr adjacency from structured dtypes
if edge_attrs:
# Extract edges with all data
for u, v, data in G.edges(data=True):
i.append(idx[u])
j.append(idx[v])
wts.append(data)
# Map each attribute to the appropriate named field in the
# structured dtype
for attr in edge_attrs:
attr_data = [wt.get(attr, 1.0) for wt in wts]
A[attr][i, j] = attr_data
if not G.is_directed():
A[attr][j, i] = attr_data
return A
for u, v, wt in G.edges(data=weight, default=1.0):
i.append(idx[u])
j.append(idx[v])
wts.append(wt)
# Set array values with advanced indexing
A[i, j] | (A, parallel_edges=False, create_using=None, edge_attr='weight', *, backend=None, **backend_kwargs) | [
0.0068152411840856075,
0.06676866114139557,
0.02268478274345398,
0.02024415321648121,
0.0021614283323287964,
-0.04271102324128151,
-0.04020502045750618,
-0.00416759354993701,
0.07626968622207642,
-0.03107444755733013,
-0.038788583129644394,
-0.009925954975187778,
0.04170862212777138,
0.03693631663918495,
0.0014750012196600437,
-0.0062432182021439075,
0.0079974215477705,
-0.0002667736553121358,
-0.008133617229759693,
0.08136885613203049,
-0.02985413372516632,
-0.11706306785345078,
0.02383972331881523,
0.03554167225956917,
0.034844350069761276,
0.013096594251692295,
0.0011168060591444373,
-0.009321245364844799,
0.021148493513464928,
-0.00015764671843498945,
-0.009495575912296772,
-0.05944677069783211,
-0.0624539740383625,
0.024951081722974777,
0.05613448843359947,
0.025321535766124725,
-0.021976564079523087,
-0.018446367233991623,
-0.07592102140188217,
0.002819254295900464,
0.04528240114450455,
-0.08023570477962494,
-0.018315618857741356,
-0.009691697545349598,
0.02610602229833603,
0.016485147178173065,
0.06262830644845963,
0.02071266621351242,
-0.05979543179273605,
-0.028829939663410187,
0.04170862212777138,
-0.02405763790011406,
0.025016456842422485,
0.058749448508024216,
-0.02344748005270958,
0.03896291181445122,
0.017269635573029518,
-0.023774350062012672,
0.010105732828378677,
-0.041773997247219086,
-0.03562883660197258,
-0.03632616251707077,
0.03584675118327141,
-0.012399271130561829,
-0.03098728321492672,
-0.0012087383074685931,
-0.0380912609398365,
-0.014436761848628521,
0.01750933937728405,
0.008378769271075726,
-0.013281820341944695,
0.0033449705224484205,
0.055088501423597336,
-0.02414480224251747,
0.02634572796523571,
0.06380503624677658,
-0.004418193828314543,
0.011222539469599724,
-0.045413147658109665,
0.04576180875301361,
-0.0005417190259322524,
0.04434537515044212,
0.012017923407256603,
-0.004551665857434273,
0.021290138363838196,
0.01933981291949749,
-0.00807369127869606,
0.08733968436717987,
-0.024624211713671684,
-0.09222093969583511,
0.017542026937007904,
-0.010824847035109997,
-0.007828538306057453,
0.055480748414993286,
0.007474428974092007,
-0.005861870013177395,
0.007964733988046646,
-0.06254114210605621,
0.010034911334514618,
0.03177177160978317,
-0.06716090440750122,
0.009457441046833992,
0.0029881373047828674,
0.014523927122354507,
-0.06297696381807327,
-0.05818287283182144,
-0.038548875600099564,
0.03127057105302811,
0.008711087517440319,
-0.020908789709210396,
-0.027980078011751175,
0.027696790173649788,
0.056831810623407364,
-0.03386373817920685,
0.049074094742536545,
0.032251179218292236,
0.011898070573806763,
0.011108134873211384,
-0.020462065935134888,
-0.000994910835288465,
0.03142311051487923,
0.03379836678504944,
0.014502136036753654,
-0.0063576227985322475,
0.008111825212836266,
-0.015482746064662933,
0.011582096107304096,
-0.01896936073899269,
0.05391177162528038,
-0.005327982362359762,
-0.022510452196002007,
-0.029570845887064934,
-0.03218580782413483,
0.022510452196002007,
-0.03312283381819725,
-0.01622365042567253,
-0.02124655432999134,
-0.026454685255885124,
0.03142311051487923,
-0.03312283381819725,
0.0152321457862854,
-0.07221649587154388,
0.028045453131198883,
0.021126702427864075,
0.015885885804891586,
-0.0068915109150111675,
0.02567019686102867,
0.003745386144146323,
-0.044890157878398895,
-0.04685137793421745,
-0.018675176426768303,
-0.044802989810705185,
-0.009876923635601997,
-0.01713888719677925,
0.029418306425213814,
0.003366761840879917,
-0.05748555064201355,
-0.03022458590567112,
0.005731122102588415,
0.031009074300527573,
-0.07304456830024719,
-0.03610824793577194,
-0.009653562679886818,
-0.005845526698976755,
-0.0029009717982262373,
0.033231791108846664,
0.016430668532848358,
-0.03813484311103821,
-0.08306857943534851,
-0.01834830641746521,
-0.020189674571156502,
-0.0685119703412056,
-0.03342791274189949,
-0.01689918339252472,
0.0148507971316576,
0.013968247920274734,
0.03249088674783707,
0.01088477298617363,
0.017542026937007904,
0.06044917181134224,
0.05718047171831131,
0.01828293316066265,
-0.011658365838229656,
0.030791161581873894,
0.012769724242389202,
-0.01789068803191185,
0.03617362305521965,
-0.04105488210916519,
0.0510353147983551,
0.02787112072110176,
0.0418611615896225,
0.013630482368171215,
-0.005033798981457949,
0.0578777939081192,
0.05792137607932091,
-0.0074253985658288,
-0.04201370105147362,
0.04563106223940849,
-0.04249310865998268,
0.112704798579216,
0.07012452930212021,
-0.04051009938120842,
0.05260429158806801,
0.041904743760824203,
0.017465757206082344,
0.0037535580340772867,
0.024711377918720245,
-0.04201370105147362,
0.007861224934458733,
0.011124477721750736,
-0.004344648215919733,
-0.02466779574751854,
0.06332562863826752,
0.006717179901897907,
-0.013684960082173347,
0.0005362711963243783,
-0.016801122575998306,
0.0540425181388855,
-0.01949235238134861,
-0.04528240114450455,
-0.04885618016123772,
0.02200925163924694,
-0.035977497696876526,
-0.019154585897922516,
-0.00025281356647610664,
-0.06480743736028671,
0.03266521543264389,
0.00011244670895393938,
0.01073768176138401,
0.031706396490335464,
0.03052966482937336,
-0.009228631854057312,
0.012562706135213375,
-0.02946188859641552,
0.020690875127911568,
0.0009172791615128517,
0.0032441855873912573,
0.04654629901051521,
0.0036909079644829035,
0.02169327810406685,
-0.04170862212777138,
-0.05822645500302315,
-0.036827363073825836,
0.02567019686102867,
0.006303144618868828,
0.003859790740534663,
0.030420707538723946,
0.029026063159108162,
-0.01024192851036787,
-0.0076106246560812,
-0.09039047360420227,
-0.016397982835769653,
0.014229743741452694,
-0.01889309100806713,
-0.018184872344136238,
-0.0011883089318871498,
-0.031706396490335464,
0.016180068254470825,
-0.04323401674628258,
-0.041621457785367966,
0.0335150770843029,
-0.005774704739451408,
-0.0048540206626057625,
-0.012268523685634136,
0.05818287283182144,
0.010056702420115471,
0.05160189047455788,
0.03774259611964226,
-0.047243621200323105,
0.029723385348916054,
-0.008509517647325993,
0.020995954051613808,
0.01773814857006073,
-0.01274793315678835,
0.021115805953741074,
-0.004208452068269253,
0.011320600286126137,
0.026934094727039337,
-0.035367343574762344,
0.007991973310709,
-0.10285511612892151,
0.013815708458423615,
-0.02298986166715622,
0.044890157878398895,
-0.06886062771081924,
-0.035977497696876526,
-0.007490772288292646,
0.009468336589634418,
-0.04234056919813156,
-0.03462643548846245,
0.05731121823191643,
-0.004559837747365236,
-0.0156025979667902,
0.0016575036570429802,
-0.01894756779074669,
-0.014763631857931614,
-0.010236481204628944,
-0.004006882198154926,
0.01244285423308611,
0.06794539093971252,
0.05792137607932091,
0.032098639756441116,
0.06071066856384277,
-0.013848395086824894,
0.007741373032331467,
0.024340923875570297,
0.0041839368641376495,
0.05574224144220352,
-0.0018250246066600084,
0.04319043084979057,
-0.03800409287214279,
0.004322856664657593,
-0.06258472055196762,
0.04438895732164383,
-0.03168460726737976,
0.037502892315387726,
0.009811550378799438,
-0.004745063837617636,
0.10067598521709442,
0.036042872816324234,
-0.01758560910820961,
0.038178425282239914,
-0.031946100294589996,
-0.0036718405317515135,
-0.08110736310482025,
0.01682291366159916,
0.07448279112577438,
0.014349596574902534,
0.015210353769361973,
0.014763631857931614,
-0.0008893589838407934,
0.03312283381819725,
-0.012007026933133602,
0.014567509293556213,
-0.04301610216498375,
0.034691810607910156,
0.01789068803191185,
-0.05073023587465286,
-0.016572313383221626,
-0.006417549215257168,
-0.060579922050237656,
0.05657031387090683,
-0.002734812907874584,
-0.019154585897922516,
0.03190251812338829,
-0.03473539277911186,
-0.03473539277911186,
0.034975096583366394,
-0.003930612467229366,
-0.011059104464948177,
0.023403897881507874,
0.05055590346455574,
-0.029178602620959282,
0.048681847751140594,
-0.033624034374952316,
-0.012758828699588776,
-0.004448156803846359,
-0.024188386276364326,
0.002467869082465768,
0.0213337205350399,
-0.032098639756441116,
0.04242773726582527,
0.04964066669344902,
-0.03462643548846245,
0.010694099590182304,
0.016343504190444946,
0.0016806569183245301,
0.019274437800049782,
0.07191141694784164,
-0.07300098240375519,
0.03800409287214279,
-0.056395985186100006,
-0.03926799073815346,
0.039921730756759644,
0.004497187212109566,
0.023316731676459312,
-0.032861337065696716,
0.008732878603041172,
0.014665571041405201,
-0.027043050155043602,
0.0042030042968690395,
-0.012780619785189629,
0.020309526473283768,
0.01473094429820776,
0.017084408551454544,
-0.018326515331864357,
0.09344125539064407,
0.06341279298067093,
-0.05687539279460907,
-0.027304546907544136,
-0.03061683103442192,
0.009217736311256886,
-0.010312750935554504,
0.017683671787381172,
-0.02991950698196888,
0.029963089153170586,
0.020745353773236275,
0.027980078011751175,
-0.02460242062807083,
-0.03473539277911186,
-0.06890421360731125,
-0.02131192944943905,
-0.0152321457862854,
0.01134239137172699,
-0.031967893242836,
0.013434359803795815,
0.005861870013177395,
-0.020527441054582596,
0.040619052946567535,
0.018217558041214943,
0.005567687097936869,
0.06145157292485237,
0.0078012989833951,
0.019579516723752022,
0.04319043084979057,
0.04850751906633377,
0.06794539093971252,
-0.027827538549900055,
0.07640042901039124,
0.013695855624973774,
0.04048830643296242,
0.026585431769490242,
0.01621275581419468,
-0.002586359390988946,
0.04430178925395012,
-0.02695588581264019,
-0.002083796774968505,
-0.00026915708440355957,
-0.05338877812027931,
0.04319043084979057,
0.014970649033784866,
-0.02138819918036461,
0.012388375587761402,
-0.03896291181445122,
-0.05382460728287697,
0.0020197846461087465,
0.010715890675783157,
-0.003927888814359903,
-0.010024015791714191,
-0.004290169570595026,
-0.008280708454549313,
0.004551665857434273,
0.003099817782640457,
-0.028873523697257042,
-0.023403897881507874,
-0.057529132813215256,
0.014589301310479641,
0.016866495832800865,
-0.043059684336185455,
-0.050207242369651794,
0.023185983300209045,
0.005649404600262642,
0.06271547079086304,
-0.006826136726886034,
-0.0784488171339035,
0.055393580347299576,
0.04889976233243942,
-0.03523659333586693,
0.008841835893690586,
0.013946456834673882,
0.039006493985652924,
0.011669261381030083,
-0.037110649049282074,
-0.03534555062651634,
0.004309237003326416,
-0.02155163325369358,
0.009511918760836124,
-0.011015521362423897,
-0.03974740207195282,
-0.005954483058303595,
0.05604732036590576,
-0.0220746248960495,
-0.027696790173649788,
-0.07326247543096542,
0.04218802973628044,
0.012649871408939362,
-0.016866495832800865,
-0.008798252791166306,
-0.032774172723293304,
-0.008967136032879353,
-0.018936673179268837,
-0.016463356092572212,
0.007174798287451267,
-0.0013932837173342705,
0.026999467983841896,
0.022216269746422768,
0.04475940763950348,
-0.02665080688893795,
-0.01518856268376112,
-0.017956063151359558,
-0.05975184962153435,
0.00428199814632535,
0.02717379853129387,
0.021508051082491875,
0.07670550793409348,
0.047243621200323105,
-0.0022009252570569515,
0.00007614200148964301,
0.036195412278175354,
0.0403357669711113,
0.002345292828977108,
-0.02802366018295288,
-0.05687539279460907,
0.020995954051613808,
0.000039794729673303664,
-0.02612781524658203,
-0.023098818957805634,
0.027304546907544136,
0.050817400217056274,
0.021126702427864075,
-0.029222184792160988,
0.06716090440750122,
-0.0388321653008461,
0.02900427207350731,
-0.009675353765487671,
0.028372323140501976,
0.003042615484446287,
-0.0018127670045942068,
0.012660767883062363,
-0.043822381645441055,
0.031009074300527573,
0.0036990796215832233,
-0.012856889516115189,
0.039333365857601166,
-0.06820689141750336,
0.09527172893285751,
0.0005454644560813904,
-0.025866318494081497,
-0.012660767883062363,
0.006335831712931395,
-0.008667504414916039,
0.028808148577809334,
-0.0041866609826684,
0.08193542808294296,
0.006352175027132034,
-0.03340611979365349,
0.10477275401353836,
0.05168905481696129,
-0.00027818005764856935,
0.004483568016439676,
0.010786712169647217,
0.017400383949279785,
-0.026541849598288536,
0.017531132325530052,
0.019819222390651703,
0.037720806896686554,
0.004617039579898119,
-0.02169327810406685,
-0.017106199637055397,
-0.07435204833745956,
-0.04545672982931137,
0.03989994153380394,
0.018108602613210678,
-0.012965845875442028,
0.06005692854523659,
-0.01887129805982113,
0.01107544731348753,
-0.05038157477974892,
0.017411278560757637,
0.010187450796365738,
-0.03412523493170738,
-0.060579922050237656,
-0.0395730696618557,
0.003290492109954357,
0.0004681732680182904,
-0.010476185940206051,
0.006973228417336941,
0.0358031690120697,
-0.03610824793577194,
0.00046340643893927336,
-0.0213337205350399,
-0.08516055345535278,
-0.018773237243294716,
-0.04584897682070732,
-0.02124655432999134,
0.004832229111343622,
-0.050904564559459686,
-0.002578187733888626,
-0.008171752095222473,
-0.014970649033784866,
-0.020810728892683983,
-0.024188386276364326,
-0.006041648332029581,
0.031030865386128426,
0.05286578834056854,
-0.03342791274189949,
-0.02671618014574051,
0.04319043084979057,
0.004725996404886246,
-0.052342794835567474,
-0.01118985190987587,
-0.044802989810705185,
0.0845068097114563,
0.012987637892365456,
-0.021431781351566315,
0.01881682127714157,
-0.009996776469051838,
-0.0010412173578515649,
0.044890157878398895,
-0.06297696381807327,
0.010247376747429371,
0.011996131390333176,
0.014894379302859306,
0.008847283199429512,
-0.017073513939976692,
0.021813130006194115,
-0.044890157878398895,
-0.03569421172142029,
0.02169327810406685,
-0.03192431107163429,
-0.040379349142313004,
0.010138420388102531,
-0.0426238588988781,
-0.055698659271001816,
-0.022946279495954514,
-0.009190496988594532,
-0.07099618017673492,
0.062018148601055145,
-0.0631512999534607,
-0.005665747914463282,
0.00394150847569108,
-0.05195055156946182,
-0.010988282039761543,
-0.030551455914974213,
-0.02597527578473091,
0.031706396490335464,
-0.010715890675783157,
-0.017182469367980957,
0.009157809428870678,
0.06445877999067307,
-0.0006758719682693481,
-0.019067421555519104,
0.02588810957968235,
0.04746153578162193,
0.04654629901051521,
-0.1256052702665329,
-0.029200393706560135,
0.02512541227042675,
0.04253669083118439,
0.04746153578162193,
-0.04142533242702484,
0.002051109680905938,
0.017247844487428665,
-0.033994488418102264,
-0.014142578467726707,
-0.04811527580022812,
0.02909143641591072,
-0.07147558778524399,
0.014349596574902534,
-0.01896936073899269,
0.020614605396986008,
-0.03456106409430504,
-0.03325358033180237,
0.04471582546830177,
0.022129103541374207,
0.05626523494720459,
-0.038178425282239914,
0.0418611615896225,
-0.005949035286903381,
-0.02336031384766102,
-0.0023766178637742996,
0.018326515331864357,
0.02162790298461914,
-0.02071266621351242,
0.04042293131351471,
0.02878635749220848,
0.017171574756503105,
-0.002501918002963066,
0.045718226581811905,
-0.008139064535498619,
-0.07291381806135178,
0.018620697781443596,
0.03737214580178261,
0.002383427694439888,
0.0028791804797947407,
0.01683380827307701,
0.028960688039660454,
-0.0072783068753778934,
0.010465290397405624,
-0.017106199637055397,
0.041381750255823135,
0.1134892925620079,
0.035912126302719116,
-0.019819222390651703,
0.0031488484237343073,
-0.06293338537216187,
0.014022726565599442,
-0.006090679205954075,
0.005791048053652048,
-0.06223606318235397,
0.0014123511500656605,
-0.024319132789969444,
0.07975629717111588,
0.041773997247219086,
-0.0023711700923740864,
-0.002702126046642661,
-0.013423464260995388,
0.04584897682070732,
-0.020908789709210396,
-0.014218848198652267,
-0.009185048751533031,
0.0037671776954084635,
-0.04781019687652588,
0.04467224329710007,
0.041142046451568604,
-0.009876923635601997,
-0.07042960822582245,
0.029352933168411255,
0.006984123960137367,
-0.01077581662684679,
-0.06010051071643829,
-0.020156987011432648,
-0.004941185936331749,
0.013238238170742989,
0.016659477725625038,
0.03238192945718765,
0.005458730272948742,
-0.008149960078299046,
-0.06641999632120132,
0.03122698701918125,
-0.014872588217258453,
0.02147536352276802,
0.029440097510814667,
0.05687539279460907,
-0.0913492888212204,
0.027217380702495575,
-0.00791570357978344,
-0.07500578463077545,
0.03146669268608093,
-0.03153206780552864,
0.021148493513464928,
0.03669661283493042,
0.06689941138029099,
0.07182425260543823,
-0.028742775321006775,
-0.012094193138182163,
-0.06280263513326645,
-0.01503602322191,
-0.0008028746233321726,
0.06894779205322266,
-0.032708797603845596,
-0.022510452196002007,
-0.03052966482937336,
0.021268345415592194,
-0.029352933168411255,
-0.007207484915852547,
-0.019819222390651703,
0.010764921084046364,
-0.031096240505576134,
-0.018925776705145836,
-0.0032687007915228605,
-0.0418611615896225,
-0.03329716622829437,
-0.014120787382125854,
0.035149428993463516,
-0.01424063928425312,
-0.007071289233863354,
-0.03312283381819725,
0.0021723241079598665,
-0.07596460729837418,
-0.053781021386384964,
0.022968070581555367,
-0.06563550978899002,
0.03388553112745285,
-0.10363960266113281,
-0.005292571149766445,
0.03830917179584503,
0.03395090624690056
]
|
30,673 | networkx.convert_matrix | from_pandas_adjacency | Returns a graph from Pandas DataFrame.
The Pandas DataFrame is interpreted as an adjacency matrix for the graph.
Parameters
----------
df : Pandas DataFrame
An adjacency matrix representation of a graph
create_using : NetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
Notes
-----
For directed graphs, explicitly mention create_using=nx.DiGraph,
and entry i,j of df corresponds to an edge from i to j.
If `df` has a single data type for each entry it will be converted to an
appropriate Python data type.
If you have node attributes stored in a separate dataframe `df_nodes`,
you can load those attributes to the graph `G` using the following code:
```
df_nodes = pd.DataFrame({"node_id": [1, 2, 3], "attribute1": ["A", "B", "C"]})
G.add_nodes_from((n, dict(d)) for n, d in df_nodes.iterrows())
```
If `df` has a user-specified compound data type the names
of the data fields will be used as attribute keys in the resulting
NetworkX graph.
See Also
--------
to_pandas_adjacency
Examples
--------
Simple integer weights on edges:
>>> import pandas as pd
>>> pd.options.display.max_columns = 20
>>> df = pd.DataFrame([[1, 1], [2, 1]])
>>> df
0 1
0 1 1
1 2 1
>>> G = nx.from_pandas_adjacency(df)
>>> G.name = "Graph from pandas adjacency matrix"
>>> print(G)
Graph named 'Graph from pandas adjacency matrix' with 2 nodes and 3 edges
| def to_numpy_array(
G,
nodelist=None,
dtype=None,
order=None,
multigraph_weight=sum,
weight="weight",
nonedge=0.0,
):
"""Returns the graph adjacency matrix as a NumPy array.
Parameters
----------
G : graph
The NetworkX graph used to construct the NumPy array.
nodelist : list, optional
The rows and columns are ordered according to the nodes in `nodelist`.
If `nodelist` is ``None``, then the ordering is produced by ``G.nodes()``.
dtype : NumPy data type, optional
A NumPy data type used to initialize the array. If None, then the NumPy
default is used. The dtype can be structured if `weight=None`, in which
case the dtype field names are used to look up edge attributes. The
result is a structured array where each named field in the dtype
corresponds to the adjacency for that edge attribute. See examples for
details.
order : {'C', 'F'}, optional
Whether to store multidimensional data in C- or Fortran-contiguous
(row- or column-wise) order in memory. If None, then the NumPy default
is used.
multigraph_weight : callable, optional
An function that determines how weights in multigraphs are handled.
The function should accept a sequence of weights and return a single
value. The default is to sum the weights of the multiple edges.
weight : string or None optional (default = 'weight')
The edge attribute that holds the numerical value used for
the edge weight. If an edge does not have that attribute, then the
value 1 is used instead. `weight` must be ``None`` if a structured
dtype is used.
nonedge : array_like (default = 0.0)
The value used to represent non-edges in the adjacency matrix.
The array values corresponding to nonedges are typically set to zero.
However, this could be undesirable if there are array values
corresponding to actual edges that also have the value zero. If so,
one might prefer nonedges to have some other value, such as ``nan``.
Returns
-------
A : NumPy ndarray
Graph adjacency matrix
Raises
------
NetworkXError
If `dtype` is a structured dtype and `G` is a multigraph
ValueError
If `dtype` is a structured dtype and `weight` is not `None`
See Also
--------
from_numpy_array
Notes
-----
For directed graphs, entry ``i, j`` corresponds to an edge from ``i`` to ``j``.
Entries in the adjacency matrix are given by the `weight` edge attribute.
When an edge does not have a weight attribute, the value of the entry is
set to the number 1. For multiple (parallel) edges, the values of the
entries are determined by the `multigraph_weight` parameter. The default is
to sum the weight attributes for each of the parallel edges.
When `nodelist` does not contain every node in `G`, the adjacency matrix is
built from the subgraph of `G` that is induced by the nodes in `nodelist`.
The convention used for self-loop edges in graphs is to assign the
diagonal array entry value to the weight attribute of the edge
(or the number 1 if the edge has no weight attribute). If the
alternate convention of doubling the edge weight is desired the
resulting NumPy array can be modified as follows:
>>> import numpy as np
>>> G = nx.Graph([(1, 1)])
>>> A = nx.to_numpy_array(G)
>>> A
array([[1.]])
>>> A[np.diag_indices_from(A)] *= 2
>>> A
array([[2.]])
Examples
--------
>>> G = nx.MultiDiGraph()
>>> G.add_edge(0, 1, weight=2)
0
>>> G.add_edge(1, 0)
0
>>> G.add_edge(2, 2, weight=3)
0
>>> G.add_edge(2, 2)
1
>>> nx.to_numpy_array(G, nodelist=[0, 1, 2])
array([[0., 2., 0.],
[1., 0., 0.],
[0., 0., 4.]])
When `nodelist` argument is used, nodes of `G` which do not appear in the `nodelist`
and their edges are not included in the adjacency matrix. Here is an example:
>>> G = nx.Graph()
>>> G.add_edge(3, 1)
>>> G.add_edge(2, 0)
>>> G.add_edge(2, 1)
>>> G.add_edge(3, 0)
>>> nx.to_numpy_array(G, nodelist=[1, 2, 3])
array([[0., 1., 1.],
[1., 0., 0.],
[1., 0., 0.]])
This function can also be used to create adjacency matrices for multiple
edge attributes with structured dtypes:
>>> G = nx.Graph()
>>> G.add_edge(0, 1, weight=10)
>>> G.add_edge(1, 2, cost=5)
>>> G.add_edge(2, 3, weight=3, cost=-4.0)
>>> dtype = np.dtype([("weight", int), ("cost", float)])
>>> A = nx.to_numpy_array(G, dtype=dtype, weight=None)
>>> A["weight"]
array([[ 0, 10, 0, 0],
[10, 0, 1, 0],
[ 0, 1, 0, 3],
[ 0, 0, 3, 0]])
>>> A["cost"]
array([[ 0., 1., 0., 0.],
[ 1., 0., 5., 0.],
[ 0., 5., 0., -4.],
[ 0., 0., -4., 0.]])
As stated above, the argument "nonedge" is useful especially when there are
actually edges with weight 0 in the graph. Setting a nonedge value different than 0,
makes it much clearer to differentiate such 0-weighted edges and actual nonedge values.
>>> G = nx.Graph()
>>> G.add_edge(3, 1, weight=2)
>>> G.add_edge(2, 0, weight=0)
>>> G.add_edge(2, 1, weight=0)
>>> G.add_edge(3, 0, weight=1)
>>> nx.to_numpy_array(G, nonedge=-1.0)
array([[-1., 2., -1., 1.],
[ 2., -1., 0., -1.],
[-1., 0., -1., 0.],
[ 1., -1., 0., -1.]])
"""
import numpy as np
if nodelist is None:
nodelist = list(G)
nlen = len(nodelist)
# Input validation
nodeset = set(nodelist)
if nodeset - set(G):
raise nx.NetworkXError(f"Nodes {nodeset - set(G)} in nodelist is not in G")
if len(nodeset) < nlen:
raise nx.NetworkXError("nodelist contains duplicates.")
A = np.full((nlen, nlen), fill_value=nonedge, dtype=dtype, order=order)
# Corner cases: empty nodelist or graph without any edges
if nlen == 0 or G.number_of_edges() == 0:
return A
# If dtype is structured and weight is None, use dtype field names as
# edge attributes
edge_attrs = None # Only single edge attribute by default
if A.dtype.names:
if weight is None:
edge_attrs = dtype.names
else:
raise ValueError(
"Specifying `weight` not supported for structured dtypes\n."
"To create adjacency matrices from structured dtypes, use `weight=None`."
)
# Map nodes to row/col in matrix
idx = dict(zip(nodelist, range(nlen)))
if len(nodelist) < len(G):
G = G.subgraph(nodelist).copy()
# Collect all edge weights and reduce with `multigraph_weights`
if G.is_multigraph():
if edge_attrs:
raise nx.NetworkXError(
"Structured arrays are not supported for MultiGraphs"
)
d = defaultdict(list)
for u, v, wt in G.edges(data=weight, default=1.0):
d[(idx[u], idx[v])].append(wt)
i, j = np.array(list(d.keys())).T # indices
wts = [multigraph_weight(ws) for ws in d.values()] # reduced weights
else:
i, j, wts = [], [], []
# Special branch: multi-attr adjacency from structured dtypes
if edge_attrs:
# Extract edges with all data
for u, v, data in G.edges(data=True):
i.append(idx[u])
j.append(idx[v])
wts.append(data)
# Map each attribute to the appropriate named field in the
# structured dtype
for attr in edge_attrs:
attr_data = [wt.get(attr, 1.0) for wt in wts]
A[attr][i, j] = attr_data
if not G.is_directed():
A[attr][j, i] = attr_data
return A
for u, v, wt in G.edges(data=weight, default=1.0):
i.append(idx[u])
j.append(idx[v])
wts.append(wt)
# Set array values with advanced indexing
A[i, j] | (df, create_using=None, *, backend=None, **backend_kwargs) | [
0.0068152411840856075,
0.06676866114139557,
0.02268478274345398,
0.02024415321648121,
0.0021614283323287964,
-0.04271102324128151,
-0.04020502045750618,
-0.00416759354993701,
0.07626968622207642,
-0.03107444755733013,
-0.038788583129644394,
-0.009925954975187778,
0.04170862212777138,
0.03693631663918495,
0.0014750012196600437,
-0.0062432182021439075,
0.0079974215477705,
-0.0002667736553121358,
-0.008133617229759693,
0.08136885613203049,
-0.02985413372516632,
-0.11706306785345078,
0.02383972331881523,
0.03554167225956917,
0.034844350069761276,
0.013096594251692295,
0.0011168060591444373,
-0.009321245364844799,
0.021148493513464928,
-0.00015764671843498945,
-0.009495575912296772,
-0.05944677069783211,
-0.0624539740383625,
0.024951081722974777,
0.05613448843359947,
0.025321535766124725,
-0.021976564079523087,
-0.018446367233991623,
-0.07592102140188217,
0.002819254295900464,
0.04528240114450455,
-0.08023570477962494,
-0.018315618857741356,
-0.009691697545349598,
0.02610602229833603,
0.016485147178173065,
0.06262830644845963,
0.02071266621351242,
-0.05979543179273605,
-0.028829939663410187,
0.04170862212777138,
-0.02405763790011406,
0.025016456842422485,
0.058749448508024216,
-0.02344748005270958,
0.03896291181445122,
0.017269635573029518,
-0.023774350062012672,
0.010105732828378677,
-0.041773997247219086,
-0.03562883660197258,
-0.03632616251707077,
0.03584675118327141,
-0.012399271130561829,
-0.03098728321492672,
-0.0012087383074685931,
-0.0380912609398365,
-0.014436761848628521,
0.01750933937728405,
0.008378769271075726,
-0.013281820341944695,
0.0033449705224484205,
0.055088501423597336,
-0.02414480224251747,
0.02634572796523571,
0.06380503624677658,
-0.004418193828314543,
0.011222539469599724,
-0.045413147658109665,
0.04576180875301361,
-0.0005417190259322524,
0.04434537515044212,
0.012017923407256603,
-0.004551665857434273,
0.021290138363838196,
0.01933981291949749,
-0.00807369127869606,
0.08733968436717987,
-0.024624211713671684,
-0.09222093969583511,
0.017542026937007904,
-0.010824847035109997,
-0.007828538306057453,
0.055480748414993286,
0.007474428974092007,
-0.005861870013177395,
0.007964733988046646,
-0.06254114210605621,
0.010034911334514618,
0.03177177160978317,
-0.06716090440750122,
0.009457441046833992,
0.0029881373047828674,
0.014523927122354507,
-0.06297696381807327,
-0.05818287283182144,
-0.038548875600099564,
0.03127057105302811,
0.008711087517440319,
-0.020908789709210396,
-0.027980078011751175,
0.027696790173649788,
0.056831810623407364,
-0.03386373817920685,
0.049074094742536545,
0.032251179218292236,
0.011898070573806763,
0.011108134873211384,
-0.020462065935134888,
-0.000994910835288465,
0.03142311051487923,
0.03379836678504944,
0.014502136036753654,
-0.0063576227985322475,
0.008111825212836266,
-0.015482746064662933,
0.011582096107304096,
-0.01896936073899269,
0.05391177162528038,
-0.005327982362359762,
-0.022510452196002007,
-0.029570845887064934,
-0.03218580782413483,
0.022510452196002007,
-0.03312283381819725,
-0.01622365042567253,
-0.02124655432999134,
-0.026454685255885124,
0.03142311051487923,
-0.03312283381819725,
0.0152321457862854,
-0.07221649587154388,
0.028045453131198883,
0.021126702427864075,
0.015885885804891586,
-0.0068915109150111675,
0.02567019686102867,
0.003745386144146323,
-0.044890157878398895,
-0.04685137793421745,
-0.018675176426768303,
-0.044802989810705185,
-0.009876923635601997,
-0.01713888719677925,
0.029418306425213814,
0.003366761840879917,
-0.05748555064201355,
-0.03022458590567112,
0.005731122102588415,
0.031009074300527573,
-0.07304456830024719,
-0.03610824793577194,
-0.009653562679886818,
-0.005845526698976755,
-0.0029009717982262373,
0.033231791108846664,
0.016430668532848358,
-0.03813484311103821,
-0.08306857943534851,
-0.01834830641746521,
-0.020189674571156502,
-0.0685119703412056,
-0.03342791274189949,
-0.01689918339252472,
0.0148507971316576,
0.013968247920274734,
0.03249088674783707,
0.01088477298617363,
0.017542026937007904,
0.06044917181134224,
0.05718047171831131,
0.01828293316066265,
-0.011658365838229656,
0.030791161581873894,
0.012769724242389202,
-0.01789068803191185,
0.03617362305521965,
-0.04105488210916519,
0.0510353147983551,
0.02787112072110176,
0.0418611615896225,
0.013630482368171215,
-0.005033798981457949,
0.0578777939081192,
0.05792137607932091,
-0.0074253985658288,
-0.04201370105147362,
0.04563106223940849,
-0.04249310865998268,
0.112704798579216,
0.07012452930212021,
-0.04051009938120842,
0.05260429158806801,
0.041904743760824203,
0.017465757206082344,
0.0037535580340772867,
0.024711377918720245,
-0.04201370105147362,
0.007861224934458733,
0.011124477721750736,
-0.004344648215919733,
-0.02466779574751854,
0.06332562863826752,
0.006717179901897907,
-0.013684960082173347,
0.0005362711963243783,
-0.016801122575998306,
0.0540425181388855,
-0.01949235238134861,
-0.04528240114450455,
-0.04885618016123772,
0.02200925163924694,
-0.035977497696876526,
-0.019154585897922516,
-0.00025281356647610664,
-0.06480743736028671,
0.03266521543264389,
0.00011244670895393938,
0.01073768176138401,
0.031706396490335464,
0.03052966482937336,
-0.009228631854057312,
0.012562706135213375,
-0.02946188859641552,
0.020690875127911568,
0.0009172791615128517,
0.0032441855873912573,
0.04654629901051521,
0.0036909079644829035,
0.02169327810406685,
-0.04170862212777138,
-0.05822645500302315,
-0.036827363073825836,
0.02567019686102867,
0.006303144618868828,
0.003859790740534663,
0.030420707538723946,
0.029026063159108162,
-0.01024192851036787,
-0.0076106246560812,
-0.09039047360420227,
-0.016397982835769653,
0.014229743741452694,
-0.01889309100806713,
-0.018184872344136238,
-0.0011883089318871498,
-0.031706396490335464,
0.016180068254470825,
-0.04323401674628258,
-0.041621457785367966,
0.0335150770843029,
-0.005774704739451408,
-0.0048540206626057625,
-0.012268523685634136,
0.05818287283182144,
0.010056702420115471,
0.05160189047455788,
0.03774259611964226,
-0.047243621200323105,
0.029723385348916054,
-0.008509517647325993,
0.020995954051613808,
0.01773814857006073,
-0.01274793315678835,
0.021115805953741074,
-0.004208452068269253,
0.011320600286126137,
0.026934094727039337,
-0.035367343574762344,
0.007991973310709,
-0.10285511612892151,
0.013815708458423615,
-0.02298986166715622,
0.044890157878398895,
-0.06886062771081924,
-0.035977497696876526,
-0.007490772288292646,
0.009468336589634418,
-0.04234056919813156,
-0.03462643548846245,
0.05731121823191643,
-0.004559837747365236,
-0.0156025979667902,
0.0016575036570429802,
-0.01894756779074669,
-0.014763631857931614,
-0.010236481204628944,
-0.004006882198154926,
0.01244285423308611,
0.06794539093971252,
0.05792137607932091,
0.032098639756441116,
0.06071066856384277,
-0.013848395086824894,
0.007741373032331467,
0.024340923875570297,
0.0041839368641376495,
0.05574224144220352,
-0.0018250246066600084,
0.04319043084979057,
-0.03800409287214279,
0.004322856664657593,
-0.06258472055196762,
0.04438895732164383,
-0.03168460726737976,
0.037502892315387726,
0.009811550378799438,
-0.004745063837617636,
0.10067598521709442,
0.036042872816324234,
-0.01758560910820961,
0.038178425282239914,
-0.031946100294589996,
-0.0036718405317515135,
-0.08110736310482025,
0.01682291366159916,
0.07448279112577438,
0.014349596574902534,
0.015210353769361973,
0.014763631857931614,
-0.0008893589838407934,
0.03312283381819725,
-0.012007026933133602,
0.014567509293556213,
-0.04301610216498375,
0.034691810607910156,
0.01789068803191185,
-0.05073023587465286,
-0.016572313383221626,
-0.006417549215257168,
-0.060579922050237656,
0.05657031387090683,
-0.002734812907874584,
-0.019154585897922516,
0.03190251812338829,
-0.03473539277911186,
-0.03473539277911186,
0.034975096583366394,
-0.003930612467229366,
-0.011059104464948177,
0.023403897881507874,
0.05055590346455574,
-0.029178602620959282,
0.048681847751140594,
-0.033624034374952316,
-0.012758828699588776,
-0.004448156803846359,
-0.024188386276364326,
0.002467869082465768,
0.0213337205350399,
-0.032098639756441116,
0.04242773726582527,
0.04964066669344902,
-0.03462643548846245,
0.010694099590182304,
0.016343504190444946,
0.0016806569183245301,
0.019274437800049782,
0.07191141694784164,
-0.07300098240375519,
0.03800409287214279,
-0.056395985186100006,
-0.03926799073815346,
0.039921730756759644,
0.004497187212109566,
0.023316731676459312,
-0.032861337065696716,
0.008732878603041172,
0.014665571041405201,
-0.027043050155043602,
0.0042030042968690395,
-0.012780619785189629,
0.020309526473283768,
0.01473094429820776,
0.017084408551454544,
-0.018326515331864357,
0.09344125539064407,
0.06341279298067093,
-0.05687539279460907,
-0.027304546907544136,
-0.03061683103442192,
0.009217736311256886,
-0.010312750935554504,
0.017683671787381172,
-0.02991950698196888,
0.029963089153170586,
0.020745353773236275,
0.027980078011751175,
-0.02460242062807083,
-0.03473539277911186,
-0.06890421360731125,
-0.02131192944943905,
-0.0152321457862854,
0.01134239137172699,
-0.031967893242836,
0.013434359803795815,
0.005861870013177395,
-0.020527441054582596,
0.040619052946567535,
0.018217558041214943,
0.005567687097936869,
0.06145157292485237,
0.0078012989833951,
0.019579516723752022,
0.04319043084979057,
0.04850751906633377,
0.06794539093971252,
-0.027827538549900055,
0.07640042901039124,
0.013695855624973774,
0.04048830643296242,
0.026585431769490242,
0.01621275581419468,
-0.002586359390988946,
0.04430178925395012,
-0.02695588581264019,
-0.002083796774968505,
-0.00026915708440355957,
-0.05338877812027931,
0.04319043084979057,
0.014970649033784866,
-0.02138819918036461,
0.012388375587761402,
-0.03896291181445122,
-0.05382460728287697,
0.0020197846461087465,
0.010715890675783157,
-0.003927888814359903,
-0.010024015791714191,
-0.004290169570595026,
-0.008280708454549313,
0.004551665857434273,
0.003099817782640457,
-0.028873523697257042,
-0.023403897881507874,
-0.057529132813215256,
0.014589301310479641,
0.016866495832800865,
-0.043059684336185455,
-0.050207242369651794,
0.023185983300209045,
0.005649404600262642,
0.06271547079086304,
-0.006826136726886034,
-0.0784488171339035,
0.055393580347299576,
0.04889976233243942,
-0.03523659333586693,
0.008841835893690586,
0.013946456834673882,
0.039006493985652924,
0.011669261381030083,
-0.037110649049282074,
-0.03534555062651634,
0.004309237003326416,
-0.02155163325369358,
0.009511918760836124,
-0.011015521362423897,
-0.03974740207195282,
-0.005954483058303595,
0.05604732036590576,
-0.0220746248960495,
-0.027696790173649788,
-0.07326247543096542,
0.04218802973628044,
0.012649871408939362,
-0.016866495832800865,
-0.008798252791166306,
-0.032774172723293304,
-0.008967136032879353,
-0.018936673179268837,
-0.016463356092572212,
0.007174798287451267,
-0.0013932837173342705,
0.026999467983841896,
0.022216269746422768,
0.04475940763950348,
-0.02665080688893795,
-0.01518856268376112,
-0.017956063151359558,
-0.05975184962153435,
0.00428199814632535,
0.02717379853129387,
0.021508051082491875,
0.07670550793409348,
0.047243621200323105,
-0.0022009252570569515,
0.00007614200148964301,
0.036195412278175354,
0.0403357669711113,
0.002345292828977108,
-0.02802366018295288,
-0.05687539279460907,
0.020995954051613808,
0.000039794729673303664,
-0.02612781524658203,
-0.023098818957805634,
0.027304546907544136,
0.050817400217056274,
0.021126702427864075,
-0.029222184792160988,
0.06716090440750122,
-0.0388321653008461,
0.02900427207350731,
-0.009675353765487671,
0.028372323140501976,
0.003042615484446287,
-0.0018127670045942068,
0.012660767883062363,
-0.043822381645441055,
0.031009074300527573,
0.0036990796215832233,
-0.012856889516115189,
0.039333365857601166,
-0.06820689141750336,
0.09527172893285751,
0.0005454644560813904,
-0.025866318494081497,
-0.012660767883062363,
0.006335831712931395,
-0.008667504414916039,
0.028808148577809334,
-0.0041866609826684,
0.08193542808294296,
0.006352175027132034,
-0.03340611979365349,
0.10477275401353836,
0.05168905481696129,
-0.00027818005764856935,
0.004483568016439676,
0.010786712169647217,
0.017400383949279785,
-0.026541849598288536,
0.017531132325530052,
0.019819222390651703,
0.037720806896686554,
0.004617039579898119,
-0.02169327810406685,
-0.017106199637055397,
-0.07435204833745956,
-0.04545672982931137,
0.03989994153380394,
0.018108602613210678,
-0.012965845875442028,
0.06005692854523659,
-0.01887129805982113,
0.01107544731348753,
-0.05038157477974892,
0.017411278560757637,
0.010187450796365738,
-0.03412523493170738,
-0.060579922050237656,
-0.0395730696618557,
0.003290492109954357,
0.0004681732680182904,
-0.010476185940206051,
0.006973228417336941,
0.0358031690120697,
-0.03610824793577194,
0.00046340643893927336,
-0.0213337205350399,
-0.08516055345535278,
-0.018773237243294716,
-0.04584897682070732,
-0.02124655432999134,
0.004832229111343622,
-0.050904564559459686,
-0.002578187733888626,
-0.008171752095222473,
-0.014970649033784866,
-0.020810728892683983,
-0.024188386276364326,
-0.006041648332029581,
0.031030865386128426,
0.05286578834056854,
-0.03342791274189949,
-0.02671618014574051,
0.04319043084979057,
0.004725996404886246,
-0.052342794835567474,
-0.01118985190987587,
-0.044802989810705185,
0.0845068097114563,
0.012987637892365456,
-0.021431781351566315,
0.01881682127714157,
-0.009996776469051838,
-0.0010412173578515649,
0.044890157878398895,
-0.06297696381807327,
0.010247376747429371,
0.011996131390333176,
0.014894379302859306,
0.008847283199429512,
-0.017073513939976692,
0.021813130006194115,
-0.044890157878398895,
-0.03569421172142029,
0.02169327810406685,
-0.03192431107163429,
-0.040379349142313004,
0.010138420388102531,
-0.0426238588988781,
-0.055698659271001816,
-0.022946279495954514,
-0.009190496988594532,
-0.07099618017673492,
0.062018148601055145,
-0.0631512999534607,
-0.005665747914463282,
0.00394150847569108,
-0.05195055156946182,
-0.010988282039761543,
-0.030551455914974213,
-0.02597527578473091,
0.031706396490335464,
-0.010715890675783157,
-0.017182469367980957,
0.009157809428870678,
0.06445877999067307,
-0.0006758719682693481,
-0.019067421555519104,
0.02588810957968235,
0.04746153578162193,
0.04654629901051521,
-0.1256052702665329,
-0.029200393706560135,
0.02512541227042675,
0.04253669083118439,
0.04746153578162193,
-0.04142533242702484,
0.002051109680905938,
0.017247844487428665,
-0.033994488418102264,
-0.014142578467726707,
-0.04811527580022812,
0.02909143641591072,
-0.07147558778524399,
0.014349596574902534,
-0.01896936073899269,
0.020614605396986008,
-0.03456106409430504,
-0.03325358033180237,
0.04471582546830177,
0.022129103541374207,
0.05626523494720459,
-0.038178425282239914,
0.0418611615896225,
-0.005949035286903381,
-0.02336031384766102,
-0.0023766178637742996,
0.018326515331864357,
0.02162790298461914,
-0.02071266621351242,
0.04042293131351471,
0.02878635749220848,
0.017171574756503105,
-0.002501918002963066,
0.045718226581811905,
-0.008139064535498619,
-0.07291381806135178,
0.018620697781443596,
0.03737214580178261,
0.002383427694439888,
0.0028791804797947407,
0.01683380827307701,
0.028960688039660454,
-0.0072783068753778934,
0.010465290397405624,
-0.017106199637055397,
0.041381750255823135,
0.1134892925620079,
0.035912126302719116,
-0.019819222390651703,
0.0031488484237343073,
-0.06293338537216187,
0.014022726565599442,
-0.006090679205954075,
0.005791048053652048,
-0.06223606318235397,
0.0014123511500656605,
-0.024319132789969444,
0.07975629717111588,
0.041773997247219086,
-0.0023711700923740864,
-0.002702126046642661,
-0.013423464260995388,
0.04584897682070732,
-0.020908789709210396,
-0.014218848198652267,
-0.009185048751533031,
0.0037671776954084635,
-0.04781019687652588,
0.04467224329710007,
0.041142046451568604,
-0.009876923635601997,
-0.07042960822582245,
0.029352933168411255,
0.006984123960137367,
-0.01077581662684679,
-0.06010051071643829,
-0.020156987011432648,
-0.004941185936331749,
0.013238238170742989,
0.016659477725625038,
0.03238192945718765,
0.005458730272948742,
-0.008149960078299046,
-0.06641999632120132,
0.03122698701918125,
-0.014872588217258453,
0.02147536352276802,
0.029440097510814667,
0.05687539279460907,
-0.0913492888212204,
0.027217380702495575,
-0.00791570357978344,
-0.07500578463077545,
0.03146669268608093,
-0.03153206780552864,
0.021148493513464928,
0.03669661283493042,
0.06689941138029099,
0.07182425260543823,
-0.028742775321006775,
-0.012094193138182163,
-0.06280263513326645,
-0.01503602322191,
-0.0008028746233321726,
0.06894779205322266,
-0.032708797603845596,
-0.022510452196002007,
-0.03052966482937336,
0.021268345415592194,
-0.029352933168411255,
-0.007207484915852547,
-0.019819222390651703,
0.010764921084046364,
-0.031096240505576134,
-0.018925776705145836,
-0.0032687007915228605,
-0.0418611615896225,
-0.03329716622829437,
-0.014120787382125854,
0.035149428993463516,
-0.01424063928425312,
-0.007071289233863354,
-0.03312283381819725,
0.0021723241079598665,
-0.07596460729837418,
-0.053781021386384964,
0.022968070581555367,
-0.06563550978899002,
0.03388553112745285,
-0.10363960266113281,
-0.005292571149766445,
0.03830917179584503,
0.03395090624690056
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.