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
6cccd783
Commit
6cccd783
authored
Dec 06, 2013
by
Tiago Peixoto
Browse files
Correct degree sequence description length in blockmodel.py
parent
2d574cb3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/community/blockmodel.py
View file @
6cccd783
...
...
@@ -297,10 +297,10 @@ class BlockState(object):
.. math::
\mathcal{L}_c = \mathcal{L}_t -
N
\sum_kp_k\ln p_k,
\mathcal{L}_c = \mathcal{L}_t -
\sum_rn_r
\sum_kp
^r
_k\ln p
^r
_k,
where :math:`p_k` is the fraction of nodes with degree :math:`
p_k`, an
d
we have instead :math:`k \to (k^-, k^+)`
for directed graphs
.
where :math:`p
^r
_k` is the fraction of nodes
in block $r$
with degree :math:`
k`. For directe
d
graphs
we have instead :math:`k \to (k^-, k^+)`.
If the "dense" entropies are requested, they will be computed as
...
...
@@ -378,15 +378,15 @@ class BlockState(object):
else
:
S
+=
model_entropy
(
self
.
B
,
N
,
E
,
directed
=
self
.
g
.
is_directed
(),
nr
=
self
.
wr
.
a
)
*
E
if
complete
and
self
.
deg_corr
:
if
self
.
deg_corr
:
S_seq
=
0
hist
=
defaultdict
(
int
)
hist
=
[
defaultdict
(
int
)
for
r
in
range
(
self
.
B
)]
for
v
in
self
.
g
.
vertices
():
hist
[(
v
.
in_degree
(),
v
.
out_degree
())]
+=
1
for
k
,
v
in
hist
.
items
(
):
p
=
v
/
float
(
self
.
g
.
num_vertice
s
()
)
S_seq
-=
p
*
log
(
p
)
S_seq
*=
self
.
g
.
num_vertices
()
hist
[
self
.
b
[
v
]][
(
v
.
in_degree
(),
v
.
out_degree
())]
+=
1
for
r
in
range
(
self
.
B
):
for
k
,
v
in
hist
[
r
].
item
s
()
:
p
=
v
/
float
(
self
.
wr
.
a
[
r
]
)
S_seq
-=
p
*
log
(
p
)
*
self
.
wr
.
a
[
r
]
S
+=
S_seq
return
S
/
E
...
...
Write
Preview
Supports
Markdown
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