Algorithms For Dummies


Exploring the World of Graphs



Download 7,18 Mb.
Pdf ko'rish
bet370/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   366   367   368   369   370   371   372   373   ...   651
Bog'liq
Algorithms

 Exploring the World of Graphs

Graph_A = nx.DiGraph()

Graph_B = nx.DiGraph()

Graph_C = nx.DiGraph()

Nodes = range(1,6)

Edges_OK = [(1,2),(1,3),(2,3),(3,1),(3,2),(3,4),(4,5),

            (4,6),(5,4),(5,6),(6,5),(6,1)]

Edges_dead_end = [(1,2),(1,3),(3,1),(3,2),(3,4),(4,5),

                  (4,6),(5,4),(5,6),(6,5),(6,1)]

Edges_trap = [(1,2),(1,3),(2,3),(3,1),(3,2),(3,4),(4,5),

              (4,6),(5,4),(5,6),(6,5)]

Graph_A.add_nodes_from(Nodes)

Graph_A.add_edges_from(Edges_OK)

Graph_B.add_nodes_from(Nodes)

Graph_B.add_edges_from(Edges_dead_end)

Graph_C.add_nodes_from(Nodes)

Graph_C.add_edges_from(Edges_trap)

This code displays the first network, the good one, as shown in Figure 11-1.

np.random.seed(2)

pos=nx.shell_layout(Graph_A)

nx.draw(Graph_A, pos, arrows=True, with_labels=True)

plt.show()

All nodes connect with each other. This is an example of a strongly connected 

graph, which contains no isolated nodes or single nodes and enclaves that act as 

dead ends. A random surfer can freely run through it and never stop, and any node 

can reach any other node. In the NetworkX representation of a directed graph, 



FIGURE 11-1: 

A strongly 

connected 

network.



CHAPTER 11


Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   366   367   368   369   370   371   372   373   ...   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