diff --git a/__pycache__/firm.cpython-38.pyc b/__pycache__/firm.cpython-38.pyc index 14d7b09..ea365f5 100644 Binary files a/__pycache__/firm.cpython-38.pyc and b/__pycache__/firm.cpython-38.pyc differ diff --git a/firm.py b/firm.py index db10d0c..692bea7 100644 --- a/firm.py +++ b/firm.py @@ -120,18 +120,12 @@ class FirmAgent(ap.Agent): if self.is_prf_conn: for firm in \ self.dct_cand_alt_supp_up_prod_disrupted[product]: - out_edges = self.model.firm_network.graph.out_edges( - self.model.firm_network.positions[firm], keys=True) - in_edges = self.model.firm_network.graph.in_edges( - self.model.firm_network.positions[firm], keys=True) - lst_adj_firm = [] - lst_adj_firm += \ - [ap.AgentIter(self.model, edge[1]).to_list()[ - 0].code for edge in out_edges] - lst_adj_firm += \ - [ap.AgentIter(self.model, edge[0]).to_list()[ - 0].code for edge in in_edges] - if self.code in lst_adj_firm: + node_self = self.get_firm_network_node() + node_firm = firm.get_firm_network_node() + if self.model.firm_network.graph.\ + has_edge(node_self, node_firm) or \ + self.model.firm_network.graph.\ + has_edge(node_firm, node_self): lst_firm_connect.append(firm) if len(lst_firm_connect) == 0: # select based on size or not @@ -201,22 +195,12 @@ class FirmAgent(ap.Agent): lst_firm_connect = [] if self.is_prf_conn: for firm in lst_firm: - out_edges = \ - self.model.firm_network.graph.out_edges( - self.model.firm_network.positions[firm], - keys=True) - in_edges = \ - self.model.firm_network.graph.in_edges( - self.model.firm_network.positions[firm], - keys=True) - lst_adj_firm = [] - lst_adj_firm += \ - [ap.AgentIter(self.model, edge[1]).to_list()[ - 0].code for edge in out_edges] - lst_adj_firm += \ - [ap.AgentIter(self.model, edge[0]).to_list()[ - 0].code for edge in in_edges] - if self.code in lst_adj_firm: + node_self = self.get_firm_network_node() + node_firm = firm.get_firm_network_node() + if self.model.firm_network.graph.\ + has_edge(node_self, node_firm) or \ + self.model.firm_network.graph.\ + has_edge(node_firm, node_self): lst_firm_connect.append(firm) if len(lst_firm_connect) == 0: # handling based on size or not