Bridges-C++  3.4.4
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 {
34  template <typename K, typename E2 = K>
35  class Edge {
36  private:
37  // The source vertex of this edge */
38  K fromv = K();
39 
40  // The destination vertex of this edge */
41  K tov = K();
42 
43  // The application specific data of this edge */
44  E2 edge_data = E2();
45 
46  // The link visualizer for this edge
47  LinkVisualizer *lvis;
48 
49  public:
50 
63  Edge(const K& from, const K& to, LinkVisualizer* lv, const E2& data = E2()) :
64  fromv(from), tov (to), edge_data(data), lvis(lv) {
65 
66  }
67  ~Edge() {
68  //lvis lifetime is managed by the graph itself
69  }
70 
76  const K& from() const {
77  return fromv;
78  }
79 
84  const K& to() const {
85  return tov;
86  }
87 
92  void setEdgeData(const E2& data) {
93  edge_data = data;
94  }
95 
100  const E2& getEdgeData() const {
101  return edge_data;
102  }
107  E2& getEdgeData() {
108  return edge_data;
109  }
114  string getLabel() const {
115  return lvis->getLabel();
116  }
117 
123  void setLabel(const string& lab) {
124  lvis->setLabel(lab);
125  }
126 
135  void setThickness(const double& th) {
136  lvis->setThickness(th);
137  }
142  double getThickness() const {
143  return lvis->getThickness();
144  }
145 
151  void setColor(const Color& col) {
152  lvis->setColor(col);
153  }
160  void setColor(const string col) {
161  lvis->setColor(col);
162  }
167  Color getColor() const {
168  return lvis->getColor();
169  }
175  return lvis;
176  }
177  }; //end of Edge class
178  }
179 } // end of bridges namespace
180 #endif
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:50
This helper class is used by the graph classes - GraphAdjList , GraphAdjMatrix - to keep track of edg...
Definition: Edge.h:35
LinkVisualizer * getLinkVisualizer()
Get the link visualizer of this edge.
Definition: Edge.h:174
const K & from() const
Source vertex accessor.
Definition: Edge.h:76
const K & to() const
Destination vertex accessor.
Definition: Edge.h:84
E2 & getEdgeData()
Return the edge data.
Definition: Edge.h:107
const E2 & getEdgeData() const
Return the edge data.
Definition: Edge.h:100
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:160
void setLabel(const string &lab)
Sets edge label to "lab".
Definition: Edge.h:123
double getThickness() const
Get the thickness of the edge.
Definition: Edge.h:142
~Edge()
Definition: Edge.h:67
void setEdgeData(const E2 &data)
Sets edge data to "data".
Definition: Edge.h:92
void setColor(const Color &col)
Set the color of the edge.
Definition: Edge.h:151
string getLabel() const
Return the edge label.
Definition: Edge.h:114
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:63
Color getColor() const
return the current color of the edge
Definition: Edge.h:167
void setThickness(const double &th)
Change the thickness of the edge when displayed.
Definition: Edge.h:135
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4