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
from . import backend as F
from . import heterograph_index
from .heterograph import DGLHeteroGraph, combine_frames, DGLBlock
from .heterograph import DGLGraph, combine_frames, DGLBlock
from . import graph_index
from . import utils
from .base import NTYPE, ETYPE, NID, EID, DGLError, dgl_warning
......@@ -224,7 +224,7 @@ def hetero_from_shared_memory(name):
HeteroGraph (in shared memory)
"""
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,
num_nodes_dict=None,
......@@ -378,7 +378,7 @@ def heterograph(data_dict,
# create graph index
hgidx = heterograph_index.create_heterograph_from_relations(
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)
......@@ -612,7 +612,7 @@ def block_to_graph(block):
"""
new_types = [ntype + '_src' for ntype in block.srctypes] + \
[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:
retg.nodes[srctype + '_src'].data.update(block.srcnodes[srctype].data)
......@@ -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})
return nx_graph
DGLHeteroGraph.to_networkx = to_networkx
DGLGraph.to_networkx = to_networkx
def to_cugraph(g):
"""Convert a DGL graph to a :class:`cugraph.Graph` and return.
......@@ -1677,7 +1677,7 @@ def to_cugraph(g):
destination='destination')
return g_cugraph
DGLHeteroGraph.to_cugraph = to_cugraph
DGLGraph.to_cugraph = to_cugraph
def from_cugraph(cugraph_graph):
"""Create a graph from a :class:`cugraph.Graph` object.
......@@ -1766,7 +1766,7 @@ def create_from_edges(sparse_fmt, arrays,
Returns
-------
DGLHeteroGraph
DGLGraph
"""
if utype == vtype:
num_ntypes = 1
......@@ -1784,6 +1784,6 @@ def create_from_edges(sparse_fmt, arrays,
num_ntypes, urange, vrange, indptr, indices, eids, ['coo', 'csr', 'csc'],
sparse_fmt == 'csc')
if utype == vtype:
return DGLHeteroGraph(hgidx, [utype], [etype])
return DGLGraph(hgidx, [utype], [etype])
else:
return DGLHeteroGraph(hgidx, [utype, vtype], [etype])
return DGLGraph(hgidx, [utype, vtype], [etype])
......@@ -7,7 +7,7 @@ from .. import backend as F
from .._ffi.function import _init_api
from .._ffi.object import ObjectBase, register_object
from ..base import DGLError, dgl_warning
from ..heterograph import DGLHeteroGraph
from ..heterograph import DGLGraph
from .heterograph_serialize import save_heterographs
_init_api("dgl.data.graph_serialize")
......@@ -69,10 +69,10 @@ class GraphData(ObjectBase):
return _CAPI_MakeGraphData(ghandle, node_tensors, edge_tensors)
def get_graph(self):
"""Get DGLHeteroGraph from GraphData"""
"""Get DGLGraph from GraphData"""
ghandle = _CAPI_GDataGraphHandle(self)
hgi = _CAPI_DGLAsHeteroGraph(ghandle)
g = DGLHeteroGraph(hgi, ["_U"], ["_E"])
g = DGLGraph(hgi, ["_U"], ["_E"])
node_tensors_items = _CAPI_GDataNodeTensors(self).items()
edge_tensors_items = _CAPI_GDataEdgeTensors(self).items()
for k, v in node_tensors_items:
......@@ -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
if (
type(g_sample) == DGLHeteroGraph
): # Doesn't support DGLHeteroGraph's derived class
type(g_sample) == DGLGraph
): # Doesn't support DGLGraph's derived class
save_heterographs(filename, g_list, labels, formats)
else:
raise DGLError(
......@@ -203,7 +203,7 @@ def load_graphs(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:
idx_list = []
assert isinstance(idx_list, list)
......
......@@ -6,7 +6,7 @@ from .._ffi.function import _init_api
from .._ffi.object import ObjectBase, register_object
from ..container import convert_to_strmap
from ..frame import Frame
from ..heterograph import DGLHeteroGraph
from ..heterograph import DGLGraph
_init_api("dgl.data.heterograph_serialize")
......@@ -23,11 +23,11 @@ def save_heterographs(filename, g_list, labels, formats):
"""Save heterographs into file"""
if labels is None:
labels = {}
if isinstance(g_list, DGLHeteroGraph):
if isinstance(g_list, DGLGraph):
g_list = [g_list]
assert all(
[type(g) == DGLHeteroGraph for g in g_list]
), "Invalid DGLHeteroGraph in g_list argument"
[type(g) == DGLGraph for g in g_list]
), "Invalid DGLGraph in g_list argument"
gdata_list = [HeteroGraphData.create(g) for g in g_list]
if formats is None:
formats = []
......@@ -39,7 +39,7 @@ def save_heterographs(filename, g_list, labels, formats):
@register_object("heterograph_serialize.HeteroGraphData")
class HeteroGraphData(ObjectBase):
"""Object to hold the data to be stored for DGLHeteroGraph"""
"""Object to hold the data to be stored for DGLGraph"""
@staticmethod
def create(g):
......@@ -75,4 +75,4 @@ class HeteroGraphData(ObjectBase):
}
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
from ..base import NID, EID, dgl_warning, DGLError
from ..batch import batch as batch_graphs
from ..heterograph import DGLHeteroGraph
from ..heterograph import DGLGraph
from ..utils import (
recursive_apply, ExceptionWrapper, recursive_apply_pair, set_num_threads, get_num_threads,
get_numa_nodes_cores, context_of, dtype_of)
......@@ -283,7 +283,7 @@ def _prefetch_for_subgraph(subg, dataloader):
def _prefetch_for(item, dataloader):
if isinstance(item, DGLHeteroGraph):
if isinstance(item, DGLGraph):
return _prefetch_for_subgraph(item, dataloader)
elif isinstance(item, LazyFeature):
return dataloader.other_storages[item.name].fetch(
......@@ -343,7 +343,7 @@ def _prefetch(batch, dataloader, stream):
def _assign_for(item, feat):
if isinstance(item, DGLHeteroGraph):
if isinstance(item, DGLGraph):
subg = item
for (tid, key), value in feat.node_feats.items():
assert isinstance(subg._node_frames[tid][key], LazyFeature)
......@@ -387,17 +387,17 @@ def _prefetcher_entry(
queue, (None, None, None, ExceptionWrapper(where='in prefetcher')), done_event)
# DGLHeteroGraphs 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
# with older code, DGLHeteroGraphs and other graph storages are handled separately: (1)
# DGLHeteroGraphs will preserve the lazy feature slicing for subgraphs. (2) Other graph storages
# DGLGraphs have the semantics of lazy feature slicing with subgraphs. Such behavior depends
# on that DGLGraph's ndata and edata are maintained by Frames. So to maintain compatibility
# with older code, DGLGraphs and other graph storages are handled separately: (1)
# 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.
def remove_parent_storage_columns(item, g):
"""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
DataLoader workers.
"""
if not isinstance(item, DGLHeteroGraph) or not isinstance(g, DGLHeteroGraph):
if not isinstance(item, DGLGraph) or not isinstance(g, DGLGraph):
return item
for subframe, frame in zip(
......@@ -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
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
for subframe, frame in zip(
......@@ -774,7 +774,7 @@ class DataLoader(torch.utils.data.DataLoader):
self.device = _get_device(device)
# 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
if use_uva:
if self.graph.device.type != 'cpu':
......@@ -1098,7 +1098,7 @@ class GraphCollator(object):
"""
elem = items[0]
elem_type = type(elem)
if isinstance(elem, DGLHeteroGraph):
if isinstance(elem, DGLGraph):
batched_graphs = batch_graphs(items)
return batched_graphs
elif F.is_tensor(elem):
......
......@@ -7,7 +7,7 @@ import os
import gc
import numpy as np
from ..heterograph import DGLHeteroGraph
from ..heterograph import DGLGraph
from ..convert import heterograph as dgl_heterograph
from ..convert import graph as dgl_graph
from ..transforms import compact_graphs
......@@ -129,7 +129,7 @@ def _get_graph_from_shared_mem(graph_name):
g, ntypes, etypes = heterograph_index.create_heterograph_from_shared_memory(graph_name)
if g is 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[NID] = _get_shared_mem_ndata(g, graph_name, NID)
......
......@@ -484,7 +484,7 @@ def _distributed_access(g, nodes, issue_remote_req, local_access):
Returns
-------
DGLHeteroGraph
DGLGraph
The subgraph that contains the neighborhoods of all input nodes.
"""
req_list = []
......
......@@ -30,7 +30,7 @@ class ServerState:
----------
kv_store : KVServer
reference for KVServer
graph : DGLHeteroGraph
graph : DGLGraph
Graph structure of one partition
total_num_nodes : int
Total number of nodes
......
......@@ -20,9 +20,9 @@ from . import backend as F
from .frame import Frame
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.
There are a few ways to create a DGLGraph:
......@@ -66,7 +66,7 @@ class DGLHeteroGraph(object):
Otherwise, ``edge_frames[i]`` stores the edge features
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.')
if not isinstance(gidx, heterograph_index.HeteroGraphIndex):
dgl_warning('Recommend creating graphs by `dgl.graph(data)`'
......@@ -5476,7 +5476,7 @@ class DGLHeteroGraph(object):
Returns
-------
DGLHeteroGraph
DGLGraph
Graph on CPU.
See Also
......@@ -5614,7 +5614,7 @@ class DGLHeteroGraph(object):
Returns
-------
DGLHeteroGraph
DGLGraph
The graph object that is a clone of current graph.
"""
# XXX(minjie): Do a shallow copy first to clone some internal metagraph information.
......@@ -5919,7 +5919,7 @@ class DGLHeteroGraph(object):
Returns
-------
DGLHeteroGraph
DGLGraph
Graph in the new ID type.
"""
if idtype is None:
......@@ -5936,7 +5936,7 @@ class DGLHeteroGraph(object):
def shared_memory(self, name, formats=('coo', 'csr', 'csc')):
"""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
or edge data.
......@@ -5949,7 +5949,7 @@ class DGLHeteroGraph(object):
Returns
-------
HeteroGraph
DGLGraph
The graph in shared memory
"""
assert len(name) > 0, "The name of shared memory cannot be empty"
......@@ -5959,7 +5959,7 @@ class DGLHeteroGraph(object):
for fmt in formats:
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)
return DGLHeteroGraph(gidx, self.ntypes, self.etypes)
return DGLGraph(gidx, self.ntypes, self.etypes)
def long(self):
......@@ -6374,7 +6374,7 @@ def combine_names(names, ids=None):
selected = sorted([names[i] for i in ids])
return '+'.join(selected)
class DGLBlock(DGLHeteroGraph):
class DGLBlock(DGLGraph):
"""Subclass that signifies the graph is a block created from
:func:`dgl.to_block`.
"""
......@@ -6465,7 +6465,7 @@ def _create_compute_graph(graph, u, v, eid, recv_nodes=None):
eframe = graph._edge_frames[0].subframe(eid)
eframe[EID] = eid
return DGLHeteroGraph(hgidx, ([srctype], [dsttype]), [etype],
return DGLGraph(hgidx, ([srctype], [dsttype]), [etype],
node_frames=[srcframe, dstframe],
edge_frames=[eframe]), unique_src, unique_dst, eid
......
......@@ -93,7 +93,7 @@ class HeteroGraphConv(nn.Block):
----------
mods : dict[str, nn.Module]
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
features or a pair of tensor object representing the source and destination
node features.
......@@ -146,7 +146,7 @@ class HeteroGraphConv(nn.Block):
Parameters
----------
g : DGLHeteroGraph
g : DGLGraph
Graph data.
inputs : dict[str, Tensor] or pair of dict[str, Tensor]
Input node features.
......
......@@ -97,7 +97,7 @@ class HeteroGraphConv(nn.Module):
----------
mods : dict[str, nn.Module]
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
features or a pair of tensor object representing the source and destination
node features.
......@@ -163,7 +163,7 @@ class HeteroGraphConv(nn.Module):
Parameters
----------
g : DGLHeteroGraph
g : DGLGraph
Graph data.
inputs : dict[str, Tensor] or pair of dict[str, Tensor]
Input node features.
......
......@@ -100,7 +100,7 @@ class HeteroGraphConv(layers.Layer):
----------
mods : dict[str, nn.Module]
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
features or a pair of tensor object representing the source and destination
node features.
......@@ -150,7 +150,7 @@ class HeteroGraphConv(layers.Layer):
Parameters
----------
g : DGLHeteroGraph
g : DGLGraph
Graph data.
inputs : dict[str, Tensor] or pair of dict[str, Tensor]
Input node features.
......
......@@ -106,7 +106,7 @@ def _gen_sddmm_func(lhs_target, rhs_target, binary_op):
Parameters
----------
g : DGLHeteroGraph
g : DGLGraph
The input graph
x : tensor
The {lhs} features.
......@@ -157,7 +157,7 @@ def copy_u(g, x):
Parameters
----------
g : DGLHeteroGraph
g : DGLGraph
The input graph.
x : tensor
The source node features.
......@@ -179,7 +179,7 @@ def copy_v(g, x):
Parameters
----------
g : DGLHeteroGraph
g : DGLGraph
The input graph.
x : tensor
The destination node features.
......
......@@ -143,7 +143,7 @@ def _gen_spmm_func(binary_op, reduce_op):
Parameters
----------
g : DGLHeteroGraph
g : DGLGraph
The input graph
x : tensor
The source node features.
......@@ -191,7 +191,7 @@ def _gen_copy_reduce_func(binary_op, reduce_op):
Parameters
----------
g : DGLHeteroGraph
g : DGLGraph
The input graph
x : tensor
The {} features.
......
......@@ -9,7 +9,7 @@ from . import backend as F
from . import utils
from ._ffi.function import _init_api
from .base import EID, ETYPE, NID, NTYPE
from .heterograph import DGLHeteroGraph
from .heterograph import DGLGraph
from .ndarray import NDArray
from .subgraph import edge_subgraph
......@@ -49,7 +49,7 @@ def reorder_nodes(g, new_node_ids):
new_gidx = _CAPI_DGLReorderGraph_Hetero(
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
return new_g
......@@ -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.
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
# from the distributed graph after training.
if reshuffle:
......@@ -325,7 +325,7 @@ def metis_partition_assignment(
# The METIS runs on the symmetric graph to generate the node assignment to partitions.
start = time.time()
sym_gidx = _CAPI_DGLMakeSymmetric_Hetero(g._graph)
sym_g = DGLHeteroGraph(gidx=sym_gidx)
sym_g = DGLGraph(gidx=sym_gidx)
print(
"Convert a graph into a bidirected graph: {:.3f} seconds, peak memory: {:.3f} GB".format(
time.time() - start, get_peak_mem()
......
......@@ -3,7 +3,7 @@ from __future__ import absolute_import
from . import backend as F
from . import traversal as trv
from .heterograph import DGLHeteroGraph
from .heterograph import DGLGraph
__all__ = [
"prop_nodes",
......@@ -84,7 +84,7 @@ def prop_nodes_bfs(
Parameters
----------
graph : DGLHeteroGraph
graph : DGLGraph
The graph object.
source : list, tensor of nodes
Source nodes.
......@@ -102,8 +102,8 @@ def prop_nodes_bfs(
dgl.traversal.bfs_nodes_generator
"""
assert isinstance(
graph, DGLHeteroGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph"
graph, DGLGraph
), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert (
len(graph.canonical_etypes) == 1
), "prop_nodes_bfs only support homogeneous graph"
......@@ -122,7 +122,7 @@ def prop_nodes_topo(
Parameters
----------
graph : DGLHeteroGraph
graph : DGLGraph
The graph object.
message_func : callable
The message function.
......@@ -138,8 +138,8 @@ def prop_nodes_topo(
dgl.traversal.topological_nodes_generator
"""
assert isinstance(
graph, DGLHeteroGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph"
graph, DGLGraph
), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert (
len(graph.canonical_etypes) == 1
), "prop_nodes_topo only support homogeneous graph"
......@@ -165,7 +165,7 @@ def prop_edges_dfs(
Parameters
----------
graph : DGLHeteroGraph
graph : DGLGraph
The graph object.
source : list, tensor of nodes
Source nodes.
......@@ -187,8 +187,8 @@ def prop_edges_dfs(
dgl.traversal.dfs_labeled_edges_generator
"""
assert isinstance(
graph, DGLHeteroGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph"
graph, DGLGraph
), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert (
len(graph.canonical_etypes) == 1
), "prop_edges_dfs only support homogeneous graph"
......
......@@ -5,7 +5,7 @@ from numpy.polynomial import polynomial
from .. import backend as F
from .. import utils
from .._ffi.function import _init_api
from ..heterograph import DGLHeteroGraph
from ..heterograph import DGLGraph
__all__ = ["global_uniform_negative_sampling"]
......@@ -120,7 +120,7 @@ def global_uniform_negative_sampling(
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
)
......
......@@ -3,7 +3,7 @@
from .._ffi.function import _init_api
from .. import backend as F
from ..base import DGLError, EID
from ..heterograph import DGLHeteroGraph
from ..heterograph import DGLGraph
from .. import ndarray as nd
from .. import utils
from .utils import EidExcluder
......@@ -157,7 +157,7 @@ def sample_etype_neighbors(
g._graph, nodes, etype_offset, fanout, edge_dir, prob_array,
replace, etype_sorted)
induced_edges = subgidx.induced_edges
ret = DGLHeteroGraph(subgidx.graph, g.ntypes, g.etypes)
ret = DGLGraph(subgidx.graph, g.ntypes, g.etypes)
# handle features
# (TODO) (BarclayII) DGL distributed fails with bus error, freezes, or other
......@@ -178,7 +178,7 @@ def sample_etype_neighbors(
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,
replace=False, copy_ndata=True, copy_edata=True,
......@@ -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,
excluded_edges_all_t, replace)
induced_edges = subgidx.induced_edges
ret = DGLHeteroGraph(subgidx.graph, g.ntypes, g.etypes)
ret = DGLGraph(subgidx.graph, g.ntypes, g.etypes)
# handle features
# (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,
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',
tag_offset_name='_TAG_OFFSET', replace=False,
......@@ -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,
tag_offset_array, edge_dir, replace)
induced_edges = subgidx.induced_edges
ret = DGLHeteroGraph(subgidx.graph, g.ntypes, g.etypes)
ret = DGLGraph(subgidx.graph, g.ntypes, g.etypes)
if copy_ndata:
node_frames = utils.extract_node_subframes(g, device)
......@@ -581,7 +581,7 @@ def sample_neighbors_biased(g, nodes, fanout, bias, edge_dir='in',
ret.edata[EID] = induced_edges[0]
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,
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,
subgidx = _CAPI_DGLSampleNeighborsTopk(
g._graph, nodes_all_types, k_array, edge_dir, weight_arrays, bool(ascending))
induced_edges = subgidx.induced_edges
ret = DGLHeteroGraph(subgidx.graph, g.ntypes, g.etypes)
ret = DGLGraph(subgidx.graph, g.ntypes, g.etypes)
# handle features
if copy_ndata:
......@@ -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)
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__)
......@@ -9,7 +9,7 @@ from . import backend as F
from . import graph_index, heterograph_index, utils
from ._ffi.function import _init_api
from .base import DGLError, dgl_warning
from .heterograph import DGLHeteroGraph
from .heterograph import DGLGraph
from .utils import context_of, recursive_apply
__all__ = [
......@@ -173,7 +173,7 @@ def node_subgraph(
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(
......@@ -346,7 +346,7 @@ def edge_subgraph(
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(
......@@ -484,7 +484,7 @@ def in_subgraph(
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(
......@@ -622,7 +622,7 @@ def out_subgraph(
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(
......@@ -807,7 +807,7 @@ def khop_in_subgraph(
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(
......@@ -992,7 +992,7 @@ def khop_out_subgraph(
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):
......@@ -1073,7 +1073,7 @@ def node_type_subgraph(graph, ntypes, output_device=None):
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):
......@@ -1178,13 +1178,13 @@ def edge_type_subgraph(graph, etypes, output_device=None):
rel_graphs,
utils.toindex(num_nodes_per_induced_type, "int64"),
)
hg = DGLHeteroGraph(
hg = DGLGraph(
hgidx, induced_ntypes, induced_etypes, node_frames, edge_frames
)
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 ####################
......@@ -1233,7 +1233,7 @@ def _create_hetero_subgraph(
edge_frames = utils.extract_edge_subframes(
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)
return hsg
......
......@@ -30,7 +30,7 @@ except ImportError:
from .._ffi.function import _init_api
from ..base import dgl_warning, DGLError, NID, EID
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 ..frame import Frame
from .. import ndarray as nd
......@@ -68,13 +68,11 @@ __all__ = [
'to_block',
'to_simple',
'to_simple_graph',
'as_immutable_graph',
'sort_csr_by_tag',
'sort_csc_by_tag',
'metis_partition_assignment',
'partition_graph_with_halo',
'metis_partition',
'as_heterograph',
'adj_product_graph',
'adj_sum_graph',
'reorder_graph',
......@@ -1034,7 +1032,7 @@ def line_graph(g, backtracking=True, shared=False):
'only homogeneous graph is supported'
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)
if shared:
new_frames = utils.extract_edge_subframes(g, None)
......@@ -1042,7 +1040,7 @@ def line_graph(g, backtracking=True, shared=False):
return lg
DGLHeteroGraph.line_graph = utils.alias_func(line_graph)
DGLGraph.line_graph = utils.alias_func(line_graph)
def khop_adj(g, k):
"""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
# currently reversing a block results in undefined behavior
raise DGLError('Reversing a block graph is not supported.')
gidx = g._graph.reverse()
new_g = DGLHeteroGraph(gidx, g.ntypes, g.etypes)
new_g = DGLGraph(gidx, g.ntypes, g.etypes)
# handle ndata
if copy_ndata:
......@@ -1293,7 +1291,7 @@ def reverse(g, copy_ndata=True, copy_edata=False, *, share_ndata=None, share_eda
return new_g
DGLHeteroGraph.reverse = utils.alias_func(reverse)
DGLGraph.reverse = utils.alias_func(reverse)
def to_simple_graph(g):
"""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):
new_g = add_edges(g, nodes, nodes, etype=etype)
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):
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):
new_g = remove_edges(g, self_loop_eids, etype=etype)
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):
"""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
induced_nodes = [F.from_dgl_nd(nodes) for nodes in induced_nodes]
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)]
if copy_ndata:
......@@ -2616,7 +2614,7 @@ def to_simple(g,
if g.is_block:
raise DGLError('Cannot convert a block graph to a simple 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]
edge_maps = [F.from_dgl_nd(edge_map) for edge_map in edge_maps]
......@@ -2644,7 +2642,7 @@ def to_simple(g,
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):
"""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'):
C_gidx = create_heterograph_from_relations(
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
return C
......@@ -2890,29 +2888,10 @@ def adj_sum_graph(graphs, weight_name):
C_gidx, C_weights = F.csrsum(gidxs, weights)
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
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'):
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',
return rg
DGLHeteroGraph.reorder_graph = utils.alias_func(reorder_graph)
DGLGraph.reorder_graph = utils.alias_func(reorder_graph)
def metis_perm(g, k):
......@@ -3750,7 +3729,7 @@ def to_half(g):
Returns
-------
DGLHeteroGraph
DGLGraph
Clone of graph with the feature data converted to float16.
"""
ret = copy.copy(g)
......@@ -3767,7 +3746,7 @@ def to_float(g):
Returns
-------
DGLHeteroGraph
DGLGraph
Clone of graph with the feature data converted to float32.
"""
ret = copy.copy(g)
......@@ -3784,7 +3763,7 @@ def to_double(g):
Returns
-------
DGLHeteroGraph
DGLGraph
Clone of graph with the feature data converted to float64.
"""
ret = copy.copy(g)
......
......@@ -4,7 +4,7 @@ from __future__ import absolute_import
from . import backend as F
from . import utils
from ._ffi.function import _init_api
from .heterograph import DGLHeteroGraph
from .heterograph import DGLGraph
__all__ = [
"bfs_nodes_generator",
......@@ -20,7 +20,7 @@ def bfs_nodes_generator(graph, source, reverse=False):
Parameters
----------
graph : DGLHeteroGraph
graph : DGLGraph
The graph object.
source : list, tensor of nodes
Source nodes.
......@@ -46,8 +46,8 @@ def bfs_nodes_generator(graph, source, reverse=False):
[tensor([0]), tensor([1]), tensor([2, 3]), tensor([4, 5])]
"""
assert isinstance(
graph, DGLHeteroGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph"
graph, DGLGraph
), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert (
len(graph.canonical_etypes) == 1
), "bfs_nodes_generator only support homogeneous graph"
......@@ -67,7 +67,7 @@ def bfs_edges_generator(graph, source, reverse=False):
Parameters
----------
graph : DGLHeteroGraph
graph : DGLGraph
The graph object.
source : list, tensor of nodes
Source nodes.
......@@ -94,8 +94,8 @@ def bfs_edges_generator(graph, source, reverse=False):
[tensor([0]), tensor([1, 2]), tensor([4, 5])]
"""
assert isinstance(
graph, DGLHeteroGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph"
graph, DGLGraph
), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert (
len(graph.canonical_etypes) == 1
), "bfs_edges_generator only support homogeneous graph"
......@@ -115,7 +115,7 @@ def topological_nodes_generator(graph, reverse=False):
Parameters
----------
graph : DGLHeteroGraph
graph : DGLGraph
The graph object.
reverse : bool, optional
If True, traverse following the in-edge direction.
......@@ -139,8 +139,8 @@ def topological_nodes_generator(graph, reverse=False):
[tensor([0]), tensor([1]), tensor([2]), tensor([3, 4]), tensor([5])]
"""
assert isinstance(
graph, DGLHeteroGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph"
graph, DGLGraph
), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert (
len(graph.canonical_etypes) == 1
), "topological_nodes_generator only support homogeneous graph"
......@@ -163,7 +163,7 @@ def dfs_edges_generator(graph, source, reverse=False):
Parameters
----------
graph : DGLHeteroGraph
graph : DGLGraph
The graph object.
source : list, tensor of nodes
Source nodes.
......@@ -191,8 +191,8 @@ def dfs_edges_generator(graph, source, reverse=False):
[tensor([0]), tensor([1]), tensor([3]), tensor([5]), tensor([4])]
"""
assert isinstance(
graph, DGLHeteroGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph"
graph, DGLGraph
), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert (
len(graph.canonical_etypes) == 1
), "dfs_edges_generator only support homogeneous graph"
......@@ -234,7 +234,7 @@ def dfs_labeled_edges_generator(
Parameters
----------
graph : DGLHeteroGraph
graph : DGLGraph
The graph object.
source : list, tensor of nodes
Source nodes.
......@@ -271,8 +271,8 @@ def dfs_labeled_edges_generator(
(tensor([0]), tensor([0]), tensor([0]), tensor([0]), tensor([0]), tensor([2]))
"""
assert isinstance(
graph, DGLHeteroGraph
), "DGLGraph is deprecated, Please use DGLHeteroGraph"
graph, DGLGraph
), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
assert (
len(graph.canonical_etypes) == 1
), "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