I want to use a dictionary representing a directed graph with a certain number of nodes (num) and with all possible edges (output).
Examples:
if num = 1, output: {0: set([])}
if num = 2, output: {0: set([1]), 1: set([0])}
if num = 3, output: {0: set([1,2]), 1: set([0,2]), 2: set([0,1])}
if num = 4, output: {0: set([1,2,3]), 1: set([0,2,3]), 2: set([0,1,3]), 3: set([0,1,2])}
My code will iterate through the dictionary and create each set by remove the key from a temperate list:
num = 3
keys = range(0,num)
mydict ={}
for key in keys:
temp = keys
value_list = temp.remove(key)
mydict[key] = set([value_list])
But it seemed by using temp.remove(key), not only temp but also keys would be muted. Why is that?