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
d4cfecaa
Commit
d4cfecaa
authored
Mar 25, 2018
by
rusty1s
Browse files
sorted rows, cols, and cuts
parent
3aad518a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
torch_cluster/functions/graclus.py
torch_cluster/functions/graclus.py
+13
-7
No files found.
torch_cluster/functions/graclus.py
View file @
d4cfecaa
...
@@ -2,21 +2,27 @@ from __future__ import division
...
@@ -2,21 +2,27 @@ from __future__ import division
import
torch
import
torch
# from .utils import get_func
from
.degree
import
node_degree
from
.degree
import
node_degree
def
graclus_cluster
(
edge_index
,
def
graclus_cluster
(
edge_index
,
num_nodes
=
None
,
edge_attr
=
None
,
rid
=
None
):
num_nodes
=
None
,
edge_attr
=
None
,
batch
=
None
,
rid
=
None
):
num_nodes
=
edge_index
.
max
()
+
1
if
num_nodes
is
None
else
num_nodes
num_nodes
=
edge_index
.
max
()
+
1
if
num_nodes
is
None
else
num_nodes
rid
=
torch
.
randperm
(
num_nodes
)
if
rid
is
None
else
rid
rid
=
torch
.
randperm
(
num_nodes
)
if
rid
is
None
else
rid
row
,
col
=
edge_index
# Compute edge-wise normalized cut.
cut
=
normalized_cut
(
edge_index
,
num_nodes
,
edge_attr
)
cut
=
normalized_cut
(
edge_index
,
num_nodes
,
edge_attr
)
print
(
cut
)
# Sort row and col indices based on the (possibly random) `rid`.
_
,
perm
=
rid
[
row
].
sort
()
row
,
col
,
cut
=
row
[
perm
],
col
[
perm
],
cut
[
perm
]
print
(
row
,
col
)
cluster
=
edge_index
.
new
(
num_nodes
).
fill_
(
-
1
)
# func = get_func('graclus', cluster)
# func(cluster, row, col, cut)
return
cluster
def
normalized_cut
(
edge_index
,
num_nodes
,
edge_attr
=
None
):
def
normalized_cut
(
edge_index
,
num_nodes
,
edge_attr
=
None
):
...
...
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