| 27 | |
| 28 | |
| 29 | def parse_args(): |
| 30 | |
| 31 | def existing_path(path): |
| 32 | if not os.path.exists(path): |
| 33 | raise argparse.ArgumentTypeError(f'file {path} does not exist.') |
| 34 | return path |
| 35 | |
| 36 | parser = argparse.ArgumentParser( |
| 37 | description= |
| 38 | "This program transforms graph data of specific dataset to get graph " |
| 39 | "data that meets the embedx format.", |
| 40 | formatter_class=argparse.RawDescriptionHelpFormatter) |
| 41 | parser.add_argument("--input_path", |
| 42 | type=existing_path, |
| 43 | required=True, |
| 44 | help="Input dataset file or directory.") |
| 45 | parser.add_argument("--output_path", |
| 46 | type=str, |
| 47 | required=True, |
| 48 | help="Output embedx graph directory.") |
| 49 | parser.add_argument("--dataset", |
| 50 | choices=["blogcatalog", "cora", "ppi"], |
| 51 | required=True, |
| 52 | help="Dataset.") |
| 53 | parser.add_argument( |
| 54 | "--train_ratio", |
| 55 | type=float, |
| 56 | default=0.5, |
| 57 | help="The ratio of nodes that needs to be set as training type, " |
| 58 | "necessary when dataset is 'blogcatalog' or 'cora'.") |
| 59 | return parser.parse_args() |
| 60 | |
| 61 | |
| 62 | def generate_embedx_graph(dataset, embedx_graph_dir): |