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

Method transform_etype

python/dgl/transforms/module.py:598–628  ·  view source on GitHub ↗

r""" Description ----------- Transform the graph corresponding to a canonical edge type. Parameters ---------- c_etype : tuple of str A canonical edge type. g : DGLGraph The graph. Returns -------

(self, c_etype, g)

Source from the content-addressed store, hash-verified

596 self.fill_data = fill_data
597
598 def transform_etype(self, c_etype, g):
599 r"""
600
601 Description
602 -----------
603 Transform the graph corresponding to a canonical edge type.
604
605 Parameters
606 ----------
607 c_etype : tuple of str
608 A canonical edge type.
609 g : DGLGraph
610 The graph.
611
612 Returns
613 -------
614 DGLGraph
615 The transformed graph.
616 """
617 utype, _, vtype = c_etype
618 if utype != vtype:
619 return g
620
621 if not self.allow_duplicate:
622 g = functional.remove_self_loop(g, etype=c_etype)
623 return functional.add_self_loop(
624 g,
625 edge_feat_names=self.edge_feat_names,
626 fill_data=self.fill_data,
627 etype=c_etype,
628 )
629
630 def __call__(self, g):
631 for c_etype in g.canonical_etypes:

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected