2 #ifndef INDIGOX_GRAPH_BASE_HPP 3 #define INDIGOX_GRAPH_BASE_HPP 5 #include "../utils/fwd_declares.hpp" 6 #include "../utils/simple_bimap.hpp" 7 #include <boost/graph/adjacency_list.hpp> 54 template <
class V,
class E,
class S,
class D = Undirected,
55 class VP = GraphLabel,
class EP = GraphLabel>
58 friend class cereal::access;
65 boost::adjacency_list<boost::setS,
67 typename D::is_directed_t,
73 using VertType =
typename graph_type::vertex_descriptor;
75 using VertIter =
typename graph_type::vertex_iterator;
77 using NbrsIter =
typename graph_type::adjacency_iterator;
79 using PredIter =
typename graph_type::inv_adjacency_iterator;
81 using EdgeType =
typename graph_type::edge_descriptor;
83 using EdgeIter =
typename graph_type::edge_iterator;
138 template <
typename Archive>
139 void serialise(Archive &archive,
const uint32_t);
172 void AddEdge(
const V &u,
const V &v,
const E &e);
195 bool HasEdge(
const E &e)
const;
200 bool HasEdge(
const V &u,
const V &v)
const;
215 int64_t
Degree(
const V &v)
const;
274 E
GetEdge(
const V &u,
const V &v)
const;
307 bool IsCyclic(
const V &v, uint32_t sz);
314 bool IsCyclic(
const E &e, uint32_t sz);
322 virtual S
Subgraph(std::vector<V> &verts) = 0;
323 virtual S
Subgraph(std::vector<V> &verts, std::vector<E> &edges) = 0;
329 VertType GetDescriptor(
const V &v)
const;
339 EdgeType GetDescriptor(
const E &e)
const;
349 int64_t OutDegree(
VertType v)
const;
int64_t NumVertices() const
Number of vertices in the graph.
Definition: base_graph_impl.hpp:204
Definition: simple_bimap.hpp:7
virtual ~BaseGraph()
Definition: base_graph.hpp:145
bool HasVertex(const V &v) const
Is the vertex in the graph.
Definition: base_graph_impl.hpp:187
std::vector< CMGEdge > EdgeContain
Type for storing edges.
Definition: base_graph.hpp:92
std::vector< VertContain > CycleVertContain
Type for storing vertex cycles.
Definition: base_graph.hpp:98
Definition: assignment.hpp:16
const EdgeContain & GetEdges() const
Get the edges of the graph.
Definition: base_graph_impl.hpp:263
BaseGraph()
Default constructor.
Definition: base_graph.hpp:143
static constexpr bool is_directed
Boolean that the type is not directed.
Definition: base_graph.hpp:29
const VertContain & GetVertices() const
Get the vertices of the graph.
Definition: base_graph_impl.hpp:259
Definition: condensed.hpp:131
int64_t Degree(const V &v) const
Degree of a vertex.
Definition: base_graph_impl.hpp:212
V GetSourceVertex(const E &e) const
Get the source vertex of an edge.
Definition: base_graph_impl.hpp:275
bool IsConnected()
Determine if the graph is connected.
Definition: base_graph_impl.hpp:315
V GetTargetVertex(const E &e) const
Get the target vertex of an edge.
Definition: base_graph_impl.hpp:279
int64_t InDegree(const V &v) const
Indegree of a vertex.
Definition: base_graph_impl.hpp:216
Type for specifying that a graph is directed.
Definition: base_graph.hpp:17
typename graph_type::inv_adjacency_iterator PredIter
Type for iterator over predecessors of a vertex descriptor.
Definition: base_graph.hpp:79
bool IsCyclic(const V &v)
Determine if a vertex of this graph is cyclic.
Definition: base_graph_impl.hpp:335
typename graph_type::vertex_descriptor VertType
Type of the graph vertex descriptor.
Definition: base_graph.hpp:73
std::shared_ptr< BaseImpl > m_basedata
Definition: base_graph.hpp:104
bool HasEdge(const E &e) const
Is the edge in the graph.
Definition: base_graph_impl.hpp:192
std::map< CMGVertex, VertContain > NbrsContain
Type for storing neighbours.
Definition: base_graph.hpp:94
const VertContain & GetNeighbours(const V &v)
Get the neighbouring vertices of a vertex.
Definition: base_graph_impl.hpp:222
Type for applying a numerical label to a vertex or edge.
Definition: base_graph.hpp:33
std::vector< VertContain > ComponentContain
Type for storing components.
Definition: base_graph.hpp:96
void RemoveEdge(const E &e)
Remove an edge from the graph.
Definition: base_graph_impl.hpp:173
const VertContain & GetSuccessors(const V &v)
Definition: base_graph_impl.hpp:242
void RemoveVertex(const V &v)
Remove a vertex from the graph.
Definition: base_graph_impl.hpp:129
static constexpr bool is_directed
Boolean that the type is directed.
Definition: base_graph.hpp:21
int64_t NumEdges() const
Number of edges in the graph.
Definition: base_graph_impl.hpp:208
const CycleEdgeContain & GetCycles()
Get the cycles of the graph.
Definition: base_graph_impl.hpp:373
std::vector< CMGVertex > VertContain
Type for storing vertices.
Definition: base_graph.hpp:90
int64_t NumConnectedComponents()
Get the number of connected components of the graph.
Definition: base_graph_impl.hpp:320
boost::bidirectionalS is_directed_t
Underlying boost type of a directed graph.
Definition: base_graph.hpp:19
virtual S Subgraph(std::vector< V > &verts)=0
boost::adjacency_list< boost::setS, boost::listS, typename Undirected ::is_directed_t, GraphLabel, GraphLabel > graph_type
Type of the underlying boost graph.
Definition: base_graph.hpp:69
std::vector< EdgeContain > CycleEdgeContain
Type for storing edge cycles.
Definition: base_graph.hpp:100
const VertContain & GetPredecessors(const V &v)
Get the predecessor vertices of a vertex.
Definition: base_graph_impl.hpp:232
E GetEdge(const V &u, const V &v) const
Get the edge between two vertices.
Definition: base_graph_impl.hpp:267
Type for specifying that a graph is undirected.
Definition: base_graph.hpp:25
typename graph_type::edge_iterator EdgeIter
Type for iterator over edges.
Definition: base_graph.hpp:83
void AddEdge(const V &u, const V &v, const E &e)
Add a new edge to the graph.
Definition: base_graph_impl.hpp:166
void AddVertex(const V &v)
Add a new vertex to the graph.
Definition: base_graph_impl.hpp:124
uint64_t isomorphism
Label used for (sub-)graph isomorphism.
Definition: base_graph.hpp:39
boost::undirectedS is_directed_t
Underlying boost type of an undirected graph.
Definition: base_graph.hpp:27
Template base class for all graphs used in the indigoX library.
Definition: base_graph.hpp:56
typename graph_type::vertex_iterator VertIter
Type for iterator over graph vertex descriptors.
Definition: base_graph.hpp:75
int64_t NumCycles()
Definition: base_graph_impl.hpp:403
const ComponentContain & GetConnectedComponents()
Get the connected components of the graph.
Definition: base_graph_impl.hpp:325
typename graph_type::edge_descriptor EdgeType
Type of the graph edge descriptor.
Definition: base_graph.hpp:81
typename graph_type::adjacency_iterator NbrsIter
Type for iterator over neighbours of vertex descriptor.
Definition: base_graph.hpp:77
int32_t component
Label used by the connected components algorithm.
Definition: base_graph.hpp:37