Skip to content
Snippets Groups Projects

pydtn agkmeans and version 1.0

Merged Hunter McConnell (rtm534) requested to merge summer2022 into develop
1 file
+ 26
26
Compare changes
  • Side-by-side
  • Inline
+ 26
26
@@ -334,19 +334,19 @@ class CommunityNode(Node):
]
def shared_community(context, create):
"""
Check context for shared community and return a shared community.
def shared_community(context, create):
"""
Check context for shared community and return a shared community.
Use this for community detection algorithms that must have one instance
for a set of nodes.
"""
if "shared-community" in context:
return context["shared-community"]
Use this for community detection algorithms that must have one instance
for a set of nodes.
"""
if "shared-community" in context:
return context["shared-community"]
community = create()
context["shared-community"] = community
return community
community = create()
context["shared-community"] = community
return community
class LouvainNode(CommunityNode):
@@ -403,25 +403,25 @@ class AGKmeansNode(CommunityNode):
super().__init__(**options)
def _decide(node, others, key):
"""
Make a decision on which node to send to best is decided based on key.
def _decide(node, others, key):
"""
Make a decision on which node to send to best is decided based on key.
If the best is better than node, return best.
If node is better than the best, return node.
If the best and node are equal, return None.
"""
best = max(others, key=key)
best_key = key(best)
node_key = key(node)
If the best is better than node, return best.
If node is better than the best, return node.
If the best and node are equal, return None.
"""
best = max(others, key=key)
best_key = key(best)
node_key = key(node)
if best_key > node_key:
return best
if best_key > node_key:
return best
if best_key < node_key:
return node
if best_key < node_key:
return node
return None
return None
class BubbleNode(CommunityNode):
Loading