Class to draw a simple undirected graph.
More...
#include <qbpp_tsp.hpp>
|
| | DrawSimpleGraph ()=default |
| | Default constructor to create an empty graph. More...
|
| |
| void | add_node (int x, int y, const std::string &label="") |
| | Add a node to the graph. More...
|
| |
| void | add_node (std::pair< int, int > node, const std::string &label="") |
| | Add a node to the graph. More...
|
| |
| void | add_edge (unsigned int node1, unsigned int node2) |
| | Add an edge to the graph. More...
|
| |
| uint32_t | node_count () const |
| | Get the number of nodes in the graph. More...
|
| |
| uint32_t | edge_count () const |
| | Get the number of edges in the graph. More...
|
| |
| void | draw (std::string filename) |
| | Draw the graph in a file. More...
|
| |
|
| std::vector< std::tuple< int, int, std::string > > | nodes |
| | List of nodes with coordinate (x, y) More...
|
| |
| std::vector< std::tuple< int, int > > | edges |
| | List of edges (node1, node2) More...
|
| |
Class to draw a simple undirected graph.
- Note
- Nodes must be numbered from 0 to size-1.
-
Graphvis must be installed to use this class.
Definition at line 206 of file qbpp_tsp.hpp.
◆ DrawSimpleGraph()
| qbpp::tsp::DrawSimpleGraph::DrawSimpleGraph |
( |
| ) |
|
|
default |
Default constructor to create an empty graph.
◆ add_node() [1/2]
| void qbpp::tsp::DrawSimpleGraph::add_node |
( |
int |
x, |
|
|
int |
y, |
|
|
const std::string & |
label = "" |
|
) |
| |
|
inline |
Add a node to the graph.
- Parameters
-
| x | x-coordinate of the node |
| y | y-coordinate of the node |
| label | Label of the node |
Definition at line 221 of file qbpp_tsp.hpp.
◆ add_node() [2/2]
| void qbpp::tsp::DrawSimpleGraph::add_node |
( |
std::pair< int, int > |
node, |
|
|
const std::string & |
label = "" |
|
) |
| |
|
inline |
Add a node to the graph.
- Parameters
-
| node | Pair of coordinates (x, y) of the node |
| label | Label of the node |
Definition at line 227 of file qbpp_tsp.hpp.
◆ add_edge()
| void qbpp::tsp::DrawSimpleGraph::add_edge |
( |
unsigned int |
node1, |
|
|
unsigned int |
node2 |
|
) |
| |
|
inline |
Add an edge to the graph.
- Parameters
-
| node1 | Index of the first node |
| node2 | Index of the second node |
- Note
- if node1 > node2, the nodes are swapped
Definition at line 235 of file qbpp_tsp.hpp.
◆ node_count()
| uint32_t qbpp::tsp::DrawSimpleGraph::node_count |
( |
| ) |
const |
|
inline |
Get the number of nodes in the graph.
Definition at line 239 of file qbpp_tsp.hpp.
◆ edge_count()
| uint32_t qbpp::tsp::DrawSimpleGraph::edge_count |
( |
| ) |
const |
|
inline |
Get the number of edges in the graph.
Definition at line 242 of file qbpp_tsp.hpp.
◆ draw()
| void qbpp::tsp::DrawSimpleGraph::draw |
( |
std::string |
filename | ) |
|
|
inline |
Draw the graph in a file.
- Parameters
-
| filename | Name of the file to save the graph |
- Note
- The file format is determined by the extension of the filename
-
The graph is drawn using the neato program from the Graphviz suite
Definition at line 248 of file qbpp_tsp.hpp.
◆ nodes
| std::vector<std::tuple<int, int, std::string> > qbpp::tsp::DrawSimpleGraph::nodes |
|
private |
List of nodes with coordinate (x, y)
- Note
- The graph is undirected
Definition at line 209 of file qbpp_tsp.hpp.
◆ edges
| std::vector<std::tuple<int, int> > qbpp::tsp::DrawSimpleGraph::edges |
|
private |
The documentation for this class was generated from the following file: