Class for storing graph structure and node/edge feature data. There are a few ways to create a DGLGraph: * To create a homogeneous graph from Tensor data, use :func:`dgl.graph`. * To create a heterogeneous graph from Tensor data, use :func:`dgl.heterograph`. * To create a graph fro
| 38 | |
| 39 | |
| 40 | class DGLGraph(object): |
| 41 | """Class for storing graph structure and node/edge feature data. |
| 42 | |
| 43 | There are a few ways to create a DGLGraph: |
| 44 | |
| 45 | * To create a homogeneous graph from Tensor data, use :func:`dgl.graph`. |
| 46 | * To create a heterogeneous graph from Tensor data, use :func:`dgl.heterograph`. |
| 47 | * To create a graph from other data sources, use ``dgl.*`` create ops. See |
| 48 | :ref:`api-graph-create-ops`. |
| 49 | |
| 50 | Read the user guide chapter :ref:`guide-graph` for an in-depth explanation about its |
| 51 | usage. |
| 52 | """ |
| 53 | |
| 54 | is_block = False |
| 55 | |
| 56 | # pylint: disable=unused-argument, dangerous-default-value |
| 57 | def __init__( |
| 58 | self, |
| 59 | gidx=[], |
| 60 | ntypes=["_N"], |
| 61 | etypes=["_E"], |
| 62 | node_frames=None, |
| 63 | edge_frames=None, |
| 64 | **deprecate_kwargs |
| 65 | ): |
| 66 | """Internal constructor for creating a DGLGraph. |
| 67 | |
| 68 | Parameters |
| 69 | ---------- |
| 70 | gidx : HeteroGraphIndex |
| 71 | Graph index object. |
| 72 | ntypes : list of str, pair of list of str |
| 73 | Node type list. ``ntypes[i]`` stores the name of node type i. |
| 74 | If a pair is given, the graph created is a uni-directional bipartite graph, |
| 75 | and its SRC node types and DST node types are given as in the pair. |
| 76 | etypes : list of str |
| 77 | Edge type list. ``etypes[i]`` stores the name of edge type i. |
| 78 | node_frames : list[Frame], optional |
| 79 | Node feature storage. If None, empty frame is created. |
| 80 | Otherwise, ``node_frames[i]`` stores the node features |
| 81 | of node type i. (default: None) |
| 82 | edge_frames : list[Frame], optional |
| 83 | Edge feature storage. If None, empty frame is created. |
| 84 | Otherwise, ``edge_frames[i]`` stores the edge features |
| 85 | of edge type i. (default: None) |
| 86 | """ |
| 87 | if isinstance(gidx, DGLGraph): |
| 88 | raise DGLError( |
| 89 | "The input is already a DGLGraph. No need to create it again." |
| 90 | ) |
| 91 | if not isinstance(gidx, heterograph_index.HeteroGraphIndex): |
| 92 | dgl_warning( |
| 93 | "Recommend creating graphs by `dgl.graph(data)`" |
| 94 | " instead of `dgl.DGLGraph(data)`." |
| 95 | ) |
| 96 | (sparse_fmt, arrays), num_src, num_dst = utils.graphdata2tensors( |
| 97 | gidx |
no outgoing calls
no test coverage detected