Bridges-C++  3.2.0
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 {
35  template <typename K, typename E2 = K>
36  class Edge {
37  private:
38  // The source vertex of this edge */
39  K fromv = K();
40 
41  // The destination vertex of this edge */
42  K tov = K();
43 
44  // The application specific data of this edge */
45  E2 edge_data = E2();
46 
47  // The link visualizer for this edge
48  LinkVisualizer *lvis;
49 
50  public:
51 
64  Edge(const K& from, const K& to, LinkVisualizer* lv, const E2& data = E2()) :
65  fromv(from), tov (to), edge_data(data), lvis(lv) {
66 
67  }
68  ~Edge() {
69  //lvis lifetime is managed by the graph itself
70  }
71 
77  const K& from() const {
78  return fromv;
79  }
80 
81 
86  const K& to() const {
87  return tov;
88  }
89 
94  void setEdgeData(const E2& data) {
95  edge_data = data;
96  }
97 
102  const E2& getEdgeData() const {
103  return edge_data;
104  }
109  E2& getEdgeData() {
110  return edge_data;
111  }
116  string getLabel() const {
117  return lvis->getLabel();
118  }
119 
125  void setLabel(const string& lab) {
126  lvis->setLabel(lab);
127  }
128 
137  void setThickness(const double& th) {
138  lvis->setThickness(th);
139  }
144  double getThickness() const {
145  return lvis->getThickness();
146  }
147 
153  void setColor(const Color& col) {
154  lvis->setColor(col);
155  }
162  void setColor(const string col) {
163  lvis->setColor(col);
164  }
169  Color getColor() const {
170  return lvis->getColor();
171  }
177  return lvis;
178  }
179  }; //end of Edge class
180  }
181 } // end of bridges namespace
182 #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:64
const K & to() const
Destination vertex accessor.
Definition: Edge.h:86
Color getColor() const
return the current color of the edge
Definition: Edge.h:169
void setEdgeData(const E2 &data)
Sets edge data to "data".
Definition: Edge.h:94
LinkVisualizer * getLinkVisualizer()
Get the link visualizer of this edge.
Definition: Edge.h:176
string getLabel() const
Return the edge label.
Definition: Edge.h:116
STL namespace.
void setColor(const string col)
Set the color to a named color. Check the Color class for a list of named colors. ...
Definition: Edge.h:162
E2 & getEdgeData()
Return the edge data.
Definition: Edge.h:109
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:51
const K & from() const
Source vertex accessor.
Definition: Edge.h:77
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
Return the edge data.
Definition: Edge.h:102
double getThickness() const
Get the thickness of the edge.
Definition: Edge.h:144
void setColor(const Color &col)
Set the color of the edge.
Definition: Edge.h:153
~Edge()
Definition: Edge.h:68
void setLabel(const string &lab)
Sets edge label to "lab".
Definition: Edge.h:125
This helper class is used by the graph classes - GraphAdjList , GraphAdjMatrix - to keep track of edg...
Definition: Edge.h:36
void setThickness(const double &th)
Change the thickness of the edge when displayed.
Definition: Edge.h:137