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
torch-cluster
Commits
7985cdd8
Commit
7985cdd8
authored
Apr 18, 2018
by
rusty1s
Browse files
removed self loops in graclus
parent
d2ee1523
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
3 deletions
+7
-3
setup.py
setup.py
+1
-1
torch_cluster/__init__.py
torch_cluster/__init__.py
+1
-1
torch_cluster/graclus.py
torch_cluster/graclus.py
+2
-1
torch_cluster/utils/loop.py
torch_cluster/utils/loop.py
+3
-0
No files found.
setup.py
View file @
7985cdd8
...
...
@@ -2,7 +2,7 @@ from os import path as osp
from
setuptools
import
setup
,
find_packages
__version__
=
'1.0.
1
'
__version__
=
'1.0.
2
'
url
=
'https://github.com/rusty1s/pytorch_cluster'
install_requires
=
[
'cffi'
]
...
...
torch_cluster/__init__.py
View file @
7985cdd8
from
.graclus
import
graclus_cluster
from
.grid
import
grid_cluster
__version__
=
'1.0.
1
'
__version__
=
'1.0.
2
'
__all__
=
[
'graclus_cluster'
,
'grid_cluster'
,
'__version__'
]
torch_cluster/graclus.py
View file @
7985cdd8
from
.utils.loop
import
remove_self_loops
from
.utils.perm
import
randperm
,
sort_row
,
randperm_sort_row
from
.utils.ffi
import
graclus
...
...
@@ -19,7 +20,6 @@ def graclus_cluster(row, col, weight=None, num_nodes=None):
>>> weight = torch.Tensor([1, 1, 1, 1])
>>> cluster = graclus_cluster(row, col, weight)
"""
num_nodes
=
row
.
max
()
+
1
if
num_nodes
is
None
else
num_nodes
if
row
.
is_cuda
:
# pragma: no cover
...
...
@@ -28,6 +28,7 @@ def graclus_cluster(row, col, weight=None, num_nodes=None):
row
,
col
=
randperm
(
row
,
col
)
row
,
col
=
randperm_sort_row
(
row
,
col
,
num_nodes
)
row
,
col
=
remove_self_loops
(
row
,
col
)
cluster
=
row
.
new
(
num_nodes
)
graclus
(
cluster
,
row
,
col
,
weight
)
...
...
torch_cluster/utils/loop.py
0 → 100644
View file @
7985cdd8
def
remove_self_loops
(
row
,
col
):
mask
=
row
!=
col
return
row
[
mask
],
col
[
mask
]
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