graph_analysis
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
graph_analysis::io::GVGraph Class Reference

An object containing a libgraph graph and its associated nodes and edges. More...

#include <GVGraph.hpp>

Public Member Functions

 GVGraph (const BaseGraph::Ptr &baseGraph, const std::string &name, double node_size=0)
 Construct a Graphviz graph object. More...
 
 ~GVGraph ()
 
int setGraphAttribute (const std::string &name, const std::string &value)
 
std::string getGraphAttribute (const std::string &name, const std::string &defaultValue=std::string()) const
 
void setNodeAttribute (const std::string &name, const std::string &value)
 
void setEdgeAttribute (const std::string &name, const std::string &value)
 
bool setAttribute (const graph_analysis::Vertex::Ptr &vertex, const std::string &name, const std::string &value)
 
bool setAttribute (const graph_analysis::Edge::Ptr &edge, const std::string &name, const std::string &value)
 
void clear ()
 
void initializeFromBaseGraph ()
 Add and remove nodes. More...
 
GraphElementId addNode (const graph_analysis::Vertex::Ptr &vertex)
 
void addNodes (const std::vector< Vertex::Ptr > &vertices)
 
void removeNode (const graph_analysis::Vertex::Ptr &vertex)
 
void removeNode (GraphElementId id)
 
void clearNodes ()
 
GraphElementId addEdge (const Edge::Ptr &edge)
 Add and remove edges. More...
 
void addEdges (const std::vector< Edge::Ptr > &edges)
 
void removeEdge (const Edge::Ptr &edge)
 
void removeEdge (GraphElementId id)
 
void clearEdges ()
 
void setFont (const std::string &fontname, uint16_t fontsizeInPt)
 Set the font to use in all the labels. More...
 
void applyLayout (const std::string &layout="dot")
 
void renderToFile (const std::string &filename, const std::string &layout="dot", const std::string &renderer="dot", bool forced=false)
 
boxf boundingRect () const
 
void setRootNode (const Vertex::Ptr &vertex)
 
std::vector< GVNode > nodes () const
 
std::vector< GVEdge > edges () const
 
GraphElementId getId (Agnode_t *node) const
 
GraphElementId getId (Agedge_t *edge) const
 
std::string getUniqueName (const Vertex::Ptr &vertex) const
 
std::string getUniqueName (const Edge::Ptr &edge) const
 

Static Public Member Functions

static std::set< std::string > getSupportedLayouts ()
 

Static Public Attributes

static const double DotDefaultDPI =72.0
 Default DPI value used by dot (which uses points instead of pixels for coordinates) More...
 

Detailed Description

An object containing a libgraph graph and its associated nodes and edges.

The GVGraph (GV for graphviz) allows to compute the layout for a given graph – however after initialization the nodes and edges have to be added explicitely using

Constructor & Destructor Documentation

◆ GVGraph()

graph_analysis::io::GVGraph::GVGraph ( const BaseGraph::Ptr &  baseGraph,
const std::string &  name,
double  node_size = 0 
)

Construct a Graphviz graph object.

Parameters
baseGraphPointer to the base graph to visualize
nameThe name of the graph, must be unique in the application
node_sizeThe size in pixels of each node

◆ ~GVGraph()

graph_analysis::io::GVGraph::~GVGraph ( )

Member Function Documentation

◆ addEdge()

GraphElementId graph_analysis::io::GVGraph::addEdge ( const Edge::Ptr &  edge)

Add and remove edges.

◆ addEdges()

void graph_analysis::io::GVGraph::addEdges ( const std::vector< Edge::Ptr > &  edges)

◆ addNode()

GraphElementId graph_analysis::io::GVGraph::addNode ( const graph_analysis::Vertex::Ptr &  vertex)

◆ addNodes()

void graph_analysis::io::GVGraph::addNodes ( const std::vector< Vertex::Ptr > &  vertices)

◆ applyLayout()

void graph_analysis::io::GVGraph::applyLayout ( const std::string &  layout = "dot")

Apply a layout to the graph layouts: circo, dot, fdp, neato, osage, sfdp, twopi

See also
http://www.graphviz.org/Documentation.php for available layouts

◆ boundingRect()

boxf graph_analysis::io::GVGraph::boundingRect ( ) const

◆ clear()

void graph_analysis::io::GVGraph::clear ( )

◆ clearEdges()

void graph_analysis::io::GVGraph::clearEdges ( )

◆ clearNodes()

void graph_analysis::io::GVGraph::clearNodes ( )

◆ edges()

std::vector< GVEdge > graph_analysis::io::GVGraph::edges ( ) const

◆ getGraphAttribute()

std::string graph_analysis::io::GVGraph::getGraphAttribute ( const std::string &  name,
const std::string &  defaultValue = std::string() 
) const

Get the graphviz based graph attribute

Parameters
nameName of attribute
defaultValueThe return value will be this if the attribute has not been set for the graph
Returns
Current or default value for this attribute

◆ getId() [1/2]

GraphElementId graph_analysis::io::GVGraph::getId ( Agedge_t *  edge) const

◆ getId() [2/2]

GraphElementId graph_analysis::io::GVGraph::getId ( Agnode_t *  node) const

◆ getSupportedLayouts()

static std::set<std::string> graph_analysis::io::GVGraph::getSupportedLayouts ( )
inlinestatic

◆ getUniqueName() [1/2]

std::string graph_analysis::io::GVGraph::getUniqueName ( const Edge::Ptr &  edge) const

◆ getUniqueName() [2/2]

std::string graph_analysis::io::GVGraph::getUniqueName ( const Vertex::Ptr &  vertex) const

◆ initializeFromBaseGraph()

void graph_analysis::io::GVGraph::initializeFromBaseGraph ( )

Add and remove nodes.

◆ nodes()

std::vector< GVNode > graph_analysis::io::GVGraph::nodes ( ) const

◆ removeEdge() [1/2]

void graph_analysis::io::GVGraph::removeEdge ( const Edge::Ptr &  edge)

◆ removeEdge() [2/2]

void graph_analysis::io::GVGraph::removeEdge ( GraphElementId  id)

◆ removeNode() [1/2]

void graph_analysis::io::GVGraph::removeNode ( const graph_analysis::Vertex::Ptr &  vertex)

◆ removeNode() [2/2]

void graph_analysis::io::GVGraph::removeNode ( GraphElementId  id)

◆ renderToFile()

void graph_analysis::io::GVGraph::renderToFile ( const std::string &  filename,
const std::string &  layout = "dot",
const std::string &  renderer = "dot",
bool  forced = false 
)

Render graph to file using a particular layout

Parameters
filenameName of the output file
layoutdefine the layout of the graph: circo, dot, fdp, neato, osage, sfdp, twopi
rendererdefine the output format for this file, e.g., dot, pdf, svn, png
forcedapply a relayouting

◆ setAttribute() [1/2]

bool graph_analysis::io::GVGraph::setAttribute ( const graph_analysis::Edge::Ptr &  edge,
const std::string &  name,
const std::string &  value 
)

Set the attribute for an edge

◆ setAttribute() [2/2]

bool graph_analysis::io::GVGraph::setAttribute ( const graph_analysis::Vertex::Ptr &  vertex,
const std::string &  name,
const std::string &  value 
)

Set the attribute for a vertex

◆ setEdgeAttribute()

void graph_analysis::io::GVGraph::setEdgeAttribute ( const std::string &  name,
const std::string &  value 
)

Set a edge attribute by name

Parameters
nameName of edge's attribute
valueValue to set

◆ setFont()

void graph_analysis::io::GVGraph::setFont ( const std::string &  fontname,
uint16_t  fontsizeInPt 
)

Set the font to use in all the labels.

◆ setGraphAttribute()

int graph_analysis::io::GVGraph::setGraphAttribute ( const std::string &  name,
const std::string &  value 
)

Set the graphviz based graph attribute by name and value

Parameters
nameName of attribute
valueValue for this attribute
Returns
status

◆ setNodeAttribute()

void graph_analysis::io::GVGraph::setNodeAttribute ( const std::string &  name,
const std::string &  value 
)

Set a node attribute by name

Parameters
nameName of node's attribute
valueValue to set

◆ setRootNode()

void graph_analysis::io::GVGraph::setRootNode ( const Vertex::Ptr &  vertex)

Member Data Documentation

◆ DotDefaultDPI

const double graph_analysis::io::GVGraph::DotDefaultDPI =72.0
static

Default DPI value used by dot (which uses points instead of pixels for coordinates)

Dot uses a 72 DPI value for converting it's position coordinates from points to pixels while we display at 96 DPI on most operating systems.


The documentation for this class was generated from the following files: