Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Building a UUID map in python

Options
  • 30-07-2012 2:41pm
    #1
    Registered Users Posts: 1,760 ✭✭✭


    uuidDict is a dictionary of UUIDs arranged in a parent child structure from example.
    {childA : parentA, unrealtedUUID : unrealtedparent, ParentA : ParentB, ParentB : ParentC, unrelatedUUID: unrelatedparent, ParentC : ParentD, ParentD : None}
    

    It contains many trees of UUID mixed together and pulled from a DB
    if searchUUID in uuidDict:
        while searchUUID is not "None":
            uuidList.append(searchUUID)
            searchUUID = uuidDict[searchUUID]    
        print uuidList
    

    If i search for a UUID i know at the bottom of the tree I get the full tree of UUIDs from child to the root parent. For example,
    searchUUID = "3384b171-772d-472e-bd81-46963323d489"
     
    ['3384b171-772d-472e-bd81-46963323d489', 'ff4430e7-92c0-4de3-afe2-d8bb6b65c653', '63c5ccb2-b56a-4e4c-95eb-90bc884bc003', 'dcf8b4b8-7668-4c83-9b7c-8734f9621232', '26408e07-a11e-4499-8783-f856824779e2', '15ec65d0-c51f-4767-aa35-e0c0b56f8ebd', 'e02b2bdc-791e-4e73-a9b5-56d56c1d9794']
    


    If I however search for a UUID in the middle of the tree obiously only get from that UUID up to the root. For example,
    searchUUID = "63c5ccb2-b56a-4e4c-95eb-90bc884bc003"
     
    ['63c5ccb2-b56a-4e4c-95eb-90bc884bc003', 'dcf8b4b8-7668-4c83-9b7c-8734f9621232', '26408e07-a11e-4499-8783-f856824779e2', '15ec65d0-c51f-4767-aa35-e0c0b56f8ebd', 'e02b2bdc-791e-4e73-a9b5-56d56c1d9794']
    

    What would be the most efficent way to build the tree from a UUID that could be in the middle of the tree to the top and include all children of the uuid without the unrelated uuid's

    I think I need to handle the incoming dict better.

    Thanks


Advertisement