Return all the source node type names in this graph. 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 *sou
(self)
| 1088 | |
| 1089 | @property |
| 1090 | def srctypes(self): |
| 1091 | """Return all the source node type names in this graph. |
| 1092 | |
| 1093 | If the graph can further divide its node types into two subsets A and B where |
| 1094 | all the edeges are from nodes of types in A to nodes of types in B, we call |
| 1095 | this graph a *uni-bipartite* graph and the nodes in A being the *source* |
| 1096 | nodes and the ones in B being the *destination* nodes. If the graph is not |
| 1097 | uni-bipartite, the source and destination nodes are just the entire set of |
| 1098 | nodes in the graph. |
| 1099 | |
| 1100 | Returns |
| 1101 | ------- |
| 1102 | list[str] |
| 1103 | All the source node type names in a list. |
| 1104 | |
| 1105 | See Also |
| 1106 | -------- |
| 1107 | dsttypes |
| 1108 | is_unibipartite |
| 1109 | |
| 1110 | Examples |
| 1111 | -------- |
| 1112 | The following example uses PyTorch backend. |
| 1113 | |
| 1114 | >>> import dgl |
| 1115 | >>> import torch |
| 1116 | |
| 1117 | Query for a uni-bipartite graph. |
| 1118 | |
| 1119 | >>> g = dgl.heterograph({ |
| 1120 | ... ('user', 'plays', 'game'): (torch.tensor([0]), torch.tensor([1])), |
| 1121 | ... ('developer', 'develops', 'game'): (torch.tensor([1]), torch.tensor([2])) |
| 1122 | ... }) |
| 1123 | >>> g.srctypes |
| 1124 | ['developer', 'user'] |
| 1125 | |
| 1126 | Query for a graph that is not uni-bipartite. |
| 1127 | |
| 1128 | >>> g = dgl.heterograph({ |
| 1129 | ... ('user', 'follows', 'user'): (torch.tensor([0]), torch.tensor([1])), |
| 1130 | ... ('developer', 'develops', 'game'): (torch.tensor([1]), torch.tensor([2])) |
| 1131 | ... }) |
| 1132 | >>> g.srctypes |
| 1133 | ['developer', 'game', 'user'] |
| 1134 | """ |
| 1135 | if self.is_unibipartite: |
| 1136 | return sorted(list(self._srctypes_invmap.keys())) |
| 1137 | else: |
| 1138 | return self.ntypes |
| 1139 | |
| 1140 | @property |
| 1141 | def dsttypes(self): |