Algorithms For Dummies


Exploring the World of Graphs



Download 7,18 Mb.
Pdf ko'rish
bet346/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   342   343   344   345   346   347   348   349   ...   651
Bog'liq
Algorithms

 Exploring the World of Graphs

code in the 

A4D; 10; Social Networks.ipynb

 file on the Dummies site as part of 

the downloadable code; see the Introduction for details.)

import networkx as nx

import matplotlib.pyplot as plt

%matplotlib inline

graph = nx.karate_club_graph()

pos=nx.spring_layout(graph)

nx.draw(graph, pos, with_labels=True)

plt.show()

To display the graphic onscreen, you also need to provide a layout that determines 

how to position the nodes onscreen. This example uses the Fruchterman- Reingold 

force-directed  algorithm  (the  call  to 

nx.spring_layout

).  However,  you  can 

choose one of the other layouts described in the Graph Layout section at 

https://

networkx.github.io/documentation/networkx-1.9/reference/drawing.

html

.  Figure  10-1  shows  the  output  from  the  example.  (Your  output  may  look 



slightly different.)

The  Fruchterman-Reingold  force-directed  algorithm  for  generating  automatic 

layouts of graphs creates understandable layouts with separated nodes and edges 

that tend not to cross by mimicking what happens in physics between electrically 

charged  particles  or  magnets  bearing  the  same  sign.  In  looking  at  the  graph 

FIGURE 10-1: 

A graph showing 

the network 

clusters of 

relationships 

between friends.




CHAPTER 10


Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   342   343   344   345   346   347   348   349   ...   651




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish