MCPcopy Create free account
hub / github.com/Tencent/embedx / EmbedxGraphGenerator

Class EmbedxGraphGenerator

demo/data/scripts/embedx_graph.py:222–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220
221
222class EmbedxGraphGenerator:
223 CONTEXT_FILE_NAME = "context.all"
224 NODE_FEATURE_FILE_NAME = "node_feature.all"
225 GROUP_CONFIG_FILE_NAME = "group_config.txt"
226 LABELS_FILE_NAME = "labels.all"
227 TRAIN_LABELS_FILE_NAME = "train_labels.all"
228 TEST_LABELS_FILE_NAME = "test_labels.all"
229
230 def __init__(self, nx_graph):
231 self.embedx_graph = EmbedxGraph(nx_graph)
232
233 def run(self, dst_dir):
234 if not os.path.isdir(dst_dir):
235 os.mkdir(dst_dir)
236
237 def get_full_path(path):
238 return os.path.join(dst_dir, path)
239
240 self.embedx_graph.write_context(
241 get_full_path(EmbedxGraphGenerator.CONTEXT_FILE_NAME))
242
243 self.embedx_graph.write_node_label(
244 get_full_path(EmbedxGraphGenerator.LABELS_FILE_NAME),
245 get_full_path(EmbedxGraphGenerator.TRAIN_LABELS_FILE_NAME),
246 get_full_path(EmbedxGraphGenerator.TEST_LABELS_FILE_NAME))
247
248 if self.embedx_graph.has_feature:
249 self.embedx_graph.write_node_feature(
250 get_full_path(EmbedxGraphGenerator.NODE_FEATURE_FILE_NAME),
251 get_full_path(EmbedxGraphGenerator.GROUP_CONFIG_FILE_NAME))
252
253 self.print_graph_statistics()
254
255 def print_graph_statistics(self):
256 for stat in self.embedx_graph.statistics():
257 logging.info("%s: %s.", stat[0], stat[1])

Callers 1

generate_embedx_graphFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected