GraphLib
Bearbeitung der Aufgabe Mini Graph Library für OOP WiSe 2023/24
Loading...
Searching...
No Matches
edge.h File Reference

Defines the Edge and WeightedEdge structures used to represent edges in graphs. More...

#include <cstddef>
#include <iostream>
#include <ostream>
#include "GraphLib/internal/concepts.h"

Go to the source code of this file.

Classes

struct  GraphLib::Internal::Edge< I >
 Represents an unweighted edge to a node identified by an ID. More...
struct  GraphLib::Internal::WeightedEdge< I, W >
 Represents a weighted edge to a node identified by an ID, with an associated weight. More...

Functions

template<valid_id_type I>
std::ostream & GraphLib::Internal::operator<< (std::ostream &os, const Edge< I > &edge)
 Stream output operator for unweighted Edge.
template<valid_id_type I, valid_weight_type W>
std::ostream & GraphLib::Internal::operator<< (std::ostream &os, const WeightedEdge< I, W > &edge)
 Stream output operator for weighted Edge.

Detailed Description

Defines the Edge and WeightedEdge structures used to represent edges in graphs.

This file implements basic edge types with ID and optional weight, including comparison operators and stream output support for debugging and logging.

Definition in file edge.h.

Function Documentation

◆ operator<<() [1/2]

template<valid_id_type I>
std::ostream & GraphLib::Internal::operator<< ( std::ostream & os,
const Edge< I > & edge )

Stream output operator for unweighted Edge.

Prints the node ID to the output stream.

Template Parameters
INode ID type.
Parameters
osOutput stream.
edgeEdge instance to output.
Returns
Reference to the output stream.

Definition at line 84 of file edge.h.

◆ operator<<() [2/2]

template<valid_id_type I, valid_weight_type W>
std::ostream & GraphLib::Internal::operator<< ( std::ostream & os,
const WeightedEdge< I, W > & edge )

Stream output operator for weighted Edge.

Prints the node ID and weight in the format "node_id (weight)".

Template Parameters
INode ID type.
WWeight type.
Parameters
osOutput stream.
edgeWeighted edge instance to output.
Returns
Reference to the output stream.

Definition at line 163 of file edge.h.