You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

graph_generator.py 603B

5 years ago
1234567891011121314151617
  1. import networkx as nx
  2. import scipy.io
  3. import numpy as np
  4. graphs = []
  5. indexes = [(1,12), (2,6),(3,4),(4,3),(6,2),(12,1)]
  6. for tupp in indexes:
  7. graphs.append(nx.grid_2d_graph(tupp[0], tupp[1]))
  8. for g in range(len(indexes)):
  9. curr_graph = nx.to_numpy_array(graphs[g])
  10. curr_graph_att = np.ones((len(curr_graph), 60))
  11. scipy.io.savemat('produced_graphs/testgraph_{}_{}__.txt'.format(indexes[g][0], indexes[g][1], g), {'data': curr_graph})
  12. scipy.io.savemat('produced_graphs/testgraph_{}_{}__.usr'.format(indexes[g][0], indexes[g][1], g), {'attributes': curr_graph_att})
  13. print(graphs)