Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pydtnsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
discus
pydtnsim
Commits
04e5f2dd
Commit
04e5f2dd
authored
2 years ago
by
ArktikHunter
Browse files
Options
Downloads
Patches
Plain Diff
forgot a file
parent
0752d04b
No related branches found
Branches containing commit
No related tags found
1 merge request
!21
pydtn agkmeans and version 1.0
Pipeline
#10894
failed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pydtnsim/community.py
+26
-26
26 additions, 26 deletions
pydtnsim/community.py
with
26 additions
and
26 deletions
pydtnsim/community.py
+
26
−
26
View file @
04e5f2dd
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment