partition.py 1.34 KB
Newer Older
1
2
3
4
5
6
import numpy as np
import argparse
import signal
import dgl
from dgl import backend as F
from dgl.data.utils import load_graphs, save_graphs
7
8
from dgl.contrib.dist_graph import partition_graph
import pickle
9
10
11
12
13

def main():
    parser = argparse.ArgumentParser(description='Partition a graph')
    parser.add_argument('--data', required=True, type=str,
                        help='The file path of the input graph in the DGL format.')
14
15
    parser.add_argument('--graph-name', required=True, type=str,
                        help='The graph name')
16
17
18
19
20
21
22
23
24
    parser.add_argument('-k', '--num-parts', required=True, type=int,
                        help='The number of partitions')
    parser.add_argument('--num-hops', type=int, default=1,
                        help='The number of hops of HALO nodes we include in a partition')
    parser.add_argument('-m', '--method', required=True, type=str,
                        help='The partitioning method: random, metis')
    parser.add_argument('-o', '--output', required=True, type=str,
                        help='The output directory of the partitioned results')
    args = parser.parse_args()
25
    glist, _ = load_graphs(args.data)
26
    g = glist[0]
27
28
    partition_graph(g, args.graph_name, args.num_parts, args.output,
                    num_hops=args.num_hops, part_method=args.method)
29
30
31
32


if __name__ == '__main__':
    main()