Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
verktoy
PyMetric
Commits
126a85f1
Commit
126a85f1
authored
Dec 03, 2019
by
Runar Borge
Browse files
Merge branch 'fix_netsplit' into 'master'
Fix netsplit Closes
#5
and
#18
See merge request
!15
parents
dbce3ce5
da7df0b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
command.py
View file @
126a85f1
...
...
@@ -82,11 +82,20 @@ class MetricShell(Cmd):
effects
=
self
.
simulation
.
get_effects
()
multinodes
=
[
x
for
x
in
list
(
effects
.
keys
())
if
len
(
list
(
effects
[
x
].
keys
()))
>=
5
]
multimulti
=
[
x
for
x
in
list
(
effects
.
keys
())
if
len
(
list
(
effects
[
x
].
keys
()))
>=
20
]
difflen
=
nx
.
average_shortest_path_length
(
self
.
simulation
.
graph
)
\
-
nx
.
average_shortest_path_length
(
self
.
model
.
G
)
components
=
list
(
self
.
model
.
G
.
subgraph
(
c
)
for
c
in
nx
.
connected_components
(
# Get all connected subgraphs of the current graph
components
=
list
(
self
.
simulation
.
graph
.
subgraph
(
c
)
for
c
in
nx
.
connected_components
(
self
.
simulation
.
graph
.
to_undirected
()))
basecomponents
=
list
(
self
.
model
.
graph
.
subgraph
(
c
)
for
c
in
nx
.
connected_components
(
self
.
model
.
graph
.
to_undirected
()))
# Average SPF is only able to be computed on connected nodes, if one node is disconnected
# it will fail computation. This code executes Averate calculation once pr. subgraph
# to circumvent this limitation
difflen
=
sum
([
nx
.
average_shortest_path_length
(
x
)
for
x
in
components
])
\
-
sum
([
nx
.
average_shortest_path_length
(
x
)
for
x
in
basecomponents
])
cnodes
=
0
if
len
(
components
)
>
1
:
cnodes
=
sum
([
len
(
g
.
nodes
())
for
g
in
components
[
1
:]])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment