1 #ifndef GL_STREAM_OVERLOAD_HPP
2 #define GL_STREAM_OVERLOAD_HPP
4 #include "../structures/Graph.hpp"
5 #include "../structures/Color.hpp"
21 template <
class SCALAR,
class STORAGE>
22 std::ostream& operator<< (std::ostream& os, const gl::Graph<SCALAR, STORAGE, gl::Directed>& rhs) {
24 os <<
"----- " << rhs.getGraphLabel() <<
" -----" << std::endl
25 <<
"Total Nodes: " << rhs.numNodes() << std::endl
26 <<
"Total Edges: " << rhs.numEdges() << std::endl
28 << (GL_IS_MATRIX ?
"Matrix" : (GL_IS_LIST ?
"List" :
"Unknown storage type"))
30 for (
auto it = rhs.edge_cbegin(); it != rhs.edge_cend(); ++it) {
31 os << it->source() <<
"--(" << it->weight()
32 <<
")->" << it->dest() << std::endl;
34 std::cout << std::endl;
41 template <
class SCALAR,
class STORAGE>
42 std::ostream& operator<< (std::ostream& os, const gl::Graph<SCALAR, STORAGE, gl::Undirected>& rhs) {
44 os <<
"----- " << rhs.getGraphLabel() <<
" -----" << std::endl
45 <<
"Total Nodes: " << rhs.numNodes() << std::endl
46 <<
"Total Edges: " << rhs.numEdges() << std::endl
48 << (GL_IS_MATRIX ?
"Matrix" : (GL_IS_LIST ?
"List" :
"Unknown storage type"))
50 for (
auto it = rhs.edge_cbegin(); it != rhs.edge_cend(); ++it) {
51 if (it->source() <= it->dest()) {
52 os << it->source() <<
"<-(" << it->weight()
53 <<
")->" << it->dest() << std::endl;
56 std::cout << std::endl;
71 template <
class val_t>
72 std::ostream& operator<< (std::ostream& os, const gl::Distance<val_t>& dist)
74 os << dist.getDistance();
82 template <
class idx_t>
83 std::ostream& operator<< (std::ostream & os, const std::list<idx_t>& rhs)
86 for (
const auto& it : rhs) {
96 template <
class idx_t>
97 std::ostream& operator<< (std::ostream& os, const std::vector<idx_t>& rhs) {
99 for (
const auto& it : rhs) {
109 template <
class idx_t>
110 std::ostream& operator<< (std::ostream& os, const std::deque<idx_t>& rhs)
113 for (
const auto& it : rhs) {
124 template <
class idx_t>
125 std::ostream& operator<< (std::ostream& os, std::stack<idx_t> rhs)
128 while (!rhs.empty()) {
129 os << rhs.top() <<
" ";
145 os <<
"[Hex: #" << std::setw(8) << std::right
146 << std::hex << +rhs.
hex() << std::setfill(
'0');
147 os <<
";(RGB: " << std::dec
150 << +rhs.
b() <<
"), Opacity: "
159 template<
class SCALAR>
160 std::ostream& operator<< (std::ostream& os, const gl::Edge<SCALAR>& rhs)
162 os <<
"[" <<rhs.source()
163 <<
"--(" << rhs.weight()
164 <<
")->" << rhs.dest()
165 <<
"; #" << rhs.color().RGBA()
170 #endif // GL_STREAM_OVERLOAD_HPP
Stores an RGBA Color.
Definition: Color.hpp:21
gl::index_type idx_t
Index type.
Definition: Graph.hpp:44
std::ostream & operator<<(std::ostream &os, const gl::Graph< SCALAR, STORAGE, gl::Directed > &rhs)
Prints all info of a directed graph.
Definition: StreamOverload.hpp:22
int hex() const
Gets the hexadecimal value of the RGBA color.
Definition: Color.hpp:160
color_val_t b() const
Gets the blue value of the RGBA color.
Definition: Color.hpp:175
color_val_t g() const
Gets the green value of the RGBA color.
Definition: Color.hpp:171
color_val_t a() const
Gets the alpha/opacity value of the RGBA color.
Definition: Color.hpp:179
color_val_t r() const
Gets the red value of the RGBA color.
Definition: Color.hpp:167