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
a7575d09
Commit
a7575d09
authored
Oct 09, 2018
by
GaiYu0
Browse files
profile lg
parent
baf5906b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
tests/profile_lg.py
tests/profile_lg.py
+59
-0
No files found.
tests/profile_lg.py
0 → 100644
View file @
a7575d09
import
argparse
import
time
import
dgl
import
dgl.backend
as
F
import
igraph
import
networkx
as
nx
import
numpy
as
np
import
scipy.sparse
as
sp
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--bt'
,
action
=
'store_true'
,
help
=
'BackTracking'
)
parser
.
add_argument
(
'--n-nodes'
,
type
=
int
,
help
=
'Number of NODES'
)
args
=
parser
.
parse_args
()
n
=
args
.
n_nodes
a
=
sp
.
random
(
n
,
n
,
1
/
n
,
data_rvs
=
lambda
n
:
np
.
ones
(
n
))
b
=
sp
.
triu
(
a
,
1
)
+
sp
.
triu
(
a
,
1
).
transpose
()
g
=
dgl
.
DGLGraph
()
g
.
from_scipy_sparse_matrix
(
b
)
N
=
10
t0
=
time
.
time
()
for
i
in
range
(
N
):
lg_sparse
=
g
.
line_graph
(
args
.
bt
)
g
.
_graph
.
_cache
.
clear
()
t
=
(
time
.
time
()
-
t0
)
/
N
print
(
'dgl.DGLGraph.line_graph: %f'
%
t
)
t0
=
time
.
time
()
for
i
in
range
(
N
):
lg
=
g
.
_line_graph
(
args
.
bt
)
g
.
_graph
.
_cache
.
clear
()
t
=
(
time
.
time
()
-
t0
)
/
N
print
(
'dgl.DGLGraph._line_graph: %f'
%
t
)
g
=
igraph
.
Graph
()
g
.
add_vertices
(
n
)
g
.
add_edges
(
list
(
zip
(
a
.
row
.
tolist
(),
a
.
col
.
tolist
())))
'''
t0 = time.time()
for i in range(N):
lg = g.linegraph()
t = (time.time() - t0) / N
print('igraph.Graph._line_graph: %f' % t)
'''
t
=
0
for
i
in
range
(
N
):
g
=
igraph
.
Graph
()
g
.
add_vertices
(
n
)
g
.
add_edges
(
list
(
zip
(
a
.
row
.
tolist
(),
a
.
col
.
tolist
())))
t0
=
time
.
time
()
lg
=
g
.
linegraph
()
t
+=
time
.
time
()
-
t0
t
/=
N
print
(
'igraph.Graph.linegraph: %f'
%
t
)
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