adevs
adevs_lp_graph.h
1 
31 #ifndef adevs_lp_graph_h
32 #define adevs_lp_graph_h
33 #include <vector>
34 #include <map>
35 
36 namespace adevs
37 {
38 
46 class LpGraph
47 {
48  public:
50  LpGraph():nodes(0){}
52  void addEdge(int A, int B)
53  {
54  if (E.find(A) == E.end()
55  && I.find(A) == I.end())
56  nodes++;
57  if (E.find(B) == E.end()
58  && I.find(B) == I.end())
59  nodes++;
60  E[A].push_back(B);
61  I[B].push_back(A);
62  }
64  int getLPCount() const { return nodes; }
66  const std::vector<int>& getI(int B) { return I[B]; }
68  const std::vector<int>& getE(int A) { return E[A]; }
71  private:
72  // Number of nodes in the graph
73  int nodes;
74  // Influencee graph
75  std::map<int,std::vector<int> > E;
76  // Complimentary influencer graph
77  std::map<int,std::vector<int> > I;
78 };
79 
80 }
81 
82 #endif
LpGraph()
Create a graph without any edges.
Definition: adevs_lp_graph.h:50
Definition: adevs_lp_graph.h:46
~LpGraph()
Destructor.
Definition: adevs_lp_graph.h:70
const std::vector< int > & getI(int B)
Get the influencers of node B.
Definition: adevs_lp_graph.h:66
int getLPCount() const
Get the number of LPs.
Definition: adevs_lp_graph.h:64
void addEdge(int A, int B)
Create an edge from node A to node B.
Definition: adevs_lp_graph.h:52
const std::vector< int > & getE(int A)
Get the influencees of node A.
Definition: adevs_lp_graph.h:68