Skip to content

multiorder laplacian #16

@federicomalizia

Description

@federicomalizia

hi,

I'm considering a "real" hypergraph, while computing the laplacians of any order I found this error:

 
      9 hypergraph = Hypergraph(hyperedges_list)
---> 10 laplacians = laplacian_matrices_all_orders(hypergraph)
     11 
     12 

~/anaconda3/lib/python3.9/site-packages/hypergraphx/linalg/linalg.py in laplacian_matrices_all_orders(hypergraph, weighted, shape)
    422     laplacian_matrices = {}
    423     for order in range(1, hypergraph.max_order() + 1):
--> 424         laplacian_matrices[order] = laplacian_matrix_by_order(
    425             hypergraph, order, weighted, shape
    426         )

~/anaconda3/lib/python3.9/site-packages/hypergraphx/linalg/linalg.py in laplacian_matrix_by_order(hypergraph, order, weighted, shape)
    407 
    408     #maybe wrong mapping of nodes? binary incidence returns the mapping of the nodes in the hypergraph
--> 409     degree_mtx = degree_matrix(hypergraph, order, mapping)
    410     laplacian = degree_mtx.multiply(order + 1) - incidence.dot(incidence.transpose())
    411 

~/anaconda3/lib/python3.9/site-packages/hypergraphx/linalg/linalg.py in degree_matrix(hypergraph, order, mapping)
    393         # calcolare il mapping dall'ipergrafo
    394         pass
--> 395     degree_lst = [degree_dct[inverse_mapping[n]] for n in sorted(inverse_mapping.keys())]
    396 
    397     return sparse.diags(degree_lst)

~/anaconda3/lib/python3.9/site-packages/hypergraphx/linalg/linalg.py in <listcomp>(.0)
    393         # calcolare il mapping dall'ipergrafo
    394         pass
--> 395     degree_lst = [degree_dct[inverse_mapping[n]] for n in sorted(inverse_mapping.keys())]
    396 
    397     return sparse.diags(degree_lst)

KeyError: 0

I think it is due to the presence of nodes which are not connected to any hyperedge of order 2 (triples).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions