Unverified Commit 3132da28 authored by peizhou001's avatar peizhou001 Committed by GitHub
Browse files

Deprecate (#4864)

rename DGLHeteroGraph to DGLGraph
parent ee9887d6
...@@ -7,7 +7,7 @@ import networkx as nx ...@@ -7,7 +7,7 @@ import networkx as nx
from . import backend as F from . import backend as F
from . import heterograph_index from . import heterograph_index
from .heterograph import DGLHeteroGraph, combine_frames, DGLBlock from .heterograph import DGLGraph, combine_frames, DGLBlock
from . import graph_index from . import graph_index
from . import utils from . import utils
from .base import NTYPE, ETYPE, NID, EID, DGLError, dgl_warning from .base import NTYPE, ETYPE, NID, EID, DGLError, dgl_warning
...@@ -224,7 +224,7 @@ def hetero_from_shared_memory(name): ...@@ -224,7 +224,7 @@ def hetero_from_shared_memory(name):
HeteroGraph (in shared memory) HeteroGraph (in shared memory)
""" """
g, ntypes, etypes = heterograph_index.create_heterograph_from_shared_memory(name) g, ntypes, etypes = heterograph_index.create_heterograph_from_shared_memory(name)
return DGLHeteroGraph(g, ntypes, etypes) return DGLGraph(g, ntypes, etypes)
def heterograph(data_dict, def heterograph(data_dict,
num_nodes_dict=None, num_nodes_dict=None,
...@@ -378,7 +378,7 @@ def heterograph(data_dict, ...@@ -378,7 +378,7 @@ def heterograph(data_dict,
# create graph index # create graph index
hgidx = heterograph_index.create_heterograph_from_relations( hgidx = heterograph_index.create_heterograph_from_relations(
metagraph, [rgrh._graph for rgrh in rel_graphs], num_nodes_per_type) metagraph, [rgrh._graph for rgrh in rel_graphs], num_nodes_per_type)
retg = DGLHeteroGraph(hgidx, ntypes, etypes) retg = DGLGraph(hgidx, ntypes, etypes)
return retg.to(device) return retg.to(device)
...@@ -612,7 +612,7 @@ def block_to_graph(block): ...@@ -612,7 +612,7 @@ def block_to_graph(block):
""" """
new_types = [ntype + '_src' for ntype in block.srctypes] + \ new_types = [ntype + '_src' for ntype in block.srctypes] + \
[ntype + '_dst' for ntype in block.dsttypes] [ntype + '_dst' for ntype in block.dsttypes]
retg = DGLHeteroGraph(block._graph, new_types, block.etypes) retg = DGLGraph(block._graph, new_types, block.etypes)
for srctype in block.srctypes: for srctype in block.srctypes:
retg.nodes[srctype + '_src'].data.update(block.srcnodes[srctype].data) retg.nodes[srctype + '_src'].data.update(block.srcnodes[srctype].data)
...@@ -1620,7 +1620,7 @@ def to_networkx(g, node_attrs=None, edge_attrs=None): ...@@ -1620,7 +1620,7 @@ def to_networkx(g, node_attrs=None, edge_attrs=None):
attr.update({key: F.squeeze(feat_dict[key], 0) for key in edge_attrs}) attr.update({key: F.squeeze(feat_dict[key], 0) for key in edge_attrs})
return nx_graph return nx_graph
DGLHeteroGraph.to_networkx = to_networkx DGLGraph.to_networkx = to_networkx
def to_cugraph(g): def to_cugraph(g):
"""Convert a DGL graph to a :class:`cugraph.Graph` and return. """Convert a DGL graph to a :class:`cugraph.Graph` and return.
...@@ -1677,7 +1677,7 @@ def to_cugraph(g): ...@@ -1677,7 +1677,7 @@ def to_cugraph(g):
destination='destination') destination='destination')
return g_cugraph return g_cugraph
DGLHeteroGraph.to_cugraph = to_cugraph DGLGraph.to_cugraph = to_cugraph
def from_cugraph(cugraph_graph): def from_cugraph(cugraph_graph):
"""Create a graph from a :class:`cugraph.Graph` object. """Create a graph from a :class:`cugraph.Graph` object.
...@@ -1766,7 +1766,7 @@ def create_from_edges(sparse_fmt, arrays, ...@@ -1766,7 +1766,7 @@ def create_from_edges(sparse_fmt, arrays,
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
""" """
if utype == vtype: if utype == vtype:
num_ntypes = 1 num_ntypes = 1
...@@ -1784,6 +1784,6 @@ def create_from_edges(sparse_fmt, arrays, ...@@ -1784,6 +1784,6 @@ def create_from_edges(sparse_fmt, arrays,
num_ntypes, urange, vrange, indptr, indices, eids, ['coo', 'csr', 'csc'], num_ntypes, urange, vrange, indptr, indices, eids, ['coo', 'csr', 'csc'],
sparse_fmt == 'csc') sparse_fmt == 'csc')
if utype == vtype: if utype == vtype:
return DGLHeteroGraph(hgidx, [utype], [etype]) return DGLGraph(hgidx, [utype], [etype])
else: else:
return DGLHeteroGraph(hgidx, [utype, vtype], [etype]) return DGLGraph(hgidx, [utype, vtype], [etype])
...@@ -7,7 +7,7 @@ from .. import backend as F ...@@ -7,7 +7,7 @@ from .. import backend as F
from .._ffi.function import _init_api from .._ffi.function import _init_api
from .._ffi.object import ObjectBase, register_object from .._ffi.object import ObjectBase, register_object
from ..base import DGLError, dgl_warning from ..base import DGLError, dgl_warning
from ..heterograph import DGLHeteroGraph from ..heterograph import DGLGraph
from .heterograph_serialize import save_heterographs from .heterograph_serialize import save_heterographs
_init_api("dgl.data.graph_serialize") _init_api("dgl.data.graph_serialize")
...@@ -69,10 +69,10 @@ class GraphData(ObjectBase): ...@@ -69,10 +69,10 @@ class GraphData(ObjectBase):
return _CAPI_MakeGraphData(ghandle, node_tensors, edge_tensors) return _CAPI_MakeGraphData(ghandle, node_tensors, edge_tensors)
def get_graph(self): def get_graph(self):
"""Get DGLHeteroGraph from GraphData""" """Get DGLGraph from GraphData"""
ghandle = _CAPI_GDataGraphHandle(self) ghandle = _CAPI_GDataGraphHandle(self)
hgi = _CAPI_DGLAsHeteroGraph(ghandle) hgi = _CAPI_DGLAsHeteroGraph(ghandle)
g = DGLHeteroGraph(hgi, ["_U"], ["_E"]) g = DGLGraph(hgi, ["_U"], ["_E"])
node_tensors_items = _CAPI_GDataNodeTensors(self).items() node_tensors_items = _CAPI_GDataNodeTensors(self).items()
edge_tensors_items = _CAPI_GDataEdgeTensors(self).items() edge_tensors_items = _CAPI_GDataEdgeTensors(self).items()
for k, v in node_tensors_items: for k, v in node_tensors_items:
...@@ -142,8 +142,8 @@ def save_graphs(filename, g_list, labels=None, formats=None): ...@@ -142,8 +142,8 @@ def save_graphs(filename, g_list, labels=None, formats=None):
g_sample = g_list[0] if isinstance(g_list, list) else g_list g_sample = g_list[0] if isinstance(g_list, list) else g_list
if ( if (
type(g_sample) == DGLHeteroGraph type(g_sample) == DGLGraph
): # Doesn't support DGLHeteroGraph's derived class ): # Doesn't support DGLGraph's derived class
save_heterographs(filename, g_list, labels, formats) save_heterographs(filename, g_list, labels, formats)
else: else:
raise DGLError( raise DGLError(
...@@ -203,7 +203,7 @@ def load_graphs(filename, idx_list=None): ...@@ -203,7 +203,7 @@ def load_graphs(filename, idx_list=None):
def load_graph_v2(filename, idx_list=None): def load_graph_v2(filename, idx_list=None):
"""Internal functions for loading DGLHeteroGraphs.""" """Internal functions for loading DGLGraphs."""
if idx_list is None: if idx_list is None:
idx_list = [] idx_list = []
assert isinstance(idx_list, list) assert isinstance(idx_list, list)
......
...@@ -6,7 +6,7 @@ from .._ffi.function import _init_api ...@@ -6,7 +6,7 @@ from .._ffi.function import _init_api
from .._ffi.object import ObjectBase, register_object from .._ffi.object import ObjectBase, register_object
from ..container import convert_to_strmap from ..container import convert_to_strmap
from ..frame import Frame from ..frame import Frame
from ..heterograph import DGLHeteroGraph from ..heterograph import DGLGraph
_init_api("dgl.data.heterograph_serialize") _init_api("dgl.data.heterograph_serialize")
...@@ -23,11 +23,11 @@ def save_heterographs(filename, g_list, labels, formats): ...@@ -23,11 +23,11 @@ def save_heterographs(filename, g_list, labels, formats):
"""Save heterographs into file""" """Save heterographs into file"""
if labels is None: if labels is None:
labels = {} labels = {}
if isinstance(g_list, DGLHeteroGraph): if isinstance(g_list, DGLGraph):
g_list = [g_list] g_list = [g_list]
assert all( assert all(
[type(g) == DGLHeteroGraph for g in g_list] [type(g) == DGLGraph for g in g_list]
), "Invalid DGLHeteroGraph in g_list argument" ), "Invalid DGLGraph in g_list argument"
gdata_list = [HeteroGraphData.create(g) for g in g_list] gdata_list = [HeteroGraphData.create(g) for g in g_list]
if formats is None: if formats is None:
formats = [] formats = []
...@@ -39,7 +39,7 @@ def save_heterographs(filename, g_list, labels, formats): ...@@ -39,7 +39,7 @@ def save_heterographs(filename, g_list, labels, formats):
@register_object("heterograph_serialize.HeteroGraphData") @register_object("heterograph_serialize.HeteroGraphData")
class HeteroGraphData(ObjectBase): class HeteroGraphData(ObjectBase):
"""Object to hold the data to be stored for DGLHeteroGraph""" """Object to hold the data to be stored for DGLGraph"""
@staticmethod @staticmethod
def create(g): def create(g):
...@@ -75,4 +75,4 @@ class HeteroGraphData(ObjectBase): ...@@ -75,4 +75,4 @@ class HeteroGraphData(ObjectBase):
} }
eframes.append(Frame(edict, num_rows=gidx.number_of_edges(etid))) eframes.append(Frame(edict, num_rows=gidx.number_of_edges(etid)))
return DGLHeteroGraph(gidx, ntype_names, etype_names, nframes, eframes) return DGLGraph(gidx, ntype_names, etype_names, nframes, eframes)
...@@ -19,7 +19,7 @@ from torch.utils.data.distributed import DistributedSampler ...@@ -19,7 +19,7 @@ from torch.utils.data.distributed import DistributedSampler
from ..base import NID, EID, dgl_warning, DGLError from ..base import NID, EID, dgl_warning, DGLError
from ..batch import batch as batch_graphs from ..batch import batch as batch_graphs
from ..heterograph import DGLHeteroGraph from ..heterograph import DGLGraph
from ..utils import ( from ..utils import (
recursive_apply, ExceptionWrapper, recursive_apply_pair, set_num_threads, get_num_threads, recursive_apply, ExceptionWrapper, recursive_apply_pair, set_num_threads, get_num_threads,
get_numa_nodes_cores, context_of, dtype_of) get_numa_nodes_cores, context_of, dtype_of)
...@@ -283,7 +283,7 @@ def _prefetch_for_subgraph(subg, dataloader): ...@@ -283,7 +283,7 @@ def _prefetch_for_subgraph(subg, dataloader):
def _prefetch_for(item, dataloader): def _prefetch_for(item, dataloader):
if isinstance(item, DGLHeteroGraph): if isinstance(item, DGLGraph):
return _prefetch_for_subgraph(item, dataloader) return _prefetch_for_subgraph(item, dataloader)
elif isinstance(item, LazyFeature): elif isinstance(item, LazyFeature):
return dataloader.other_storages[item.name].fetch( return dataloader.other_storages[item.name].fetch(
...@@ -343,7 +343,7 @@ def _prefetch(batch, dataloader, stream): ...@@ -343,7 +343,7 @@ def _prefetch(batch, dataloader, stream):
def _assign_for(item, feat): def _assign_for(item, feat):
if isinstance(item, DGLHeteroGraph): if isinstance(item, DGLGraph):
subg = item subg = item
for (tid, key), value in feat.node_feats.items(): for (tid, key), value in feat.node_feats.items():
assert isinstance(subg._node_frames[tid][key], LazyFeature) assert isinstance(subg._node_frames[tid][key], LazyFeature)
...@@ -387,17 +387,17 @@ def _prefetcher_entry( ...@@ -387,17 +387,17 @@ def _prefetcher_entry(
queue, (None, None, None, ExceptionWrapper(where='in prefetcher')), done_event) queue, (None, None, None, ExceptionWrapper(where='in prefetcher')), done_event)
# DGLHeteroGraphs have the semantics of lazy feature slicing with subgraphs. Such behavior depends # DGLGraphs have the semantics of lazy feature slicing with subgraphs. Such behavior depends
# on that DGLHeteroGraph's ndata and edata are maintained by Frames. So to maintain compatibility # on that DGLGraph's ndata and edata are maintained by Frames. So to maintain compatibility
# with older code, DGLHeteroGraphs and other graph storages are handled separately: (1) # with older code, DGLGraphs and other graph storages are handled separately: (1)
# DGLHeteroGraphs will preserve the lazy feature slicing for subgraphs. (2) Other graph storages # DGLGraphs will preserve the lazy feature slicing for subgraphs. (2) Other graph storages
# will not have lazy feature slicing; all feature slicing will be eager. # will not have lazy feature slicing; all feature slicing will be eager.
def remove_parent_storage_columns(item, g): def remove_parent_storage_columns(item, g):
"""Removes the storage objects in the given graphs' Frames if it is a sub-frame of the """Removes the storage objects in the given graphs' Frames if it is a sub-frame of the
given parent graph, so that the storages are not serialized during IPC from PyTorch given parent graph, so that the storages are not serialized during IPC from PyTorch
DataLoader workers. DataLoader workers.
""" """
if not isinstance(item, DGLHeteroGraph) or not isinstance(g, DGLHeteroGraph): if not isinstance(item, DGLGraph) or not isinstance(g, DGLGraph):
return item return item
for subframe, frame in zip( for subframe, frame in zip(
...@@ -419,7 +419,7 @@ def restore_parent_storage_columns(item, g): ...@@ -419,7 +419,7 @@ def restore_parent_storage_columns(item, g):
"""Restores the storage objects in the given graphs' Frames if it is a sub-frame of the """Restores the storage objects in the given graphs' Frames if it is a sub-frame of the
given parent graph (i.e. when the storage object is None). given parent graph (i.e. when the storage object is None).
""" """
if not isinstance(item, DGLHeteroGraph) or not isinstance(g, DGLHeteroGraph): if not isinstance(item, DGLGraph) or not isinstance(g, DGLGraph):
return item return item
for subframe, frame in zip( for subframe, frame in zip(
...@@ -774,7 +774,7 @@ class DataLoader(torch.utils.data.DataLoader): ...@@ -774,7 +774,7 @@ class DataLoader(torch.utils.data.DataLoader):
self.device = _get_device(device) self.device = _get_device(device)
# Sanity check - we only check for DGLGraphs. # Sanity check - we only check for DGLGraphs.
if isinstance(self.graph, DGLHeteroGraph): if isinstance(self.graph, DGLGraph):
# Check graph and indices device as well as num_workers # Check graph and indices device as well as num_workers
if use_uva: if use_uva:
if self.graph.device.type != 'cpu': if self.graph.device.type != 'cpu':
...@@ -1098,7 +1098,7 @@ class GraphCollator(object): ...@@ -1098,7 +1098,7 @@ class GraphCollator(object):
""" """
elem = items[0] elem = items[0]
elem_type = type(elem) elem_type = type(elem)
if isinstance(elem, DGLHeteroGraph): if isinstance(elem, DGLGraph):
batched_graphs = batch_graphs(items) batched_graphs = batch_graphs(items)
return batched_graphs return batched_graphs
elif F.is_tensor(elem): elif F.is_tensor(elem):
......
...@@ -7,7 +7,7 @@ import os ...@@ -7,7 +7,7 @@ import os
import gc import gc
import numpy as np import numpy as np
from ..heterograph import DGLHeteroGraph from ..heterograph import DGLGraph
from ..convert import heterograph as dgl_heterograph from ..convert import heterograph as dgl_heterograph
from ..convert import graph as dgl_graph from ..convert import graph as dgl_graph
from ..transforms import compact_graphs from ..transforms import compact_graphs
...@@ -129,7 +129,7 @@ def _get_graph_from_shared_mem(graph_name): ...@@ -129,7 +129,7 @@ def _get_graph_from_shared_mem(graph_name):
g, ntypes, etypes = heterograph_index.create_heterograph_from_shared_memory(graph_name) g, ntypes, etypes = heterograph_index.create_heterograph_from_shared_memory(graph_name)
if g is None: if g is None:
return None return None
g = DGLHeteroGraph(g, ntypes, etypes) g = DGLGraph(g, ntypes, etypes)
g.ndata['inner_node'] = _get_shared_mem_ndata(g, graph_name, 'inner_node') g.ndata['inner_node'] = _get_shared_mem_ndata(g, graph_name, 'inner_node')
g.ndata[NID] = _get_shared_mem_ndata(g, graph_name, NID) g.ndata[NID] = _get_shared_mem_ndata(g, graph_name, NID)
......
...@@ -484,7 +484,7 @@ def _distributed_access(g, nodes, issue_remote_req, local_access): ...@@ -484,7 +484,7 @@ def _distributed_access(g, nodes, issue_remote_req, local_access):
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
The subgraph that contains the neighborhoods of all input nodes. The subgraph that contains the neighborhoods of all input nodes.
""" """
req_list = [] req_list = []
......
...@@ -30,7 +30,7 @@ class ServerState: ...@@ -30,7 +30,7 @@ class ServerState:
---------- ----------
kv_store : KVServer kv_store : KVServer
reference for KVServer reference for KVServer
graph : DGLHeteroGraph graph : DGLGraph
Graph structure of one partition Graph structure of one partition
total_num_nodes : int total_num_nodes : int
Total number of nodes Total number of nodes
......
...@@ -20,9 +20,9 @@ from . import backend as F ...@@ -20,9 +20,9 @@ from . import backend as F
from .frame import Frame from .frame import Frame
from .view import HeteroNodeView, HeteroNodeDataView, HeteroEdgeView, HeteroEdgeDataView from .view import HeteroNodeView, HeteroNodeDataView, HeteroEdgeView, HeteroEdgeDataView
__all__ = ['DGLHeteroGraph', 'combine_names'] __all__ = ['DGLGraph', 'combine_names']
class DGLHeteroGraph(object): class DGLGraph(object):
"""Class for storing graph structure and node/edge feature data. """Class for storing graph structure and node/edge feature data.
There are a few ways to create a DGLGraph: There are a few ways to create a DGLGraph:
...@@ -66,7 +66,7 @@ class DGLHeteroGraph(object): ...@@ -66,7 +66,7 @@ class DGLHeteroGraph(object):
Otherwise, ``edge_frames[i]`` stores the edge features Otherwise, ``edge_frames[i]`` stores the edge features
of edge type i. (default: None) of edge type i. (default: None)
""" """
if isinstance(gidx, DGLHeteroGraph): if isinstance(gidx, DGLGraph):
raise DGLError('The input is already a DGLGraph. No need to create it again.') raise DGLError('The input is already a DGLGraph. No need to create it again.')
if not isinstance(gidx, heterograph_index.HeteroGraphIndex): if not isinstance(gidx, heterograph_index.HeteroGraphIndex):
dgl_warning('Recommend creating graphs by `dgl.graph(data)`' dgl_warning('Recommend creating graphs by `dgl.graph(data)`'
...@@ -5476,7 +5476,7 @@ class DGLHeteroGraph(object): ...@@ -5476,7 +5476,7 @@ class DGLHeteroGraph(object):
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
Graph on CPU. Graph on CPU.
See Also See Also
...@@ -5614,7 +5614,7 @@ class DGLHeteroGraph(object): ...@@ -5614,7 +5614,7 @@ class DGLHeteroGraph(object):
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
The graph object that is a clone of current graph. The graph object that is a clone of current graph.
""" """
# XXX(minjie): Do a shallow copy first to clone some internal metagraph information. # XXX(minjie): Do a shallow copy first to clone some internal metagraph information.
...@@ -5919,7 +5919,7 @@ class DGLHeteroGraph(object): ...@@ -5919,7 +5919,7 @@ class DGLHeteroGraph(object):
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
Graph in the new ID type. Graph in the new ID type.
""" """
if idtype is None: if idtype is None:
...@@ -5936,7 +5936,7 @@ class DGLHeteroGraph(object): ...@@ -5936,7 +5936,7 @@ class DGLHeteroGraph(object):
def shared_memory(self, name, formats=('coo', 'csr', 'csc')): def shared_memory(self, name, formats=('coo', 'csr', 'csc')):
"""Return a copy of this graph in shared memory, without node data or edge data. """Return a copy of this graph in shared memory, without node data or edge data.
It moves the graph index to shared memory and returns a DGLHeterograph object which It moves the graph index to shared memory and returns a DGLGraph object which
has the same graph structure, node types and edge types but does not contain node data has the same graph structure, node types and edge types but does not contain node data
or edge data. or edge data.
...@@ -5949,7 +5949,7 @@ class DGLHeteroGraph(object): ...@@ -5949,7 +5949,7 @@ class DGLHeteroGraph(object):
Returns Returns
------- -------
HeteroGraph DGLGraph
The graph in shared memory The graph in shared memory
""" """
assert len(name) > 0, "The name of shared memory cannot be empty" assert len(name) > 0, "The name of shared memory cannot be empty"
...@@ -5959,7 +5959,7 @@ class DGLHeteroGraph(object): ...@@ -5959,7 +5959,7 @@ class DGLHeteroGraph(object):
for fmt in formats: for fmt in formats:
assert fmt in ("coo", "csr", "csc"), '{} is not coo, csr or csc'.format(fmt) assert fmt in ("coo", "csr", "csc"), '{} is not coo, csr or csc'.format(fmt)
gidx = self._graph.shared_memory(name, self.ntypes, self.etypes, formats) gidx = self._graph.shared_memory(name, self.ntypes, self.etypes, formats)
return DGLHeteroGraph(gidx, self.ntypes, self.etypes) return DGLGraph(gidx, self.ntypes, self.etypes)
def long(self): def long(self):
...@@ -6374,7 +6374,7 @@ def combine_names(names, ids=None): ...@@ -6374,7 +6374,7 @@ def combine_names(names, ids=None):
selected = sorted([names[i] for i in ids]) selected = sorted([names[i] for i in ids])
return '+'.join(selected) return '+'.join(selected)
class DGLBlock(DGLHeteroGraph): class DGLBlock(DGLGraph):
"""Subclass that signifies the graph is a block created from """Subclass that signifies the graph is a block created from
:func:`dgl.to_block`. :func:`dgl.to_block`.
""" """
...@@ -6465,7 +6465,7 @@ def _create_compute_graph(graph, u, v, eid, recv_nodes=None): ...@@ -6465,7 +6465,7 @@ def _create_compute_graph(graph, u, v, eid, recv_nodes=None):
eframe = graph._edge_frames[0].subframe(eid) eframe = graph._edge_frames[0].subframe(eid)
eframe[EID] = eid eframe[EID] = eid
return DGLHeteroGraph(hgidx, ([srctype], [dsttype]), [etype], return DGLGraph(hgidx, ([srctype], [dsttype]), [etype],
node_frames=[srcframe, dstframe], node_frames=[srcframe, dstframe],
edge_frames=[eframe]), unique_src, unique_dst, eid edge_frames=[eframe]), unique_src, unique_dst, eid
......
...@@ -93,7 +93,7 @@ class HeteroGraphConv(nn.Block): ...@@ -93,7 +93,7 @@ class HeteroGraphConv(nn.Block):
---------- ----------
mods : dict[str, nn.Module] mods : dict[str, nn.Module]
Modules associated with every edge types. The forward function of each Modules associated with every edge types. The forward function of each
module must have a `DGLHeteroGraph` object as the first argument, and module must have a `DGLGraph` object as the first argument, and
its second argument is either a tensor object representing the node its second argument is either a tensor object representing the node
features or a pair of tensor object representing the source and destination features or a pair of tensor object representing the source and destination
node features. node features.
...@@ -146,7 +146,7 @@ class HeteroGraphConv(nn.Block): ...@@ -146,7 +146,7 @@ class HeteroGraphConv(nn.Block):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
Graph data. Graph data.
inputs : dict[str, Tensor] or pair of dict[str, Tensor] inputs : dict[str, Tensor] or pair of dict[str, Tensor]
Input node features. Input node features.
......
...@@ -97,7 +97,7 @@ class HeteroGraphConv(nn.Module): ...@@ -97,7 +97,7 @@ class HeteroGraphConv(nn.Module):
---------- ----------
mods : dict[str, nn.Module] mods : dict[str, nn.Module]
Modules associated with every edge types. The forward function of each Modules associated with every edge types. The forward function of each
module must have a `DGLHeteroGraph` object as the first argument, and module must have a `DGLGraph` object as the first argument, and
its second argument is either a tensor object representing the node its second argument is either a tensor object representing the node
features or a pair of tensor object representing the source and destination features or a pair of tensor object representing the source and destination
node features. node features.
...@@ -163,7 +163,7 @@ class HeteroGraphConv(nn.Module): ...@@ -163,7 +163,7 @@ class HeteroGraphConv(nn.Module):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
Graph data. Graph data.
inputs : dict[str, Tensor] or pair of dict[str, Tensor] inputs : dict[str, Tensor] or pair of dict[str, Tensor]
Input node features. Input node features.
......
...@@ -100,7 +100,7 @@ class HeteroGraphConv(layers.Layer): ...@@ -100,7 +100,7 @@ class HeteroGraphConv(layers.Layer):
---------- ----------
mods : dict[str, nn.Module] mods : dict[str, nn.Module]
Modules associated with every edge types. The forward function of each Modules associated with every edge types. The forward function of each
module must have a `DGLHeteroGraph` object as the first argument, and module must have a `DGLGraph` object as the first argument, and
its second argument is either a tensor object representing the node its second argument is either a tensor object representing the node
features or a pair of tensor object representing the source and destination features or a pair of tensor object representing the source and destination
node features. node features.
...@@ -150,7 +150,7 @@ class HeteroGraphConv(layers.Layer): ...@@ -150,7 +150,7 @@ class HeteroGraphConv(layers.Layer):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
Graph data. Graph data.
inputs : dict[str, Tensor] or pair of dict[str, Tensor] inputs : dict[str, Tensor] or pair of dict[str, Tensor]
Input node features. Input node features.
......
...@@ -106,7 +106,7 @@ def _gen_sddmm_func(lhs_target, rhs_target, binary_op): ...@@ -106,7 +106,7 @@ def _gen_sddmm_func(lhs_target, rhs_target, binary_op):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
The input graph The input graph
x : tensor x : tensor
The {lhs} features. The {lhs} features.
...@@ -157,7 +157,7 @@ def copy_u(g, x): ...@@ -157,7 +157,7 @@ def copy_u(g, x):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
The input graph. The input graph.
x : tensor x : tensor
The source node features. The source node features.
...@@ -179,7 +179,7 @@ def copy_v(g, x): ...@@ -179,7 +179,7 @@ def copy_v(g, x):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
The input graph. The input graph.
x : tensor x : tensor
The destination node features. The destination node features.
......
...@@ -143,7 +143,7 @@ def _gen_spmm_func(binary_op, reduce_op): ...@@ -143,7 +143,7 @@ def _gen_spmm_func(binary_op, reduce_op):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
The input graph The input graph
x : tensor x : tensor
The source node features. The source node features.
...@@ -191,7 +191,7 @@ def _gen_copy_reduce_func(binary_op, reduce_op): ...@@ -191,7 +191,7 @@ def _gen_copy_reduce_func(binary_op, reduce_op):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
The input graph The input graph
x : tensor x : tensor
The {} features. The {} features.
......
...@@ -9,7 +9,7 @@ from . import backend as F ...@@ -9,7 +9,7 @@ from . import backend as F
from . import utils from . import utils
from ._ffi.function import _init_api from ._ffi.function import _init_api
from .base import EID, ETYPE, NID, NTYPE from .base import EID, ETYPE, NID, NTYPE
from .heterograph import DGLHeteroGraph from .heterograph import DGLGraph
from .ndarray import NDArray from .ndarray import NDArray
from .subgraph import edge_subgraph from .subgraph import edge_subgraph
...@@ -49,7 +49,7 @@ def reorder_nodes(g, new_node_ids): ...@@ -49,7 +49,7 @@ def reorder_nodes(g, new_node_ids):
new_gidx = _CAPI_DGLReorderGraph_Hetero( new_gidx = _CAPI_DGLReorderGraph_Hetero(
g._graph, new_node_ids.todgltensor() g._graph, new_node_ids.todgltensor()
) )
new_g = DGLHeteroGraph(gidx=new_gidx, ntypes=["_N"], etypes=["_E"]) new_g = DGLGraph(gidx=new_gidx, ntypes=["_N"], etypes=["_E"])
new_g.ndata["orig_id"] = idx new_g.ndata["orig_id"] = idx
return new_g return new_g
...@@ -211,7 +211,7 @@ def partition_graph_with_halo(g, node_part, extra_cached_hops, reshuffle=False): ...@@ -211,7 +211,7 @@ def partition_graph_with_halo(g, node_part, extra_cached_hops, reshuffle=False):
# This creaets a subgraph from subgraphs returned from the CAPI above. # This creaets a subgraph from subgraphs returned from the CAPI above.
def create_subgraph(subg, induced_nodes, induced_edges, inner_node): def create_subgraph(subg, induced_nodes, induced_edges, inner_node):
subg1 = DGLHeteroGraph(gidx=subg.graph, ntypes=["_N"], etypes=["_E"]) subg1 = DGLGraph(gidx=subg.graph, ntypes=["_N"], etypes=["_E"])
# If IDs are shuffled, we should shuffled edges. This will help us collect edge data # If IDs are shuffled, we should shuffled edges. This will help us collect edge data
# from the distributed graph after training. # from the distributed graph after training.
if reshuffle: if reshuffle:
...@@ -325,7 +325,7 @@ def metis_partition_assignment( ...@@ -325,7 +325,7 @@ def metis_partition_assignment(
# The METIS runs on the symmetric graph to generate the node assignment to partitions. # The METIS runs on the symmetric graph to generate the node assignment to partitions.
start = time.time() start = time.time()
sym_gidx = _CAPI_DGLMakeSymmetric_Hetero(g._graph) sym_gidx = _CAPI_DGLMakeSymmetric_Hetero(g._graph)
sym_g = DGLHeteroGraph(gidx=sym_gidx) sym_g = DGLGraph(gidx=sym_gidx)
print( print(
"Convert a graph into a bidirected graph: {:.3f} seconds, peak memory: {:.3f} GB".format( "Convert a graph into a bidirected graph: {:.3f} seconds, peak memory: {:.3f} GB".format(
time.time() - start, get_peak_mem() time.time() - start, get_peak_mem()
......
...@@ -3,7 +3,7 @@ from __future__ import absolute_import ...@@ -3,7 +3,7 @@ from __future__ import absolute_import
from . import backend as F from . import backend as F
from . import traversal as trv from . import traversal as trv
from .heterograph import DGLHeteroGraph from .heterograph import DGLGraph
__all__ = [ __all__ = [
"prop_nodes", "prop_nodes",
...@@ -84,7 +84,7 @@ def prop_nodes_bfs( ...@@ -84,7 +84,7 @@ def prop_nodes_bfs(
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
The graph object. The graph object.
source : list, tensor of nodes source : list, tensor of nodes
Source nodes. Source nodes.
...@@ -102,8 +102,8 @@ def prop_nodes_bfs( ...@@ -102,8 +102,8 @@ def prop_nodes_bfs(
dgl.traversal.bfs_nodes_generator dgl.traversal.bfs_nodes_generator
""" """
assert isinstance( assert isinstance(
graph, DGLHeteroGraph graph, DGLGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph" ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert ( assert (
len(graph.canonical_etypes) == 1 len(graph.canonical_etypes) == 1
), "prop_nodes_bfs only support homogeneous graph" ), "prop_nodes_bfs only support homogeneous graph"
...@@ -122,7 +122,7 @@ def prop_nodes_topo( ...@@ -122,7 +122,7 @@ def prop_nodes_topo(
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
The graph object. The graph object.
message_func : callable message_func : callable
The message function. The message function.
...@@ -138,8 +138,8 @@ def prop_nodes_topo( ...@@ -138,8 +138,8 @@ def prop_nodes_topo(
dgl.traversal.topological_nodes_generator dgl.traversal.topological_nodes_generator
""" """
assert isinstance( assert isinstance(
graph, DGLHeteroGraph graph, DGLGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph" ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert ( assert (
len(graph.canonical_etypes) == 1 len(graph.canonical_etypes) == 1
), "prop_nodes_topo only support homogeneous graph" ), "prop_nodes_topo only support homogeneous graph"
...@@ -165,7 +165,7 @@ def prop_edges_dfs( ...@@ -165,7 +165,7 @@ def prop_edges_dfs(
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
The graph object. The graph object.
source : list, tensor of nodes source : list, tensor of nodes
Source nodes. Source nodes.
...@@ -187,8 +187,8 @@ def prop_edges_dfs( ...@@ -187,8 +187,8 @@ def prop_edges_dfs(
dgl.traversal.dfs_labeled_edges_generator dgl.traversal.dfs_labeled_edges_generator
""" """
assert isinstance( assert isinstance(
graph, DGLHeteroGraph graph, DGLGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph" ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert ( assert (
len(graph.canonical_etypes) == 1 len(graph.canonical_etypes) == 1
), "prop_edges_dfs only support homogeneous graph" ), "prop_edges_dfs only support homogeneous graph"
......
...@@ -5,7 +5,7 @@ from numpy.polynomial import polynomial ...@@ -5,7 +5,7 @@ from numpy.polynomial import polynomial
from .. import backend as F from .. import backend as F
from .. import utils from .. import utils
from .._ffi.function import _init_api from .._ffi.function import _init_api
from ..heterograph import DGLHeteroGraph from ..heterograph import DGLGraph
__all__ = ["global_uniform_negative_sampling"] __all__ = ["global_uniform_negative_sampling"]
...@@ -120,7 +120,7 @@ def global_uniform_negative_sampling( ...@@ -120,7 +120,7 @@ def global_uniform_negative_sampling(
return F.from_dgl_nd(src), F.from_dgl_nd(dst) return F.from_dgl_nd(src), F.from_dgl_nd(dst)
DGLHeteroGraph.global_uniform_negative_sampling = utils.alias_func( DGLGraph.global_uniform_negative_sampling = utils.alias_func(
global_uniform_negative_sampling global_uniform_negative_sampling
) )
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
from .._ffi.function import _init_api from .._ffi.function import _init_api
from .. import backend as F from .. import backend as F
from ..base import DGLError, EID from ..base import DGLError, EID
from ..heterograph import DGLHeteroGraph from ..heterograph import DGLGraph
from .. import ndarray as nd from .. import ndarray as nd
from .. import utils from .. import utils
from .utils import EidExcluder from .utils import EidExcluder
...@@ -157,7 +157,7 @@ def sample_etype_neighbors( ...@@ -157,7 +157,7 @@ def sample_etype_neighbors(
g._graph, nodes, etype_offset, fanout, edge_dir, prob_array, g._graph, nodes, etype_offset, fanout, edge_dir, prob_array,
replace, etype_sorted) replace, etype_sorted)
induced_edges = subgidx.induced_edges induced_edges = subgidx.induced_edges
ret = DGLHeteroGraph(subgidx.graph, g.ntypes, g.etypes) ret = DGLGraph(subgidx.graph, g.ntypes, g.etypes)
# handle features # handle features
# (TODO) (BarclayII) DGL distributed fails with bus error, freezes, or other # (TODO) (BarclayII) DGL distributed fails with bus error, freezes, or other
...@@ -178,7 +178,7 @@ def sample_etype_neighbors( ...@@ -178,7 +178,7 @@ def sample_etype_neighbors(
return ret if output_device is None else ret.to(output_device) return ret if output_device is None else ret.to(output_device)
DGLHeteroGraph.sample_etype_neighbors = utils.alias_func(sample_etype_neighbors) DGLGraph.sample_etype_neighbors = utils.alias_func(sample_etype_neighbors)
def sample_neighbors(g, nodes, fanout, edge_dir='in', prob=None, def sample_neighbors(g, nodes, fanout, edge_dir='in', prob=None,
replace=False, copy_ndata=True, copy_edata=True, replace=False, copy_ndata=True, copy_edata=True,
...@@ -388,7 +388,7 @@ def _sample_neighbors(g, nodes, fanout, edge_dir='in', prob=None, ...@@ -388,7 +388,7 @@ def _sample_neighbors(g, nodes, fanout, edge_dir='in', prob=None,
g._graph, nodes_all_types, fanout_array, edge_dir, prob_arrays, g._graph, nodes_all_types, fanout_array, edge_dir, prob_arrays,
excluded_edges_all_t, replace) excluded_edges_all_t, replace)
induced_edges = subgidx.induced_edges induced_edges = subgidx.induced_edges
ret = DGLHeteroGraph(subgidx.graph, g.ntypes, g.etypes) ret = DGLGraph(subgidx.graph, g.ntypes, g.etypes)
# handle features # handle features
# (TODO) (BarclayII) DGL distributed fails with bus error, freezes, or other # (TODO) (BarclayII) DGL distributed fails with bus error, freezes, or other
...@@ -409,7 +409,7 @@ def _sample_neighbors(g, nodes, fanout, edge_dir='in', prob=None, ...@@ -409,7 +409,7 @@ def _sample_neighbors(g, nodes, fanout, edge_dir='in', prob=None,
return ret return ret
DGLHeteroGraph.sample_neighbors = utils.alias_func(sample_neighbors) DGLGraph.sample_neighbors = utils.alias_func(sample_neighbors)
def sample_neighbors_biased(g, nodes, fanout, bias, edge_dir='in', def sample_neighbors_biased(g, nodes, fanout, bias, edge_dir='in',
tag_offset_name='_TAG_OFFSET', replace=False, tag_offset_name='_TAG_OFFSET', replace=False,
...@@ -568,7 +568,7 @@ def sample_neighbors_biased(g, nodes, fanout, bias, edge_dir='in', ...@@ -568,7 +568,7 @@ def sample_neighbors_biased(g, nodes, fanout, bias, edge_dir='in',
subgidx = _CAPI_DGLSampleNeighborsBiased(g._graph, nodes_array, fanout, bias_array, subgidx = _CAPI_DGLSampleNeighborsBiased(g._graph, nodes_array, fanout, bias_array,
tag_offset_array, edge_dir, replace) tag_offset_array, edge_dir, replace)
induced_edges = subgidx.induced_edges induced_edges = subgidx.induced_edges
ret = DGLHeteroGraph(subgidx.graph, g.ntypes, g.etypes) ret = DGLGraph(subgidx.graph, g.ntypes, g.etypes)
if copy_ndata: if copy_ndata:
node_frames = utils.extract_node_subframes(g, device) node_frames = utils.extract_node_subframes(g, device)
...@@ -581,7 +581,7 @@ def sample_neighbors_biased(g, nodes, fanout, bias, edge_dir='in', ...@@ -581,7 +581,7 @@ def sample_neighbors_biased(g, nodes, fanout, bias, edge_dir='in',
ret.edata[EID] = induced_edges[0] ret.edata[EID] = induced_edges[0]
return ret if output_device is None else ret.to(output_device) return ret if output_device is None else ret.to(output_device)
DGLHeteroGraph.sample_neighbors_biased = utils.alias_func(sample_neighbors_biased) DGLGraph.sample_neighbors_biased = utils.alias_func(sample_neighbors_biased)
def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False, def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False,
copy_ndata=True, copy_edata=True, output_device=None): copy_ndata=True, copy_edata=True, output_device=None):
...@@ -705,7 +705,7 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False, ...@@ -705,7 +705,7 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False,
subgidx = _CAPI_DGLSampleNeighborsTopk( subgidx = _CAPI_DGLSampleNeighborsTopk(
g._graph, nodes_all_types, k_array, edge_dir, weight_arrays, bool(ascending)) g._graph, nodes_all_types, k_array, edge_dir, weight_arrays, bool(ascending))
induced_edges = subgidx.induced_edges induced_edges = subgidx.induced_edges
ret = DGLHeteroGraph(subgidx.graph, g.ntypes, g.etypes) ret = DGLGraph(subgidx.graph, g.ntypes, g.etypes)
# handle features # handle features
if copy_ndata: if copy_ndata:
...@@ -717,6 +717,6 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False, ...@@ -717,6 +717,6 @@ def select_topk(g, k, weight, nodes=None, edge_dir='in', ascending=False,
utils.set_new_frames(ret, edge_frames=edge_frames) utils.set_new_frames(ret, edge_frames=edge_frames)
return ret if output_device is None else ret.to(output_device) return ret if output_device is None else ret.to(output_device)
DGLHeteroGraph.select_topk = utils.alias_func(select_topk) DGLGraph.select_topk = utils.alias_func(select_topk)
_init_api('dgl.sampling.neighbor', __name__) _init_api('dgl.sampling.neighbor', __name__)
...@@ -9,7 +9,7 @@ from . import backend as F ...@@ -9,7 +9,7 @@ from . import backend as F
from . import graph_index, heterograph_index, utils from . import graph_index, heterograph_index, utils
from ._ffi.function import _init_api from ._ffi.function import _init_api
from .base import DGLError, dgl_warning from .base import DGLError, dgl_warning
from .heterograph import DGLHeteroGraph from .heterograph import DGLGraph
from .utils import context_of, recursive_apply from .utils import context_of, recursive_apply
__all__ = [ __all__ = [
...@@ -173,7 +173,7 @@ def node_subgraph( ...@@ -173,7 +173,7 @@ def node_subgraph(
return subg if output_device is None else subg.to(output_device) return subg if output_device is None else subg.to(output_device)
DGLHeteroGraph.subgraph = utils.alias_func(node_subgraph) DGLGraph.subgraph = utils.alias_func(node_subgraph)
def edge_subgraph( def edge_subgraph(
...@@ -346,7 +346,7 @@ def edge_subgraph( ...@@ -346,7 +346,7 @@ def edge_subgraph(
return subg if output_device is None else subg.to(output_device) return subg if output_device is None else subg.to(output_device)
DGLHeteroGraph.edge_subgraph = utils.alias_func(edge_subgraph) DGLGraph.edge_subgraph = utils.alias_func(edge_subgraph)
def in_subgraph( def in_subgraph(
...@@ -484,7 +484,7 @@ def in_subgraph( ...@@ -484,7 +484,7 @@ def in_subgraph(
return subg if output_device is None else subg.to(output_device) return subg if output_device is None else subg.to(output_device)
DGLHeteroGraph.in_subgraph = utils.alias_func(in_subgraph) DGLGraph.in_subgraph = utils.alias_func(in_subgraph)
def out_subgraph( def out_subgraph(
...@@ -622,7 +622,7 @@ def out_subgraph( ...@@ -622,7 +622,7 @@ def out_subgraph(
return subg if output_device is None else subg.to(output_device) return subg if output_device is None else subg.to(output_device)
DGLHeteroGraph.out_subgraph = utils.alias_func(out_subgraph) DGLGraph.out_subgraph = utils.alias_func(out_subgraph)
def khop_in_subgraph( def khop_in_subgraph(
...@@ -807,7 +807,7 @@ def khop_in_subgraph( ...@@ -807,7 +807,7 @@ def khop_in_subgraph(
return sub_g return sub_g
DGLHeteroGraph.khop_in_subgraph = utils.alias_func(khop_in_subgraph) DGLGraph.khop_in_subgraph = utils.alias_func(khop_in_subgraph)
def khop_out_subgraph( def khop_out_subgraph(
...@@ -992,7 +992,7 @@ def khop_out_subgraph( ...@@ -992,7 +992,7 @@ def khop_out_subgraph(
return sub_g return sub_g
DGLHeteroGraph.khop_out_subgraph = utils.alias_func(khop_out_subgraph) DGLGraph.khop_out_subgraph = utils.alias_func(khop_out_subgraph)
def node_type_subgraph(graph, ntypes, output_device=None): def node_type_subgraph(graph, ntypes, output_device=None):
...@@ -1073,7 +1073,7 @@ def node_type_subgraph(graph, ntypes, output_device=None): ...@@ -1073,7 +1073,7 @@ def node_type_subgraph(graph, ntypes, output_device=None):
return edge_type_subgraph(graph, etypes, output_device=output_device) return edge_type_subgraph(graph, etypes, output_device=output_device)
DGLHeteroGraph.node_type_subgraph = utils.alias_func(node_type_subgraph) DGLGraph.node_type_subgraph = utils.alias_func(node_type_subgraph)
def edge_type_subgraph(graph, etypes, output_device=None): def edge_type_subgraph(graph, etypes, output_device=None):
...@@ -1178,13 +1178,13 @@ def edge_type_subgraph(graph, etypes, output_device=None): ...@@ -1178,13 +1178,13 @@ def edge_type_subgraph(graph, etypes, output_device=None):
rel_graphs, rel_graphs,
utils.toindex(num_nodes_per_induced_type, "int64"), utils.toindex(num_nodes_per_induced_type, "int64"),
) )
hg = DGLHeteroGraph( hg = DGLGraph(
hgidx, induced_ntypes, induced_etypes, node_frames, edge_frames hgidx, induced_ntypes, induced_etypes, node_frames, edge_frames
) )
return hg if output_device is None else hg.to(output_device) return hg if output_device is None else hg.to(output_device)
DGLHeteroGraph.edge_type_subgraph = utils.alias_func(edge_type_subgraph) DGLGraph.edge_type_subgraph = utils.alias_func(edge_type_subgraph)
#################### Internal functions #################### #################### Internal functions ####################
...@@ -1233,7 +1233,7 @@ def _create_hetero_subgraph( ...@@ -1233,7 +1233,7 @@ def _create_hetero_subgraph(
edge_frames = utils.extract_edge_subframes( edge_frames = utils.extract_edge_subframes(
parent, induced_edges_or_device, store_ids parent, induced_edges_or_device, store_ids
) )
hsg = DGLHeteroGraph(sgi.graph, parent.ntypes, parent.etypes) hsg = DGLGraph(sgi.graph, parent.ntypes, parent.etypes)
utils.set_new_frames(hsg, node_frames=node_frames, edge_frames=edge_frames) utils.set_new_frames(hsg, node_frames=node_frames, edge_frames=edge_frames)
return hsg return hsg
......
...@@ -30,7 +30,7 @@ except ImportError: ...@@ -30,7 +30,7 @@ except ImportError:
from .._ffi.function import _init_api from .._ffi.function import _init_api
from ..base import dgl_warning, DGLError, NID, EID from ..base import dgl_warning, DGLError, NID, EID
from .. import convert from .. import convert
from ..heterograph import DGLHeteroGraph, DGLBlock from ..heterograph import DGLGraph, DGLBlock
from ..heterograph_index import create_metagraph_index, create_heterograph_from_relations from ..heterograph_index import create_metagraph_index, create_heterograph_from_relations
from ..frame import Frame from ..frame import Frame
from .. import ndarray as nd from .. import ndarray as nd
...@@ -68,13 +68,11 @@ __all__ = [ ...@@ -68,13 +68,11 @@ __all__ = [
'to_block', 'to_block',
'to_simple', 'to_simple',
'to_simple_graph', 'to_simple_graph',
'as_immutable_graph',
'sort_csr_by_tag', 'sort_csr_by_tag',
'sort_csc_by_tag', 'sort_csc_by_tag',
'metis_partition_assignment', 'metis_partition_assignment',
'partition_graph_with_halo', 'partition_graph_with_halo',
'metis_partition', 'metis_partition',
'as_heterograph',
'adj_product_graph', 'adj_product_graph',
'adj_sum_graph', 'adj_sum_graph',
'reorder_graph', 'reorder_graph',
...@@ -1034,7 +1032,7 @@ def line_graph(g, backtracking=True, shared=False): ...@@ -1034,7 +1032,7 @@ def line_graph(g, backtracking=True, shared=False):
'only homogeneous graph is supported' 'only homogeneous graph is supported'
dev = g.device dev = g.device
lg = DGLHeteroGraph(_CAPI_DGLHeteroLineGraph(g._graph.copy_to(nd.cpu()), backtracking)) lg = DGLGraph(_CAPI_DGLHeteroLineGraph(g._graph.copy_to(nd.cpu()), backtracking))
lg = lg.to(dev) lg = lg.to(dev)
if shared: if shared:
new_frames = utils.extract_edge_subframes(g, None) new_frames = utils.extract_edge_subframes(g, None)
...@@ -1042,7 +1040,7 @@ def line_graph(g, backtracking=True, shared=False): ...@@ -1042,7 +1040,7 @@ def line_graph(g, backtracking=True, shared=False):
return lg return lg
DGLHeteroGraph.line_graph = utils.alias_func(line_graph) DGLGraph.line_graph = utils.alias_func(line_graph)
def khop_adj(g, k): def khop_adj(g, k):
"""Return the matrix of :math:`A^k` where :math:`A` is the adjacency matrix of the graph """Return the matrix of :math:`A^k` where :math:`A` is the adjacency matrix of the graph
...@@ -1276,7 +1274,7 @@ def reverse(g, copy_ndata=True, copy_edata=False, *, share_ndata=None, share_eda ...@@ -1276,7 +1274,7 @@ def reverse(g, copy_ndata=True, copy_edata=False, *, share_ndata=None, share_eda
# currently reversing a block results in undefined behavior # currently reversing a block results in undefined behavior
raise DGLError('Reversing a block graph is not supported.') raise DGLError('Reversing a block graph is not supported.')
gidx = g._graph.reverse() gidx = g._graph.reverse()
new_g = DGLHeteroGraph(gidx, g.ntypes, g.etypes) new_g = DGLGraph(gidx, g.ntypes, g.etypes)
# handle ndata # handle ndata
if copy_ndata: if copy_ndata:
...@@ -1293,7 +1291,7 @@ def reverse(g, copy_ndata=True, copy_edata=False, *, share_ndata=None, share_eda ...@@ -1293,7 +1291,7 @@ def reverse(g, copy_ndata=True, copy_edata=False, *, share_ndata=None, share_eda
return new_g return new_g
DGLHeteroGraph.reverse = utils.alias_func(reverse) DGLGraph.reverse = utils.alias_func(reverse)
def to_simple_graph(g): def to_simple_graph(g):
"""Convert the graph to a simple graph with no multi-edge. """Convert the graph to a simple graph with no multi-edge.
...@@ -1959,7 +1957,7 @@ def add_self_loop(g, edge_feat_names=None, fill_data=1., etype=None): ...@@ -1959,7 +1957,7 @@ def add_self_loop(g, edge_feat_names=None, fill_data=1., etype=None):
new_g = add_edges(g, nodes, nodes, etype=etype) new_g = add_edges(g, nodes, nodes, etype=etype)
return new_g return new_g
DGLHeteroGraph.add_self_loop = utils.alias_func(add_self_loop) DGLGraph.add_self_loop = utils.alias_func(add_self_loop)
def remove_self_loop(g, etype=None): def remove_self_loop(g, etype=None):
r""" Remove self-loops for each node in the graph and return a new graph. r""" Remove self-loops for each node in the graph and return a new graph.
...@@ -2034,7 +2032,7 @@ def remove_self_loop(g, etype=None): ...@@ -2034,7 +2032,7 @@ def remove_self_loop(g, etype=None):
new_g = remove_edges(g, self_loop_eids, etype=etype) new_g = remove_edges(g, self_loop_eids, etype=etype)
return new_g return new_g
DGLHeteroGraph.remove_self_loop = utils.alias_func(remove_self_loop) DGLGraph.remove_self_loop = utils.alias_func(remove_self_loop)
def compact_graphs(graphs, always_preserve=None, copy_ndata=True, copy_edata=True): def compact_graphs(graphs, always_preserve=None, copy_ndata=True, copy_edata=True):
"""Given a list of graphs with the same set of nodes, find and eliminate the common """Given a list of graphs with the same set of nodes, find and eliminate the common
...@@ -2192,7 +2190,7 @@ def compact_graphs(graphs, always_preserve=None, copy_ndata=True, copy_edata=Tru ...@@ -2192,7 +2190,7 @@ def compact_graphs(graphs, always_preserve=None, copy_ndata=True, copy_edata=Tru
induced_nodes = [F.from_dgl_nd(nodes) for nodes in induced_nodes] induced_nodes = [F.from_dgl_nd(nodes) for nodes in induced_nodes]
new_graphs = [ new_graphs = [
DGLHeteroGraph(new_graph_index, graph.ntypes, graph.etypes) DGLGraph(new_graph_index, graph.ntypes, graph.etypes)
for new_graph_index, graph in zip(new_graph_indexes, graphs)] for new_graph_index, graph in zip(new_graph_indexes, graphs)]
if copy_ndata: if copy_ndata:
...@@ -2616,7 +2614,7 @@ def to_simple(g, ...@@ -2616,7 +2614,7 @@ def to_simple(g,
if g.is_block: if g.is_block:
raise DGLError('Cannot convert a block graph to a simple graph.') raise DGLError('Cannot convert a block graph to a simple graph.')
simple_graph_index, counts, edge_maps = _CAPI_DGLToSimpleHetero(g._graph) simple_graph_index, counts, edge_maps = _CAPI_DGLToSimpleHetero(g._graph)
simple_graph = DGLHeteroGraph(simple_graph_index, g.ntypes, g.etypes) simple_graph = DGLGraph(simple_graph_index, g.ntypes, g.etypes)
counts = [F.from_dgl_nd(count) for count in counts] counts = [F.from_dgl_nd(count) for count in counts]
edge_maps = [F.from_dgl_nd(edge_map) for edge_map in edge_maps] edge_maps = [F.from_dgl_nd(edge_map) for edge_map in edge_maps]
...@@ -2644,7 +2642,7 @@ def to_simple(g, ...@@ -2644,7 +2642,7 @@ def to_simple(g,
return simple_graph return simple_graph
DGLHeteroGraph.to_simple = utils.alias_func(to_simple) DGLGraph.to_simple = utils.alias_func(to_simple)
def _unitgraph_less_than_int32(g): def _unitgraph_less_than_int32(g):
"""Check if a graph with only one edge type has more than 2 ** 31 - 1 """Check if a graph with only one edge type has more than 2 ** 31 - 1
...@@ -2789,7 +2787,7 @@ def adj_product_graph(A, B, weight_name, etype='_E'): ...@@ -2789,7 +2787,7 @@ def adj_product_graph(A, B, weight_name, etype='_E'):
C_gidx = create_heterograph_from_relations( C_gidx = create_heterograph_from_relations(
C_metagraph, [C_gidx], utils.toindex(num_nodes_per_type)) C_metagraph, [C_gidx], utils.toindex(num_nodes_per_type))
C = DGLHeteroGraph(C_gidx, ntypes, etypes) C = DGLGraph(C_gidx, ntypes, etypes)
C.edata[weight_name] = C_weights C.edata[weight_name] = C_weights
return C return C
...@@ -2890,29 +2888,10 @@ def adj_sum_graph(graphs, weight_name): ...@@ -2890,29 +2888,10 @@ def adj_sum_graph(graphs, weight_name):
C_gidx, C_weights = F.csrsum(gidxs, weights) C_gidx, C_weights = F.csrsum(gidxs, weights)
C_gidx = create_heterograph_from_relations(metagraph, [C_gidx], num_nodes) C_gidx = create_heterograph_from_relations(metagraph, [C_gidx], num_nodes)
C = DGLHeteroGraph(C_gidx, graphs[0].ntypes, graphs[0].etypes) C = DGLGraph(C_gidx, graphs[0].ntypes, graphs[0].etypes)
C.edata[weight_name] = C_weights C.edata[weight_name] = C_weights
return C return C
def as_heterograph(g, ntype='_U', etype='_E'): # pylint: disable=unused-argument
"""Convert a DGLGraph to a DGLHeteroGraph with one node and edge type.
DEPRECATED: DGLGraph and DGLHeteroGraph have been merged. This function will
do nothing and can be removed safely in all cases.
"""
dgl_warning('DEPRECATED: DGLGraph and DGLHeteroGraph have been merged in v0.5.\n'
'\tdgl.as_heterograph will do nothing and can be removed safely in all cases.')
return g
def as_immutable_graph(hg):
"""Convert a DGLHeteroGraph with one node and edge type into a DGLGraph.
DEPRECATED: DGLGraph and DGLHeteroGraph have been merged. This function will
do nothing and can be removed safely in all cases.
"""
dgl_warning('DEPRECATED: DGLGraph and DGLHeteroGraph have been merged in v0.5.\n'
'\tdgl.as_immutable_graph will do nothing and can be removed safely in all cases.')
return hg
def sort_csr_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'): def sort_csr_by_tag(g, tag, tag_offset_name='_TAG_OFFSET', tag_type='node'):
r"""Return a new graph whose CSR matrix is sorted by the given tag. r"""Return a new graph whose CSR matrix is sorted by the given tag.
...@@ -3398,7 +3377,7 @@ def reorder_graph(g, node_permute_algo=None, edge_permute_algo='src', ...@@ -3398,7 +3377,7 @@ def reorder_graph(g, node_permute_algo=None, edge_permute_algo='src',
return rg return rg
DGLHeteroGraph.reorder_graph = utils.alias_func(reorder_graph) DGLGraph.reorder_graph = utils.alias_func(reorder_graph)
def metis_perm(g, k): def metis_perm(g, k):
...@@ -3750,7 +3729,7 @@ def to_half(g): ...@@ -3750,7 +3729,7 @@ def to_half(g):
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
Clone of graph with the feature data converted to float16. Clone of graph with the feature data converted to float16.
""" """
ret = copy.copy(g) ret = copy.copy(g)
...@@ -3767,7 +3746,7 @@ def to_float(g): ...@@ -3767,7 +3746,7 @@ def to_float(g):
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
Clone of graph with the feature data converted to float32. Clone of graph with the feature data converted to float32.
""" """
ret = copy.copy(g) ret = copy.copy(g)
...@@ -3784,7 +3763,7 @@ def to_double(g): ...@@ -3784,7 +3763,7 @@ def to_double(g):
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
Clone of graph with the feature data converted to float64. Clone of graph with the feature data converted to float64.
""" """
ret = copy.copy(g) ret = copy.copy(g)
......
...@@ -4,7 +4,7 @@ from __future__ import absolute_import ...@@ -4,7 +4,7 @@ from __future__ import absolute_import
from . import backend as F from . import backend as F
from . import utils from . import utils
from ._ffi.function import _init_api from ._ffi.function import _init_api
from .heterograph import DGLHeteroGraph from .heterograph import DGLGraph
__all__ = [ __all__ = [
"bfs_nodes_generator", "bfs_nodes_generator",
...@@ -20,7 +20,7 @@ def bfs_nodes_generator(graph, source, reverse=False): ...@@ -20,7 +20,7 @@ def bfs_nodes_generator(graph, source, reverse=False):
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
The graph object. The graph object.
source : list, tensor of nodes source : list, tensor of nodes
Source nodes. Source nodes.
...@@ -46,8 +46,8 @@ def bfs_nodes_generator(graph, source, reverse=False): ...@@ -46,8 +46,8 @@ def bfs_nodes_generator(graph, source, reverse=False):
[tensor([0]), tensor([1]), tensor([2, 3]), tensor([4, 5])] [tensor([0]), tensor([1]), tensor([2, 3]), tensor([4, 5])]
""" """
assert isinstance( assert isinstance(
graph, DGLHeteroGraph graph, DGLGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph" ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert ( assert (
len(graph.canonical_etypes) == 1 len(graph.canonical_etypes) == 1
), "bfs_nodes_generator only support homogeneous graph" ), "bfs_nodes_generator only support homogeneous graph"
...@@ -67,7 +67,7 @@ def bfs_edges_generator(graph, source, reverse=False): ...@@ -67,7 +67,7 @@ def bfs_edges_generator(graph, source, reverse=False):
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
The graph object. The graph object.
source : list, tensor of nodes source : list, tensor of nodes
Source nodes. Source nodes.
...@@ -94,8 +94,8 @@ def bfs_edges_generator(graph, source, reverse=False): ...@@ -94,8 +94,8 @@ def bfs_edges_generator(graph, source, reverse=False):
[tensor([0]), tensor([1, 2]), tensor([4, 5])] [tensor([0]), tensor([1, 2]), tensor([4, 5])]
""" """
assert isinstance( assert isinstance(
graph, DGLHeteroGraph graph, DGLGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph" ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert ( assert (
len(graph.canonical_etypes) == 1 len(graph.canonical_etypes) == 1
), "bfs_edges_generator only support homogeneous graph" ), "bfs_edges_generator only support homogeneous graph"
...@@ -115,7 +115,7 @@ def topological_nodes_generator(graph, reverse=False): ...@@ -115,7 +115,7 @@ def topological_nodes_generator(graph, reverse=False):
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
The graph object. The graph object.
reverse : bool, optional reverse : bool, optional
If True, traverse following the in-edge direction. If True, traverse following the in-edge direction.
...@@ -139,8 +139,8 @@ def topological_nodes_generator(graph, reverse=False): ...@@ -139,8 +139,8 @@ def topological_nodes_generator(graph, reverse=False):
[tensor([0]), tensor([1]), tensor([2]), tensor([3, 4]), tensor([5])] [tensor([0]), tensor([1]), tensor([2]), tensor([3, 4]), tensor([5])]
""" """
assert isinstance( assert isinstance(
graph, DGLHeteroGraph graph, DGLGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph" ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert ( assert (
len(graph.canonical_etypes) == 1 len(graph.canonical_etypes) == 1
), "topological_nodes_generator only support homogeneous graph" ), "topological_nodes_generator only support homogeneous graph"
...@@ -163,7 +163,7 @@ def dfs_edges_generator(graph, source, reverse=False): ...@@ -163,7 +163,7 @@ def dfs_edges_generator(graph, source, reverse=False):
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
The graph object. The graph object.
source : list, tensor of nodes source : list, tensor of nodes
Source nodes. Source nodes.
...@@ -191,8 +191,8 @@ def dfs_edges_generator(graph, source, reverse=False): ...@@ -191,8 +191,8 @@ def dfs_edges_generator(graph, source, reverse=False):
[tensor([0]), tensor([1]), tensor([3]), tensor([5]), tensor([4])] [tensor([0]), tensor([1]), tensor([3]), tensor([5]), tensor([4])]
""" """
assert isinstance( assert isinstance(
graph, DGLHeteroGraph graph, DGLGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph" ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert ( assert (
len(graph.canonical_etypes) == 1 len(graph.canonical_etypes) == 1
), "dfs_edges_generator only support homogeneous graph" ), "dfs_edges_generator only support homogeneous graph"
...@@ -234,7 +234,7 @@ def dfs_labeled_edges_generator( ...@@ -234,7 +234,7 @@ def dfs_labeled_edges_generator(
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
The graph object. The graph object.
source : list, tensor of nodes source : list, tensor of nodes
Source nodes. Source nodes.
...@@ -271,8 +271,8 @@ def dfs_labeled_edges_generator( ...@@ -271,8 +271,8 @@ def dfs_labeled_edges_generator(
(tensor([0]), tensor([0]), tensor([0]), tensor([0]), tensor([0]), tensor([2])) (tensor([0]), tensor([0]), tensor([0]), tensor([0]), tensor([0]), tensor([2]))
""" """
assert isinstance( assert isinstance(
graph, DGLHeteroGraph graph, DGLGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph" ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert ( assert (
len(graph.canonical_etypes) == 1 len(graph.canonical_etypes) == 1
), "dfs_labeled_edges_generator only support homogeneous graph" ), "dfs_labeled_edges_generator only support homogeneous graph"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment