def fig1C(): net = social.Network() net.friend(A, B) net.enemy(B, C) net.friend(C, D) net.friend(D, E) net.friend(E, A) net.friend(A, D) net.friend(B, E) return net
def _create_network(self, graph): nodes = graph.nodes(data=True) net = social.Network() for edge in graph.edges(data=True): n1 = self.groups_to_dwave_nodes[edge[0]] n2 = self.groups_to_dwave_nodes[edge[1]] type = edge[2]['type'] self._add_link(net, n1, n2, type) #print 'add_link:', n1, n2, type, edge[0], edge[1] return net
def make_social_network(g): net = soc.Network() for e in g.edges(): n1 = e[0] n2 = e[1] r = ran.random() if r <= 0.5: net.friend(n1, n2) else: net.enemy(n1, n2) return net
def make_network_from_graph(g): edges = g.edges(data=True) net = social.Network() for edge in edges: source = edge[0] n1 = int(source) target = edge[1] n2 = int(target) relation = edge[2]['type'] if relation in enemyTypes: net.enemy(n1, n2) elif relation in friendTypes: net.friend(n1, n2) return net
def make_network_from_graph(self): edges = self.graph.edges(data=True) net = social.Network() for edge in edges: source = edge[0] n1 = self.groups_to_dwave_nodes[source] target = edge[1] n2 = self.groups_to_dwave_nodes[target] relation = edge[2]['type'] if relation in enemyTypes: edge[2]['weight'] = enemyValue net.enemy(n1,n2) elif relation in friendTypes: net.friend(n1,n2) edge[2]['weight'] = friendValue return net
def generate_game(size): players = [] for i in range(size): players.append(social.Player(int((i - size / 2) > 0))) graph = [[0 for _ in players] for _ in players] for i in range(size): for j in range(size): if i != j and (i - size / 2) * (j - size / 2) > 0: graph[i][j] = 2 / (size - 1) network = social.Network(players, { "a": 0.2, "b": .05 }, { "a": 1.2, "b": 1.1 }, graph=graph) return network
def fig1A4(): net = social.Network() net.enemy(A, B) net.friend(A, C) net.enemy(B, C) return net