22 #ifndef OTAWA_GRAPH_GRAPH_H
23 #define OTAWA_GRAPH_GRAPH_H
25 #include <elm/assert.h>
26 #include <elm/PreIterator.h>
27 #include <elm/genstruct/FragTable.h>
28 #include <elm/util/BitVector.h>
29 #include <elm/genstruct/VectorQueue.h>
31 namespace otawa {
namespace graph {
57 inline bool ended(
void)
const;
58 inline void next(
void);
68 inline bool ended(
void)
const;
69 inline void next(
void);
135 inline operator bool(
void)
const {
return !
isEmpty(); }
149 template <
template <
class _>
class C>
void addAll(
const C<Node *> &items)
150 {
for(
typename C<Node *>::Iterator item(items); item; item++)
add(item); }
151 void remove(
Node *node);
152 template <
template <
class _>
class C>
void removeAll(
const C<Node *> &items)
153 {
for(
typename C<Node *>::Iterator item(items); item; item++)
remove(item); }
202 : _graph(0), idx(-1), ins(0), outs(0) {
231 return _edge->target();
235 _edge = _edge->sedges;
245 _edge = _edge->tedges;
257 return _edge->source();
266 #endif // OTAWA_UTIL_GRAPH_H
A simple iterator on the nodes contained in a graph.
Definition: Graph.h:138
bool ended(void) const
Definition: Graph.h:226
OutIterator(const Node *source)
Definition: Graph.h:164
dtd::RefAttr< BasicBlock * > source("source", dtd::STRICT|dtd::REQUIRED)
Node * sourceOf(graph::Edge *edge) const
Definition: Graph.h:175
InIterator(const InIterator &iterator)
Definition: Graph.h:184
dtd::Element edge(dtd::make("edge", _EDGE).attr(source).attr(target).attr(called))
void next(void)
Definition: Graph.h:244
bool isSuccOf(const Node *node)
Test if the current node is a successor of the given one.
Definition: Graph.h:214
void next(void)
Definition: Graph.h:187
Node::Successor iter
Definition: Graph.h:171
OutIterator(const Graph &graph, const Node *source)
Definition: Graph.h:165
Edge * tedges
Definition: Graph.h:103
Node::Predecessor iter
Definition: Graph.h:189
Graph * _graph
Definition: Graph.h:43
int outDegree(Node *vertex) const
Get the out degree of the given vertex.
Definition: util_Graph.cpp:150
int index(void) const
Get the index of the node in the graph.
Definition: Graph.h:76
void removeAll(const C< Node * > &items)
Definition: Graph.h:152
Predecessor(const Node *node)
Build an iterator on the predecessors of the given node.
Definition: Graph.h:248
void next(void)
Definition: Graph.h:234
This class represents a full graph with nodes and edges.
Definition: Graph.h:122
Successor(const Node *node)
Build an iterator on the successor of the given node.
Definition: Graph.h:222
This class represents a directed edge between two nodes.
Definition: Graph.h:97
Node * item(void) const
Definition: Graph.h:256
int indexOf(Node *vertex) const
Definition: Graph.h:193
Iterator(const Iterator &iter)
Definition: Graph.h:142
Node * tgt
Definition: Graph.h:102
Edge * _edge
Definition: Graph.h:65
int idx
Definition: Graph.h:44
Edge * edge(void) const
Get the edge leading to the current predecessor.
Definition: Graph.h:260
bool isEmpty(void) const
Definition: Graph.h:134
int count(void) const
Definition: Graph.h:132
Edge * ins
Definition: Graph.h:45
Node * src
Definition: Graph.h:102
Graph * graph(void) const
Get the container graph if any.
Definition: Graph.h:75
bool isSuccessorOf(Node *succ, Node *ref) const
Test if the vertex succ is successor of the vertex ref.
Definition: util_Graph.cpp:164
This class allows to iterates on the successors of a node.
Definition: Graph.h:53
Edge(Node *source, Node *target)
Build an edge between two nodes.
Definition: Graph.h:107
void next(void)
Definition: Graph.h:169
graph::Edge * item(void) const
Definition: Graph.h:168
void addAll(const C< Node * > &items)
Definition: Graph.h:149
bool ended(void) const
Definition: Graph.h:167
otawa::graph::Edge * Edge
Definition: Graph.h:127
OutIterator(const OutIterator &iterator)
Definition: Graph.h:166
Node * source(void) const
Get the source node.
Definition: Graph.h:116
void clear(void)
Definition: util_Graph.cpp:66
Edge * sedges
Definition: Graph.h:103
bool ended(void) const
Definition: Graph.h:252
~Graph(void)
Definition: util_Graph.cpp:81
InIterator(const Node *source)
Definition: Graph.h:182
bool isPredecessorOf(Node *prev, Node *ref) const
Test if the vertex pred is predecessor of the vertex ref.
Definition: util_Graph.cpp:191
int countSucc(void) const
Count the successors of the current node.
Definition: Graph.h:79
InIterator(const Graph &graph, const Node *source)
Definition: Graph.h:183
Node * target(void) const
Get the target node.
Definition: Graph.h:117
otawa::graph::Node * Vertex
Definition: Graph.h:126
bool ended(void) const
Definition: Graph.h:185
bool hasPred(void) const
Test if the node has predecessors.
Definition: Graph.h:78
Edge * outs
Definition: Graph.h:45
bool isPredOf(const Node *node)
Test if the current node is a predecessor of the given one.
Definition: Graph.h:207
elm::genstruct::FragTable< Node * > nodes
Definition: Graph.h:196
bool contains(Node *item) const
Definition: Graph.h:133
Node * sinkOf(graph::Edge *edge) const
Definition: Graph.h:157
The node from a directed graph.
Definition: Graph.h:40
virtual ~Edge(void)
Definition: util_Edge.cpp:24
graph::Edge * item(void) const
Definition: Graph.h:186
void add(Node *node)
Add new node.
Definition: util_Graph.cpp:90
Node(Graph *graph=0)
Build a new node.
Definition: Graph.h:201
Iterator(const Graph *graph)
Definition: Graph.h:140
virtual ~Node(void)
Definition: util_Node.cpp:40
void unlink(void)
Unlink the node, that is, remove its entering or leaving edges.
Definition: util_Node.cpp:30
bool hasSucc(void) const
Test if the node has successors.
Definition: Graph.h:77
Node * item(void) const
Definition: Graph.h:230
int countPred(void) const
Count the predecessors of the current node.
Definition: Graph.h:85
int inDegree(Node *vertex) const
Get the in degree of the given vertex.
Definition: util_Graph.cpp:177
This class allows to iterates on the predecessors of a node.
Definition: Graph.h:64
Edge * _edge
Definition: Graph.h:54
Edge * edge(void) const
Get the edge leading to the current successor.
Definition: Graph.h:238