LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
|
Abstract class for graphs. More...
#include <graph.hpp>
Public Member Functions | |
graph () noexcept | |
Empty constructor. | |
graph (const uint64_t n) noexcept | |
Constructor with number of nodes. | |
graph (const graph &g) noexcept | |
Copy constructor. | |
graph (graph &&g) noexcept | |
Move constructor. | |
virtual | ~graph () noexcept |
Destructor. | |
graph & | operator= (const graph &g) noexcept |
Copy assignment operator. | |
graph & | operator= (graph &&g) noexcept |
Move assignment operator. | |
virtual void | init (const uint64_t n) noexcept |
Allocates the necessary memory for this class. | |
virtual void | clear () noexcept |
Frees the memory occupied by this graph. | |
virtual void | normalize () noexcept |
Normalizes the graph. | |
virtual bool | check_normalized () noexcept |
Checks if the graph is normalized. | |
virtual void | finish_bulk_add (const bool norm=true, const bool check=true) noexcept=0 |
Completes the inner structure of the graph after adding a bulk of edges. | |
virtual void | finish_bulk_remove (const bool norm=true, const bool check=true) noexcept=0 |
Completes the inner structure of the graph after removing edges in bulk. | |
void | set_normalized (const bool v=true) noexcept |
Sets whether this graph is normalized or not. | |
virtual std::vector< edge_pair > | get_Q () const noexcept=0 |
Returns all independent pairs of edges of this graph. | |
bool | has_node (const node u) const noexcept |
Returns true if node u is in this graph. | |
virtual bool | has_edge (const node u, const node v) const =0 |
Returns true if the undirected edge (u, v) exists in the graph. | |
uint64_t | get_num_nodes () const noexcept |
Returns the number of ndoes. | |
uint64_t | get_num_edges () const noexcept |
Returns the number of edges. | |
virtual std::vector< edge > | get_edges () const noexcept=0 |
Returns all edges of this graph. | |
bool | is_normalized () const noexcept |
Returns whether this graph is normalized or not. | |
virtual bool | is_directed () const noexcept=0 |
Returns whether this graph is directed or not. | |
virtual bool | is_undirected () const noexcept=0 |
Returns whether this graph is undirected or not. | |
Protected Member Functions | |
virtual void | _init (const uint64_t n) noexcept |
Initializes memory of graph class. | |
virtual void | _clear () noexcept |
Clears memory for the graph class. | |
void | copy_full_graph (const graph &g) noexcept |
Copies all members of this class. | |
void | move_full_graph (graph &&g) noexcept |
Moves all members of this class. | |
void | __add_node () noexcept |
Adds a node to the graph. | |
void | __disjoint_union (const graph &g) noexcept |
Disjoint union of graphs. | |
virtual void | actions_after_add_edge (const node u, const node v) noexcept |
Do some extra work after the addition of an edge. | |
virtual void | actions_after_add_edges (const edge_list &e) noexcept |
Do some extra work after the addition of several edges. | |
virtual void | actions_after_add_edges_bulk () noexcept |
Do some extra work after the addition of several edges in bulk. | |
virtual void | actions_after_remove_edge (const node u, const node v) noexcept |
Do some extra work after the removal of an edge. | |
virtual void | actions_after_remove_edges (const edge_list &e) noexcept |
Do some extra work after the removal of several edges. | |
virtual void | actions_after_remove_edges_bulk () noexcept |
Do some extra work after the removal of several edges in bulk. | |
virtual void | actions_before_remove_edges_incident_to (const node u) noexcept |
Do some work before all edges incident to a node is removed. | |
virtual void | actions_after_remove_node (const node u) noexcept |
Do some work before the removal of a vertex. | |
void | normalize_after_edge_addition (const bool norm, const bool check) noexcept |
Normalize the graph after one (or more) edges have been added. | |
void | normalize_after_edge_removal (const bool norm, const bool check) noexcept |
Normalize the graph after one (or more) edges have been removed. | |
Protected Attributes | |
std::vector< neighbourhood > | m_adjacency_list |
Data structure that implements the graph. | |
uint64_t | m_num_edges = 0 |
Amount of edges of this graph. | |
bool | m_is_normalized = true |
Is this graph normalized? | |
Abstract class for graphs.
Class used as an interface for all types of graphs. This means that this class cannot be instantiated. The classes that can be instantiated are undirected_graph, directed_graph, free_tree, rooted_tree.
A usual way of initialising classes inheriting from this one is to use one of the init methods available. Depending on the subclass, this method admits either the number of nodes of the graph or a whole other graph and further data (see rooted_tree::init_rooted(const lal::graphs::free_tree&, node, bool, bool)). While these classes' internal memory can be initialized, it can also be cleared using method clear. Each class reimplements this method to carry this task appropriately.
|
inlinenoexcept |
Constructor with number of nodes.
n | Number of nodes. |
|
inlinenoexcept |
Copy constructor.
g | Graph. |
|
inlinenoexcept |
Move constructor.
g | Graph. |
|
protectednoexcept |
Disjoint union of graphs.
Given a graph, append it to the current graph.
All the nodes in g are relabelled starting at n, the number of nodes of the current graph.
g | Input graph. |
|
inlineprotectedvirtualnoexcept |
Initializes memory of graph class.
n | Number of nodes. |
Reimplemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the addition of an edge.
u | Node of the edge |
v | Node of the edge |
Reimplemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the addition of several edges.
e | List of edges. |
Reimplemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the addition of several edges in bulk.
This method should only be called after several calls to undirected_graph::add_edge_bulk or directed_graph::add_edge_bulk.
Reimplemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the removal of an edge.
u | Node of the edge |
v | Node of the edge |
Reimplemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the removal of several edges.
e | List of edges. |
Reimplemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the removal of several edges in bulk.
This method should only be called after several calls to undirected_graph::remove_edge_bulk or directed_graph::remove_edge_bulk.
Reimplemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some work before the removal of a vertex.
u | Node to be removed. |
Reimplemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some work before all edges incident to a node is removed.
u | Node whose incident edges are to be removed. |
Reimplemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
virtualnoexcept |
Checks if the graph is normalized.
Checks, whether the graph's adjacency structure is normalized or not. In case it is, attribute m_is_normalized is set to true, so method is_normalized evaluates to true.
Reimplemented in lal::graphs::directed_graph.
|
virtualnoexcept |
Frees the memory occupied by this graph.
See _clear for details.
|
pure virtualnoexcept |
Completes the inner structure of the graph after adding a bulk of edges.
This is meant to be used after several calls to undirected_graph::add_edge_bulk, directed_graph::add_edge_bulk.
norm | Normalize the graph. |
check | Check wether the graph is normalized or not. |
Implemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
pure virtualnoexcept |
Completes the inner structure of the graph after removing edges in bulk.
This is meant to be used after several calls to undirected_graph::remove_edge_bulk, directed_graph::remove_edge_bulk.
norm | Normalize the graph. |
check | Check wether the graph is normalized or not. |
Implemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
nodiscardpure virtualnoexcept |
Returns all independent pairs of edges of this graph.
The set \(Q(G)\) is defined as the pairs of edges of \(G\), \(E(G) \times E(G)\), that are independent, that is, that share no nodes.
Implemented in lal::graphs::directed_graph, and lal::graphs::undirected_graph.
|
virtualnoexcept |
|
inlinenodiscardnoexcept |
Returns whether this graph is normalized or not.
A graph is normalized if every node's adjacency list is sorted increasingly. For this, use method normalize().
|
virtualnoexcept |
Normalizes the graph.
Sorts this graph's adjacency list structure in increasing order.
Besides expensive, this method may be unnecessary. Method check_normalized() checks whether the graph is normalized or not; in case it is, using this method is completely unnecessary.
Reimplemented in lal::graphs::directed_graph.
Copy assignment operator.
g | Graph. |
Move assignment operator.
g | Graph. |
|
protected |
Is this graph normalized?
An undirected graph is normalized iff every node's adjacency list is sorted in increasing order.
In directed graphs, however, it is necessary that the adjacency lists of the out-neighbors and in-neighbors of nodes be sorted.
This attribute is set to 'true' in all graph's initialisation and destruction (when clear() method is called).