Algorithms For Dummies



Download 7,18 Mb.
Pdf ko'rish
bet330/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   326   327   328   329   330   331   332   333   ...   651
Bog'liq
Algorithms

  Reconnecting the Dots 

     189


spanning tree. Another function

represent_tree

, turns the key and value pairs 

of the dictionary into a tuple and then sorts each of the resulting tuples for better 

readability of the tree path:

def represent_tree(treepath):

    progression = list()

    for node in treepath:

        if node != treepath[node]:

            progression.append((treepath[node], node))

    return sorted(progression, key=lambda x:x[0])

print (represent_tree(treepath))

[('A','B'), ('B','C'), ('B','D'), ('D','E'), ('E','F')]

The 


represent_tree

 function reorders the output of Prim’s algorithm for better 

readability. However, the algorithm works on an undirected graph, which means 

that you can traverse the edges in both directions. The algorithm incorporates this 

assumption because there is no edge directionality check to add to the priority 

queue for later processing.




Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   326   327   328   329   330   331   332   333   ...   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