Microsoft Word Python review



Download 80,38 Kb.
Pdf ko'rish
bet2/2
Sana15.07.2021
Hajmi80,38 Kb.
#120128
1   2
Bog'liq
Python review

Exercise  

Graph  traversal.  Take  a  piece  of  paper,  and  make  up  a  small  graph  (network)  with  5  

vertices   (nodes)   in   it.   Randomly   assign   a   few   links   or   edges   between   them.   Your  

graph  may  look  something  like  

this


.  Label  the  nodes  with  numbers  or  strings.  Your  

first   task   is   to   represent   this   graph   in   Python.   You   may   use   any   data-­‐structure   of  

your   choice:   it   may   be   a   dictionary   with   keys   standing   for   node   labels   and   values  

standing  for  the  neighboring  nodes’  labels;  or  two  separate  lists,  one  containing  all  

the  “from”  nodes,  and  the  other  containing  lists  of  all  the  “to”  nodes  that  each  “from”  

node  is  connected  to;  or  define  a  connectivity  matrix  (figure  out  how);  or  you  can  get  

creative.   Your   second   task   is   to   pick   up   all   possible   paths,   between   two   chosen  

nodes,  that  won’t  be  let  to  visit  any  node  more  than  once.  Note  that  since  there  are  

only  5  nodes,  the  maximum  number  of  edges  in  such  paths  between  any  two  nodes  

is  only  4  –  you  can  use  this  as  a  stopping  criterion  for  any  potential  path  that  your  

program  chooses.  If  you  want  to  be  challenged  even  more,  you  can  randomly  assign  

a   direction   to   each   edge   in   your   graph,   so   your   program   will   be   constrained   to  



traverse  edges  only  in  the  directions  specified.    

Download 80,38 Kb.

Do'stlaringiz bilan baham:
1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
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