Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
graph-tool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
40
Issues
40
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tiago Peixoto
graph-tool
Commits
e81cdd98
Commit
e81cdd98
authored
Jul 11, 2020
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PPBlockState(): add compatibility functions
This fixes issue #668
parent
d546bb2b
Pipeline
#688
passed with stage
in 100 minutes and 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
src/graph_tool/inference/planted_partition.py
src/graph_tool/inference/planted_partition.py
+16
-0
No files found.
src/graph_tool/inference/planted_partition.py
View file @
e81cdd98
...
...
@@ -130,6 +130,10 @@ class PPBlockState(object):
r
"Returns the total number of blocks."
return
len
(
np
.
unique
(
self
.
b
.
fa
))
def
get_nonempty_B
(
self
):
r
"Alias to :meth:`~PPBlockState.get_B`."
return
self
.
get_B
()
def
get_Be
(
self
):
r
"""Returns the effective number of blocks, defined as :math:`e^{H}`, with
:math:`H=-\sum_r\frac{n_r}{N}\ln \frac{n_r}{N}`, where :math:`n_r` is
...
...
@@ -140,6 +144,18 @@ class PPBlockState(object):
w
/=
w
.
sum
()
return
numpy
.
exp
(
-
(
w
*
log
(
w
)).
sum
())
def
virtual_vertex_move
(
self
,
v
,
s
,
**
kwargs
):
r
"""Computes the entropy difference if vertex ``v`` is moved to block ``s``. The
remaining parameters are the same as in
:meth:`~graph_tool.inference.planted_partition.PPBlockState.entropy`."""
return
self
.
_state
.
virtual_move
(
int
(
v
),
self
.
b
[
v
],
s
,
get_pp_entropy_args
(
dict
(
self
.
_entropy_args
,
**
kwargs
)))
def
move_vertex
(
self
,
v
,
s
):
r
"""Move vertex ``v`` to block ``s``."""
self
.
_state
.
move_vertex
(
int
(
v
),
int
(
s
))
def
entropy
(
self
,
uniform
=
False
,
degree_dl_kind
=
"distributed"
,
**
kwargs
):
r
"""Return the model entropy (negative log-likelihood).
...
...
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