graph_wrapper.h
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
32 #ifndef _GRAPH_WRAPPER_H_
33 #define _GRAPH_WRAPPER_H_
34 
35 #include <iostream>
36 #include <graphviz/gvc.h>
37 #include <graphviz/graph.h>
38 #include <boost/lexical_cast.hpp>
39 #include <algorithm>
40 #include <vector>
41 #include <map>
42 
43 using namespace std;
44 using namespace boost;
45 
54 class GVGraph
55 {
56  public:
58  static const double DotDefaultDPI;
59 
66  GVGraph(string name,double node_size=50);
67 
73  ~GVGraph();
74 
75 
83  void addNode(const string& name);
84 
91  void addNodes(vector<string>& names);
92 
102  void removeNode(const string& name);
103 
109  void clearNodes();
110 
118  Agnode_t*selectNode(string&name);
119 
120  Agedge_t*selectEdge(string&source,string&target);
121 
130  int setNodeAttribute(string name,string attribute,string value);
131 
132  int setEdgeAttribute(string source,string target,string attribute,string value);
133 
141  void addEdge(const string& source, const string& target);
142 
151  void removeEdge(const string& source, const string& target);
152 
160  void removeEdge(const pair<string, string>& key);
161 
168  void setRootNode(const string& name);
169 
176  void applyLayout();
177 
183  void freeLayout();
184 
191  void startRender();
192 
198  GVC_t*getGVCcontext(void);
199 
200  private:
208  Agraph_t* _agopen(string name,int kind);
209 
217  Agsym_t* _agnodeattr(string name,string value);
218 
226  Agsym_t* _agedgeattr(string name,string value);
227 
237  string _agget(void*object,string attr,string alt=string());
238 
248  int _agset(void*object,string attr,string value);
249 
257  Agnode_t* _agnode(string name);
258 
268  int _gvLayout(GVC_t*gvc,graph_t*graph,string engine);
269 
271  GVC_t*_context;
272 
274  Agraph_t*_graph;
275 
277  map<string, Agnode_t*> _nodes;
278 
280  map<pair<string,string>, Agedge_t*> _edges;
281 };
282 
283 #endif
An object containing a libgraph graph and its associated nodes and edges. .
Definition: graph_wrapper.h:54
Agraph_t * _graph
Agraph main object.
GVC_t * _context
GV context main variable.
map< pair< string, string >, Agedge_t * > _edges
Edge map, used for edge tracking.
map< string, Agnode_t * > _nodes
Node map, used for node tracking.
static const double DotDefaultDPI
Default DPI value used by dot (which uses points instead of pixels for coordinates) ...
Definition: graph_wrapper.h:58


mtt
Author(s): Jorge Almeida
autogenerated on Mon Mar 2 2015 01:32:18