Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
5b67db19
Commit
5b67db19
authored
Jan 29, 2013
by
Tiago Peixoto
Browse files
Fix computation of normalized Laplacian matrix
parent
fc732cfa
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/spectral/__init__.py
View file @
5b67db19
...
...
@@ -228,15 +228,24 @@ def laplacian(g, deg="total", normalized=True, sparse=True, weight=None):
d
=
_get_deg
(
v
,
deg
,
weight
)
for
e
in
v
.
out_edges
():
if
not
normalized
:
m
[
index
[
v
],
index
[
e
.
target
()]]
+=
(
-
1
if
weight
is
None
else
-
weight
[
e
])
if
weight
is
None
:
val
=
-
1
else
:
val
=
-
weight
[
e
]
# increment in case of parallel edges
m
[
index
[
v
],
index
[
e
.
target
()]]
+=
val
else
:
val
=
(
d
*
_get_deg
(
e
.
target
(),
deg
,
weight
))
**
(
-
0.5
)
m
[
index
[
v
],
index
[
e
.
target
()]]
=
val
d2
=
_get_deg
(
e
.
target
(),
deg
,
weight
)
if
weight
is
None
:
w
=
1
else
:
w
=
weight
[
e
]
# increment in case of parallel edges
m
[
index
[
v
],
index
[
e
.
target
()]]
+=
-
w
/
sqrt
(
d
*
d2
)
if
not
normalized
:
m
[
index
[
v
],
index
[
v
]]
=
d
elif
d
>
0
:
m
[
index
[
v
],
index
[
v
]]
=
1
m
[
index
[
v
],
index
[
v
]]
=
1
if
d
!=
0
else
0
if
sparse
:
m
=
m
.
tocsr
()
return
m
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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