5 #include <unordered_set> 6 #include <unordered_map> 17 namespace datastructure {
19 template <
typename K,
typename E1,
typename E2>
class GraphAdjList;
46 template <
typename K,
typename E1,
typename E2>
friend class GraphAdjList;
48 template <
typename K>
friend class Array;
49 template <
typename K>
friend class Array1D;
50 template <
typename K>
friend class Array2D;
51 template <
typename K>
friend class Array3D;
61 static const unordered_map<const Shape, const string, hash<int>>& ShapeNames() {
63 static std::unordered_map<const Shape, const string, hash<int>> sn = {
87 unordered_map<Element*, LinkVisualizer>
links;
97 explicit Element(
const E& val = E(),
const string& lab =
string()) :
98 label(lab), value(val) {
109 : label(e.label), value(e.value), elvis(new
ElementVisualizer(*(e.elvis))), links(e.links) {
113 this->label = e.label;
114 this->value = e.value;
115 *(this->elvis) = *(e.elvis);
116 this->links = e.
links;
120 E& operator= (E
const& e) {
155 if (links.find(const_cast<Element*>(el)) != links.end()) {
156 return &(links.at(const_cast<Element*>(el)));
159 cerr <<
"Element " << label <<
" not linked to Element " 160 << el->
getLabel() <<
", returning NULL" << endl;
171 return const_cast<Element*
> (
this)->getLinkVisualizer(el);
257 const string& src,
const string& dest) {
double getLocationY() const
Definition: ElementVisualizer.h:153
double getLocationX() const
Definition: ElementVisualizer.h:147
void setSize(const double &sz)
Sets size of the element.
Definition: Element.h:280
void setValue(const E &val)
Definition: Element.h:212
This is the fundamental building block for all data structures in BRIDGES.
Definition: Element.h:44
static const string getLinkRepresentation(const LinkVisualizer &lv, const string &src, const string &dest)
Definition: Element.h:256
Element(const E &val=E(), const string &lab=string())
Definition: Element.h:97
Definition: ElementVisualizer.h:10
Definition: ElementVisualizer.h:10
double getThickness() const
Get the link thickness.
Definition: LinkVisualizer.h:92
void setOpacity(double opacity)
Definition: ElementVisualizer.h:104
E & getValue()
Definition: Element.h:203
const string COLON
Definition: DataStructure.h:51
E const & getValue() const
Definition: Element.h:195
This class provides methods to represent adjacency list based graphs.
Definition: Element.h:19
Shape getShape() const
Returns the shape of the element.
Definition: Element.h:351
string const & getLabel() const
Definition: Element.h:178
Definition: ElementVisualizer.h:10
This class maintains the visual properties of the a Bridges element.
Definition: ElementVisualizer.h:28
The foundation of BRIDGES array types. It is not meant to be used directly by students.
Definition: Array.h:21
const string OPEN_BOX
Definition: DataStructure.h:54
void setOpacity(double opacity)
Definition: Element.h:323
void setColor(const Color &col)
Set the color to "col".
Definition: ElementVisualizer.h:79
const string CLOSE_CURLY
Definition: DataStructure.h:53
double getOpacity()
Get opacity of element.
Definition: ElementVisualizer.h:114
virtual const string getElementRepresentation() const
Definition: Element.h:221
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:51
Color getColor() const
Return the link color.
Definition: LinkVisualizer.h:116
void setShape(const Shape &shp)
Set the shape of the element.
Definition: Element.h:342
LinkVisualizer * getLinkVisualizer(const Element *el) const
Definition: Element.h:170
void setLocation(const double &locX, const double &locY)
Definition: ElementVisualizer.h:139
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
const string OPEN_CURLY
Definition: DataStructure.h:52
void setColor(const Color &col)
Set the color of the Element.
Definition: Element.h:297
const string CLOSE_BOX
Definition: DataStructure.h:55
void setLocation(const double &locX, const double &locY)
Definition: Element.h:360
double getSize() const
Definition: Element.h:289
Color getColor() const
Get the current color of the element.
Definition: Element.h:314
void setSize(const double &sz)
Definition: ElementVisualizer.h:64
const string getCSSRepresentation() const
Definition: Color.h:404
A BRIDGES array type.
Definition: Array2D.h:43
const ElementVisualizer * getVisualizer() const
Definition: Element.h:144
A BRIDGES 1D array type.
Definition: Array1D.h:53
A BRIDGES array type.
Definition: Array3D.h:43
double getSize() const
Definition: ElementVisualizer.h:71
void setLabel(const string &lab)
Definition: Element.h:187
This class provides methods to represent adjacency matrix based graphs.
Definition: Element.h:20
This class maintains the visual properties of links within data structures.
Definition: LinkVisualizer.h:26
string getLabel() const
Return the link label.
Definition: LinkVisualizer.h:61
Color getColor() const
Definition: ElementVisualizer.h:95
Definition: ElementVisualizer.h:10
Shape
Definition: ElementVisualizer.h:10
double getOpacity()
Definition: Element.h:332
ElementVisualizer * getVisualizer()
Definition: Element.h:136
unordered_map< Element *, LinkVisualizer > links
Definition: Element.h:87
Definition: ElementVisualizer.h:10
double getLocationY() const
Definition: Element.h:375
void setShape(const Shape &shp)
Set the shape of the element.
Definition: ElementVisualizer.h:122
const string COMMA
Definition: DataStructure.h:50
Shape getShape() const
Return the shape of the element.
Definition: ElementVisualizer.h:129
double getLocationX() const
Definition: Element.h:368
const string QUOTE
Definition: DataStructure.h:49
Element(const Element &e)
Definition: Element.h:108
void setColor(const string col)
Set the color by name.
Definition: Element.h:305
virtual ~Element()
Definition: Element.h:128
Definition: ElementVisualizer.h:10
Definition: ElementVisualizer.h:10
std::string JSONencode(const T &d)
Definition: JSONutil.h:37
LinkVisualizer * getLinkVisualizer(const Element *el)
Definition: Element.h:154