Graph 3
graph Class Reference

#include <graph.h>

Public Member Functions

 graph (const std::string &file_name)
 Reads edges for graph from file. More...
 
 graph (graph const &org)=default
 
 graph (graph &&org)=default
 
graphoperator= (graph const &rhs)=default
 
graphoperator= (graph &&rhs)=default
 
 ~graph ()=default
 
std::vector< std::vector< unsigned int > > get_node2nodes () const
 
size_t Nedges () const
 
size_t Nvertices () const
 
size_t Max_vertex () const
 
bool Append (unsigned int v1, unsigned int v2)
 Appends one directed edge to the graph. The method add only edges that not already contained in the graph. More...
 
bool Delete (unsigned int v1, unsigned int v2)
 Removes one directed edge (v1, v2) from the graph. The method add only edges that not already contained in the graph. More...
 
bool Delete (Edge const &e)
 Removes edge e from the graph. More...
 
void Delete (std::vector< Edge > const &v)
 Removes the given edges from the graph. The method add only edges that not already contained in the graph. More...
 

Friends

std::ostream & operator<< (std::ostream &s, graph const &rhs)
 Prints edges and vertices of the graph. More...
 

Detailed Description

Directed graph class. A better graph class that doesn't requires a consecutive numbering of the vertices.

Definition at line 14 of file graph.h.

Constructor & Destructor Documentation

◆ graph() [1/3]

graph::graph ( const std::string &  file_name)
explicit

Reads edges for graph from file.

If the file file_name does not exist then the code stops with an appropriate message.

A consecutive numbering of the vertices is required.

Parameters
[in]file_namename of the ASCII-file

◆ graph() [2/3]

graph::graph ( graph const &  org)
default

◆ graph() [3/3]

graph::graph ( graph &&  org)
default

◆ ~graph()

graph::~graph ( )
default

Member Function Documentation

◆ Append()

bool graph::Append ( unsigned int  v1,
unsigned int  v2 
)

Appends one directed edge to the graph. The method add only edges that not already contained in the graph.

Parameters
[in]v1start vertex
[in]v2end vertex

Definition at line 99 of file graph.cpp.

◆ Delete() [1/3]

bool graph::Delete ( Edge const &  e)

Removes edge e from the graph.

Parameters
[in]eedge
Returns
True if edge e exists in the graph.

Definition at line 113 of file graph.cpp.

◆ Delete() [2/3]

void graph::Delete ( std::vector< Edge > const &  v)

Removes the given edges from the graph. The method add only edges that not already contained in the graph.

Parameters
[in]vvector[ne],[2] of edges
Warning
No message if an edge (v[k][1], v[k][2]) doesn't exist in the graph.

◆ Delete() [3/3]

bool graph::Delete ( unsigned int  v1,
unsigned int  v2 
)

Removes one directed edge (v1, v2) from the graph. The method add only edges that not already contained in the graph.

Parameters
[in]v1start vertex
[in]v2end vertex
Returns
True if edge e exists in the graph.

Definition at line 124 of file graph.cpp.

◆ get_node2nodes()

vector< vector< unsigned int > > graph::get_node2nodes ( ) const

Determines the neighboring vertices for each node from the edge definition. The node itself is not contained in the neighboring vertices.

Returns
vector[nn][*] with all neighboring vertices for each node

Definition at line 35 of file graph.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Max_vertex()

size_t graph::Max_vertex ( ) const
inline
Returns
largest vertex index

Definition at line 61 of file graph.h.

Here is the caller graph for this function:

◆ Nedges()

size_t graph::Nedges ( ) const
inline
Returns
number of edges

Definition at line 45 of file graph.h.

Here is the caller graph for this function:

◆ Nvertices()

size_t graph::Nvertices ( ) const
inline
Returns
number of vertices

Definition at line 53 of file graph.h.

Here is the caller graph for this function:

◆ operator=() [1/2]

graph& graph::operator= ( graph &&  rhs)
default

◆ operator=() [2/2]

graph& graph::operator= ( graph const &  rhs)
default

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  s,
graph const &  rhs 
)
friend

Prints edges and vertices of the graph.

Parameters
[in,out]soutput stream
[in]rhsgraph
Returns
Output stream.

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