MCPcopy Index your code
hub / github.com/shenweichen/GraphEmbedding / _create_A_L

Function _create_A_L

ge/models/sdne.py:168–188  ·  view source on GitHub ↗
(graph, node2idx)

Source from the content-addressed store, hash-verified

166
167
168def _create_A_L(graph, node2idx):
169 node_size = graph.number_of_nodes()
170 A_data = []
171 A_row_index = []
172 A_col_index = []
173
174 for edge in graph.edges():
175 v1, v2 = edge
176 edge_weight = graph[v1][v2].get('weight', 1)
177
178 A_data.append(edge_weight)
179 A_row_index.append(node2idx[v1])
180 A_col_index.append(node2idx[v2])
181
182 A = sp.csr_matrix((A_data, (A_row_index, A_col_index)), shape=(node_size, node_size))
183 A_ = sp.csr_matrix((A_data + A_data, (A_row_index + A_col_index, A_col_index + A_row_index)),
184 shape=(node_size, node_size))
185
186 D = sp.diags(A_.sum(axis=1).flatten().tolist()[0])
187 L = D - A_
188 return A, L

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected