save network

This commit is contained in:
2023-03-14 21:20:38 +08:00
parent 4f7be2c76c
commit 9435484e3f
8 changed files with 9 additions and 1 deletions

View File

@@ -93,6 +93,11 @@ class Model(ap.Model):
self.firm_network = ap.Network(self, G_Firm)
self.product_network = ap.Network(self, G_bom)
out_file = open("myfile.json", "w")
import json
json.dump(nx.adjacency_data(G_Firm), out_file)
out_file.close()
# init product
for ag_node, attr in self.product_network.graph.nodes(data=True):
product = ProductAgent(self, code=ag_node.label, name=attr['Name'])