"docs/git@developer.sourcefind.cn:OpenDAS/bitsandbytes.git" did not exist on "bf0153812f3648c584b6698f5fa2e14c412a7be7"
Unverified Commit 625f8a6b authored by Mingbang Wang's avatar Mingbang Wang Committed by GitHub
Browse files

[GraphBolt] Modify `from_dglgraph()` (#6470)

parent a6daf822
...@@ -825,14 +825,19 @@ def from_dglgraph( ...@@ -825,14 +825,19 @@ def from_dglgraph(
include_original_edge_id: bool = False, include_original_edge_id: bool = False,
) -> CSCSamplingGraph: ) -> CSCSamplingGraph:
"""Convert a DGLGraph to CSCSamplingGraph.""" """Convert a DGLGraph to CSCSamplingGraph."""
homo_g, ntype_count, _ = to_homogeneous(g, return_count=True) homo_g, ntype_count, _ = to_homogeneous(g, return_count=True)
# Initialize metadata.
node_type_to_id = {ntype: g.get_ntype_id(ntype) for ntype in g.ntypes} if is_homogeneous:
edge_type_to_id = { metadata = None
etype_tuple_to_str(etype): g.get_etype_id(etype) else:
for etype in g.canonical_etypes # Initialize metadata.
} node_type_to_id = {ntype: g.get_ntype_id(ntype) for ntype in g.ntypes}
metadata = GraphMetadata(node_type_to_id, edge_type_to_id) edge_type_to_id = {
etype_tuple_to_str(etype): g.get_etype_id(etype)
for etype in g.canonical_etypes
}
metadata = GraphMetadata(node_type_to_id, edge_type_to_id)
# Obtain CSC matrix. # Obtain CSC matrix.
indptr, indices, edge_ids = homo_g.adj_tensors("csc") indptr, indices, edge_ids = homo_g.adj_tensors("csc")
......
...@@ -1321,8 +1321,7 @@ def test_from_dglgraph_homogeneous(): ...@@ -1321,8 +1321,7 @@ def test_from_dglgraph_homogeneous():
assert gb_g.total_num_edges == dgl_g.num_edges() assert gb_g.total_num_edges == dgl_g.num_edges()
assert torch.equal(gb_g.node_type_offset, torch.tensor([0, 1000])) assert torch.equal(gb_g.node_type_offset, torch.tensor([0, 1000]))
assert gb_g.type_per_edge is None assert gb_g.type_per_edge is None
assert gb_g.metadata.node_type_to_id == {"_N": 0} assert gb_g.metadata is None
assert gb_g.metadata.edge_type_to_id == {"_N:_E:_N": 0}
@unittest.skipIf( @unittest.skipIf(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment