30 template<
typename VertexProperty,
typename EdgeProperty,
bool UniqueVertices = true>
67 const std::vector<Vertex>&
out()
const {
75 std::vector<std::vector<Edge>>
mEdges;
93 assert(source <
mEdges.size());
94 mEdges[source].emplace_back(ep);
95 return mEdges[source].back();
98 Edge&
newEdge(
const VertexProperty& source,
const EdgeProperty& ep) {
99 return newEdge(getVertex(source), ep);
109 static_assert(!UniqueVertices,
"Non-const references to vertex properties are not supported if UniqueVertices is set to true.");
118 const std::vector<Edge>&
out(
const VertexProperty& v)
const {
119 return mEdges[getVertex(v)];
134 void toDot(
const std::string& filename)
const;
137 template<
typename VP,
typename EP>
151 template<
typename FHG,
typename Collector>
This class implements a forward hypergraph.
const std::vector< Edge > & out(const VertexProperty &v) const
Retrieves all outgoing edges for the given vertex.
void toDot(const std::string &filename) const
Writes a representation of this graph to the given file.
Edge & newEdge(const VertexProperty &source, const EdgeProperty &ep)
Creates a new edge where the given vertex is the incoming vertex that is labeled with the given edge ...
const std::vector< Edge > & out(Vertex v) const
Retrieves all outgoing edges for the given vertex.
std::vector< std::vector< Edge > > mEdges
Mapping from vertices to outgoing edges.
std::size_t Vertex
Internal type of a vertex.
const VertexProperty & operator[](Vertex v) const
Retrieves the vertex property for the given vertex.
Vertex end() const
Returns the past-the-last vertex.
Vertex newVertex(const VertexProperty &vp)
Returns a new vertex that is labeled with the given vertex property.
Edge & newEdge(Vertex source, const EdgeProperty &ep)
Creates a new edge where the given vertex is the incoming vertex that is labeled with the given edge ...
VertexProperty & operator[](Vertex v)
Retrieves the vertex property for the given vertex.
std::vector< VertexProperty > mVertexProperties
Storage for all vertex properties.
Vertex begin() const
Returns the first vertex.
std::size_t size() const
Returns the number of vertices.
friend std::ostream & operator<<(std::ostream &os, const ForwardHyperGraph< VP, EP > &fhg)
Writes a textual representation of this graph to the given stream.
std::map< VertexProperty, Vertex > mVertexMap
Mapping from vertex properties to vertices to ensure uniqueness.
Class to create the formulas for axioms.
This class encapsulates an algorithm for enumerating all cycles.
CycleEnumerator(const FHG &fhg, Collector &c)
Constructor from a graph and a collector object.
std::vector< std::vector< Vertex > > mBlockDependencies
Stores vertex dependencies when vertices are blocked.
std::vector< typename FHG::Vertex > mVertexStack
Stores the current list of vertices.
bool findAll()
Start the search for all cycles. Returns whether the search was finished (true) or aborted (false).
bool enumerate(Vertex src, Vertex v)
Recursively enumerate all cycles that start in src and are currently in v.
Collector & mCollector
The callback object.
void unblock(Vertex v)
Unblocks the given vertex and all vertices that depend on it.
const FHG & mGraph
Reference to the graph we search cycles in.
typename FHG::Vertex Vertex
Type of a vertex.
std::vector< typename FHG::Edge > mEdgeStack
Stores the current list of edges.
bool mAborted
Whether this search has been aborted by the collector.
std::vector< bool > mBlocked
Stores whether a vector is currently blocked.
Internal type of an edge.
const EdgeProperty * operator->() const
Access the property.
EdgeProperty * operator->()
Access the property.
EdgeProperty mProperty
Property of this edge.
std::vector< Vertex > mOut
Outgoing vertices.
Edge(const EdgeProperty &ep)
Constructor from a property.
void addOut(Vertex v)
Add v to the outgoing vertices of this edge.
const EdgeProperty & operator*() const
Access the property.
EdgeProperty & operator*()
Access the property.
const std::vector< Vertex > & out() const
Retrieve the list of outgoing vertices.