| 20 | import os |
| 21 | import numpy as np |
| 22 | def gen_node_map(cite_file): |
| 23 | node_map = {} |
| 24 | node_index = 0 |
| 25 | with open(os.path.realpath(cite_file), 'r') as f: |
| 26 | for line in f: |
| 27 | nodes = line.strip().split("\t") |
| 28 | if len(nodes) != 4: |
| 29 | continue |
| 30 | src_node = nodes[1].split(":")[1] |
| 31 | if not node_map.has_key(src_node): |
| 32 | node_map[src_node] = node_index |
| 33 | node_index += 1 |
| 34 | dst_node = nodes[3].split(":")[1] |
| 35 | if not node_map.has_key(dst_node): |
| 36 | node_map[dst_node] = node_index |
| 37 | node_index += 1 |
| 38 | return node_map |
| 39 | |
| 40 | def gen_edge(cite_file, node_map, train_num): |
| 41 | src = [] |