QUBO++ Library with QUBO Solver APIs
Author: Koji Nakano, License: Non-commercial research and evaluation purposes without any guarantees.
Public Member Functions | Private Attributes | List of all members
qbpp::tsp::DrawSimpleGraph Class Reference

Class to draw a simple undirected graph. More...

#include <qbpp_tsp.hpp>

Public Member Functions

 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...
 

Private Attributes

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DrawSimpleGraph()

qbpp::tsp::DrawSimpleGraph::DrawSimpleGraph ( )
default

Default constructor to create an empty graph.

Member Function Documentation

◆ 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
xx-coordinate of the node
yy-coordinate of the node
labelLabel of the node

Definition at line 221 of file qbpp_tsp.hpp.

Here is the caller graph for this function:

◆ 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
nodePair of coordinates (x, y) of the node
labelLabel of the node

Definition at line 227 of file qbpp_tsp.hpp.

Here is the call graph for this function:

◆ add_edge()

void qbpp::tsp::DrawSimpleGraph::add_edge ( unsigned int  node1,
unsigned int  node2 
)
inline

Add an edge to the graph.

Parameters
node1Index of the first node
node2Index of the second node
Note
if node1 > node2, the nodes are swapped

Definition at line 235 of file qbpp_tsp.hpp.

Here is the caller graph for this function:

◆ 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
filenameName 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.

Here is the caller graph for this function:

Member Data Documentation

◆ 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

List of edges (node1, node2)

Definition at line 211 of file qbpp_tsp.hpp.


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