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

utils.py 288 B

1234567891011
  1. import networkx as nx
  2. import numpy as np
  3. def getSPLengths(G1):
  4. sp = nx.shortest_path(G1)
  5. distances = np.zeros((G1.number_of_nodes(), G1.number_of_nodes()))
  6. for i in sp.keys():
  7. for j in sp[i].keys():
  8. distances[i, j] = len(sp[i][j])-1
  9. return distances

A Python package for graph kernels, graph edit distances and graph pre-image problem.