Verify the partitioned graph objects with the metadata Parameters: ----------- part_schema : json object which is created by reading the metadata.json file for the partitioned graph part_g : DGL graph object of a graph partition graph_schema : json object
(part_schema, part_g, graph_schema, g, partid)
| 141 | |
| 142 | |
| 143 | def verify_metadata_counts(part_schema, part_g, graph_schema, g, partid): |
| 144 | """Verify the partitioned graph objects with the metadata |
| 145 | |
| 146 | Parameters: |
| 147 | ----------- |
| 148 | part_schema : json object |
| 149 | which is created by reading the metadata.json file for the |
| 150 | partitioned graph |
| 151 | part_g : DGL graph object |
| 152 | of a graph partition |
| 153 | graph_schema : json object |
| 154 | which is created by reading the metadata.json file for the |
| 155 | original graph |
| 156 | g : DGL Graph object |
| 157 | created by reading the original graph from the disk. |
| 158 | partid : integer |
| 159 | specifying the partition id of the graph object, part_g |
| 160 | """ |
| 161 | for ntype in part_schema[constants.STR_NTYPES]: |
| 162 | ntype_data = part_schema[constants.STR_NODE_MAP][ntype] |
| 163 | meta_ntype_count = ntype_data[partid][1] - ntype_data[partid][0] |
| 164 | inner_node_mask = _get_inner_node_mask(part_g, g.get_ntype_id(ntype)) |
| 165 | graph_ntype_count = len(part_g.ndata[dgl.NID][inner_node_mask]) |
| 166 | assert ( |
| 167 | meta_ntype_count == graph_ntype_count |
| 168 | ), f"Metadata ntypecount = {meta_ntype_count} and graph_ntype_count = {graph_ntype_count}" |
| 169 | |
| 170 | for etype in part_schema[constants.STR_ETYPES]: |
| 171 | etype_data = part_schema[constants.STR_EDGE_MAP][etype] |
| 172 | meta_etype_count = etype_data[partid][1] - etype_data[partid][0] |
| 173 | mask = _get_inner_edge_mask( |
| 174 | part_g, g.get_etype_id(_etype_str_to_tuple(etype)) |
| 175 | ) |
| 176 | graph_etype_count = len(part_g.edata[dgl.EID][mask]) |
| 177 | assert ( |
| 178 | meta_etype_count == graph_etype_count |
| 179 | ), f"Metadata etypecount = {meta_etype_count} does not match part graph etypecount = {graph_etype_count}" |
| 180 | |
| 181 | |
| 182 | def get_node_partids(partitions_dir, graph_schema): |
no test coverage detected