[Python] graph-tool crashes with segmentation fault at minimize_nested_blockmodel_dl() when...

Discussão em 'Python' iniciado por Stack, Maio 21, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to run a weighted Stochastic Block Model (SBM) using graph-tool on a bipartite gene–SNP network, but I consistently hit a segmentation fault or ValueError: zero-size array at the line:

    state = gt.minimize_nested_blockmodel_dl(g, state_args={"eweight": edge_weight})


    Heres example code:


    g = gt.Graph(directed=False)
    vprop_type = g.new_vertex_property("int")
    vmap = {}
    eprop_weight = g.new_edge_property("float")

    def add_vertex(name, ntype):
    if name not in vmap:
    v = g.add_vertex()
    vmap[name] = v
    vprop_type[v] = ntype
    return vmap[name]

    for _, row in df.iterrows():
    v1 = add_vertex(row['left_node'], 0)
    v2 = add_vertex(row['right_node'], 1)
    e = g.add_edge(v1, v2)
    eprop_weight[e] = row['weight']

    g.vp["type"] = vprop_type
    g.ep["weight"] = eprop_weight

    state = gt.minimize_nested_blockmodel_dl(g, state_args={"eweight": eprop_weight})




    I have:

    • Created an undirected bipartite graph
    • Assigned node types
    • Assigned edge weights, all values in the range [0.1, 1.0], strictly positive
    • Verified all edges and weights exist: number of edges > 27,000 No nodes are isolated
    • Edge weight property was correctly added
    • The unweighted SBM runs fine

    Environment:

    graph-tool version: (tried a couple...)

    Python version: 3.13, 3.11, 3.10 (via Homebrew)

    macOS: Ventura 13.x (Apple M1)

    Graph has ~4,500 nodes, ~27,000 edges

    Are there any known bugs related to edge-weighted SBM in graph-tool that I might be hitting?

    Any tips for stabilizing or debugging weighted SBM inference on bipartite graphs?

    Continue reading...

Compartilhe esta Página