-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleSource.cpp
68 lines (55 loc) · 1.3 KB
/
SimpleSource.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* SimpleSource.cpp
*
* Created on: Jun 23, 2011
* Author: ameyahate
*/
#include "SimpleSource.h"
SimpleSource::SimpleSource() {
// TODO Auto-generated constructor stub
}
SimpleSource::SimpleSource(int id, int seed, double val): nid(id), nseed(seed), nval(val){
nseedLeft = nseed;
}
void SimpleSource::addNType(NodeType nodeType)
{
nodeTrust.push_back(nodeType);
}
double SimpleSource::getTrust(int nType){
std::vector<NodeType>::iterator pos;
for(pos = nodeTrust.begin(); pos !=nodeTrust.end(); ++pos)
{
if(pos->first == nType){return pos->second;}
}
std::cerr<<"Error:- Source:" <<nid <<" Node Type:"<<nType <<" not found!" <<std::endl;
exit(1);
}
void SimpleSource::printSource()
{
std::cout<<"Source Id:"<<nid <<", No. of Seeds:"<< nseed << ", Info Value:"<< nval <<std::endl;
std::vector<NodeType>::iterator pos;
for(pos = nodeTrust.begin(); pos !=nodeTrust.end(); ++pos)
{
std::cout<<"(Node Type:"<< pos->first <<" Trust: "<< pos->second << ")";
}
std::cout<<std::endl;
}
int SimpleSource::getNid() const
{
return nid;
}
int SimpleSource::getNseed() const
{
return nseed;
}
double SimpleSource::getNval() const
{
return nval;
}
int SimpleSource::getNseedLeft() const
{
return nseedLeft;
}
SimpleSource::~SimpleSource() {
// TODO Auto-generated destructor stub
}