UnCoVer (Using Coverability for Verification)
|
An AnonHypergraph is a data structure storing a hypergraph. More...
#include <AnonHypergraph.h>
Public Types | |
typedef map< IDType, Vertex > | VMap |
Alias for a vertex map returned by this class. More... | |
typedef map< IDType, Edge > | EMap |
Alias for an edge map returned by this class. More... | |
typedef unordered_multiset < IDType > | ESet |
Alias for a set of edge IDs connected to a vertex. More... | |
Public Member Functions | |
AnonHypergraph (std::string name="") | |
Generates a new graph with the given name and an empty collection of vertices and edges. More... | |
AnonHypergraph (const AnonHypergraph &graph) | |
Generates a new graph with data copied from the given graph. More... | |
virtual | ~AnonHypergraph () |
Deletes this graph, freeing all its memory. | |
string | getName () const |
Returns the name of this graph. More... | |
void | setName (string s) |
Sets the name of this graph to the given string. More... | |
virtual void | streamTo (std::ostream &ost) const override |
Prints a string representation of this graph to the given stream. More... | |
IDType | addVertex () |
Adds a new vertex to this graph and returns the ID of the added vertex. More... | |
bool | hasVertex (IDType id) const |
Returns true if and only if this graph has a vertex with the given ID. More... | |
bool | deleteVertex (IDType id, unordered_set< IDType > *delEdges=nullptr) |
Deletes the vertex with the given ID if it exists in this graph. More... | |
bool | deleteVertices (vector< IDType > const &ids, unordered_set< IDType > *delEdges=nullptr) |
All vertices with IDs in the given vector will be deleted, also deleting all edges incident to them. More... | |
size_t | getVertexCount () const |
Returns the number of vertices of this graph. More... | |
AnonHypergraph::VMap::iterator | beginVertices () noexcept |
Returns an iterator to the first entry in the vertex map. More... | |
AnonHypergraph::VMap::const_iterator | beginVertices () const noexcept |
Returns a const_iterator to the first entry in the vertex map. More... | |
AnonHypergraph::VMap::const_iterator | cbeginVertices () const noexcept |
Returns a const_iterator to the first entry in the vertex map. More... | |
AnonHypergraph::VMap::iterator | endVertices () noexcept |
Returns an iterator pointing beyond the last entry in the vertex map. More... | |
AnonHypergraph::VMap::const_iterator | endVertices () const noexcept |
Returns a const_iterator pointing beyond the last entry in the vertex map. More... | |
AnonHypergraph::VMap::const_iterator | cendVertices () const noexcept |
Returns a const_iterator pointing beyond the last entry in the vertex map. More... | |
AnonHypergraph::ESet * | getConnectedEdges (IDType vid) |
Returns the set of IDs of edges incident to the vertex with the given ID. More... | |
AnonHypergraph::ESet const * | getConnectedEdges (IDType vid) const |
Returns the set of IDs of edges incident to the vertex with the given ID. More... | |
int | getConnEdgesCount (IDType vid) const |
Returns the number of edges connected to the vertex with the given ID. More... | |
IDType | mergeVertices (IDType id1, IDType id2) |
Merges the vertices with the given IDs, such that all edges incident to one of the vertices will be incident to the merging. More... | |
void | mergeVertexIntoFirst (IDType id1, IDType id2) |
Same as mergeVertices(IDType,IDType), but it is guaranteed that the ID of the merged vertex will be the ID of the first vertex, i.e. More... | |
IDType | mergeVertices (unordered_set< IDType > const &ids) |
Merges all vertices in the given vector into one vertex. More... | |
bool | hasEdge (IDType id) const |
Returns true, iff this graph has an edge with the given ID. More... | |
IDType | addEdge (string label, vector< IDType > const &attVertices=vector< IDType >()) |
Adds an edge with the given label and incident vertices to this graph. More... | |
bool | deleteEdge (IDType id) |
Deleted the edge with the given ID, if it exists (ignored if it does not exist). More... | |
vector< IDType > * | getVerticesOfEdge (IDType edgeID) |
Returns the sequence of vertices incident to the edge with the given ID. More... | |
vector< IDType > const * | getVerticesOfEdge (IDType edgeID) const |
Returns the sequence of vertices incident to the edge with the given ID. More... | |
Edge * | getEdge (IDType id) |
Returns the edge with the given ID if it exists. More... | |
Edge const * | getEdge (IDType id) const |
Returns the edge with the given ID if it exists. More... | |
int | getEdgeArity (IDType id) const |
Returns the arity of the edge with the given ID, i.e. More... | |
size_t | getEdgeCount () const |
Returns the number of edges of this graph. More... | |
AnonHypergraph::EMap::iterator | beginEdges () noexcept |
Returns an iterator to the first entry in the edge map. More... | |
AnonHypergraph::EMap::const_iterator | beginEdges () const noexcept |
Returns a const_iterator to the first entry in the edge map. More... | |
AnonHypergraph::EMap::const_iterator | cbeginEdges () const noexcept |
Returns a const_iterator to the first entry in the edge map. More... | |
AnonHypergraph::EMap::iterator | endEdges () noexcept |
Returns an iterator pointing beyond the last entry in the edge map. More... | |
AnonHypergraph::EMap::const_iterator | endEdges () const noexcept |
Returns a const_iterator pointing beyond the last entry in the edge map. More... | |
AnonHypergraph::EMap::const_iterator | cendEdges () const noexcept |
Returns a const_iterator pointing beyond the last entry in the edge map. More... | |
IDType | mergeEdges (IDType id1, IDType id2) |
Merges the edges with the given IDs. More... | |
IDType | mergeEdges (unordered_set< IDType > const &ids) |
Merges all edges in the given vector into one edge. More... | |
bool | areParallelEdges (IDType id1, IDType id2) const |
Returns true if the given IDs are parallel edges, i.e. More... | |
Protected Attributes | |
IDType | lastUsedID |
Stores the last ID assigned to a vertex or edge. | |
string | name |
Stores the name of this graph. | |
AnonHypergraph::VMap | vertices |
Stores a map of all vertices of this graph, where the key is their ID. | |
AnonHypergraph::EMap | edges |
Stores a map of all edges of this graph, where the key is their ID. | |
unordered_map< IDType, AnonHypergraph::ESet > | connectedEdges |
Maps every vertex ID to a set containing all IDs of edges incident to them. More... | |
An AnonHypergraph is a data structure storing a hypergraph.
It stores a name, a collection of vertices and a collection of edges connected to these vertices. Furthermore, it provides a large collection of functions to manipulate the graph structure, ranging from add- and delete-function to iterators. The Hypergraph class extends AnonHypergraph by additionally providing an unique identifier for the graph. Note that this class can be big; the use of pointers is recommended.
Alias for an edge map returned by this class.
The keys are IDs and the values are edges.
Alias for a set of edge IDs connected to a vertex.
An ID may occur more than once if an edge is connected to the same vertex more than once.
Alias for a vertex map returned by this class.
The keys are IDs and the values are vertices.
AnonHypergraph | ( | std::string | name = "" | ) |
Generates a new graph with the given name and an empty collection of vertices and edges.
name | a name for the graph, not necessarily unique |
AnonHypergraph | ( | const AnonHypergraph & | graph | ) |
Generates a new graph with data copied from the given graph.
The new graph is an independent copy of the given graph.
graph | the graph to be copied |
Adds an edge with the given label and incident vertices to this graph.
If an ID in the vector of incident vertices is not a vertex in this graph, an exception is thrown.
label | the label of the new edge |
attVertices | the sequence of incident vertices; order is important; if not given, an edge with no incident vertices is added |
InvalidInputException | if an incident ID is no vertex in this graph |
IDType addVertex | ( | ) |
Adds a new vertex to this graph and returns the ID of the added vertex.
Returns true if the given IDs are parallel edges, i.e.
they have the same label, the same arity and the same sequence of vertices incident to them. Throws an exception if one of the IDs is not an edge.
id1 | ID of an edge |
id2 | ID of an edge |
InvalidInputException | if one of the IDs is not an edge |
|
noexcept |
Returns an iterator to the first entry in the edge map.
No order on the entries is guaranteed.
|
noexcept |
Returns a const_iterator to the first entry in the edge map.
No order on the entries is guaranteed.
|
noexcept |
Returns an iterator to the first entry in the vertex map.
No order on the entries is guaranteed.
|
noexcept |
Returns a const_iterator to the first entry in the vertex map.
No order on the entries is guaranteed.
|
noexcept |
Returns a const_iterator to the first entry in the edge map.
No order on the entries is guaranteed.
|
noexcept |
Returns a const_iterator to the first entry in the vertex map.
No order on the entries is guaranteed.
|
noexcept |
Returns a const_iterator pointing beyond the last entry in the edge map.
No order on the entries is guaranteed.
|
noexcept |
Returns a const_iterator pointing beyond the last entry in the vertex map.
No order on the entries is guaranteed.
bool deleteEdge | ( | IDType | id | ) |
Deleted the edge with the given ID, if it exists (ignored if it does not exist).
id | the ID of the edge to be deleted |
Deletes the vertex with the given ID if it exists in this graph.
All edges incident to the deleted vertex will be deleted as well. Optionally a set can be given, in which the IDs of all deleted edges will be stored.
id | the ID of the vertex to be deleted |
delEdges | a set in which all IDs of deleted edges will be stored; use null if the IDs should not be stored |
All vertices with IDs in the given vector will be deleted, also deleting all edges incident to them.
If there is an ID for which there is no vertex in the graph, the ID is simply ignored. Optionally a set can be given, in which the IDs of all deleted edges will be stored.
ids | a vector of all vertices which should be deleted |
delEdges | a set in which all IDs of deleted edges will be stored; use null if the IDs should not be stored |
|
noexcept |
Returns an iterator pointing beyond the last entry in the edge map.
No order on the entries is guaranteed.
|
noexcept |
Returns a const_iterator pointing beyond the last entry in the edge map.
No order on the entries is guaranteed.
|
noexcept |
Returns an iterator pointing beyond the last entry in the vertex map.
No order on the entries is guaranteed.
|
noexcept |
Returns a const_iterator pointing beyond the last entry in the vertex map.
No order on the entries is guaranteed.
AnonHypergraph::ESet * getConnectedEdges | ( | IDType | vid | ) |
Returns the set of IDs of edges incident to the vertex with the given ID.
If there is no such vertex, null is returned. The returned set contains every ID as often as it is connected to the vertex.
vid | the ID of the vertex of which the incident edges should be returned |
AnonHypergraph::ESet const * getConnectedEdges | ( | IDType | vid | ) | const |
Returns the set of IDs of edges incident to the vertex with the given ID.
If there is no such vertex, null is returned. The returned set contains every ID as often as it is connected to the vertex.
vid | the ID of the vertex of which the incident edges should be returned |
int getConnEdgesCount | ( | IDType | vid | ) | const |
Returns the number of edges connected to the vertex with the given ID.
If there is no vertex with the given ID, then -1 is returned.
vid | the vertex ID of which the number of incident edges should be returned |
Returns the edge with the given ID if it exists.
Returns null, if it does not exist.
id | the ID of the edge |
Returns the edge with the given ID if it exists.
Returns null, if it does not exist.
id | the ID of the edge |
int getEdgeArity | ( | IDType | id | ) | const |
Returns the arity of the edge with the given ID, i.e.
the number of vertices to which it is incident. A vertex to which the edge is incident multiple times, is counted multiple times. If no edge with the given ID exists, -1 is returned.
id | the ID of the edge to be checked |
size_t getEdgeCount | ( | ) | const |
Returns the number of edges of this graph.
string getName | ( | ) | const |
Returns the name of this graph.
size_t getVertexCount | ( | ) | const |
Returns the number of vertices of this graph.
Returns the sequence of vertices incident to the edge with the given ID.
If there is no edge with the given ID, null is returned.
edgeID | the edge for which the sequence of incident vertices should be returned |
Returns the sequence of vertices incident to the edge with the given ID.
If there is no edge with the given ID, null is returned.
edgeID | the edge for which the sequence of incident vertices should be returned |
bool hasEdge | ( | IDType | id | ) | const |
Returns true, iff this graph has an edge with the given ID.
id | the ID to be checked |
bool hasVertex | ( | IDType | id | ) | const |
Returns true if and only if this graph has a vertex with the given ID.
id | the ID to be checked |
Merges the edges with the given IDs.
This automatically merges the i-th vertex incident to both edges, for every i up to the arity. An exception is thrown if the IDs do not represent two edges, the label differ or the arity differs.
id1 | ID of an edge to be merged |
id2 | ID of an edge to be merged |
InvalidInputException | if one of the IDs does not represent an edge or the edges differ in label or arity |
Merges all edges in the given vector into one edge.
If an ID in the vector is not a valid edge ID, it is ignored, but if there are only invalid IDs, an exception is thrown.
ids | the vector of IDs of edges which will be merged |
InvalidInputException | if all IDs in the given vector are non-valid edge IDs |
Same as mergeVertices(IDType,IDType), but it is guaranteed that the ID of the merged vertex will be the ID of the first vertex, i.e.
the second vertex will be merged into the first one.
id1 | the ID of the vertex to which the other vertex is merged |
id2 | the ID of the vertex which is merged into the other vertex |
Merges the vertices with the given IDs, such that all edges incident to one of the vertices will be incident to the merging.
If one of the given IDs is not a vertex, an InvalidInputException is thrown. The ID of the new (merged) vertex is returned.
id1 | the first vertex ID to be merged |
id2 | the second vertex ID to be merged |
InvalidInputException | if one of the given IDs is not a vertex |
Merges all vertices in the given vector into one vertex.
If an ID in the vector is not a valid vertex ID, it is ignored, but if there are only invalid IDs, an exception is thrown.
ids | the vector of IDs of vertices which will be merged |
InvalidInputException | if all IDs in the given vector are non-valid vertex IDs |
void setName | ( | string | s | ) |
Sets the name of this graph to the given string.
s | the new name of this graph |
|
overridevirtual |
Prints a string representation of this graph to the given stream.
ost | the stream to which the graph will be printed |
Implements Streamable.
Reimplemented in Hypergraph.
|
protected |
Maps every vertex ID to a set containing all IDs of edges incident to them.
An edge is in the set as often as it is incident to the vertex.