20 #ifndef __CXXGRAPH_UNDIRECTEDWEIGHTEDEDGE_H__
21 #define __CXXGRAPH_UNDIRECTEDWEIGHTEDEDGE_H__
25 #include "UndirectedEdge.hpp"
26 #include "Weighted.hpp"
32 class DirectedWeightedEdge;
35 class UndirectedWeightedEdge;
39 std::ostream &operator<<(std::ostream &o,
const UndirectedWeightedEdge<T> &edge);
42 class UndirectedWeightedEdge :
public UndirectedEdge<T>,
public Weighted
45 UndirectedWeightedEdge(
const unsigned long id,
const Node<T> &node1,
const Node<T> &node2,
const double weight);
46 UndirectedWeightedEdge(
const unsigned long id,
const std::pair<
const Node<T> *,
const Node<T> *> &nodepair,
const double weight);
47 UndirectedWeightedEdge(
const UndirectedEdge<T> &edge,
const double weight);
48 UndirectedWeightedEdge(
const Edge<T> &edge,
const double weight);
49 UndirectedWeightedEdge(
const UndirectedEdge<T> &edge);
50 UndirectedWeightedEdge(
const Edge<T> &edge);
51 UndirectedWeightedEdge(
const DirectedWeightedEdge<T> &edge);
52 virtual ~UndirectedWeightedEdge() =
default;
53 const std::optional<bool> isWeighted()
const override;
55 explicit operator DirectedWeightedEdge<T>()
const {
return DirectedWeightedEdge<T>(Edge<T>::getId(), Edge<T>::getNodePair(), Weighted::getWeight()); }
57 friend std::ostream &operator<<<>(std::ostream &os,
const UndirectedWeightedEdge<T> &edge);
61 UndirectedWeightedEdge<T>::UndirectedWeightedEdge(
const unsigned long id,
const Node<T> &node1,
const Node<T> &node2,
const double weight) : UndirectedEdge<T>(id, node1, node2), Weighted(weight)
66 UndirectedWeightedEdge<T>::UndirectedWeightedEdge(
const unsigned long id,
const std::pair<
const Node<T> *,
const Node<T> *> &nodepair,
const double weight) : UndirectedEdge<T>(id, nodepair), Weighted(weight)
71 UndirectedWeightedEdge<T>::UndirectedWeightedEdge(
const UndirectedEdge<T> &edge,
const double weight) : UndirectedEdge<T>(edge), Weighted(weight)
76 UndirectedWeightedEdge<T>::UndirectedWeightedEdge(
const Edge<T> &edge,
const double weight) : UndirectedEdge<T>(edge), Weighted(weight)
81 UndirectedWeightedEdge<T>::UndirectedWeightedEdge(
const UndirectedEdge<T> &edge) : UndirectedEdge<T>(edge), Weighted()
86 UndirectedWeightedEdge<T>::UndirectedWeightedEdge(
const Edge<T> &edge) : UndirectedEdge<T>(edge), Weighted()
91 UndirectedWeightedEdge<T>::UndirectedWeightedEdge(
const DirectedWeightedEdge<T> &edge) : UndirectedEdge<T>(edge), Weighted(edge.getWeight())
96 const std::optional<bool> UndirectedWeightedEdge<T>::isWeighted()
const
101 template <
typename T>
102 std::ostream &operator<<(std::ostream &os,
const UndirectedWeightedEdge<T> &edge)
104 os <<
"((Node: " << edge.getNode1().getId() <<
")) <----- |Edge: #" << edge.getId() <<
" W:" << edge.getWeight() <<
"|-----> ((Node: " << edge.getNode2().getId() <<
"))";
110 #endif // __CXXGRAPH_UNDIRECTEDWEIGHTEDEDGE_H__