Giter Club home page Giter Club logo

Comments (9)

xmweijh avatar xmweijh commented on June 15, 2024

我用了club数据集,跑出来的Q值是0.2869而不是CSDN展示的0.38,请问是什么问题呢?

我这里是正常的,可能是随机数的影响?

from communitydetection.

jiymyq avatar jiymyq commented on June 15, 2024
G = load_graph('club.txt')
obj = Graph()
G1 = obj.createGraph("club.txt")

start_time = time.time()
algorithm = Louvain(G)
communities = algorithm.execute()
end_time = time.time()
# 按照社区大小从大到小排序输出
communities = sorted(communities, key=lambda b: -len(b))  # 按社区大小排序
count = 0
for communitie in communities:
    count += 1
    print("社区", count, " ", communitie)

print(cal_Q(communities, G1))
print(f'算法执行时间{end_time - start_time}')

from communitydetection.

jiymyq avatar jiymyq commented on June 15, 2024
G = load_graph('club.txt')
obj = Graph()
G1 = obj.createGraph("club.txt")

start_time = time.time()
algorithm = Louvain(G)
communities = algorithm.execute()
end_time = time.time()
# 按照社区大小从大到小排序输出
communities = sorted(communities, key=lambda b: -len(b))  # 按社区大小排序
count = 0
for communitie in communities:
    count += 1
    print("社区", count, " ", communitie)

print(cal_Q(communities, G1))
print(f'算法执行时间{end_time - start_time}')

主要代码是这样的,应该也没什么能错的地方啊。。。

from communitydetection.

jiymyq avatar jiymyq commented on June 15, 2024
G = load_graph('club.txt')
obj = Graph()
G1 = obj.createGraph("club.txt")

start_time = time.time()
algorithm = Louvain(G)
communities = algorithm.execute()
end_time = time.time()
# 按照社区大小从大到小排序输出
communities = sorted(communities, key=lambda b: -len(b))  # 按社区大小排序
count = 0
for communitie in communities:
    count += 1
    print("社区", count, " ", communitie)

print(cal_Q(communities, G1))
print(f'算法执行时间{end_time - start_time}')

主要代码是这样的,应该也没什么能错的地方啊。。。

最终分区的结果是一样的,就是Q值不对。

from communitydetection.

xmweijh avatar xmweijh commented on June 15, 2024
G = load_graph('club.txt')
obj = Graph()
G1 = obj.createGraph("club.txt")

start_time = time.time()
algorithm = Louvain(G)
communities = algorithm.execute()
end_time = time.time()
# 按照社区大小从大到小排序输出
communities = sorted(communities, key=lambda b: -len(b))  # 按社区大小排序
count = 0
for communitie in communities:
    count += 1
    print("社区", count, " ", communitie)

print(cal_Q(communities, G1))
print(f'算法执行时间{end_time - start_time}')

主要代码是这样的,应该也没什么能错的地方啊。。。

最终分区的结果是一样的,就是Q值不对。

obj.createGraph有点问题,邻居没重复计算。所以我用的G1 = nx.karate_club_graph()。以后有空修改下。

from communitydetection.

xmweijh avatar xmweijh commented on June 15, 2024

改为无向图就行了, self.graph = nx.Graph()

from communitydetection.

jiymyq avatar jiymyq commented on June 15, 2024

改为无向图就行了, self.graph = nx.Graph()

哇,确实解决了,感谢大佬。

from communitydetection.

LBJgigigi avatar LBJgigigi commented on June 15, 2024

我用了俱乐部数据集,跑出来的Q值是0.2869而不是CSDN展示的0.38,请问是什么问题呢?
有偿求教

from communitydetection.

LBJgigigi avatar LBJgigigi commented on June 15, 2024

想求教这个louvain算法的整个流程讲解,我需要对其进行改进,有偿求教,微信号LBJgigigi13

from communitydetection.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.