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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
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
// 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
//#define GET_BC // Uncomment this line to get the betweeness centrality
#include "main.h"
#include "main.h"
...
@@ -14,18 +15,22 @@ Graph::Graph(int size, int k, int maxPeers, mt19937 rng) :
...
@@ -14,18 +15,22 @@ Graph::Graph(int size, int k, int maxPeers, mt19937 rng) :
{
{
adjacency
=
new
vector
<
int
>
[
size
];
adjacency
=
new
vector
<
int
>
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
set
<
int
>
alreadyConnected
;
alreadyConnected
.
insert
(
i
);
for
(
int
j
=
0
;
j
<
k
;
j
++
)
for
(
int
j
=
0
;
j
<
k
;
j
++
)
{
{
int
otherNode
;
int
otherNode
;
// TODO : forbid to connect twice to the same node
// it can only improve the result
while
(
alreadyConnected
.
count
(
otherNode
=
distrib
(
rng
))
==
1
while
((
otherNode
=
distrib
(
rng
))
==
i
||
otherNode
>
i
&&
adjacency
[
otherNode
].
size
()
>
maxPeers
-
10
||
otherNode
>
i
&&
adjacency
[
otherNode
].
size
()
>
maxPeers
-
10
||
adjacency
[
otherNode
].
size
()
>
maxPeers
)
||
adjacency
[
otherNode
].
size
()
>
maxPeers
)
{
}
{
}
adjacency
[
i
].
push_back
(
otherNode
);
adjacency
[
i
].
push_back
(
otherNode
);
adjacency
[
otherNode
].
push_back
(
i
);
adjacency
[
otherNode
].
push_back
(
i
);
}
}
}
}
}
void
Graph
::
GetDistancesFrom
(
int
node
,
int
*
distance
)
void
Graph
::
GetDistancesFrom
(
int
node
,
int
*
distance
)
...
@@ -51,6 +56,12 @@ 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
()
int
main
()
{
{
mt19937
rng
(
time
(
NULL
));
mt19937
rng
(
time
(
NULL
));
...
@@ -79,6 +90,7 @@ int main()
...
@@ -79,6 +90,7 @@ int main()
for
(
int
i
=
0
;
i
<
graph
.
size
;
i
++
)
for
(
int
i
=
0
;
i
<
graph
.
size
;
i
++
)
{
{
int
distance
[
graph
.
size
];
int
distance
[
graph
.
size
];
// if(i%10==0) cout << "Computing distances from node " << i << endl;
graph
.
GetDistancesFrom
(
i
,
distance
);
graph
.
GetDistancesFrom
(
i
,
distance
);
// retrieve the distance
// retrieve the distance
...
...
simulation/main.h
View file @
f8574d91
...
@@ -18,7 +18,7 @@ public:
...
@@ -18,7 +18,7 @@ public:
~
Graph
()
{
delete
[]
adjacency
;
};
~
Graph
()
{
delete
[]
adjacency
;
};
void
GetDistancesFrom
(
int
node
,
int
*
distance
);
void
GetDistancesFrom
(
int
node
,
int
*
distance
);
//void KillMachines(float portion, vector<int>* graph)
void
KillMachines
(
float
proportion
);
vector
<
int
>*
adjacency
;
vector
<
int
>*
adjacency
;
int
size
;
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