Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
72957c99
Commit
72957c99
authored
Mar 18, 2018
by
Éloïs
Committed by
nanocryk
Mar 19, 2018
Browse files
Options
Downloads
Patches
Plain Diff
[tests] add test to cover bug
#39
parent
20dc0a62
No related branches found
No related tags found
1 merge request
!29
Resolve "RustyWot : get_paths is stuck in an infinite loop !"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
wotb/lib.rs
+34
-0
34 additions, 0 deletions
wotb/lib.rs
with
34 additions
and
0 deletions
wotb/lib.rs
+
34
−
0
View file @
72957c99
...
...
@@ -828,5 +828,39 @@ mod tests {
outdistanced
:
false
,
},)
);
// Test centralities computation in g1_genesis wot
let
wot_size
=
wot3
.size
();
let
members_count
=
wot3
.get_enabled
()
.len
()
as
u64
;
assert_eq!
(
members_count
,
59
);
let
oriented_couples_count
:
u64
=
members_count
*
(
members_count
-
1
);
let
mut
centralities
=
vec!
[
0
;
wot_size
];
for
i
in
0
..
wot_size
{
for
j
in
0
..
wot_size
{
let
paths
=
wot3
.get_paths
(
NodeId
(
i
),
NodeId
(
j
),
5
);
let
mut
intermediate_members
:
Vec
<
NodeId
>
=
Vec
::
new
();
for
path
in
paths
{
if
path
.len
()
>
2
{
for
node_id
in
&
path
[
1
..
path
.len
()
-
1
]
{
if
!
intermediate_members
.contains
(
node_id
)
{
intermediate_members
.push
(
*
node_id
);
}
}
}
}
let
centralities_copy
=
centralities
.clone
();
for
node_id
in
intermediate_members
{
let
centrality
=
&
centralities_copy
[
node_id
.0
];
if
let
Some
(
tmp
)
=
centralities
.get_mut
(
node_id
.0
)
{
*
tmp
=
*
centrality
+
1
;
}
}
}
}
let
mut
relative_centralities
=
Vec
::
with_capacity
(
wot_size
);
for
centrality
in
centralities
{
relative_centralities
.push
((
centrality
*
100_000
/
oriented_couples_count
)
as
usize
);
}
assert_eq!
(
relative_centralities
.len
(),
59
);
}
}
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
sign in
to comment