Commit 0b01305b authored by Tiago Peixoto's avatar Tiago Peixoto

latent_multigraph(): Add `verbose` parameter

parent 36d81582
...@@ -25,7 +25,8 @@ using namespace boost; ...@@ -25,7 +25,8 @@ using namespace boost;
using namespace graph_tool; using namespace graph_tool;
void latent_multigraph(GraphInterface& gi, boost::any aw, boost::any atheta_out, void latent_multigraph(GraphInterface& gi, boost::any aw, boost::any atheta_out,
boost::any atheta_in, double epsilon, size_t max_niter) boost::any atheta_in, double epsilon, size_t max_niter,
bool verbose)
{ {
typedef eprop_map_t<double>::type emap_t; typedef eprop_map_t<double>::type emap_t;
typedef vprop_map_t<double>::type vmap_t; typedef vprop_map_t<double>::type vmap_t;
...@@ -35,7 +36,7 @@ void latent_multigraph(GraphInterface& gi, boost::any aw, boost::any atheta_out, ...@@ -35,7 +36,7 @@ void latent_multigraph(GraphInterface& gi, boost::any aw, boost::any atheta_out,
run_action<>() run_action<>()
(gi, [&](auto& g){ get_latent_multigraph(g, w, theta_out, theta_in, (gi, [&](auto& g){ get_latent_multigraph(g, w, theta_out, theta_in,
epsilon, max_niter); })(); epsilon, max_niter, verbose); })();
} }
using namespace boost::python; using namespace boost::python;
......
...@@ -34,7 +34,7 @@ using namespace boost; ...@@ -34,7 +34,7 @@ using namespace boost;
template <class Graph, class WMap, class TMap> template <class Graph, class WMap, class TMap>
void get_latent_multigraph(Graph& g, WMap w, TMap theta_out, TMap theta_in, void get_latent_multigraph(Graph& g, WMap w, TMap theta_out, TMap theta_in,
double epsilon, size_t max_niter) double epsilon, size_t max_niter, bool verbose)
{ {
auto wc = w.get_checked(); auto wc = w.get_checked();
for (auto v : vertices_range(g)) for (auto v : vertices_range(g))
...@@ -101,6 +101,8 @@ void get_latent_multigraph(Graph& g, WMap w, TMap theta_out, TMap theta_in, ...@@ -101,6 +101,8 @@ void get_latent_multigraph(Graph& g, WMap w, TMap theta_out, TMap theta_in,
} }
}); });
niter++; niter++;
if (verbose)
cout << delta << endl;
} }
}; };
......
...@@ -25,7 +25,7 @@ dl_import("from . import libgraph_tool_inference as libinference") ...@@ -25,7 +25,7 @@ dl_import("from . import libgraph_tool_inference as libinference")
from numpy import sqrt from numpy import sqrt
def latent_multigraph(g, epsilon=1e-8, max_niter=0): def latent_multigraph(g, epsilon=1e-8, max_niter=0, verbose=False):
r"""Infer latent Poisson multigraph model given an "erased" simple graph. r"""Infer latent Poisson multigraph model given an "erased" simple graph.
Parameters Parameters
...@@ -36,6 +36,8 @@ def latent_multigraph(g, epsilon=1e-8, max_niter=0): ...@@ -36,6 +36,8 @@ def latent_multigraph(g, epsilon=1e-8, max_niter=0):
Convergence criterion. Convergence criterion.
max_niter : ``int`` (optional, default: ``0``) max_niter : ``int`` (optional, default: ``0``)
Maximum number of iterations allowed (if ``0``, no maximum is assumed). Maximum number of iterations allowed (if ``0``, no maximum is assumed).
verbose : ``boolean`` (optional, default: ``False``)
If ``True``, display verbose information.
Returns Returns
------- -------
...@@ -69,6 +71,5 @@ def latent_multigraph(g, epsilon=1e-8, max_niter=0): ...@@ -69,6 +71,5 @@ def latent_multigraph(g, epsilon=1e-8, max_niter=0):
_prop("e", g, w), _prop("e", g, w),
_prop("v", g, theta_out), _prop("v", g, theta_out),
_prop("v", g, theta_in), _prop("v", g, theta_in),
epsilon, epsilon, max_niter, verbose)
max_niter)
return g, w return g, w
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