INPUT:-
mainlist:[12345,23456,09768]
Need to construct the following dependency graph
12345 has 01242(internal dep),34567(externaldep)
01242 has 23456(internaldep),56789,32345(externaldep)
34567 has 11111(internal dep),no external dependencies
23456 has 33456(internaldep),no external dependencies
56789 no dependencies
32345 no dependencies
11111 no dependencies
33456 no dependencies
09768 has 12222(internal dep),34333(External dep)
12222 no dependencies
34333 no dependencies
OUTPUT:-
[12345,01242,34567,23456,56789,32345,11111,33456,09768,12222,34333]
I have some database objects that are fully linked to each other as dependencies like above...What i want to do is to write an algorithm to retrieve that information and represent all this as a graph. Right now i am writing a pseudo code , then after i should be able to write the python implementation This seems like a recursive algorithm and this is where i am stuck!
For every item in the main list am trying to find out the internal dependency and external dependency recursively until there are no dependencies and create a list with all the changes.
build_dep_list=[]
local_list=[]
for each item in mainlist:
local_list.append(item)
build_dep_list.append(item)
for each localitem in local_list:
head = localitem
internal_dep_list =getinternaldep(change)
external_dep_list= getexternaldep(change)
append.internal_dep_list.local_list
append.external_dep_list.local_list
append.internal_dep_list.build_dep_list
append.external_dep_list.build_dep_list
delete(head).local_list
def getinternaldep:
//code1
def getexternaldep:
//code2