MCPcopy
hub / github.com/dmlc/dgl / dsttypes

Method dsttypes

python/dgl/heterograph.py:1141–1189  ·  view source on GitHub ↗

Return all the destination 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

(self)

Source from the content-addressed store, hash-verified

1139
1140 @property
1141 def dsttypes(self):
1142 """Return all the destination node type names in this graph.
1143
1144 If the graph can further divide its node types into two subsets A and B where
1145 all the edeges are from nodes of types in A to nodes of types in B, we call
1146 this graph a *uni-bipartite* graph and the nodes in A being the *source*
1147 nodes and the ones in B being the *destination* nodes. If the graph is not
1148 uni-bipartite, the source and destination nodes are just the entire set of
1149 nodes in the graph.
1150
1151 Returns
1152 -------
1153 list[str]
1154 All the destination node type names in a list.
1155
1156 See Also
1157 --------
1158 srctypes
1159 is_unibipartite
1160
1161 Examples
1162 --------
1163 The following example uses PyTorch backend.
1164
1165 >>> import dgl
1166 >>> import torch
1167
1168 Query for a uni-bipartite graph.
1169
1170 >>> g = dgl.heterograph({
1171 ... ('user', 'plays', 'game'): (torch.tensor([0]), torch.tensor([1])),
1172 ... ('developer', 'develops', 'game'): (torch.tensor([1]), torch.tensor([2]))
1173 ... })
1174 >>> g.dsttypes
1175 ['game']
1176
1177 Query for a graph that is not uni-bipartite.
1178
1179 >>> g = dgl.heterograph({
1180 ... ('user', 'follows', 'user'): (torch.tensor([0]), torch.tensor([1])),
1181 ... ('developer', 'develops', 'game'): (torch.tensor([1]), torch.tensor([2]))
1182 ... })
1183 >>> g.dsttypes
1184 ['developer', 'game', 'user']
1185 """
1186 if self.is_unibipartite:
1187 return sorted(list(self._dsttypes_invmap.keys()))
1188 else:
1189 return self.ntypes
1190
1191 def metagraph(self):
1192 """Return the metagraph of the heterograph.

Callers

nothing calls this directly

Calls 1

keysMethod · 0.45

Tested by

no test coverage detected