Bridges-C++  3.4.5-dev1-6-g935685a
Bridges(C++ API)
GraphAdjList.h
Go to the documentation of this file.
1 #ifndef GRAPH_ADJ_LIST
2 #define GRAPH_ADJ_LIST
3 
4 #include <stdexcept>
5 #include <sstream>
6 #include <unordered_map>
7 #include <JSONutil.h>
8 
9 using namespace std;
10 
11 #include "SLelement.h"
12 #include "Edge.h"
13 
14 namespace bridges {
15  namespace datastructure {
109  template<typename K, typename E1 = K, typename E2 = E1>
110  class GraphAdjList : public DataStructure {
111  private:
112  // list of graph vertices
113  // maintained as a map to accommodate strings
114  unordered_map<K, Element<E1>* > vertices;
115  // adjacency lists
116  unordered_map<K, SLelement<Edge<K, E2> >*> adj_list;
117 
118  // large graph related
119  static const int LargeGraphVertSize = 2000;
120 
121  bool forceLargeViz = false;
122  bool forceSmallViz = false;
123 
124  GraphAdjList(const GraphAdjList& gr) = delete; //would not be correct
125  const GraphAdjList& operator= (const GraphAdjList& gr) = delete; //would not be correct
126  public:
127 
128  GraphAdjList() = default;
129  GraphAdjList(GraphAdjList&& gr) = default;
130 
131  virtual ~GraphAdjList() override {
132  for (auto& v : vertices) {
133  if (adj_list[v.first]) {
134  // discard the edges in the adj. list
136  for (SLelement<Edge<K, E2 >> *sle =
137  adj_list[v.first]; sle != nullptr; ) {
138  tmp = sle;
139  sle = sle->getNext();
140  delete tmp;
141  }
142  adj_list[v.first] = nullptr;
143  }
144  delete vertices[v.first]; // free the element at v
145  vertices[v.first] = nullptr;
146 
147  }
148  }
154  virtual const string getDStype() const override {
155  if (forceLargeViz || (!forceSmallViz &&
156  vertices.size() > LargeGraphVertSize &&
157  areAllVerticesLocated())) {
158  return "largegraph";
159  }
160  return "GraphAdjacencyList";
161  }
162 
175  void addVertex(const K& k, const E1& e = E1()) {
176  stringstream conv;
177  conv << k;
178  if (vertices.find(k) == vertices.end()) {
179  // vertex does not exist, create one
180  vertices[k] = new Element<E1>(e, conv.str());
181  adj_list[k] = nullptr;
182  }
183  }
198  void addEdge(const K& src, const K& dest, const E2& data = E2()) {
199  try {
200  vertices.at(src);
201  vertices.at(dest);
202  // links structure is redundant and needs
203  // to be removed in future implementations!
204  vertices[src]->links[vertices.at(dest)]; //In C++ this creates the linkvisualizer
205 
206  stringstream conv;
207  conv << dest;
208  // add the edge
209  adj_list.at(src) =
210  new SLelement<Edge<K, E2> > (adj_list.at(src),
211  Edge<K, E2> (src, dest, &(vertices[src]->links[vertices.at(dest)]), data), conv.str());
212 
213  }
214  catch ( const out_of_range& ) {
215  cerr << "addEdge(): Nonexistent vertex?" << endl <<
216  "Create vertices first prior to adding edges that use that vertex" << endl
217  << "Cannot add edge between non-existent verticies"
218  << endl;
219  throw;
220  }
221  }
229  bool isEdge(const K& src, const K& dest) {
230  try {
231  vertices.at(src);
232  vertices.at(dest);
233  for (auto& e : outgoingEdgeSetOf(src))
234  if (e.to() == dest) { // found it
235  cout << "found it!" << src << "," << dest << endl;
236  return true;
237  }
238  }
239  catch ( const out_of_range& ) {
240  return false;
241  }
242  return false;
243  }
251  const E1& getVertexData (const K& src)& {
252  try {
253  Element<E1> *el = vertices.at(src);
254  return (vertices.at(src))->getValue();
255  }
256  catch ( const out_of_range& ) {
257  cerr << "getVertexData(): vertex not found" << endl;
258  throw;
259  }
260  // should never reach here
261  throw "getVertexData(): vertex not found";
262  }
270  void setVertexData (const K& vertID, E1 const & data) {
271  try {
272  Element<E1> *el = vertices.at(vertID);
273  el->setValue (data);
274  }
275  catch ( const out_of_range& ) {
276  cerr << "setVertexData(): Nonexistent vertex" << endl;
277  throw;
278  }
279  catch (const char* msg) {
280  cerr << msg << endl;
281  }
282  }
291  E2& getEdgeData (const K& src, const K& dest) {
292  try {
293  vertices.at(src);
294  vertices.at(dest);
295  SLelement<Edge<K, E2> > *sle = adj_list.at(src);
296  while (sle) {
297  Edge<K, E2> ed = sle->getValue();
298  if (ed.to() == dest) { //edge exists
299  return ed.getEdgeData();
300  }
301  sle = sle->getNext();
302  }
303  throw "Edge not found!";
304  }
305  catch ( const out_of_range& ) {
306  cerr << "getEdgeData(): Edge not found" << endl;
307  throw;
308  }
309  catch (const char* msg) {
310  cerr << msg << endl;
311  }
312  // should never reach here
313  throw "getEdgeData(): Edge not found";
314  }
323  E2 const& getEdgeData (const K& src, const K& dest) const {
324  try {
325  vertices.at(src);
326  vertices.at(dest);
327  SLelement<Edge<K, E2> > *sle = adj_list.at(src);
328  while (sle) {
329  Edge<K, E2> ed = sle->getValue();
330  if (ed.getVertex() == dest) { //edge exists
331  return ed.getEdgeData();
332  }
333  sle = sle->getNext();
334  }
335  throw "Edge not found!";
336  }
337  catch ( const out_of_range& ) {
338  cerr << "getEdgeData(): Edge not found" << endl;
339  throw;
340  }
341  catch (const char* msg) {
342  cerr << msg << endl;
343  }
344  // should never reach here
345  throw "getEdgeData(): Edge not found";
346  }
347 
356  void setEdgeData (const K& src, const K& dest, E2& data) {
357  try {
358  vertices.at(src);
359  vertices.at(dest);
360  SLelement<Edge<K, E2> > *sle = adj_list.at(src);
361  while (sle) {
362  Edge<K, E2> ed = sle->getValue();
363  if (ed.to() == dest) { //edge exists
364  ed.setEdgeData(data); //change edge data
365  sle->setValue(ed); //change slelement data
366  return;
367  }
368  sle = sle->getNext();
369  }
370  throw "getEdgeData(): Edge not found!";
371  }
372  catch ( const out_of_range& ) {
373  cerr << "setEdgeData(): Nonexistent vertices or " <<
374  " edge not found" << endl;
375  throw;
376  }
377  catch (const char* msg) {
378  cerr << msg << endl;
379  }
380  // will never reach here, but avoids compiler warnings
381  throw "getEdgeData(): Edge not found";
382  }
388  unordered_map<K, Element<E1>*>* getVertices() {
389  return &vertices;
390  }
391 
397  const unordered_map<K, Element<E1>*>* getVertices() const {
398  return &vertices;
399  }
405  const Element<E1>* getVertex(const K& key) const {
406  try {
407  return vertices.at(key);
408  }
409  catch (const std::out_of_range& oor) {
410  /* std::cerr << "Out of Range error: " << oor.what() */
411  /* << "returning null pointer\n"; */
412  return nullptr;
413  }
414  }
415 
421  Element<E1>* getVertex(const K& key) {
422  try {
423  return vertices.at(key);
424  }
425  catch (const std::out_of_range& oor) {
426  /* std::cerr << "Out of Range error: " << oor.what() */
427  /* << "returning null pointer\n"; */
428  return nullptr;
429  }
430  }
431 
439  Edge<K, E2> getEdge(const K& src, const K& dest) {
440  // check to see if the two vertices exist, else
441  // return null
442  try {
443  // look for the edge
444  SLelement<Edge<K, E2 >> *sle = adj_list[src];
445  while (sle != nullptr) {
446  K edge_dest = ((Edge<K, E2>) sle->getValue()).to();
447  if (edge_dest == dest) // found
448  return sle->getValue();
449  sle = sle->getNext();
450  }
451  }
452  catch (const std::out_of_range& oor) {
453  // one or both vertices doesnt exist
454  std::cout << "one or both vertices are likely missing from graph\n";
455  throw;
456  }
457  throw "Edge not found";
458  }
459 
464  const unordered_map<K, SLelement<Edge<K, E2> >*>&
466  return adj_list;
467  }
468 
478  try {
479  return adj_list.at(k);
480  }
481  catch (const out_of_range& ) {
482  cerr << "Cannot get adjacencyList of a non-existent vertex -- " << k << "\n";
483  throw;
484  }
485  }
486 
495  const SLelement<Edge<K, E2> >* getAdjacencyList(const K& k) const {
496  try {
497  return adj_list.at(k);
498  }
499  catch (const out_of_range& ) {
500  cerr << "Cannot getAdjacencyList() of a non-existent vertex!"
501  << endl;
502  throw;
503  }
504  }
505 
515  try {
516  Element<E1> *el = vertices.at(k);
517 
518  return el->getVisualizer();
519  }
520  catch (const out_of_range& ) {
521  cerr << "Graph vertex " << k << " not found in graph!" << endl;
522  throw;
523  }
524  }
535  LinkVisualizer *getLinkVisualizer (const K& k1, const K& k2) {
536  try {
537  return getEdge(k1, k2).getLinkVisualizer();
538  }
539  catch (const out_of_range& ) {
540  cerr << "Either source or destination node not found in graph!\n";
541  throw;
542  }
543  }
544  private:
550  virtual const string getDataStructureRepresentation() const override {
552 
553  // map the nodes to a sequence of ids, 0...N-1
554  // then get the JSON string for nodes placeholder
555  // nullptr prevents insertion of other nullptrs
556 
557  // check for large graph
558  if (forceLargeViz ||
559  (!forceSmallViz &&
560  vertices.size() > LargeGraphVertSize &&
561  areAllVerticesLocated())) {
562  return getDataStructureRepresentationLargeGraph();
563  }
564 
565  unordered_map<K, int> node_map;
566  int i = 0;
567  string nodes_JSON = "", links_JSON = "";
568 
569  for (const auto& v : vertices) {
570  if (node_map.emplace(v.first, i).second) {
571  i++;
572  nodes_JSON += v.second->getElementRepresentation() + COMMA;
573  }
574  }
575 
576  //Remove trailing comma and nullptr entry
577 
578  if (nodes_JSON.size()) {
579  nodes_JSON = nodes_JSON.erase(nodes_JSON.size() - 1);
580  }
581 
582  // iterate through the vertices and form the links JSON
583 
584  for (const auto& v : vertices) {
585  // get adj. list
586  Element<E1>* src_vert = vertices.at(v.first);
587  // iterate through list and form links
588  for (SLelement<Edge<K, E2 >> * it = adj_list.at(v.first); it != nullptr;
589  it = it->getNext()) {
590  Element<E1>* dest_vert = vertices.at(it->getValue().to() );
591  links_JSON += src_vert->getLinkRepresentation(
592  *(src_vert->getLinkVisualizer(dest_vert)),
593  JSONencode(node_map.at(v.first)),
594  JSONencode(node_map.at(it->getValue().to())) ) + COMMA;
595  }
596  }
597 
598  //Remove trailing comma
599  if (links_JSON.size()) {
600  links_JSON = links_JSON.erase(links_JSON.size() - 1);
601  }
602 
603  string graph_alist_json =
604  QUOTE + "nodes" + QUOTE + COLON +
605  OPEN_BOX + nodes_JSON + CLOSE_BOX + COMMA +
606  QUOTE + "links" + QUOTE + COLON + OPEN_BOX +
607  links_JSON + CLOSE_BOX +
608  CLOSE_CURLY;
609 
610  return graph_alist_json;
611  }
622  string getDataStructureRepresentationLargeGraph () const {
623 
625  // map the nodes to a sequence of ids, 0...N-1
626  // then get the JSON string for nodes placeholder
627  // nullptr prevents insertion of other nullptrs
628 
629  unordered_map<K, int> node_map;
630  int i = 0;
631  string nodes_JSON = "";
632 
633  for (const auto& v : vertices) {
634  if (node_map.emplace(v.first, i).second) {
635  i++;
636  const ElementVisualizer *elvis =
637  vertices.at(v.first)->getVisualizer();
638  string loc_str = "";
639  if ( (elvis->getLocationX() != INFINITY) &&
640  (elvis->getLocationY() != INFINITY) ) {
641  loc_str =
642  OPEN_BOX +
643  JSONencode(elvis->getLocationX()) + COMMA +
644  JSONencode(elvis->getLocationY()) +
645  CLOSE_BOX + COMMA;
646  }
647  nodes_JSON += OPEN_BOX + loc_str +
648  elvis->getColor().getCSSRepresentation() +
649  CLOSE_BOX + COMMA;
650  }
651  }
652 
653  //Remove trailing comma and nullptr entry
654 
655  if (nodes_JSON.size()) {
656  nodes_JSON = nodes_JSON.erase(nodes_JSON.size() - 1);
657  }
658 
659  // next link information
660  string links_JSON = "";
661  for (const auto& v : vertices) {
662  // get adj. list
663  Element<E1>* src_vert = vertices.at(v.first);
664  // iterate through list and form links
665  for (SLelement<Edge<K, E2 >> * it = adj_list.at(v.first); it != nullptr;
666  it = it->getNext()) {
667  Element<E1>* dest_vert = vertices.at(it->getValue().to() );
668  LinkVisualizer *lv = src_vert->getLinkVisualizer(dest_vert);
669  string src = JSONencode(node_map.at(v.first));
670  string dest = JSONencode(node_map.at(it->getValue().to()));
671  links_JSON += OPEN_BOX +
672  src + COMMA +
673  dest + COMMA +
674  lv->getColor().getCSSRepresentation() +
675  CLOSE_BOX + COMMA;
676 
677  }
678  }
679  //Remove trailing comma
680  if (links_JSON.size())
681  links_JSON = links_JSON.erase(links_JSON.size() - 1);
682 
683  string graph_alist_json =
684  QUOTE + "nodes" + QUOTE + COLON +
685  OPEN_BOX + nodes_JSON + CLOSE_BOX + COMMA +
686  QUOTE + "links" + QUOTE + COLON +
687  OPEN_BOX + links_JSON + CLOSE_BOX +
688  CLOSE_CURLY;
689 
690  return graph_alist_json;
691 
692  }
696  bool areAllVerticesLocated() const {
697  for (const auto& v : vertices) {
698  ElementVisualizer *elvis = v.second->getVisualizer();
699  if (elvis->getLocationX() == INFINITY
700  || elvis->getLocationY() == INFINITY)
701  return false;
702  }
703  return true;
704  }
705 
706  public:
707 
724  void forceLargeVisualization(bool f) {
725  if (f) {
726  forceLargeViz = true;
727  forceSmallViz = false;
728  }
729  else {
730  forceLargeViz = false;
731  }
732  }
733 
750  void forceSmallVisualization(bool f) {
751  if (f) {
752  forceSmallViz = true;
753  forceLargeViz = false;
754  }
755  else {
756  forceSmallViz = false;
757  }
758  }
759 
760  // @brief This is a helper class to return sets of vertices
761  // in a way that are iterable with range for loops.
762  // Students should not have to use this directly.
764  std::unordered_map<K, Element<E1>* > const & underlying_map;
765 
766  public:
767  KeySet_helper (std::unordered_map<K, Element<E1>* > const & um)
768  : underlying_map(um)
769  {}
770 
772  typename std::unordered_map<K, Element<E1>* >::const_iterator it;
773  public:
774  const_iterator(typename std::unordered_map<K, Element<E1>* >::const_iterator i )
775  : it(i)
776  {}
777 
778  bool operator!=(const const_iterator& it) const {
779  return this->it != it.it;
780  }
781 
782  const K& operator*() const {
783  return it->first;
784  }
785 
787  it ++;
788  return *this;
789  }
790  };
791 
793  return const_iterator(underlying_map.begin());
794  }
795 
796  const_iterator end() const {
797  return const_iterator(underlying_map.end());
798  }
799  };
800 
811  return KeySet_helper(this->vertices);
812  }
813 
818  typename SLelement<Edge<K, E2 >>::SLelement_listhelper
819  outgoingEdgeSetOf(K const & k) {
820  return typename SLelement<Edge<K, E2 >>::SLelement_listhelper(getAdjacencyList(k));
821  }
822 
827  typename SLelement<Edge<K, E2 >>::SLelement_constlisthelper
828  outgoingEdgeSetOf(K const & k) const {
829  return typename SLelement<Edge<K, E2 >>::SLelement_constlisthelper(getAdjacencyList(k));
830  }
831 
838  typename std::unordered_map<K, Element<E1>* > & underlying_map;
839 
840  public:
841  VertexElementSet_listhelper (std::unordered_map<K, Element<E1>* > & um)
842  : underlying_map(um)
843  {}
844 
850  class iterator {
851  typename std::unordered_map<K, Element<E1>* >::iterator it;
852  public:
853  iterator(typename std::unordered_map<K, Element<E1>* >::iterator i )
854  : it(i)
855  {}
856 
857  bool operator!=(const iterator & it) const {
858  return this->it != it.it;
859  }
860 
862  return it->second;
863  }
864 
866  it ++;
867  return *this;
868  }
869  };
870 
877  typename std::unordered_map<K, Element<E1>* >::const_iterator it;
878  public:
879  const_iterator(typename std::unordered_map<K, Element<E1>* >::const_iterator i )
880  : it(i)
881  {}
882 
883  bool operator!=(const const_iterator & it) const {
884  return this->it != it.it;
885  }
886 
887  Element<E1> const* operator*() const {
888  return it->second;
889  }
890 
892  it ++;
893  return *this;
894  }
895  };
896 
898  return iterator(underlying_map.begin());
899  }
900 
902  return iterator(underlying_map.end());
903  }
904 
906  return const_iterator(underlying_map.begin());
907  }
908 
909  const_iterator end() const {
910  return const_iterator(underlying_map.end());
911  }
912 
913  };
914 
920  return VertexElementSet_listhelper(vertices);
921  }
922 
929  typename std::unordered_map<K, Element<E1>* > const & underlying_map;
930 
931  public:
932  constVertexElementSet_listhelper (std::unordered_map<K, Element<E1>* > const & um)
933  : underlying_map(um)
934  {}
935 
938  typename std::unordered_map<K, Element<E1>* >::const_iterator it;
939  public:
940  const_iterator(typename std::unordered_map<K, Element<E1>* >::const_iterator i )
941  : it(i)
942  {}
943 
944  bool operator!=(const const_iterator & it) const {
945  return this->it != it.it;
946  }
947 
948  Element<E1> const* operator*() const {
949  return it->second;
950  }
951 
953  it ++;
954  return *this;
955  }
956  };
957 
959  return const_iterator(underlying_map.begin());
960  }
961 
962  const_iterator end() const {
963  return const_iterator(underlying_map.begin());
964  }
965  };
971  return constVertexElementSet_listhelper(vertices);
972  }
973  };
974 
975  //end of GraphAdjList class
976  }
977 }//end of bridges namespace
978 #endif
This is the superclass of all data structure types in BRIDGES.
Definition: DataStructure.h:74
This helper class is used by the graph classes - GraphAdjList , GraphAdjMatrix - to keep track of edg...
Definition: Edge.h:35
const K & to() const
Destination vertex accessor.
Definition: Edge.h:84
const E2 & getEdgeData() const
Return the edge data.
Definition: Edge.h:100
void setEdgeData(const E2 &data)
Sets edge data to "data".
Definition: Edge.h:92
void setValue(const E &val)
Sets generic object to "val".
Definition: Element.h:226
E const & getValue() const
Gets the object held in the generic object E.
Definition: Element.h:207
ElementVisualizer * getVisualizer()
Get the element visualizer object.
Definition: Element.h:141
This class maintains the visual properties of the a Bridges element.
Definition: ElementVisualizer.h:31
const_iterator(typename std::unordered_map< K, Element< E1 > * >::const_iterator i)
Definition: GraphAdjList.h:774
bool operator!=(const const_iterator &it) const
Definition: GraphAdjList.h:778
const K & operator*() const
Definition: GraphAdjList.h:782
const_iterator & operator++()
Definition: GraphAdjList.h:786
const_iterator end() const
Definition: GraphAdjList.h:796
KeySet_helper(std::unordered_map< K, Element< E1 > * > const &um)
Definition: GraphAdjList.h:767
const_iterator begin() const
Definition: GraphAdjList.h:792
This is a helper class to return sets of vertices in a way that are iterable with range for loops....
Definition: GraphAdjList.h:876
const_iterator(typename std::unordered_map< K, Element< E1 > * >::const_iterator i)
Definition: GraphAdjList.h:879
Element< E1 > const * operator*() const
Definition: GraphAdjList.h:887
bool operator!=(const const_iterator &it) const
Definition: GraphAdjList.h:883
This is a helper class to return sets of vertices in a way that are iterable with range for loops....
Definition: GraphAdjList.h:850
bool operator!=(const iterator &it) const
Definition: GraphAdjList.h:857
iterator(typename std::unordered_map< K, Element< E1 > * >::iterator i)
Definition: GraphAdjList.h:853
This is a helper class to return sets of vertices in a way that are iterable with range for loops....
Definition: GraphAdjList.h:837
VertexElementSet_listhelper(std::unordered_map< K, Element< E1 > * > &um)
Definition: GraphAdjList.h:841
const_iterator begin() const
Definition: GraphAdjList.h:905
const_iterator end() const
Definition: GraphAdjList.h:909
This is a helper class to return sets of vertices ina way that are iterable with range for loops....
Definition: GraphAdjList.h:937
const_iterator(typename std::unordered_map< K, Element< E1 > * >::const_iterator i)
Definition: GraphAdjList.h:940
bool operator!=(const const_iterator &it) const
Definition: GraphAdjList.h:944
Element< E1 > const * operator*() const
Definition: GraphAdjList.h:948
This is a helper class to return sets of vertices in a way that are iterable with range for loops....
Definition: GraphAdjList.h:928
const_iterator end() const
Definition: GraphAdjList.h:962
const_iterator begin() const
Definition: GraphAdjList.h:958
constVertexElementSet_listhelper(std::unordered_map< K, Element< E1 > * > const &um)
Definition: GraphAdjList.h:932
This class provides methods to represent adjacency list based graphs.
Definition: GraphAdjList.h:110
KeySet_helper keySet() const
Definition: GraphAdjList.h:810
ElementVisualizer * getVisualizer(const K &k)
Returns the visualizer corresponding to a graph vertex. convenient method to set attributes of the gr...
Definition: GraphAdjList.h:514
virtual ~GraphAdjList() override
Definition: GraphAdjList.h:131
const SLelement< Edge< K, E2 > > * getAdjacencyList(const K &k) const
Definition: GraphAdjList.h:495
void setEdgeData(const K &src, const K &dest, E2 &data)
Loads edge specific information for the edge from "src" to "dest".
Definition: GraphAdjList.h:356
const unordered_map< K, SLelement< Edge< K, E2 > > * > & getAdjacencyList() const
Return the adjacency list.
Definition: GraphAdjList.h:465
Edge< K, E2 > getEdge(const K &src, const K &dest)
Get the edge between src and dest vertices.
Definition: GraphAdjList.h:439
const E1 & getVertexData(const K &src) &
Gets vertex data for a graph vertex.
Definition: GraphAdjList.h:251
void addVertex(const K &k, const E1 &e=E1())
Adds a vertex to the graph.
Definition: GraphAdjList.h:175
SLelement< Edge< K, E2 > >::SLelement_listhelper outgoingEdgeSetOf(K const &k)
This method is useful for iterating through a set of outgoing edges from a vertex.
Definition: GraphAdjList.h:819
E2 const & getEdgeData(const K &src, const K &dest) const
Gets edge data for the edge from "src" to "dest" - const version.
Definition: GraphAdjList.h:323
constVertexElementSet_listhelper vertexSet() const
Definition: GraphAdjList.h:970
void addEdge(const K &src, const K &dest, const E2 &data=E2())
Definition: GraphAdjList.h:198
void forceLargeVisualization(bool f)
Force the rendering engine to use large graph visualization.
Definition: GraphAdjList.h:724
const unordered_map< K, Element< E1 > * > * getVertices() const
Return the graph nodes - const version.
Definition: GraphAdjList.h:397
bool isEdge(const K &src, const K &dest)
Definition: GraphAdjList.h:229
void forceSmallVisualization(bool f)
Force the rendering engine to use small graph visualization.
Definition: GraphAdjList.h:750
VertexElementSet_listhelper vertexSet()
Definition: GraphAdjList.h:919
SLelement< Edge< K, E2 > > * getAdjacencyList(const K &k)
Returns adjacency list of a vertex with name k.
Definition: GraphAdjList.h:477
Element< E1 > * getVertex(const K &key)
Definition: GraphAdjList.h:421
E2 & getEdgeData(const K &src, const K &dest)
Gets edge data for the edge from "src" to "dest".
Definition: GraphAdjList.h:291
void setVertexData(const K &vertID, E1 const &data)
Loads vertex specific information for a graph vertex.
Definition: GraphAdjList.h:270
GraphAdjList(GraphAdjList &&gr)=default
const Element< E1 > * getVertex(const K &key) const
Return the vertex corresponding to a key.
Definition: GraphAdjList.h:405
virtual const string getDStype() const override
Get the string representation of this data structure type.
Definition: GraphAdjList.h:154
LinkVisualizer * getLinkVisualizer(const K &k1, const K &k2)
Returns the link visualizer corresponding to an edge. Returns the link visualizer corresponding to tw...
Definition: GraphAdjList.h:535
SLelement< Edge< K, E2 > >::SLelement_constlisthelper outgoingEdgeSetOf(K const &k) const
This method is useful for iterating through a set of outgoing edges from a vertex - const version.
Definition: GraphAdjList.h:828
unordered_map< K, Element< E1 > * > * getVertices()
Return the graph nodes.
Definition: GraphAdjList.h:388
The singly linked list element, derived from Element.
Definition: SLelement.h:26
virtual SLelement * getNext()
Returns the next element in the list.
Definition: SLelement.h:74
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 CLOSE_BOX
Definition: DataStructure.h:56
const string CLOSE_CURLY
Definition: DataStructure.h:54
const string QUOTE
Definition: DataStructure.h:50