A simple graph structure for graph-based operations.
More...
#include <GraphUtils.h>
|
const std::set< Vertex, Compare > | clique (const Vertex &vertex) const |
| Obtains the set of all vertices in the same clique than the given vertex. More...
|
|
bool | contains (const Vertex &from, const Vertex &to) const |
| Determines whether the given edge is present. More...
|
|
bool | contains (const Vertex &vertex) const |
| Determines whether the given vertex is present. More...
|
|
void | insert (const Vertex &from, const Vertex &to) |
| Adds a new edge from the given vertex to the target vertex. More...
|
|
void | insert (const Vertex &vertex) |
| Adds a vertex. More...
|
|
const std::set< Vertex, Compare > & | predecessors (const Vertex &to) const |
| Returns the set of vertices the given vertex has edges from. More...
|
|
void | print (std::ostream &out) const |
| Enables graphs to be printed (e.g. More...
|
|
bool | reaches (const Vertex &from, const Vertex &to) const |
| Determines whether there is a directed path between the two vertices. More...
|
|
const std::set< Vertex, Compare > & | successors (const Vertex &from) const |
| Returns the set of vertices the given vertex has edges to. More...
|
|
const std::set< Vertex, Compare > & | vertices () const |
| Obtains a reference to the set of all vertices. More...
|
|
template<typename Lambda > |
void | visitDepthFirst (const Vertex &vertex, const Lambda &lambda) const |
| A generic utility for depth-first visits. More...
|
|
|
template<typename Lambda > |
void | visitDepthFirst (const Vertex &vertex, const Lambda &lambda, std::set< Vertex, Compare > &visited) const |
| The internal implementation of depth-first visits. More...
|
|
template<typename Vertex, typename Compare = std::less<Vertex>>
class souffle::Graph< Vertex, Compare >
A simple graph structure for graph-based operations.
Definition at line 40 of file GraphUtils.h.
◆ clique()
template<typename Vertex , typename Compare = std::less<Vertex>>
const std::set<Vertex, Compare> souffle::Graph< Vertex, Compare >::clique |
( |
const Vertex & |
vertex | ) |
const |
|
inline |
Obtains the set of all vertices in the same clique than the given vertex.
Definition at line 117 of file GraphUtils.h.
119 std::set<Vertex, Compare> visited;
124 void print(std::ostream& out)
const {
◆ contains() [1/2]
template<typename Vertex , typename Compare = std::less<Vertex>>
bool souffle::Graph< Vertex, Compare >::contains |
( |
const Vertex & |
from, |
|
|
const Vertex & |
to |
|
) |
| const |
|
inline |
Determines whether the given edge is present.
Definition at line 90 of file GraphUtils.h.
◆ contains() [2/2]
template<typename Vertex , typename Compare = std::less<Vertex>>
bool souffle::Graph< Vertex, Compare >::contains |
( |
const Vertex & |
vertex | ) |
const |
|
inline |
Determines whether the given vertex is present.
Definition at line 85 of file GraphUtils.h.
◆ insert() [1/2]
template<typename Vertex , typename Compare = std::less<Vertex>>
void souffle::Graph< Vertex, Compare >::insert |
( |
const Vertex & |
from, |
|
|
const Vertex & |
to |
|
) |
| |
|
inline |
Adds a new edge from the given vertex to the target vertex.
Definition at line 51 of file GraphUtils.h.
52 _successors.insert(std::make_pair(vertex, std::set<Vertex, Compare>()));
53 _predecessors.insert(std::make_pair(vertex, std::set<Vertex, Compare>()));
◆ insert() [2/2]
template<typename Vertex , typename Compare = std::less<Vertex>>
void souffle::Graph< Vertex, Compare >::insert |
( |
const Vertex & |
vertex | ) |
|
|
inline |
◆ predecessors()
template<typename Vertex , typename Compare = std::less<Vertex>>
const std::set<Vertex, Compare>& souffle::Graph< Vertex, Compare >::predecessors |
( |
const Vertex & |
to | ) |
const |
|
inline |
Returns the set of vertices the given vertex has edges from.
Definition at line 80 of file GraphUtils.h.
◆ print()
template<typename Vertex , typename Compare = std::less<Vertex>>
void souffle::Graph< Vertex, Compare >::print |
( |
std::ostream & |
out | ) |
const |
|
inline |
Enables graphs to be printed (e.g.
for debugging)
Definition at line 136 of file GraphUtils.h.
147 std::map<Vertex, std::set<Vertex, Compare>>
_successors;
◆ reaches()
template<typename Vertex , typename Compare = std::less<Vertex>>
bool souffle::Graph< Vertex, Compare >::reaches |
( |
const Vertex & |
from, |
|
|
const Vertex & |
to |
|
) |
| const |
|
inline |
Determines whether there is a directed path between the two vertices.
Definition at line 100 of file GraphUtils.h.
106 std::set<Vertex, Compare> res;
108 for (
const auto& cur :
vertices()) {
◆ successors()
template<typename Vertex , typename Compare = std::less<Vertex>>
const std::set<Vertex, Compare>& souffle::Graph< Vertex, Compare >::successors |
( |
const Vertex & |
from | ) |
const |
|
inline |
Returns the set of vertices the given vertex has edges to.
Definition at line 75 of file GraphUtils.h.
◆ vertices()
template<typename Vertex , typename Compare = std::less<Vertex>>
const std::set<Vertex, Compare>& souffle::Graph< Vertex, Compare >::vertices |
( |
| ) |
const |
|
inline |
Obtains a reference to the set of all vertices.
Definition at line 70 of file GraphUtils.h.
◆ visitDepthFirst() [1/2]
template<typename Vertex , typename Compare = std::less<Vertex>>
template<typename Lambda >
void souffle::Graph< Vertex, Compare >::visitDepthFirst |
( |
const Vertex & |
vertex, |
|
|
const Lambda & |
lambda |
|
) |
| const |
|
inline |
◆ visitDepthFirst() [2/2]
template<typename Vertex , typename Compare = std::less<Vertex>>
template<typename Lambda >
void souffle::Graph< Vertex, Compare >::visitDepthFirst |
( |
const Vertex & |
vertex, |
|
|
const Lambda & |
lambda, |
|
|
std::set< Vertex, Compare > & |
visited |
|
) |
| const |
|
inlineprivate |
The internal implementation of depth-first visits.
Definition at line 164 of file GraphUtils.h.
168 static const std::vector<char> table = {
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
169 'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'a',
'b',
'c',
'd',
'e',
'f',
170 'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
171 'z',
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'+',
'/'};
173 std::string tmp =
data;
174 unsigned int padding = 0;
175 if (
data.size() % 3 == 2) {
◆ operator<<
template<typename Vertex , typename Compare = std::less<Vertex>>
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const Graph< Vertex, Compare > & |
g |
|
) |
| |
|
friend |
◆ _predecessors
template<typename Vertex , typename Compare = std::less<Vertex>>
std::map<Vertex, std::set<Vertex, Compare> > souffle::Graph< Vertex, Compare >::_predecessors |
|
private |
◆ _successors
template<typename Vertex , typename Compare = std::less<Vertex>>
std::map<Vertex, std::set<Vertex, Compare> > souffle::Graph< Vertex, Compare >::_successors |
|
private |
◆ _vertices
template<typename Vertex , typename Compare = std::less<Vertex>>
std::set<Vertex, Compare> souffle::Graph< Vertex, Compare >::_vertices |
|
private |
The documentation for this class was generated from the following file: