9 namespace datastructure {
26 vector<TreeElement*> children;
74 return (n >= children.size() || n < 0 ) ? nullptr : children.at(n);
87 return (n >= children.size() || n < 0) ? nullptr : children.at(n);
95 children.push_back(child);
117 if ((index < children.size()) && index >= 0) {
118 children[index] = kid;
119 this->
links.erase(children[index]);
137 virtual const string getDataStructureRepresentation() const override final {
156 string json_str =
"", children =
"", link_props =
"", elem_rep =
"";
162 t_str = elem_rep.substr(1, elem_rep.size() - 2);
163 json_str += t_str +
COMMA;
165 if (root->children.size())
167 for (
int k = 0; k < root->children.size(); k++) {
168 if (root->children[k] == NULL) {
177 Color c = lv->getColor();
180 c.getCSSRepresentation() +
COMMA +
188 json_str +=
"linkProperties" +
COLON +
"{}" +
COMMA;
190 json_str += preOrder(root->children[k]);
195 json_str = json_str.substr(0, json_str.size() - 1);
197 if (root->children.size())
This is the superclass of all data structure types in BRIDGES.
Definition: DataStructure.h:74
This is the fundamental building block for all data structures in BRIDGES.
Definition: Element.h:51
virtual const string getElementRepresentation() const
Gets the JSON string of the element representation.
Definition: Element.h:235
LinkVisualizer * getLinkVisualizer(const Element *el)
Returns the LinkVisualizer of element.
Definition: Element.h:162
unordered_map< Element *, LinkVisualizer > links
Definition: Element.h:92
This class can be used to create tree elements, derived from Element.
Definition: TreeElement.h:24
TreeElement(const E &e=E(), const string &lab=string())
Construct a TreeElement from given values.
Definition: TreeElement.h:38
const vector< TreeElement * > & getChildren() const
Get the children of this node.
Definition: TreeElement.h:61
vector< TreeElement * > & getChildren()
Get the children of this node.
Definition: TreeElement.h:52
void addChild(TreeElement *child)
Adds a child to children.
Definition: TreeElement.h:94
TreeElement * getChild(const int &n)
Gets the nth child of this node.
Definition: TreeElement.h:73
const TreeElement * getChild(const int &n) const
Gets the nth child of this node - constant version.
Definition: TreeElement.h:86
virtual const string getDStype() const override
Get the data structure name.
Definition: TreeElement.h:45
void setChild(const size_t &index, TreeElement *kid)
Sets child at index to "kid".
Definition: TreeElement.h:108
std::string JSONencode(const T &d)
Definition: JSONutil.h:38
Support for drawing Bar charts.
Definition: alltypes.h:4
const string COLON
Definition: DataStructure.h:52
const string OPEN_BOX
Definition: DataStructure.h:55
const string COMMA
Definition: DataStructure.h:51
const string OPEN_CURLY
Definition: DataStructure.h:53
const string CLOSE_BOX
Definition: DataStructure.h:56
const string CLOSE_CURLY
Definition: DataStructure.h:54
const string QUOTE
Definition: DataStructure.h:50