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
95613970
Commit
95613970
authored
7 years ago
by
Jarrod Pas
Browse files
Options
Downloads
Patches
Plain Diff
Fix bugs in community detection base
parent
030475fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!3
Version 0.2
,
!1
Full rewrite
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pydtn/community.py
+9
-9
9 additions, 9 deletions
pydtn/community.py
with
9 additions
and
9 deletions
pydtn/community.py
+
9
−
9
View file @
95613970
...
@@ -140,7 +140,7 @@ class Community:
...
@@ -140,7 +140,7 @@ class Community:
return
0
return
0
return
sum
(
return
sum
(
edge
[
'
duration
'
]
edge
[
'
weight
'
]
for
other
,
edge
in
graph
[
node
].
items
()
for
other
,
edge
in
graph
[
node
].
items
()
if
other
in
node
.
community
if
other
in
node
.
community
)
)
...
@@ -153,7 +153,7 @@ class Community:
...
@@ -153,7 +153,7 @@ class Community:
return
0
return
0
return
sum
(
return
sum
(
edge
[
'
duration
'
]
edge
[
'
weight
'
]
for
other
,
edge
in
graph
[
node
].
items
()
for
other
,
edge
in
graph
[
node
].
items
()
if
other
not
in
node
.
community
if
other
not
in
node
.
community
)
)
...
@@ -165,11 +165,11 @@ class Community:
...
@@ -165,11 +165,11 @@ class Community:
if
node
not
in
graph
:
if
node
not
in
graph
:
return
0
return
0
return
len
(
return
len
(
[
other
other
for
other
in
node
.
community
for
other
in
node
.
community
if
graph
.
has_edge
(
node
,
node
)
if
graph
.
has_edge
(
node
,
node
)
)
]
)
def
community_betweenness
(
self
,
node_a
,
node_b
):
def
community_betweenness
(
self
,
node_a
,
node_b
):
"""
Return community betweenness for 2 nodes.
"""
"""
Return community betweenness for 2 nodes.
"""
...
@@ -181,12 +181,12 @@ class Community:
...
@@ -181,12 +181,12 @@ class Community:
return
float
(
'
inf
'
)
return
float
(
'
inf
'
)
return
sum
(
return
sum
(
graph
[
a
][
b
][
'
duration
'
]
graph
[
a
][
b
][
'
weight
'
]
for
a
,
b
in
product
(
community_a
,
community_b
)
for
a
,
b
in
product
(
community_a
,
community_b
)
if
graph
.
has_edge
(
a
,
b
)
if
graph
.
has_edge
(
a
,
b
)
)
)
def
nodal_contribution
_factor
(
self
,
node_a
,
node_b
):
def
nodal_contribution
(
self
,
node_a
,
node_b
):
"""
Return nodal contribution factor of node_a in node_b
'
s community.
"""
"""
Return nodal contribution factor of node_a in node_b
'
s community.
"""
graph
=
self
.
graph_old
graph
=
self
.
graph_old
community_b
=
self
[
node_b
]
community_b
=
self
[
node_b
]
...
@@ -195,7 +195,7 @@ class Community:
...
@@ -195,7 +195,7 @@ class Community:
return
0
return
0
return
sum
(
return
sum
(
graph
[
node_a
][
b
][
'
duration
'
]
graph
[
node_a
][
b
][
'
weight
'
]
for
b
in
community_b
for
b
in
community_b
if
graph
.
has_edge
(
node_a
,
b
)
if
graph
.
has_edge
(
node_a
,
b
)
)
)
...
@@ -231,9 +231,9 @@ class LouvainCommunity(Community):
...
@@ -231,9 +231,9 @@ class LouvainCommunity(Community):
class
CommunityNode
(
Node
):
class
CommunityNode
(
Node
):
"""
Base node for community based forwarding heuristics.
"""
"""
Base node for community based forwarding heuristics.
"""
def
__init__
(
self
,
name
,
community
=
None
,
**
options
):
def
__init__
(
self
,
community
=
None
,
**
options
):
"""
Create a community based node.
"""
"""
Create a community based node.
"""
super
().
__init__
(
name
,
**
options
)
super
().
__init__
(
**
options
)
if
community
is
None
:
if
community
is
None
:
raise
ValueError
(
'
No community set
'
)
raise
ValueError
(
'
No community set
'
)
self
.
_community
=
community
self
.
_community
=
community
...
...
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