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
c0d1f8e4
Unverified
Commit
c0d1f8e4
authored
Dec 06, 2018
by
Da Zheng
Committed by
GitHub
Dec 06, 2018
Browse files
small fixes in the immutable graph index. (#271)
* small fix in immutable graph index. * minor fix.
parent
f720ce13
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
python/dgl/immutable_graph_index.py
python/dgl/immutable_graph_index.py
+10
-6
No files found.
python/dgl/immutable_graph_index.py
View file @
c0d1f8e4
...
...
@@ -8,7 +8,7 @@ import scipy.sparse as sp
from
._ffi.function
import
_init_api
from
.
import
backend
as
F
from
.
import
utils
from
.base
import
ALL
,
is_all
,
dgl_warning
,
DGLError
from
.base
import
ALL
,
is_all
,
DGLError
class
ImmutableGraphIndex
(
object
):
"""Graph index object on immutable graphs.
...
...
@@ -514,8 +514,6 @@ class ImmutableGraphIndex(object):
def
get_adj
(
ctx
):
new_mat
=
self
.
_sparse
.
adjacency_matrix
(
transpose
)
return
F
.
copy_to
(
new_mat
,
ctx
)
# FIXME(minjie): calculate the shuffle index
dgl_warning
(
'Shuffle index is not correctly computed. SPMV with edge feature might fail!!'
)
return
self
.
_sparse
.
adjacency_matrix
(
transpose
,
ctx
),
None
def
incidence_matrix
(
self
,
type
,
ctx
):
...
...
@@ -649,9 +647,15 @@ class ImmutableGraphIndex(object):
min_nodes
=
min
(
src
.
min
(),
dst
.
min
())
if
min_nodes
!=
0
:
raise
DGLError
(
'Invalid edge list. Nodes must start from 0.'
)
data
=
np
.
ones
((
len
(
src
),),
dtype
=
np
.
int32
)
spmat
=
sp
.
coo_matrix
((
data
,
(
src
,
dst
)),
shape
=
(
num_nodes
,
num_nodes
))
self
.
_sparse
.
from_coo_matrix
(
spmat
)
edge_ids
=
mx
.
nd
.
arange
(
0
,
len
(
src
),
step
=
1
,
repeat
=
1
,
dtype
=
np
.
int32
)
src
=
mx
.
nd
.
array
(
src
,
dtype
=
np
.
int64
)
dst
=
mx
.
nd
.
array
(
dst
,
dtype
=
np
.
int64
)
# TODO we can't generate a csr_matrix with np.int64 directly.
in_csr
=
mx
.
nd
.
sparse
.
csr_matrix
((
edge_ids
,
(
dst
,
src
)),
shape
=
(
num_nodes
,
num_nodes
)).
astype
(
np
.
int64
)
out_csr
=
mx
.
nd
.
sparse
.
csr_matrix
((
edge_ids
,
(
src
,
dst
)),
shape
=
(
num_nodes
,
num_nodes
)).
astype
(
np
.
int64
)
self
.
__init__
(
in_csr
,
out_csr
)
def
line_graph
(
self
,
backtracking
=
True
):
"""Return the line graph of this graph.
...
...
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