Skip to content
GitLab
Menu
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
b8d0dd73
Commit
b8d0dd73
authored
Jan 04, 2013
by
Tiago Peixoto
Browse files
Fix bug in BlockState.entropy()
parent
29d46748
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/community/blockmodel.py
View file @
b8d0dd73
...
...
@@ -28,6 +28,7 @@ import random
from
numpy
import
*
from
scipy.optimize
import
fsolve
,
fminbound
import
scipy.special
from
collections
import
defaultdict
from
..
dl_import
import
dl_import
dl_import
(
"from . import libgraph_tool_community as libcommunity"
)
...
...
@@ -292,18 +293,17 @@ class BlockState(object):
self
.
deg_corr
)
if
complete
:
if
deg_seq
and
self
.
deg_corr
:
if
self
.
deg_corr
:
S_seq
=
0
hist
=
defaultdict
(
int
)
for
v
in
self
.
g
.
vertices
():
hist
[(
v
.
in_degree
(),
v
.
out_degree
())]
+=
1
for
k
,
v
in
hist
.
iter
items
():
for
k
,
v
in
hist
.
items
():
p
=
v
/
float
(
self
.
g
.
num_vertices
())
S_seq
-=
p
*
log
(
p
)
S_seq
*=
self
.
g
.
num_vertices
()
S
+=
S_seq
if
self
.
deg_corr
:
S
-=
E
for
v
in
self
.
g
.
vertices
():
S
-=
scipy
.
special
.
gammaln
(
v
.
out_degree
()
+
1
)
...
...
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