Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion algorithm/LPA.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def get_max_neighbor_label(self,node_index):
for neighbor_index in self._G.neighbors(node_index):
neighbor_label = self._G.node[neighbor_index]["label"]
m[neighbor_label] += 1

if(not bool(m)):
#return label of the vertex itself if it's an isolated vertex
return [self._G.node[node_index]["label"]]

max_v = max(m.itervalues())
return [item[0] for item in m.items() if item[1] == max_v]

Expand Down Expand Up @@ -68,4 +73,4 @@ def execute(self):
algorithm = LPA(G)
communities = algorithm.execute()
for community in communities:
print community
print community