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
030475fa
Commit
030475fa
authored
7 years ago
by
Jarrod Pas
Browse files
Options
Downloads
Patches
Plain Diff
Finish up node community statistics
parent
3d4e40aa
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
+22
-4
22 additions, 4 deletions
pydtn/community.py
with
22 additions
and
4 deletions
pydtn/community.py
+
22
−
4
View file @
030475fa
...
@@ -135,6 +135,7 @@ class Community:
...
@@ -135,6 +135,7 @@ class Community:
def
local_popularity
(
self
,
node
):
def
local_popularity
(
self
,
node
):
"""
Return local popularity of a node.
"""
"""
Return local popularity of a node.
"""
graph
=
self
.
graph_old
graph
=
self
.
graph_old
if
node
not
in
graph
:
if
node
not
in
graph
:
return
0
return
0
...
@@ -147,6 +148,7 @@ class Community:
...
@@ -147,6 +148,7 @@ class Community:
def
global_popularity
(
self
,
node
):
def
global_popularity
(
self
,
node
):
"""
Return global popularity of a node.
"""
"""
Return global popularity of a node.
"""
graph
=
self
.
graph_old
graph
=
self
.
graph_old
if
node
not
in
graph
:
if
node
not
in
graph
:
return
0
return
0
...
@@ -159,27 +161,43 @@ class Community:
...
@@ -159,27 +161,43 @@ class Community:
def
unique_interactions
(
self
,
node
):
def
unique_interactions
(
self
,
node
):
"""
Unique interactions for a node within it
'
s community.
"""
"""
Unique interactions for a node within it
'
s community.
"""
graph
=
self
.
graph_old
graph
=
self
.
graph_old
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
other
in
graph
[
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.
"""
graph
=
self
.
graph_old
community_a
=
self
[
node_a
]
community_a
=
self
[
node_a
]
community_b
=
self
[
node_b
]
community_b
=
self
[
node_b
]
if
community_a
==
community_b
:
if
community_a
==
community_b
:
return
float
(
'
inf
'
)
return
float
(
'
inf
'
)
return
sum
(
graph
[
a
][
b
][
'
duration
'
]
for
a
,
b
in
product
(
community_a
,
community_b
)
if
graph
.
has_edge
(
a
,
b
)
)
def
nodal_contribution_factor
(
self
,
node_a
,
node_b
):
"""
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
]
if
node_a
not
in
graph
or
node_a
in
community_b
:
return
0
return
sum
(
return
sum
(
graph
[
node_a
][
node_
b
][
'
duration
'
]
graph
[
node_a
][
b
][
'
duration
'
]
for
node_a
,
node_b
in
product
(
community_a
,
community_b
)
for
b
in
community_b
if
node_a
in
graph
and
node_b
in
graph
[
node_a
]
if
graph
.
has_edge
(
node_a
,
b
)
)
)
...
...
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