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
0d2a5c24
There was a problem fetching the pipeline summary.
Commit
0d2a5c24
authored
7 years ago
by
Jarrod Pas
Browse files
Options
Downloads
Patches
Plain Diff
Move more specific node types to pydtn.community
parent
ff96d8e3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!8
Adds kclique to simulation
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/shed.py
+6
-34
6 additions, 34 deletions
examples/shed.py
pydtn/community.py
+59
-0
59 additions, 0 deletions
pydtn/community.py
with
65 additions
and
34 deletions
examples/shed.py
+
6
−
34
View file @
0d2a5c24
...
...
@@ -8,42 +8,14 @@ from collections import namedtuple
from
multiprocessing
import
Pool
from
pydtn
import
Network
,
RandomTraffic
,
Node
,
EpidemicNode
from
pydtn.community
import
Bubble
Node
,
HCBF
Node
from
pydtn.community
import
LouvainCommunity
,
KCliqueCommunity
from
pydtn.community
import
Bubble
KCliqueNode
,
BubbleLouvain
Node
from
pydtn.community
import
HCBFKCliqueNode
,
HCBFLouvainNode
from
pydtn.shed
import
ShedTrace
Simulation
=
namedtuple
(
'
Simulation
'
,
[
'
trace
'
,
'
node_type
'
,
'
seed
'
])
class
LouvainNode
(
Node
):
def
__init__
(
self
,
**
options
):
options
[
'
community
'
]
=
LouvainCommunity
(
options
[
'
epoch
'
])
super
().
__init__
(
**
options
)
class
LouvainHCBFNode
(
LouvainNode
,
HCBFNode
):
pass
class
LouvainBubbleNode
(
LouvainNode
,
BubbleNode
):
pass
class
KCliqueNode
(
Node
):
def
__init__
(
self
,
**
options
):
options
[
'
community
'
]
=
KCliqueCommunity
(
options
[
'
epoch
'
],
options
[
'
k
'
])
super
().
__init__
(
**
options
)
class
KCliqueHCBFNode
(
KCliqueNode
,
HCBFNode
):
pass
class
KCliqueBubbleNode
(
KCliqueNode
,
BubbleNode
):
pass
def
run_simulation
(
simulation
):
"""
Run a simulation.
"""
seed
=
simulation
.
seed
...
...
@@ -92,10 +64,10 @@ def main(args):
node_types
=
[
Node
,
EpidemicNode
,
KCliqu
eBubbl
eNode
,
KClique
HCBF
Node
,
Louvain
Bubble
Node
,
Louvain
HCBF
Node
,
Bubble
KCliqueNode
,
HCBF
KCliqueNode
,
Bubble
LouvainNode
,
HCBF
LouvainNode
,
]
for
seed
in
args
[
'
seeds
'
]:
...
...
This diff is collapsed.
Click to expand it.
pydtn/community.py
+
59
−
0
View file @
0d2a5c24
...
...
@@ -16,8 +16,14 @@ __all__ = [
"
LouvainCommunity
"
,
"
CommunityNode
"
,
"
KCliqueNode
"
,
"
LouvainNode
"
,
"
BubbleNode
"
,
"
BubbleKCliqueNode
"
,
"
BubbleLouvainNode
"
,
"
HCBFNode
"
,
"
HCBFKCliqueNode
"
,
"
HCBFLouvainNode
"
,
]
__author__
=
'
Jarrod Pas <j.pas@usask.ca>
'
...
...
@@ -301,6 +307,35 @@ class CommunityNode(Node):
]
class
LouvainNode
(
CommunityNode
):
"""
Wrapper to add louvain community detection automatically to a node.
"""
def
__init__
(
self
,
**
options
):
"""
Create lovain node.
Keyword Arguments:
epoch -- how often to recalculate communities
"""
options
[
'
community
'
]
=
LouvainCommunity
(
options
[
'
epoch
'
])
super
().
__init__
(
**
options
)
class
KCliqueNode
(
CommunityNode
):
"""
Wrapper to add kclique community detection automatically to a node.
"""
def
__init__
(
self
,
**
options
):
"""
Create k-clique node.
Keyword Arguments:
epoch -- how often to recalculate communities
k -- initial community size
"""
options
[
'
community
'
]
=
KCliqueCommunity
(
options
[
'
epoch
'
],
options
[
'
k
'
])
super
().
__init__
(
**
options
)
def
_decide
(
node
,
others
,
key
):
"""
Make a decision on which node to send to best is decided based on key.
...
...
@@ -349,6 +384,18 @@ class BubbleNode(CommunityNode):
return
{}
class
BubbleKCliqueNode
(
KCliqueNode
,
BubbleNode
):
"""
Bubble node with k-clique community detection.
"""
pass
class
BubbleLouvainNode
(
LouvainNode
,
BubbleNode
):
"""
Bubble node with louvain community detection.
"""
pass
class
HCBFNode
(
CommunityNode
):
"""
Node with Hybrid Community Based forwarding.
"""
...
...
@@ -392,3 +439,15 @@ class HCBFNode(CommunityNode):
return
{
target
:
'
local-popularity
'
}
return
{}
class
HCBFKCliqueNode
(
KCliqueNode
,
HCBFNode
):
"""
HCBF node with k-clique community detection.
"""
pass
class
HCBFLouvainNode
(
LouvainNode
,
HCBFNode
):
"""
HCBF node with louvain community detection.
"""
pass
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