Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
3132da28
Unverified
Commit
3132da28
authored
Nov 15, 2022
by
peizhou001
Committed by
GitHub
Nov 15, 2022
Browse files
Deprecate (#4864)
rename DGLHeteroGraph to DGLGraph
parent
ee9887d6
Changes
45
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
126 additions
and
147 deletions
+126
-147
python/dgl/convert.py
python/dgl/convert.py
+9
-9
python/dgl/data/graph_serialize.py
python/dgl/data/graph_serialize.py
+6
-6
python/dgl/data/heterograph_serialize.py
python/dgl/data/heterograph_serialize.py
+6
-6
python/dgl/dataloading/dataloader.py
python/dgl/dataloading/dataloader.py
+11
-11
python/dgl/distributed/dist_graph.py
python/dgl/distributed/dist_graph.py
+2
-2
python/dgl/distributed/graph_services.py
python/dgl/distributed/graph_services.py
+1
-1
python/dgl/distributed/server_state.py
python/dgl/distributed/server_state.py
+1
-1
python/dgl/heterograph.py
python/dgl/heterograph.py
+11
-11
python/dgl/nn/mxnet/hetero.py
python/dgl/nn/mxnet/hetero.py
+2
-2
python/dgl/nn/pytorch/hetero.py
python/dgl/nn/pytorch/hetero.py
+2
-2
python/dgl/nn/tensorflow/hetero.py
python/dgl/nn/tensorflow/hetero.py
+2
-2
python/dgl/ops/sddmm.py
python/dgl/ops/sddmm.py
+3
-3
python/dgl/ops/spmm.py
python/dgl/ops/spmm.py
+2
-2
python/dgl/partition.py
python/dgl/partition.py
+4
-4
python/dgl/propagate.py
python/dgl/propagate.py
+10
-10
python/dgl/sampling/negative.py
python/dgl/sampling/negative.py
+2
-2
python/dgl/sampling/neighbor.py
python/dgl/sampling/neighbor.py
+9
-9
python/dgl/subgraph.py
python/dgl/subgraph.py
+11
-11
python/dgl/transforms/functional.py
python/dgl/transforms/functional.py
+16
-37
python/dgl/traversal.py
python/dgl/traversal.py
+16
-16
No files found.
python/dgl/convert.py
View file @
3132da28
...
...
@@ -7,7 +7,7 @@ import networkx as nx
from
.
import
backend
as
F
from
.
import
heterograph_index
from
.heterograph
import
DGL
Hetero
Graph
,
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
DGL
Hetero
Graph
(
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
=
DGL
Hetero
Graph
(
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
=
DGL
Hetero
Graph
(
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
DGL
Hetero
Graph
.
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
DGL
Hetero
Graph
.
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
-------
DGL
Hetero
Graph
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
DGL
Hetero
Graph
(
hgidx
,
[
utype
],
[
etype
])
return
DGLGraph
(
hgidx
,
[
utype
],
[
etype
])
else
:
return
DGL
Hetero
Graph
(
hgidx
,
[
utype
,
vtype
],
[
etype
])
return
DGLGraph
(
hgidx
,
[
utype
,
vtype
],
[
etype
])
python/dgl/data/graph_serialize.py
View file @
3132da28
...
...
@@ -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
DGL
Hetero
Graph
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 DGL
Hetero
Graph from GraphData"""
"""Get DGLGraph from GraphData"""
ghandle
=
_CAPI_GDataGraphHandle
(
self
)
hgi
=
_CAPI_DGLAsHeteroGraph
(
ghandle
)
g
=
DGL
Hetero
Graph
(
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
)
==
DGL
Hetero
Graph
):
# Doesn't support DGL
Hetero
Graph'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 DGL
Hetero
Graphs."""
"""Internal functions for loading DGLGraphs."""
if
idx_list
is
None
:
idx_list
=
[]
assert
isinstance
(
idx_list
,
list
)
...
...
python/dgl/data/heterograph_serialize.py
View file @
3132da28
...
...
@@ -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
DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
):
if
isinstance
(
g_list
,
DGLGraph
):
g_list
=
[
g_list
]
assert
all
(
[
type
(
g
)
==
DGL
Hetero
Graph
for
g
in
g_list
]
),
"Invalid DGL
Hetero
Graph 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 DGL
Hetero
Graph"""
"""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
DGL
Hetero
Graph
(
gidx
,
ntype_names
,
etype_names
,
nframes
,
eframes
)
return
DGLGraph
(
gidx
,
ntype_names
,
etype_names
,
nframes
,
eframes
)
python/dgl/dataloading/dataloader.py
View file @
3132da28
...
...
@@ -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
DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
):
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
,
DGL
Hetero
Graph
):
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
)
# DGL
Hetero
Graphs have the semantics of lazy feature slicing with subgraphs. Such behavior depends
# on that DGL
Hetero
Graph's ndata and edata are maintained by Frames. So to maintain compatibility
# with older code, DGL
Hetero
Graphs and other graph storages are handled separately: (1)
# DGL
Hetero
Graphs 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
,
DGL
Hetero
Graph
)
or
not
isinstance
(
g
,
DGL
Hetero
Graph
):
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
,
DGL
Hetero
Graph
)
or
not
isinstance
(
g
,
DGL
Hetero
Graph
):
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
,
DGL
Hetero
Graph
):
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
,
DGL
Hetero
Graph
):
if
isinstance
(
elem
,
DGLGraph
):
batched_graphs
=
batch_graphs
(
items
)
return
batched_graphs
elif
F
.
is_tensor
(
elem
):
...
...
python/dgl/distributed/dist_graph.py
View file @
3132da28
...
...
@@ -7,7 +7,7 @@ import os
import
gc
import
numpy
as
np
from
..heterograph
import
DGL
Hetero
Graph
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
=
DGL
Hetero
Graph
(
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
)
...
...
python/dgl/distributed/graph_services.py
View file @
3132da28
...
...
@@ -484,7 +484,7 @@ def _distributed_access(g, nodes, issue_remote_req, local_access):
Returns
-------
DGL
Hetero
Graph
DGLGraph
The subgraph that contains the neighborhoods of all input nodes.
"""
req_list
=
[]
...
...
python/dgl/distributed/server_state.py
View file @
3132da28
...
...
@@ -30,7 +30,7 @@ class ServerState:
----------
kv_store : KVServer
reference for KVServer
graph : DGL
Hetero
Graph
graph : DGLGraph
Graph structure of one partition
total_num_nodes : int
Total number of nodes
...
...
python/dgl/heterograph.py
View file @
3132da28
...
...
@@ -20,9 +20,9 @@ from . import backend as F
from
.frame
import
Frame
from
.view
import
HeteroNodeView
,
HeteroNodeDataView
,
HeteroEdgeView
,
HeteroEdgeDataView
__all__
=
[
'DGL
Hetero
Graph'
,
'combine_names'
]
__all__
=
[
'DGLGraph'
,
'combine_names'
]
class
DGL
Hetero
Graph
(
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
,
DGL
Hetero
Graph
):
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
-------
DGL
Hetero
Graph
DGLGraph
Graph on CPU.
See Also
...
...
@@ -5614,7 +5614,7 @@ class DGLHeteroGraph(object):
Returns
-------
DGL
Hetero
Graph
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
-------
DGL
Hetero
Graph
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 DGL
Heterog
raph object which
It moves the graph index to shared memory and returns a DGL
G
raph 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
-------
Hetero
Graph
DGL
Graph
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
DGL
Hetero
Graph
(
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
(
DGL
Hetero
Graph
):
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
DGL
Hetero
Graph
(
hgidx
,
([
srctype
],
[
dsttype
]),
[
etype
],
return
DGLGraph
(
hgidx
,
([
srctype
],
[
dsttype
]),
[
etype
],
node_frames
=
[
srcframe
,
dstframe
],
edge_frames
=
[
eframe
]),
unique_src
,
unique_dst
,
eid
...
...
python/dgl/nn/mxnet/hetero.py
View file @
3132da28
...
...
@@ -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 `DGL
Hetero
Graph` 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 : DGL
Hetero
Graph
g : DGLGraph
Graph data.
inputs : dict[str, Tensor] or pair of dict[str, Tensor]
Input node features.
...
...
python/dgl/nn/pytorch/hetero.py
View file @
3132da28
...
...
@@ -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 `DGL
Hetero
Graph` 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 : DGL
Hetero
Graph
g : DGLGraph
Graph data.
inputs : dict[str, Tensor] or pair of dict[str, Tensor]
Input node features.
...
...
python/dgl/nn/tensorflow/hetero.py
View file @
3132da28
...
...
@@ -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 `DGL
Hetero
Graph` 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 : DGL
Hetero
Graph
g : DGLGraph
Graph data.
inputs : dict[str, Tensor] or pair of dict[str, Tensor]
Input node features.
...
...
python/dgl/ops/sddmm.py
View file @
3132da28
...
...
@@ -106,7 +106,7 @@ def _gen_sddmm_func(lhs_target, rhs_target, binary_op):
Parameters
----------
g : DGL
Hetero
Graph
g : DGLGraph
The input graph
x : tensor
The {lhs} features.
...
...
@@ -157,7 +157,7 @@ def copy_u(g, x):
Parameters
----------
g : DGL
Hetero
Graph
g : DGLGraph
The input graph.
x : tensor
The source node features.
...
...
@@ -179,7 +179,7 @@ def copy_v(g, x):
Parameters
----------
g : DGL
Hetero
Graph
g : DGLGraph
The input graph.
x : tensor
The destination node features.
...
...
python/dgl/ops/spmm.py
View file @
3132da28
...
...
@@ -143,7 +143,7 @@ def _gen_spmm_func(binary_op, reduce_op):
Parameters
----------
g : DGL
Hetero
Graph
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 : DGL
Hetero
Graph
g : DGLGraph
The input graph
x : tensor
The {} features.
...
...
python/dgl/partition.py
View file @
3132da28
...
...
@@ -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
DGL
Hetero
Graph
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
=
DGL
Hetero
Graph
(
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
=
DGL
Hetero
Graph
(
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
=
DGL
Hetero
Graph
(
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
()
...
...
python/dgl/propagate.py
View file @
3132da28
...
...
@@ -3,7 +3,7 @@ from __future__ import absolute_import
from
.
import
backend
as
F
from
.
import
traversal
as
trv
from
.heterograph
import
DGL
Hetero
Graph
from
.heterograph
import
DGLGraph
__all__
=
[
"prop_nodes"
,
...
...
@@ -84,7 +84,7 @@ def prop_nodes_bfs(
Parameters
----------
graph : DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
),
"DGLGraph is
deprecated
, Please use DGL
Hetero
Graph"
graph
,
DGLGraph
),
"DGL
Hetero
Graph 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 : DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
),
"DGLGraph is
deprecated
, Please use DGL
Hetero
Graph"
graph
,
DGLGraph
),
"DGL
Hetero
Graph 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 : DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
),
"DGLGraph is
deprecated
, Please use DGL
Hetero
Graph"
graph
,
DGLGraph
),
"DGL
Hetero
Graph is
merged with DGLGraph
, Please use DGLGraph"
assert
(
len
(
graph
.
canonical_etypes
)
==
1
),
"prop_edges_dfs only support homogeneous graph"
...
...
python/dgl/sampling/negative.py
View file @
3132da28
...
...
@@ -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
DGL
Hetero
Graph
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
)
DGL
Hetero
Graph
.
global_uniform_negative_sampling
=
utils
.
alias_func
(
DGLGraph
.
global_uniform_negative_sampling
=
utils
.
alias_func
(
global_uniform_negative_sampling
)
...
...
python/dgl/sampling/neighbor.py
View file @
3132da28
...
...
@@ -3,7 +3,7 @@
from
.._ffi.function
import
_init_api
from
..
import
backend
as
F
from
..base
import
DGLError
,
EID
from
..heterograph
import
DGL
Hetero
Graph
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
=
DGL
Hetero
Graph
(
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
)
DGL
Hetero
Graph
.
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
=
DGL
Hetero
Graph
(
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
DGL
Hetero
Graph
.
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
=
DGL
Hetero
Graph
(
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
)
DGL
Hetero
Graph
.
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
=
DGL
Hetero
Graph
(
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
)
DGL
Hetero
Graph
.
select_topk
=
utils
.
alias_func
(
select_topk
)
DGLGraph
.
select_topk
=
utils
.
alias_func
(
select_topk
)
_init_api
(
'dgl.sampling.neighbor'
,
__name__
)
python/dgl/subgraph.py
View file @
3132da28
...
...
@@ -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
DGL
Hetero
Graph
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
)
DGL
Hetero
Graph
.
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
)
DGL
Hetero
Graph
.
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
)
DGL
Hetero
Graph
.
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
)
DGL
Hetero
Graph
.
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
DGL
Hetero
Graph
.
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
DGL
Hetero
Graph
.
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
)
DGL
Hetero
Graph
.
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
=
DGL
Hetero
Graph
(
hg
=
DGLGraph
(
hgidx
,
induced_ntypes
,
induced_etypes
,
node_frames
,
edge_frames
)
return
hg
if
output_device
is
None
else
hg
.
to
(
output_device
)
DGL
Hetero
Graph
.
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
=
DGL
Hetero
Graph
(
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
...
...
python/dgl/transforms/functional.py
View file @
3132da28
...
...
@@ -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
DGL
Hetero
Graph
,
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
=
DGL
Hetero
Graph
(
_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
DGL
Hetero
Graph
.
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
=
DGL
Hetero
Graph
(
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
DGL
Hetero
Graph
.
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
DGL
Hetero
Graph
.
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
DGL
Hetero
Graph
.
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
=
[
DGL
Hetero
Graph
(
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
=
DGL
Hetero
Graph
(
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
DGL
Hetero
Graph
.
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
=
DGL
Hetero
Graph
(
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
=
DGL
Hetero
Graph
(
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
'
'
\t
dgl.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
'
'
\t
dgl.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
DGL
Hetero
Graph
.
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
-------
DGL
Hetero
Graph
DGLGraph
Clone of graph with the feature data converted to float16.
"""
ret
=
copy
.
copy
(
g
)
...
...
@@ -3767,7 +3746,7 @@ def to_float(g):
Returns
-------
DGL
Hetero
Graph
DGLGraph
Clone of graph with the feature data converted to float32.
"""
ret
=
copy
.
copy
(
g
)
...
...
@@ -3784,7 +3763,7 @@ def to_double(g):
Returns
-------
DGL
Hetero
Graph
DGLGraph
Clone of graph with the feature data converted to float64.
"""
ret
=
copy
.
copy
(
g
)
...
...
python/dgl/traversal.py
View file @
3132da28
...
...
@@ -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
DGL
Hetero
Graph
from
.heterograph
import
DGLGraph
__all__
=
[
"bfs_nodes_generator"
,
...
...
@@ -20,7 +20,7 @@ def bfs_nodes_generator(graph, source, reverse=False):
Parameters
----------
graph : DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
),
"DGLGraph is
deprecated
, Please use DGL
Hetero
Graph"
graph
,
DGLGraph
),
"DGL
Hetero
Graph 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 : DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
),
"DGLGraph is
deprecated
, Please use DGL
Hetero
Graph"
graph
,
DGLGraph
),
"DGL
Hetero
Graph 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 : DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
),
"DGLGraph is
deprecated
, Please use DGL
Hetero
Graph"
graph
,
DGLGraph
),
"DGL
Hetero
Graph 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 : DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
),
"DGLGraph is
deprecated
, Please use DGL
Hetero
Graph"
graph
,
DGLGraph
),
"DGL
Hetero
Graph 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 : DGL
Hetero
Graph
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
,
DGL
Hetero
Graph
),
"DGLGraph is
deprecated
, Please use DGL
Hetero
Graph"
graph
,
DGLGraph
),
"DGL
Hetero
Graph is
merged with DGLGraph
, Please use DGLGraph"
assert
(
len
(
graph
.
canonical_etypes
)
==
1
),
"dfs_labeled_edges_generator only support homogeneous graph"
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment