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

How to transform a igraph or networkx object into hypergraph? #29

Open
wanglu2014 opened this issue Feb 13, 2023 · 5 comments
Open

How to transform a igraph or networkx object into hypergraph? #29

wanglu2014 opened this issue Feb 13, 2023 · 5 comments

Comments

@wanglu2014
Copy link

How to transform a igraph or networkx object into hypergraph object used in DHG?

@yifanfeng97
Copy link
Member

yifanfeng97 commented Feb 15, 2023

Hi, you can extract the edge list and the number of vertices from G of networkx. Then, you can construct a DHG's Graph with the default construction function https://deephypergraph.readthedocs.io/en/0.9.3/api/dhg.html#dhg.Graph .
We will add the transform function of structures from igraph and networkx libraries in the next version. ^^

@wanglu2014
Copy link
Author

Thank you for your timely reply. Could you kindly suggest how to set node attribute?

@yifanfeng97
Copy link
Member

If you don't have the node attribute, you can try the following ways:

  1. initialize the vertex feature with the normal distribution and set it as trainable parameters. (Common in recommender system)
  2. initialize the vertex feature with the normal distribution.
  3. initialize the vertex feature with a one-hot encoded vector. (you can encode the degree of each vertex or directly use a identity matrix as the vertex feature)
  4. train a auto encoder: the input is the adjacency matrix A and the output is the same. initialize the vertex feature with the hidden embeddings.

@wanglu2014
Copy link
Author

Thanks. If I want to set a numeric vector (degree) as node attribute. How to assign the numbers to nodes?

@yifanfeng97
Copy link
Member

You can try to transform the degree to a one-hot vector. Refer to this https://github.com/weihua916/powerful-gnns/blob/master/util.py#L118

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

2 participants