1 #ifndef GL_WRITE_TIKZ_HPP
2 #define GL_WRITE_TIKZ_HPP
4 #include "../structures/Graph.hpp"
17 template <
class SCALAR,
class STORAGE_KIND,
class DIRECTION>
20 s <<
"\\RequirePackage{luatex85}" << std::endl;
21 s <<
"\\documentclass{standalone}" << std::endl;
22 s <<
"\\usepackage{tikz-network}" << std::endl;
23 s <<
"\\begin{document}" << std::endl;
24 s <<
"\\begin{tikzpicture}" << std::endl;
30 <<
",RGB,color={" << +color.r() <<
"," << +color.g()
31 <<
"," << +color.b() <<
"},opacity=" << +color.a()
39 s <<
",label=" << g.
getNodeLabel(i) <<
",position=above";
41 s << (writeNodes ?
"" :
",NoLabel")
42 <<
"]{" << i <<
"}" << std::endl;
49 if ((std::is_same_v<DIRECTION, gl::Undirected> && it->source() <= it->dest()) || std::is_same_v<DIRECTION, gl::Directed>)
51 auto color = it->color();
52 s <<
" \\Edge[" << (g.
isDirected() ?
"Direct," :
"")
53 << (it->source() == it->dest() ?
"loopshape=45," :
"")
54 <<
"RGB,color={" << +color.r() <<
"," << +color.g()
55 <<
"," << +color.b() <<
"},opacity=" << +color.a();
58 s <<
",label=" << it->weight();
60 s <<
"](" << it->source() <<
")(" << it->dest() <<
")" << std::endl;
63 s <<
"\\node[above,align=center,font=\\bfseries] at (current bounding box.north) {" << g.
getGraphLabel() <<
"};" << std::endl;
64 s <<
"\\end{tikzpicture}" << std::endl;
65 s <<
"\\end{document}" << std::endl;
71 #endif // GL_WRITE_TIKZ_HPP
ConstEdgeIterator edge_cbegin() const
ConstEdgeIterator to the first edge.
Definition: Graph.hpp:967
void writeTikzNetwork(std::ostream &s, Graph< SCALAR, STORAGE_KIND, DIRECTION > &g, bool writeNodes=true, bool writeEdgeWeights=true)
Write structure to stream, given.
Definition: WriteTikz.hpp:18
val_t getNodeCapacity(const idx_t &id) const
Finds the flow capacity of the given node.
Definition: Graph.hpp:1264
Stores and implements a Graph.
Definition: Graph.hpp:39
ConstEdgeIterator edge_cend() const
ConstEdgeIterator to the last edge.
Definition: Graph.hpp:989
std::string getGraphLabel() const
Returns the label of the graph.
Definition: Graph.hpp:390
bool isDirected() const
Returns true if the graph is directed, false if not.
Definition: Graph.hpp:426
idx_t numNodes() const
Returns the number of nodes currently in the graph.
Definition: Graph.hpp:406
std::size_t index_type
Definition: gl_base.hpp:18
Color getNodeColor(const idx_t &id) const
Returns the color of a node.
Definition: Graph.hpp:1325
std::string getNodeLabel(const idx_t &id) const
Finds the label of the given node.
Definition: Graph.hpp:1255
std::pair< float, float > getNodePosition(const idx_t &id) const
Finds the position of the given node.
Definition: Graph.hpp:1273