Mace C++ Graph Library 1.0
The fast and flexible graph library for C++. Developed by Matthias Mace Hädrich.
|
This is the base class for an undirected graph. More...
#include <undirected_graph.h>
Public Member Functions | |
DLL | undirected_graph (std::string name="", bool parallels_allowed=true) |
The constructor. | |
~undirected_graph () | |
The destructor. | |
DLL bool | add_edge (vertex *p_src, vertex *p_dest, int weight=0) |
Add an edge to the graph. | |
DLL bool | add_edge (vertex *p_src, edge *p_edge) |
Add an edge to the graph. | |
DLL bool | remove_edge (vertex *p_vertex_0, vertex *p_vertex_1) |
Remove an edge from vertex p_vertex_0 to p_vertex_1 . | |
DLL bool | remove_edge (edge *p_edge) |
Remove an edge from the graph. |
This is the base class for an undirected graph.
An undirected graph contains vertices and edges which are bidirectional.
That means that for every added adge there are created edges from the one vertex to the other and vice versa.
This results in a slightly larger mememory allocation, because an undirected graph needs O(|V| + 2 * |E|) of memory.
Definition at line 24 of file undirected_graph.h.
undirected_graph::undirected_graph | ( | std::string | name = "" , |
bool | parallels_allowed = true |
||
) |
The constructor.
An undirected graph can be initialized with a name name
and the instruction of allowing parallel edges or not.
parallels_allowed
is true by default.
Definition at line 15 of file undirected_graph.cpp.
undirected_graph::~undirected_graph | ( | ) |
The destructor.
For all vertices there has been memory allocated which should be freed now.
Definition at line 26 of file undirected_graph.cpp.
Add an edge to the graph.
Creates an edge with the destination vertex p_dest
and weight
, then appends it to the source vertex p_src
.
Implements graph.
Definition at line 50 of file undirected_graph.cpp.
Add an edge to the graph.
Appends the edge p_edge
to the vertex p_src
. Parallel edges can only be created if the graph allows that.
Because this is the implementation for an undirected graph, the edge is not only added from source to destination, but also from destination to source. Memory needed: O(|V| + 2 * |E|)
This fact is to be ignored if the edge is a loop.
Implements graph.
Definition at line 73 of file undirected_graph.cpp.
Remove an edge from vertex p_vertex_0
to p_vertex_1
.
Because this is the implementation for an undirected graph, not only the edge from vertex p_vertex_0
to vertex p_vertex_1
has to be removed
but also the edge from vertex p_vertex_1
to vertex p_vertex_0
.
Implements graph.
Definition at line 105 of file undirected_graph.cpp.
bool undirected_graph::remove_edge | ( | edge * | p_edge | ) | [virtual] |
Remove an edge from the graph.
Implements graph.
Definition at line 140 of file undirected_graph.cpp.