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

Class HeteroEdgeView

python/dgl/view.py:142–179  ·  view source on GitHub ↗

A EdgeView class to act as G.edges for a DGLGraph.

Source from the content-addressed store, hash-verified

140
141
142class HeteroEdgeView(object):
143 """A EdgeView class to act as G.edges for a DGLGraph."""
144
145 __slots__ = ["_graph"]
146
147 def __init__(self, graph):
148 self._graph = graph
149
150 def __getitem__(self, key):
151 if isinstance(key, slice):
152 # slice
153 if not (
154 key.start is None and key.stop is None and key.step is None
155 ):
156 raise DGLError('Currently only full slice ":" is supported')
157 edges = ALL
158 etype = None
159 elif key is None:
160 edges = ALL
161 etype = None
162 elif isinstance(key, tuple):
163 if len(key) == 3:
164 edges = ALL
165 etype = key
166 else:
167 edges = key
168 etype = None
169 elif isinstance(key, str):
170 edges = ALL
171 etype = key
172 else:
173 edges = key
174 etype = None
175 return EdgeSpace(data=HeteroEdgeDataView(self._graph, etype, edges))
176
177 def __call__(self, *args, **kwargs):
178 """Return all the edges."""
179 return self._graph.all_edges(*args, **kwargs)
180
181
182class HeteroEdgeDataView(MutableMapping):

Callers 1

edgesMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected