Verify partitioned graph objects node counts with the original graph Parameters: ----------- params : argparser object to access command line arguments for this python script part_data : list of tuples partitioned graph objects read from the disk g : DGL Graph ob
(
node_partids, part_g, g, gpb, graph_schema, orig_nids, partition_id
)
| 222 | |
| 223 | |
| 224 | def verify_node_partitionids( |
| 225 | node_partids, part_g, g, gpb, graph_schema, orig_nids, partition_id |
| 226 | ): |
| 227 | """Verify partitioned graph objects node counts with the original graph |
| 228 | |
| 229 | Parameters: |
| 230 | ----------- |
| 231 | params : argparser object |
| 232 | to access command line arguments for this python script |
| 233 | part_data : list of tuples |
| 234 | partitioned graph objects read from the disk |
| 235 | g : DGL Graph object |
| 236 | created by reading the original graph from disk |
| 237 | graph_schema : json object |
| 238 | created by reading the metadata.json file for the original graph |
| 239 | orig_nids : dictionary |
| 240 | which contains the origial(global) node-ids |
| 241 | partition_id : integer |
| 242 | partition id of the partitioned graph, part_g |
| 243 | """ |
| 244 | # read part graphs and verify the counts |
| 245 | # inner node masks, should give the node counts in each part-g and get the corresponding orig-ids to map to the original graph node-ids |
| 246 | for ntype_id, ntype in enumerate(graph_schema[constants.STR_NODE_TYPE]): |
| 247 | mask = _get_inner_node_mask(part_g, g.get_ntype_id(ntype)) |
| 248 | |
| 249 | # map these to orig-nids. |
| 250 | inner_nids = part_g.ndata[dgl.NID][mask] |
| 251 | ntype_ids, inner_type_nids = gpb.map_to_per_ntype(inner_nids) |
| 252 | partid = gpb.nid2partid(inner_type_nids, ntype) |
| 253 | |
| 254 | assert np.all(ntype_ids.numpy() == ntype_id) |
| 255 | assert np.all(partid.numpy() == gpb.partid) |
| 256 | |
| 257 | idxes = orig_nids[ntype][inner_type_nids] |
| 258 | assert np.all(idxes >= 0) |
| 259 | |
| 260 | # get the partition-ids for these nodes. |
| 261 | assert np.all( |
| 262 | node_partids[ntype][idxes] == partition_id |
| 263 | ), f"All the nodes in the partition = {partid} does not their nodeid to partition-id maps are defined by the partitioning algorithm. Node-type = {ntype}" |
| 264 | |
| 265 | |
| 266 | def read_orig_ids(out_dir, fname, num_parts): |
no test coverage detected