Commit 2bf29df9 authored by Jeff Trull's avatar Jeff Trull
Browse files

Merge branch 'master' into header-cleanup

parents 1dc8f781 541f949c
Pipeline #671 failed with stage
in 692 minutes and 58 seconds
.. _planted_partition:
Assortative community structure
-------------------------------
Traditionally, `"community structure"
<https://en.wikipedia.org/wiki/Community_structure>`_ in the proper
sense refers to groups of nodes that are more connected to each other
than to nodes of other communities. The SBM is capable of representing
this kind of structure without any problems, but in some circumstances
it might make sense to search exclusively for assortative communities
[lizhi-statistical-2020]_. A version of the SBM that is constrained in
this way is called the "planted partition model", which can be inferred
with graph-tool using
:class:`~graph_tool.inference.planted_partition.PPBlockState`. This
class behaves just like
:class:`~graph_tool.inference.blockmodel.BlockState`, therefore all
algorithms described in this documentation work in the same way. Below
we show how this model can be inferred for the football network
considered previously
.. testsetup:: assortative
import os
try:
os.chdir("demos/inference")
except FileNotFoundError:
pass
gt.seed_rng(42)
.. testcode:: assortative
g = gt.collection.data["football"]
state = gt.PPBlockState(g)
# Now we run 1,000 sweeps of the MCMC with zero temperature.
state.multiflip_mcmc_sweep(beta=np.inf, niter=1000)
state.draw(pos=g.vp.pos, output="football-pp.svg")
.. figure:: football-pp.*
:align: center
:width: 350px
Best fit of the degree-corrected planted partition model to a
network of American college football teams.
It is possible to perform model comparison with other model variations
in the same manner as described in :ref:`sec_model_selection` below.
......@@ -430,6 +430,7 @@ class PropertyMap(object):
"long double", "vector<bool>", "vector<int16_t>",
"vector<int32_t>", "vector<int64_t>", "vector<double>",
"vector<long double>", "string", "vector<string>"]
p = None
for t in types:
try:
p = self.copy(value_type=t, full=full)
......@@ -439,8 +440,10 @@ class PropertyMap(object):
continue
if p.copy(value_type=self.value_type(), full=full) == self:
break
except (TypeError, ValueError, OverflowError):
except (TypeError, ValueError, OverflowError, AttributeError):
pass
if p is None:
p = self.copy()
return p
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment