Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please provide support for weighted hypergraphs #35

Closed
jim-rafferty opened this issue Jun 24, 2020 · 6 comments
Closed

Please provide support for weighted hypergraphs #35

jim-rafferty opened this issue Jun 24, 2020 · 6 comments

Comments

@jim-rafferty
Copy link

Hi, this is a really good package :)

It would be loads more useful if you could provide support for weighted hypergraphs. It seems to be possible to create a weighted hypergraph at the moment like this:

import itertools
import hypernetx as hnx
import numpy as np

labels = "ABCD"
nodes = set(labels)
edges = list(
    itertools.chain(
        *[list(itertools.combinations(set(labels), ii)) for ii in range(2, len(labels))]
    )
)
hnx_edges = hnx.EntitySet(
    "Edges", 
    [hnx.Entity(
            "".join(ee), 
            ee,
            weight=np.random.rand() 
        ) for ee in edges]
)

h = hnx.Hypergraph(hnx_edges)
hnx.draw(h)
print(h.edges.elements)

but it's not possible to do any analysis with the weights as far as I can tell (see for example, the output of hnx.dist_stats(h) )

Are there any plans to add this type of functionality?

Thanks!

@brendapraggastis
Copy link
Collaborator

Thanks @jim-rafferty,
You are correct, at present we only have the ability to add weight (or any other property) to an Entity. What we do with that information needs to be added to the library. We hope to include it in all of our statistics and algorithms but are slow to release anything before we know how best to integrate it into the existing code. If you have specific suggestions or would like to contribute code, that would be great. Stay tuned as we hope to have some new material pushed by the end of summer.

@jim-rafferty
Copy link
Author

Thanks @brendapraggastis

I realise my initial request was horribly vague and open ended - apologies. I will have a look at the code and see if I can send you a PR.

Thanks again.

@michaeldorner
Copy link

michaeldorner commented Jul 6, 2021

Have I understood that correctly: Any property added to an edge (via Entity property) is not accessible in the graph?

edges_set = hnx.EntitySet(
    "edges", 
    elements = [hnx.Entity('e1', elements=['a', 'b'], weight=1)]
)
hnx.Hypergraph(edges_set).edges.elements

No change to get the weight?

@vivek2000anand
Copy link

Could we please get an answer to the above question?
Also, since this thread is about an year old, have there been any updates with weighted hyperedges?
#35 (comment)

@brendapraggastis
Copy link
Collaborator

To answer @michaeldorner , when the hypergraph is generated it creates a copy of the EntitySet so any change to the original EntitySet will not be reflected in the hypergraph.

@Vivdaddy : We are actively working on the most intuitive and useful way to add metadata to a hypergraph. Currently attributes can be added directly to the nodes and edges. Tutorial 13 based on our hypergraph modularity module uses the attributes strength and weight on the nodes and edges. Have a look specifically at the precompute_attributes method starting on line 74 of the module.

@vivek2000anand
Copy link

Thank you, I will check it out.

bonicim added a commit that referenced this issue May 15, 2023
Merge in HYP/hypernetx from devops/modify-precommit to develop

* commit '0d0939bd3ab594d82e50ecc716d32a339b75b9b9':
  Remove mypy from CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants