Bridges-C++  3.1.1
Bridges(C++API)
Edge.h
Go to the documentation of this file.
1 
2 #include <string>
3 using namespace std;
4 
5 #include "LinkVisualizer.h"
6 
7 #ifndef EDGE_H
8 
9 #define EDGE_H
10 
11 namespace bridges {
12 
13  namespace datastructure {
33  template <typename K, typename E2 = K>
34  class Edge {
35  private:
36  // The source vertex of this edge */
37  K fromv = K();
38 
39  // The destination vertex of this edge */
40  K tov = K();
41 
42  // The application specific data of this edge */
43  E2 edge_data = E2();
44 
45  // The link visualizer for this edge
46  LinkVisualizer *lvis;
47 
48  public:
49 
62  Edge(const K& from, const K& to, LinkVisualizer* lv, const E2& data = E2()) :
63  fromv(from), tov (to), edge_data(data), lvis(lv) {
64 
65  }
66  ~Edge() {
67  //lvis lifetime is managed by the graph itself
68  }
69 
73  const K& from() const {
74  return fromv;
75  }
76 
77 
81  const K& to() const {
82  return tov;
83  }
84 
89  void setEdgeData(const E2& data) {
90  edge_data = data;
91  }
92 
97  const E2& getEdgeData() const {
98  return edge_data;
99  }
104  E2& getEdgeData() {
105  return edge_data;
106  }
111  string getLabel() const {
112  return lvis->getLabel();
113  }
114 
120  void setLabel(const string& lab) {
121  lvis->setLabel(lab);
122  }
123 
132  void setThickness(const double& th) {
133  lvis->setThickness(th);
134  }
138  double getThickness() const {
139  return lvis->getThickness();
140  }
141 
147  void setColor(const Color& col) {
148  lvis->setColor(col);
149  }
155  void setColor(const string col) {
156  lvis->setColor(col);
157  }
161  Color getColor() const {
162  return lvis->getColor();
163  }
164  }; //end of Edge class
165  }
166 } // end of bridges namespace
167 #endif
Edge(const K &from, const K &to, LinkVisualizer *lv, const E2 &data=E2())
Constructs an edge with the given destination vertex, and edge data.
Definition: Edge.h:62
const K & to() const
Definition: Edge.h:81
Color getColor() const
Definition: Edge.h:161
void setEdgeData(const E2 &data)
Definition: Edge.h:89
string getLabel() const
Definition: Edge.h:111
STL namespace.
void setColor(const string col)
Set the color to a named color.
Definition: Edge.h:155
E2 & getEdgeData()
Definition: Edge.h:104
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:51
const K & from() const
Definition: Edge.h:73
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
const E2 & getEdgeData() const
Definition: Edge.h:97
double getThickness() const
Definition: Edge.h:138
void setColor(const Color &col)
Set the color of the edge when displayed.
Definition: Edge.h:147
~Edge()
Definition: Edge.h:66
void setLabel(const string &lab)
Definition: Edge.h:120
This helper class is used by the graph classes - GraphAdjList , GraphAdjMatrix - to keep track of edg...
Definition: Edge.h:34
void setThickness(const double &th)
Change the thickness of the edge when displayed.
Definition: Edge.h:132