iMoonLab / DeepHypergraph

A pytorch library for graph and hypergraph computation.

Home Page:https://deephypergraph.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

超图的顶点度矩阵D_v

liuzhh1998 opened this issue · comments

如果生成一个5个顶点以及3条边的超图,超边的权重为2,3,4
hg = dhg.Hypergraph(5, [(0, 1, 2), (2, 3), (0, 4)], [2.0, 3.0, 4.0])
dhg中计算得到的D_v为 :
tensor([[2., 0., 0., 0., 0.],
[0., 1., 0., 0., 0.],
[0., 0., 2., 0., 0.],
[0., 0., 0., 1., 0.],
[0., 0., 0., 0., 1.]])
但是按照实际的定义以及论文“Hypergraph Neural Networks”所展示的:
For a vertex v ∈ V, its degree is defined as d(v) =Σ ω(e)h(v, e)

从严谨的角度来讲,这里你提的问题是对的,确实D_v应该多乘上一个W。我这里因为目前处理的都是等权超边的超图,所以实现D_v的时候只对H的列做了sum,并没有乘上W。我会在下个版本修复这个bug,或者你也可以尝试提交pull request哦!

预计一周内会发一个新版本,你还有没有一些其他的需求?我可以顺便都加上

好,在实际的超图的抽象类里面,我已经增加了顶点权重,原本计划后续版本再把顶点权重放出来。我可以在下个版本提前增加顶点权重到无向超图类里面!

Reference in

Fix in 7786e2d .

hg = dhg.Hypergraph(5, [(0, 1, 2), (2, 3), (0, 4)], [2.0, 3.0, 4.0])
最新main分支中dhg中计算得到的D_v为 :
tensor([[6., 0., 0., 0., 0.],
[0., 2., 0., 0., 0.],
[0., 0., 5., 0., 0.],
[0., 0., 0., 3., 0.],
[0., 0., 0., 0., 4.]])

方便的话,可以star一下哦!

e17fc95 增加了 v_weight
在超图构建的时候传入参数v_weight即可初始化节点权重
W_v : https://deephypergraph.readthedocs.io/en/latest/api/dhg.html#dhg.Hypergraph.W_v
这个新特性预计这两天随着dhg 0.9.3 一起发布

已发布 0.9.3 https://pypi.org/project/dhg/
可以直接pip install dhg 来安装0.9.3啦