def log_likelihood_network(<EOL>digraph, traffic_in, traffic_out, params, weight=None):
loglik = <NUM_LIT:0><EOL>for i in range(len(traffic_in)):<EOL><INDENT>loglik += traffic_in[i] * params[i]<EOL>if digraph.out_degree(i) > <NUM_LIT:0>:<EOL><INDENT>neighbors = list(digraph.successors(i))<EOL>if weight is None:<EOL><INDENT>loglik -= traffic_out[i] * logsumexp(params.take(neighbors))<EOL><DEDENT>else:<EOL><INDENT>weights = [digraph[i][j][weight] for j in neighbors]<EOL>loglik -= traffic_out[i] * logsumexp(<EOL>params.take(neighbors), b=weights)<EOL><DEDENT><DEDENT><DEDENT>return loglik<EOL>
Compute the log-likelihood of model parameters.

If ``weight`` is not ``None``, the log-likelihood is correct only up to a
constant (independent of the parameters).