|
graph_analysis
|
Allows the alignment of nodes into a grid, i.e. perform some kind of prealignment using the pos attribute However, this will only work when: (a) using the 'canon' renderer and (b) using fdp for later layouting. For example: More...
#include <GraphvizGridStyle.hpp>


Public Types | |
| typedef shared_ptr< GraphvizGridStyle > | Ptr |
Public Types inherited from graph_analysis::io::GraphvizStyle | |
| typedef shared_ptr< GraphvizStyle > | Ptr |
Public Member Functions | |
| GraphvizGridStyle (size_t rows, size_t columns, VertexRowMapper rowMapperFunction, VertexColumnMapper columnMapperFunction) | |
| virtual | ~GraphvizGridStyle () |
| void | setColumnScalingFactor (double f) |
| double | getColumnScalingFactor () const |
| void | setRowScalingFactor (double f) |
| double | getRowScalingFactor () const |
| virtual void | apply (const Edge::Ptr &edge, GVGraph *gvGraph, const BaseGraph::Ptr &graph) const |
| virtual void | apply (const Vertex::Ptr &vertex, GVGraph *gvGraph, const BaseGraph::Ptr &graph) const |
Public Member Functions inherited from graph_analysis::io::GraphvizStyle | |
| GraphvizStyle () | |
| virtual | ~GraphvizStyle () |
Allows the alignment of nodes into a grid, i.e. perform some kind of prealignment using the pos attribute However, this will only work when: (a) using the 'canon' renderer and (b) using fdp for later layouting. For example:
class RowColumnVertex : public graph_analysis::Vertex
{
public:
typedef shared_ptr<RowColumnVertex> Ptr;
RowColumnVertex(const std::string& name, size_t row, size_t column)
: graph_analysis::Vertex(name)
, row(row)
, column(column)
{}
virtual std::string getClassName() const{ return "RowColumnVertex"; }
size_t row;
size_t column;
static size_t getRow(const graph_analysis::Vertex::Ptr& vertex)
{
return dynamic_pointer_cast<RowColumnVertex>(vertex)->row;
}
static size_t getColumn(const graph_analysis::Vertex::Ptr& vertex)
{
return dynamic_pointer_cast<RowColumnVertex>(vertex)->column;
}
protected:
virtual graph_analysis::Vertex* getClone() const { return new RowColumnVertex(getLabel(), row, column); }
};
io::GraphvizWriter gvWriter("dot","canon");
io::GraphvizGridStyle::Ptr style(new io::GraphvizGridStyle(3,3,
&RowColumnVertex::getRow,
&RowColumnVertex::getColumn
));
style->setColumnScalingFactor(2.0);
style->setRowScalingFactor(2.0);
gvWriter.setStyle(style);
gvWriter.write("graphviz_grid_layout.dot", graph);Eventually render with:
xdot -f fdp graphviz_grid_layout.dot
or
dot -s -Kfdp -Tpng graphviz_grid_layout.dot > layouted_grid.png
TODO: alternatively one could use an approach using rankdir and {rank=same; ...}
| typedef shared_ptr<GraphvizGridStyle> graph_analysis::io::GraphvizGridStyle::Ptr |
| graph_analysis::io::GraphvizGridStyle::GraphvizGridStyle | ( | size_t | rows, |
| size_t | columns, | ||
| VertexRowMapper | rowMapperFunction, | ||
| VertexColumnMapper | columnMapperFunction | ||
| ) |
|
virtual |
|
inlinevirtual |
Apply style to an edge, e.g. by implementing the style
gvGraph->setAttribute(edge,"color","red");
Reimplemented from graph_analysis::io::GraphvizStyle.
|
virtual |
Apply style to a vertex
gvGraph->setAttribute(vertex,"color","blue");
Reimplemented from graph_analysis::io::GraphvizStyle.
|
inline |
|
inline |
|
inline |
|
inline |
1.8.17