def get_vertex_fingerprints(self, vertex_strings, edge_strings, num_iter=None):
import hashlib<EOL>def str2array(x):<EOL><INDENT>"""<STR_LIT>"""<EOL>if len(x) == <NUM_LIT:0>:<EOL><INDENT>return np.zeros(<NUM_LIT:0>, np.ubyte)<EOL><DEDENT>elif sys.version_info[<NUM_LIT:0>] == <NUM_LIT:2>:<EOL><INDENT>return np.frombuffer(x, np.ubyte)<EOL><DEDENT>else:<EOL><INDENT>return np.frombuffer(x.encode(), np.ubyte)<EOL><DEDENT><DEDENT>hashrow = lambda x: np.frombuffer(hashlib.sha1(x.data).digest(), np.ubyte)<EOL>result = np.zeros((self.num_vertices, <NUM_LIT:20>), np.ubyte)<EOL>for i in range(self.num_vertices):<EOL><INDENT>result[i] = hashrow(str2array(vertex_strings[i]))<EOL><DEDENT>for i in range(self.num_edges):<EOL><INDENT>a, b = self.edges[i]<EOL>tmp = hashrow(str2array(edge_strings[i]))<EOL>result[a] += tmp<EOL>result[b] += tmp<EOL><DEDENT>work = result.copy()<EOL>if num_iter is None:<EOL><INDENT>num_iter = self.max_distance<EOL><DEDENT>for i in range(num_iter):<EOL><INDENT>for a, b in self.edges:<EOL><INDENT>work[a] += result[b]<EOL>work[b] += result[a]<EOL><DEDENT>for a in range(self.num_vertices):<EOL><INDENT>result[a] = hashrow(work[a])<EOL><DEDENT><DEDENT>return result<EOL>
Return an array with fingerprints for each vertex