Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
re6stnet
Commits
f8574d91
Commit
f8574d91
authored
Jul 10, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A few fixes in the simulator, preapring the simulation of major failure in the network
parent
1c0c9b54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
simulation/main.cpp
simulation/main.cpp
+15
-3
simulation/main.h
simulation/main.h
+1
-1
No files found.
simulation/main.cpp
View file @
f8574d91
// To compile with -std=c++0x
// The GET_BC option might not be working
//#define GET_BC // Uncomment this line to get the betweeness centrality
#include "main.h"
...
...
@@ -14,18 +15,22 @@ Graph::Graph(int size, int k, int maxPeers, mt19937 rng) :
{
adjacency
=
new
vector
<
int
>
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
set
<
int
>
alreadyConnected
;
alreadyConnected
.
insert
(
i
);
for
(
int
j
=
0
;
j
<
k
;
j
++
)
{
int
otherNode
;
// TODO : forbid to connect twice to the same node
// it can only improve the result
while
((
otherNode
=
distrib
(
rng
))
==
i
while
(
alreadyConnected
.
count
(
otherNode
=
distrib
(
rng
))
==
1
||
otherNode
>
i
&&
adjacency
[
otherNode
].
size
()
>
maxPeers
-
10
||
adjacency
[
otherNode
].
size
()
>
maxPeers
)
{
}
adjacency
[
i
].
push_back
(
otherNode
);
adjacency
[
otherNode
].
push_back
(
i
);
}
}
}
void
Graph
::
GetDistancesFrom
(
int
node
,
int
*
distance
)
...
...
@@ -51,6 +56,12 @@ void Graph::GetDistancesFrom(int node, int* distance)
}
}
// kill the last proportion*size machines of the graph
void
Graph
::
KillMachines
(
float
proportion
)
{
// TODO
}
int
main
()
{
mt19937
rng
(
time
(
NULL
));
...
...
@@ -79,6 +90,7 @@ int main()
for
(
int
i
=
0
;
i
<
graph
.
size
;
i
++
)
{
int
distance
[
graph
.
size
];
// if(i%10==0) cout << "Computing distances from node " << i << endl;
graph
.
GetDistancesFrom
(
i
,
distance
);
// retrieve the distance
...
...
simulation/main.h
View file @
f8574d91
...
...
@@ -18,7 +18,7 @@ public:
~
Graph
()
{
delete
[]
adjacency
;
};
void
GetDistancesFrom
(
int
node
,
int
*
distance
);
//void KillMachines(float portion, vector<int>* graph)
void
KillMachines
(
float
proportion
);
vector
<
int
>*
adjacency
;
int
size
;
...
...
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