21 #ifndef ANONHYPERGRAPH_H_
22 #define ANONHYPERGRAPH_H_
24 #include "../basic_types/globals.h"
27 #include "../basic_types/InitialisationException.h"
28 #include "../basic_types/InvalidInputException.h"
29 #include "../basic_types/Streamable.h"
51 typedef map<IDType, Vertex>
VMap;
57 typedef map<IDType, Edge>
EMap;
63 typedef unordered_multiset<IDType>
ESet;
99 virtual void streamTo(std::ostream& ost)
const override;
138 bool deleteVertices(vector<IDType>
const& ids, unordered_set<IDType>* delEdges =
nullptr);
370 IDType
mergeEdges(unordered_set<IDType> const& ids);
IDType addEdge(string label, vector< IDType > const &attVertices=vector< IDType >())
Adds an edge with the given label and incident vertices to this graph.
Definition: AnonHypergraph.cpp:296
shared_ptr< AnonHypergraph > AnonHypergraph_sp
Alias of a shared pointer to an AnonHypergraph.
Definition: AnonHypergraph.h:415
IDType lastUsedID
Stores the last ID assigned to a vertex or edge.
Definition: AnonHypergraph.h:387
AnonHypergraph::VMap::const_iterator cbeginVertices() const noexcept
Returns a const_iterator to the first entry in the vertex map.
Definition: AnonHypergraph.cpp:244
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...
Definition: AnonHypergraph.cpp:464
Streamable provides a streaming function which must be implemented by any deriving class...
Definition: Streamable.h:31
unordered_map< IDType, AnonHypergraph::ESet > connectedEdges
Maps every vertex ID to a set containing all IDs of edges incident to them.
Definition: AnonHypergraph.h:408
shared_ptr< const AnonHypergraph > AnonHypergraph_csp
Alias of a shared pointer to a constant AnonHypergraph.
Definition: AnonHypergraph.h:420
unordered_multiset< IDType > ESet
Alias for a set of edge IDs connected to a vertex.
Definition: AnonHypergraph.h:63
Edge * getEdge(IDType id)
Returns the edge with the given ID if it exists.
Definition: AnonHypergraph.cpp:353
IDType addVertex()
Adds a new vertex to this graph and returns the ID of the added vertex.
Definition: AnonHypergraph.cpp:322
string getName() const
Returns the name of this graph.
Definition: AnonHypergraph.cpp:226
AnonHypergraph::EMap edges
Stores a map of all edges of this graph, where the key is their ID.
Definition: AnonHypergraph.h:402
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 i...
Definition: AnonHypergraph.cpp:55
AnonHypergraph::EMap::const_iterator cbeginEdges() const noexcept
Returns a const_iterator to the first entry in the edge map.
Definition: AnonHypergraph.cpp:268
void setName(string s)
Sets the name of this graph to the given string.
Definition: AnonHypergraph.cpp:231
int getEdgeArity(IDType id) const
Returns the arity of the edge with the given ID, i.e.
Definition: AnonHypergraph.cpp:365
map< IDType, Vertex > VMap
Alias for a vertex map returned by this class.
Definition: AnonHypergraph.h:51
size_t getEdgeCount() const
Returns the number of edges of this graph.
Definition: AnonHypergraph.cpp:373
string name
Stores the name of this graph.
Definition: AnonHypergraph.h:392
AnonHypergraph::EMap::const_iterator cendEdges() const noexcept
Returns a const_iterator pointing beyond the last entry in the edge map.
Definition: AnonHypergraph.cpp:280
virtual ~AnonHypergraph()
Deletes this graph, freeing all its memory.
Definition: AnonHypergraph.cpp:49
size_t getVertexCount() const
Returns the number of vertices of this graph.
Definition: AnonHypergraph.cpp:377
AnonHypergraph::VMap::const_iterator cendVertices() const noexcept
Returns a const_iterator pointing beyond the last entry in the vertex map.
Definition: AnonHypergraph.cpp:256
bool hasEdge(IDType id) const
Returns true, iff this graph has an edge with the given ID.
Definition: AnonHypergraph.cpp:329
AnonHypergraph::VMap::iterator endVertices() noexcept
Returns an iterator pointing beyond the last entry in the vertex map.
Definition: AnonHypergraph.cpp:248
bool deleteEdge(IDType id)
Deleted the edge with the given ID, if it exists (ignored if it does not exist).
Definition: AnonHypergraph.cpp:397
AnonHypergraph::VMap vertices
Stores a map of all vertices of this graph, where the key is their ID.
Definition: AnonHypergraph.h:397
virtual void streamTo(std::ostream &ost) const override
Prints a string representation of this graph to the given stream.
Definition: AnonHypergraph.cpp:414
AnonHypergraph::EMap::iterator endEdges() noexcept
Returns an iterator pointing beyond the last entry in the edge map.
Definition: AnonHypergraph.cpp:272
int getConnEdgesCount(IDType vid) const
Returns the number of edges connected to the vertex with the given ID.
Definition: AnonHypergraph.cpp:284
An AnonHypergraph is a data structure storing a hypergraph.
Definition: AnonHypergraph.h:43
AnonHypergraph::EMap::iterator beginEdges() noexcept
Returns an iterator to the first entry in the edge map.
Definition: AnonHypergraph.cpp:260
map< IDType, Edge > EMap
Alias for an edge map returned by this class.
Definition: AnonHypergraph.h:57
vector< IDType > * getVerticesOfEdge(IDType edgeID)
Returns the sequence of vertices incident to the edge with the given ID.
Definition: AnonHypergraph.cpp:339
void mergeVertexIntoFirst(IDType id1, IDType id2)
Same as mergeVertices(IDType,IDType), but it is guaranteed that the ID of the merged vertex will be t...
Definition: AnonHypergraph.cpp:51
AnonHypergraph(std::string name="")
Generates a new graph with the given name and an empty collection of vertices and edges...
AnonHypergraph::VMap::iterator beginVertices() noexcept
Returns an iterator to the first entry in the vertex map.
Definition: AnonHypergraph.cpp:236
bool areParallelEdges(IDType id1, IDType id2) const
Returns true if the given IDs are parallel edges, i.e.
Definition: AnonHypergraph.cpp:472
bool deleteVertex(IDType id, unordered_set< IDType > *delEdges=nullptr)
Deletes the vertex with the given ID if it exists in this graph.
Definition: AnonHypergraph.cpp:441
bool hasVertex(IDType id) const
Returns true if and only if this graph has a vertex with the given ID.
Definition: AnonHypergraph.cpp:334
AnonHypergraph::ESet * getConnectedEdges(IDType vid)
Returns the set of IDs of edges incident to the vertex with the given ID.
Definition: AnonHypergraph.cpp:381
IDType mergeEdges(IDType id1, IDType id2)
Merges the edges with the given IDs.
Definition: AnonHypergraph.cpp:134
unsigned int IDType
IDType is an (unsigned) integer specifically used as an Identifier of graphs, elements of graphs or a...
Definition: globals.h:53
This class represents an edge in a Hypergraph.
Definition: Edge.h:34