LAL: Linear Arrangement Library 21.07.01
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 (uint32_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 (uint32_t n) noexcept |
Allocates the necessary memory for this class. | |
virtual void | clear () noexcept |
Frees the memory occupied by this graph. | |
virtual void | normalise () noexcept |
Normalises the graph. | |
virtual bool | check_normalised () noexcept |
Checks if the graph is normalised. | |
virtual void | finish_bulk_add (bool norm=true, bool check=true) noexcept=0 |
Completes the inner structure of the graph after adding a bulk of edges. | |
void | set_normalised (bool v=true) noexcept |
Sets whether this graph is normalised or not. | |
virtual std::vector< edge_pair > | get_Q () const noexcept=0 |
Returns all independent pairs of edges of this graph. | |
bool | has_node (node u) const noexcept |
Returns true if node u is in this graph. | |
virtual bool | has_edge (node u, node v) const =0 |
Returns true if the undirected edge (u, v) exists in the graph. | |
uint32_t | get_num_nodes () const noexcept |
Returns the number of ndoes. | |
uint32_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_normalised () const noexcept |
Returns whether this graph is normalised 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 (uint32_t n) noexcept |
Initialises 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 | __disjoint_union (const graph &g) noexcept |
Disjoint union of graphs. | |
virtual void | extra_work_per_edge_add (node u, node v) noexcept |
Do some extra work after an edge has been added. | |
virtual void | extra_work_per_edge_remove (node u, node v) noexcept |
Do some extra work after an edge has been removed. | |
void | normalise_after_add (bool norm, bool check) noexcept |
Normalise the graph after one (or more) edges have been added. | |
void | normalise_after_remove (bool norm, bool check) noexcept |
Normalise the graph after one (or more) edges have been removed. | |
Protected Attributes | |
std::vector< neighbourhood > | m_adjacency_list |
Data structure that implements the graph. | |
uint32_t | m_num_edges = 0 |
Amount of edges of this graph. | |
bool | m_normalised = true |
Is this graph normalised? | |
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 information (see rooted_tree::init_rooted(const free_tree&,node). While these classes' internal memory can be initialised, 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. |
|
virtualnoexcept |
Checks if the graph is normalised.
Checks, whether the graph's adjacency structure is normalised or not. In case it is, attribute m_normalised is set to true, so method is_normalised 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 | Normalise the graph |
check | Check wether the graph is normalised or not. |
Implemented in lal::graphs::directed_graph, lal::graphs::free_tree, lal::graphs::rooted_tree, and lal::graphs::undirected_graph.
|
pure 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 |
|
inlinenoexcept |
Returns whether this graph is normalised or not.
A graph is normalised if every node's adjacency list is sorted increasingly. For this, use method normalise().
|
virtualnoexcept |
Normalises the graph.
Sorts this graph's adjacency list structure in increasing order.
Besides expensive, this method may be unnecessary. Method check_normalised() checks whether the graph is normalised 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 normalised?
An undirected graph is normalised 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-neighbours and in-neighbours of nodes be sorted.
This attribute is set to 'true' in all graph's initialisation and destruction (when clear() method is called).