17 #ifndef ABSTRACT_GRAPH_H 18 #define ABSTRACT_GRAPH_H 23 #include "abstractplugin.h" 24 #include "attrsgenerator.h" 48 virtual bool reset() = 0;
65 const QString&
id()
const;
70 GraphType
type()
const;
92 inline const Edge&
edge(
int edgeId)
const;
100 inline const Edge&
edge(
int originId,
int neighbourId)
const;
187 Nodes::iterator
removeNode(Nodes::iterator it);
202 Edges::iterator
removeEdge(Edges::iterator it);
207 AttrsGeneratorPtr m_edgeAttrsGen;
219 std::uniform_int_distribution<int> m_numNodesDist;
221 bool setup(Trial& trial, AttrsGeneratorPtr edgeGen,
231 {
return type() == GraphType::Directed; }
234 {
return type() == GraphType::Undirected; }
243 {
return m_edges.at(edgeId); }
246 {
return m_nodes.at(originId).outEdges().at(neighbourId); }
249 {
return m_nodes.at(nodeId); }
252 {
return static_cast<int>(m_edges.size()); }
255 {
return static_cast<int>(m_nodes.size()); }
261 {
return addEdge(m_nodes.at(originId), m_nodes.at(neighbourId),
attrs); }
264 #endif // ABSTRACT_GRAPH_H AbstractGraph()
constructor
Node addNode(Attributes attr)
Creates a Node with attrs and adds it into the graph.
Definition: abstractgraph.h:257
const Edges & edges() const
Gets the edges.
Definition: abstractgraph.h:236
It wraps a std::shared_ptr<BaseNode>.
Definition: node.h:35
int numEdges() const
Gets the number of edges in the graph.
Definition: abstractgraph.h:251
Node randNode() const
Gets a random Node in the graph.
virtual ~AbstractGraphInterface()=default
Provide a default destructor to keep compilers happy.
Edge addEdge(int originId, int neighbourId, Attributes *attrs=new Attributes())
Creates and adds an Edge into the graph.
Definition: abstractgraph.h:260
const Attributes * attrs() const
Gets the plugin's attributes.
Definition: abstractplugin.h:121
void removeAllEdges()
Removes all edges of the graph.
Node node(int nodeId) const
Gets the Node corresponding to nodeId.
Definition: abstractgraph.h:248
const QString & id() const
Gets the graph id.
A Node container.
Definition: nodes.h:32
virtual bool reset()=0
Resets the graph object to the original state.
An Edge connects a Node to itself or to another Node.
Definition: edge.h:37
GraphType type() const
Gets the graph type.
const Value & attr(int attrId) const
Gets the attribute's value for attrId.
Definition: abstractplugin.h:127
const Edge & edge(int edgeId) const
Returns the Edge corresponding to edgeId.
Definition: abstractgraph.h:242
bool isDirected() const
Returns true if the graph is directed.
Definition: abstractgraph.h:230
Provides a common interface for Graph plugins.
Definition: abstractgraph.h:35
int numNodes() const
Gets the number of nodes in the graph.
Definition: abstractgraph.h:254
Base class for plugins.
Definition: abstractplugin.h:34
void removeNode(const Node &node)
Removes the node from the graph.
const Nodes & nodes() const
Gets the nodes.
Definition: abstractgraph.h:239
void removeEdge(const Edge &edge)
Removes the edge from the graph.
Definition: abstractgraph.h:29
A container of labeled values.
Definition: attributes.h:39
Abstract base class for graph plugins.
Definition: abstractgraph.h:54
virtual bool init()
Initializes the plugin.
bool isUndirected() const
Returns true if the graph is undirected.
Definition: abstractgraph.h:233
An Edge container.
Definition: edges.h:32