OpenASIP 2.2
Loading...
Searching...
No Matches
Graph.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file Graph.hh
26 *
27 * Declaration of prototype of base graph interface.
28 *
29 * @author Andrea Cilio 2005 (cilio-no.spam-cs.tut.fi)
30 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31 * @note rating: red
32 */
33
34
35#ifndef TTA_GRAPH_HH
36#define TTA_GRAPH_HH
37
38#include "Exception.hh"
39#include "TCEString.hh"
40
41#include <set>
42
43/**
44 * Graph base interface shared by all clients within the project.
45 *
46 * Templated interface with node and edge types as parameters. If an
47 * implementation of this interface deals with multiple types of nodes, all
48 * types must share a common base type. Ditto for edges.
49 */
50template<typename GraphNode, typename GraphEdge>
51class GraphBase {
52public:
53 typedef std::set<GraphNode*, typename GraphNode::Comparator > NodeSet;
54 typedef std::set<GraphEdge*, typename GraphEdge::Comparator > EdgeSet;
55
57 virtual ~GraphBase() {}
58
59 /// Node type of this graph (possibly, a base class).
60 typedef GraphNode Node;
61 /// Edge type of this graph (possibly, a base class).
62 typedef GraphEdge Edge;
63
64 virtual int nodeCount() const = 0;
65 virtual int edgeCount() const = 0;
66
67 virtual Node& node(const int index) const = 0;
68 virtual Edge& edge(const int index) const = 0;
69
70 virtual int outDegree(const Node& node) const = 0;
71 virtual int inDegree(const Node& node) const = 0;
72
73 virtual Edge& outEdge(const Node& node, const int index) const = 0;
74
75 virtual Edge& inEdge(const Node& node, const int index) const = 0;
76
77 virtual EdgeSet outEdges(const Node& node) const = 0;
78 virtual EdgeSet inEdges(const Node& node) const = 0;
79
80 virtual Node& tailNode(const Edge& edge) const = 0;
81 virtual Node& headNode(const Edge& edge) const = 0;
82
83 virtual bool hasEdge(
84 const Node& nTail,
85 const Node& nHead) const = 0;
86
88 const Node& nTail, const Node& nHead) const = 0;
89
90 virtual TCEString dotString() const;
91 virtual void writeToDotFile(const TCEString& fileName) const;
92
93 virtual void addNode(Node& node) = 0;
94
95 virtual void removeNode(Node& node) = 0;
96
97 virtual void removeEdge(Edge& e) = 0;
98
99 virtual void connectNodes(
100 const Node& nTail, const Node& nHead, Edge& e) = 0;
101 virtual void disconnectNodes(const Node& nTail, const Node& nHead) = 0;
102 virtual const TCEString& name() const = 0;
103protected:
104 virtual bool hasNode(const Node&) const = 0;
105};
106
107#include "Graph.icc"
108
109#endif
virtual void disconnectNodes(const Node &nTail, const Node &nHead)=0
virtual EdgeSet inEdges(const Node &node) const =0
virtual void writeToDotFile(const TCEString &fileName) const
virtual void addNode(Node &node)=0
virtual TCEString dotString() const
std::set< GraphNode *, typename GraphNode::Comparator > NodeSet
Definition Graph.hh:53
virtual Edge & inEdge(const Node &node, const int index) const =0
virtual Edge & outEdge(const Node &node, const int index) const =0
virtual void removeNode(Node &node)=0
virtual int outDegree(const Node &node) const =0
virtual int edgeCount() const =0
virtual int nodeCount() const =0
GraphBase()
Definition Graph.hh:56
virtual Node & node(const int index) const =0
virtual Node & tailNode(const Edge &edge) const =0
GraphNode Node
Node type of this graph (possibly, a base class).
Definition Graph.hh:60
virtual void connectNodes(const Node &nTail, const Node &nHead, Edge &e)=0
virtual Node & headNode(const Edge &edge) const =0
virtual ~GraphBase()
Definition Graph.hh:57
virtual bool hasEdge(const Node &nTail, const Node &nHead) const =0
std::set< GraphEdge *, typename GraphEdge::Comparator > EdgeSet
Definition Graph.hh:54
virtual const TCEString & name() const =0
virtual void removeEdge(Edge &e)=0
virtual bool hasNode(const Node &) const =0
virtual EdgeSet outEdges(const Node &node) const =0
virtual EdgeSet connectingEdges(const Node &nTail, const Node &nHead) const =0
virtual Edge & edge(const int index) const =0
GraphEdge Edge
Edge type of this graph (possibly, a base class).
Definition Graph.hh:62
virtual int inDegree(const Node &node) const =0