Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • graph-tool graph-tool
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 48
    • Issues 48
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Please use the issue tracker only to report bugs (i.e. errors in the library that need to be fixed) or feature requests.

For questions about how to compile, install or use the library, please use instead the web forum at https://forum.skewed.de/c/graph-tool.


(If unsure, use the forum first.)


IMPORTANT: When opening new issues, please choose the BUG template from the drop-down menu, and fill out the required information.

  • Tiago Peixoto
  • graph-toolgraph-tool
  • Issues
  • #426
Closed
Open
Issue created Nov 08, 2017 by David W@Sinthoras

Link Prediction with get_edges_prob

I am trying to use the nested SBM for link prediction. I get the error "segmentation fault (core dumped)" running the following code.

import graph_tool.all as gt
import random
import numpy as np

G = gt.collection.data["celegansneural"]
# Advice from issue #375
G = gt.Graph(G, directed=False, prune=True)
# Find the approximate Block separation of the Network
ground_state_estimation = gt.minimize_nested_blockmodel_dl(G, mcmc_args=dict(niter=1000))
# Take 1% of the non existent edges as potential edges
potential_edges = [(v1, v2) for v1 in G.vertices() for v2 in G.vertices() if random.random() < 0.01 if not ((v1, v2) in G.edges() or v1 <= v2)]
probs = [[] for _ in range(len(potential_edges))]
bs = ground_state_estimation.get_bs()
bs += [np.zeros(1)] * (10 - len(bs))
ground_state = ground_state_estimation.copy(bs=bs, sampling=True)

def collect_edge_probs(s):
    for i in range(len(potential_edges)):
        p = s.get_edges_prob([potential_edges[i]], entropy_args=dict(partition_dl=False))  # Here the error seems to happen
        probs[i].append(p)

gt.mcmc_equilibrate(ground_state, force_niter=1000, mcmc_args=dict(niter=10), callback=collect_edge_probs)

def get_avg(p):
    p = np.array(p)
    p_avg = np.exp(p).mean()
    return p_avg

probabilities = [(potential_edges[i][0], potential_edges[i][1], get_avg(probs[i])) for i in range(len(potential_edges))]
probabilities = sorted(probabilities, key=lambda probabilities: probabilities[2], reverse=True)
print probabilities

The error seems to appear in the function s.get_edges_prob() during one of the later calls of the function. When running with less Monte Carlo Sweeps or a smaller network it seems to work better. I used version 2.24 (latest version I could get from the apt repository), but since then no changes in the used functions have been made.

Assignee
Assign to
Time tracking