Go to the documentation of this file. 1 #ifndef GRAPH_ANALYSIS_IO_GVGRAPH_HPP
2 #define GRAPH_ANALYSIS_IO_GVGRAPH_HPP
7 #include <graphviz/cgraph.h>
9 #include <graphviz/gvc.h>
10 #include "../BaseGraph.hpp"
18 static inline Agraph_t* _agopen(
const std::string& name, Agdesc_t kind)
25 #ifdef GRAPHVIZ_DEPRECATED
26 #warning "You are using a graphviz version < 2.36.0 -- limited support only"
27 return agopen(
const_cast<char*
>(name.c_str()), kind);
29 return agopen(
const_cast<char*
>(name.c_str()), kind, 0);
33 static inline Agnode_t* _agnode(Agraph_t* g,
const std::string& name)
35 return agnode(g,
const_cast<char*
>(name.c_str()),
true);
38 static inline Agedge_t* _agedge(Agraph_t* g, Agnode_t* node0, Agnode_t* node1,
const std::string& name,
bool create)
40 return agedge(g, node0, node1,
const_cast<char*
>(name.c_str()), create);
45 return agidedge(g, node0, node1,
id, create);
63 const std::string&
getName()
const {
return mName; }
65 int x()
const {
return mCenterPosX; }
66 int y()
const {
return mCenterPosY; }
67 int height()
const {
return mHeight; }
68 int width()
const {
return mWidth; }
86 int mCenterPosX, mCenterPosY;
89 double mHeight, mWidth;
154 std::string
getGraphAttribute(
const std::string& name,
const std::string& defaultValue = std::string())
const;
185 void addNodes(
const std::vector<Vertex::Ptr>& vertices);
198 void setFont(
const std::string& fontname, uint16_t fontsizeInPt);
205 void applyLayout(
const std::string& layout =
"dot");
215 void renderToFile(
const std::string& filename,
const std::string& layout =
"dot",
const std::string& renderer =
"dot",
bool forced =
false);
219 std::vector<GVNode>
nodes()
const;
220 std::vector<GVEdge>
edges()
const;
237 std::map<GraphElementId, Agnode_t*> mNodes;
239 std::map<GraphElementId, Agedge_t*> mEdges;
244 double mScalingFactor;
248 static std::set<std::string> msSupportedLayouts;
254 #endif // GRAPH_ANALYSIS_IO_GVGRAPH_HPP
Vertex::Ptr getVertex() const
Definition: GVGraph.hpp:62
GVGraph(const BaseGraph::Ptr &baseGraph, const std::string &name, double node_size=0)
Construct a Graphviz graph object.
Definition: GVGraph.cpp:30
void applyLayout(const std::string &layout="dot")
Definition: GVGraph.cpp:344
void clear()
Definition: GVGraph.cpp:168
Edge::Ptr getEdge() const
Definition: GVGraph.hpp:100
~GVGraph()
Definition: GVGraph.cpp:82
void initializeFromBaseGraph()
Add and remove nodes.
Definition: GVGraph.cpp:156
GVNode(Vertex::Ptr vertex, const std::string &name, int x, int y, double height, double width)
Definition: GVGraph.hpp:70
void clearNodes()
Definition: GVGraph.cpp:247
void setRootNode(const Vertex::Ptr &vertex)
Definition: GVGraph.cpp:256
std::string getGraphAttribute(const std::string &name, const std::string &defaultValue=std::string()) const
Definition: GVGraph.cpp:104
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
shared_ptr< BaseGraph > Ptr
Definition: BaseGraph.hpp:34
const std::string & getName() const
Definition: GVGraph.hpp:63
void addNodes(const std::vector< Vertex::Ptr > &vertices)
Definition: GVGraph.cpp:206
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
An object containing a libgraph graph and its associated nodes and edges.
Definition: GVGraph.hpp:119
std::vector< GVNode > nodes() const
Definition: GVGraph.cpp:399
void setFont(const std::string &fontname, uint16_t fontsizeInPt)
Set the font to use in all the labels.
Definition: GVGraph.cpp:328
int height() const
Definition: GVGraph.hpp:67
void addEdges(const std::vector< Edge::Ptr > &edges)
Definition: GVGraph.cpp:265
void setEdgeAttribute(const std::string &name, const std::string &value)
Definition: GVGraph.cpp:119
int y() const
Definition: GVGraph.hpp:66
GraphElementId addNode(const graph_analysis::Vertex::Ptr &vertex)
Definition: GVGraph.cpp:180
GVNode()
Definition: GVGraph.hpp:59
void removeNode(const graph_analysis::Vertex::Ptr &vertex)
Definition: GVGraph.cpp:215
static const double DotDefaultDPI
Default DPI value used by dot (which uses points instead of pixels for coordinates)
Definition: GVGraph.hpp:123
uint32_t GraphElementId
Definition: GraphElement.hpp:21
GraphElementId getId(Agnode_t *node) const
Definition: GVGraph.cpp:495
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
GraphElementId addEdge(const Edge::Ptr &edge)
Add and remove edges.
Definition: GVGraph.cpp:274
static std::set< std::string > getSupportedLayouts()
Definition: GVGraph.hpp:125
A struct containing the information for a GVGraph's edge.
Definition: GVGraph.hpp:93
void removeEdge(const Edge::Ptr &edge)
Definition: GVGraph.cpp:301
void renderToFile(const std::string &filename, const std::string &layout="dot", const std::string &renderer="dot", bool forced=false)
Definition: GVGraph.cpp:363
std::vector< GVEdge > edges() const
Definition: GVGraph.cpp:432
int width() const
Definition: GVGraph.hpp:68
std::string getUniqueName(const Vertex::Ptr &vertex) const
Definition: GVGraph.cpp:522
int x() const
Definition: GVGraph.hpp:65
bool setAttribute(const graph_analysis::Vertex::Ptr &vertex, const std::string &name, const std::string &value)
Definition: GVGraph.cpp:126
void clearEdges()
Definition: GVGraph.cpp:319
void setNodeAttribute(const std::string &name, const std::string &value)
Definition: GVGraph.cpp:114
Definition: GVGraph.hpp:56
GVEdge(Edge::Ptr edge)
Definition: GVGraph.hpp:96
boxf boundingRect() const
Definition: GVGraph.cpp:379
int setGraphAttribute(const std::string &name, const std::string &value)
Definition: GVGraph.cpp:96