MCPcopy Create free account
hub / github.com/alibaba/GraphScope / EdgeLabel

Class EdgeLabel

python/graphscope/framework/graph_schema.py:204–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202
203
204class EdgeLabel(Label):
205 __slots__ = ["_relations"]
206
207 def __init__(self, name, label_id=0):
208 super().__init__(name, label_id)
209 self._relations: List[Relation] = []
210
211 @property
212 def type_enum(self):
213 return graph_def_pb2.TypeEnumPb.EDGE
214
215 def source(self, label):
216 self._relations.append(Relation(label, ""))
217 return self
218
219 def destination(self, label):
220 assert (
221 self._relations
222 ), "Found empty relation, maybe you should use `source` first."
223 assert not self._relations[-1].destination, "An destination is already exists."
224 self._relations[-1] = self._relations[-1]._replace(destination=label)
225 return self
226
227 @property
228 def relations(self) -> List[Relation]:
229 return self._relations
230
231 def __repr__(self) -> str:
232 s = super().__repr__()
233 if self._relations:
234 s += f"Relations: {self.relations}"
235 return s
236
237 def to_dict(self) -> dict:
238 # super dict
239 sd = super().to_dict()
240 relations = []
241 for r in self._relations:
242 relations.append(
243 {"source_vertex": r.source, "destination_vertex": r.destination}
244 )
245 sd.update({"vertex_type_pair_relations": relations})
246 return sd
247
248
249class GraphSchema:

Callers 6

_from_vineyardMethod · 0.70
from_dictMethod · 0.70
add_edge_labelMethod · 0.70
add_edge_propertiesMethod · 0.70
dropMethod · 0.70
drop_allMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected