bigbossfr
11-02-2011, 11:42 PM
Hi,
I try to find a good algorithm for a problem.
Here the problem :
I have a dictionary like this :
allGroups = {"property1":["object1", "object2", "object3", "object4"], "property2":["object1, "object2", "object4"], "property3":["object2", "object3", "object4"], "property4":["object1"], "property5":[]}
I want to generate some "groups" of objects with unique properties.
Like :
["object1"] have property1, property2, property4
["object2", "object4"] have property1, property2, property3
["object3"] have property1, property3
etc etc....
Each object can not be in another "group".
And obviously, i must to have the result in a dictionary to trace all object(s) with their properties, like :
{ ["property1", "property2", "property4"]:["object1"]}
{ ["property1", "property2", "property3"]:["object2", "object4"]}
for example, etc etc...
Anyone have a solution ? And if it is possible, without to parse all objects.
I tried to use set intersection or itertools.combinations, i failed.
Thanks.
I try to find a good algorithm for a problem.
Here the problem :
I have a dictionary like this :
allGroups = {"property1":["object1", "object2", "object3", "object4"], "property2":["object1, "object2", "object4"], "property3":["object2", "object3", "object4"], "property4":["object1"], "property5":[]}
I want to generate some "groups" of objects with unique properties.
Like :
["object1"] have property1, property2, property4
["object2", "object4"] have property1, property2, property3
["object3"] have property1, property3
etc etc....
Each object can not be in another "group".
And obviously, i must to have the result in a dictionary to trace all object(s) with their properties, like :
{ ["property1", "property2", "property4"]:["object1"]}
{ ["property1", "property2", "property3"]:["object2", "object4"]}
for example, etc etc...
Anyone have a solution ? And if it is possible, without to parse all objects.
I tried to use set intersection or itertools.combinations, i failed.
Thanks.
