dgl.DGLGraph.srctypes
- property DGLGraph.srctypes
返回此图中所有源节点类型的名称。
If the graph can further divide its node types into two subsets A and B where all the edeges are from nodes of types in A to nodes of types in B, we call this graph a uni-bipartite graph and the nodes in A being the source nodes and the ones in B being the destination nodes. If the graph is not uni-bipartite, the source and destination nodes are just the entire set of nodes in the graph.
另请参阅
示例
以下示例使用PyTorch后端。
>>> import dgl >>> import torch
查询一个单二分图。
>>> g = dgl.heterograph({ ... ('user', 'plays', 'game'): (torch.tensor([0]), torch.tensor([1])), ... ('developer', 'develops', 'game'): (torch.tensor([1]), torch.tensor([2])) ... }) >>> g.srctypes ['developer', 'user']
查询一个不是单二分图的图。
>>> g = dgl.heterograph({ ... ('user', 'follows', 'user'): (torch.tensor([0]), torch.tensor([1])), ... ('developer', 'develops', 'game'): (torch.tensor([1]), torch.tensor([2])) ... }) >>> g.srctypes ['developer', 'game', 'user']