Changeset 2111:ea1fa1bc3f6d in lemon-0.x for lemon/concept/graph_component.h
- Timestamp:
- 06/28/06 17:06:24 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2817
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/concept/graph_component.h
r1999 r2111 459 459 /// core clear functions for the graph structure. 460 460 /// The most of the base graphs should be conform to this concept. 461 class ClearableGraphComponent : virtual public BaseGraphComponent {461 class BaseClearableGraphComponent : virtual public BaseGraphComponent { 462 462 public: 463 463 … … 647 647 /// This class provides beside the core graph features 648 648 /// iterator based iterable interface for the graph structure. 649 /// This concept is part of the StaticGraphConcept.649 /// This concept is part of the GraphConcept. 650 650 class IterableGraphComponent : virtual public BaseGraphComponent { 651 651 … … 818 818 /// This class provides beside the core graph features 819 819 /// map interface for the graph structure. 820 /// This concept is part of the StaticGraphConcept.820 /// This concept is part of the GraphConcept. 821 821 class MappableGraphComponent : virtual public BaseGraphComponent { 822 822 public: … … 931 931 }; 932 932 933 /// \brief An empty extendable extended graph class. 934 /// 935 /// This class provides beside the core graph features 936 /// item addition interface for the graph structure. 937 /// The difference between this class and the 938 /// \c BaseExtendableGraphComponent is that it should 939 /// notify the item alteration observers. 940 class ExtendableGraphComponent : virtual public BaseGraphComponent { 941 public: 942 943 typedef ExtendableGraphComponent Graph; 944 945 typedef BaseGraphComponent::Node Node; 946 typedef BaseGraphComponent::Edge Edge; 947 948 /// \brief Add a node to the graph. 949 /// 950 /// Add a node to the graph and notify the observers. 951 Node addNode() { 952 return INVALID; 933 934 // /// Skeleton class which describes an edge with direction in \ref 935 // /// UGraph "undirected graph". 936 template <typename UGraph> 937 class UGraphEdge : public UGraph::UEdge { 938 typedef typename UGraph::UEdge UEdge; 939 typedef typename UGraph::Node Node; 940 public: 941 942 /// \e 943 UGraphEdge() {} 944 945 /// \e 946 UGraphEdge(const UGraphEdge& e) : UGraph::UEdge(e) {} 947 948 /// \e 949 UGraphEdge(Invalid) {} 950 951 /// \brief Directed edge from undirected edge and a source node. 952 /// 953 /// Constructs a directed edge from undirected edge and a source node. 954 /// 955 /// \note You have to specify the graph for this constructor. 956 UGraphEdge(const UGraph &g, 957 UEdge u_edge, Node n) { 958 ignore_unused_variable_warning(u_edge); 959 ignore_unused_variable_warning(g); 960 ignore_unused_variable_warning(n); 953 961 } 962 963 /// \e 964 UGraphEdge& operator=(UGraphEdge) { return *this; } 965 966 /// \e 967 bool operator==(UGraphEdge) const { return true; } 968 /// \e 969 bool operator!=(UGraphEdge) const { return false; } 970 971 /// \e 972 bool operator<(UGraphEdge) const { return false; } 973 974 template <typename Edge> 975 struct Constraints { 976 void constraints() { 977 const_constraints(); 978 } 979 void const_constraints() const { 980 /// \bug This should be is_base_and_derived ... 981 UEdge ue = e; 982 ue = e; 983 984 Edge e_with_source(graph,ue,n); 985 ignore_unused_variable_warning(e_with_source); 986 } 987 Edge e; 988 UEdge ue; 989 UGraph graph; 990 Node n; 991 }; 992 }; 954 993 955 /// \brief Add an edge to the graph. 956 /// 957 /// Add an edge to the graph and notify the observers. 958 Edge addEdge(const Node&, const Node&) { 959 return INVALID; 960 } 961 962 template <typename _Graph> 963 struct Constraints { 964 void constraints() { 965 checkConcept<BaseGraphComponent, _Graph >(); 966 typename _Graph::Node node_a, node_b; 967 node_a = graph.addNode(); 968 node_b = graph.addNode(); 969 typename _Graph::Edge edge; 970 edge = graph.addEdge(node_a, node_b); 971 } 972 _Graph& graph; 973 }; 974 }; 975 976 /// \brief An empty erasable extended graph class. 977 /// 978 /// This class provides beside the core graph features 979 /// item erase interface for the graph structure. 980 /// The difference between this class and the 981 /// \c BaseErasableGraphComponent is that it should 982 /// notify the item alteration observers. 983 class ErasableGraphComponent : virtual public BaseGraphComponent { 984 public: 985 986 typedef ErasableGraphComponent Graph; 987 988 typedef BaseGraphComponent::Node Node; 989 typedef BaseGraphComponent::Edge Edge; 990 991 /// \brief Erase the Node and notify the node alteration observers. 992 /// 993 /// Erase the Node and notify the node alteration observers. 994 void erase(const Node&) {} 995 996 /// \brief Erase the Edge and notify the edge alteration observers. 997 /// 998 /// Erase the Edge and notify the edge alteration observers. 999 void erase(const Edge&) {} 1000 1001 template <typename _Graph> 1002 struct Constraints { 1003 void constraints() { 1004 checkConcept<BaseGraphComponent, _Graph >(); 1005 typename _Graph::Node node; 1006 graph.erase(node); 1007 typename _Graph::Edge edge; 1008 graph.erase(edge); 1009 } 1010 1011 _Graph& graph; 1012 }; 994 995 struct BaseIterableUGraphConcept { 996 997 template <typename Graph> 998 struct Constraints { 999 1000 typedef typename Graph::UEdge UEdge; 1001 typedef typename Graph::Edge Edge; 1002 typedef typename Graph::Node Node; 1003 1004 void constraints() { 1005 checkConcept<BaseIterableGraphComponent, Graph>(); 1006 checkConcept<GraphItem<>, UEdge>(); 1007 //checkConcept<UGraphEdge<Graph>, Edge>(); 1008 1009 graph.first(ue); 1010 graph.next(ue); 1011 1012 const_constraints(); 1013 } 1014 void const_constraints() { 1015 Node n; 1016 n = graph.target(ue); 1017 n = graph.source(ue); 1018 n = graph.oppositeNode(n0, ue); 1019 1020 bool b; 1021 b = graph.direction(e); 1022 Edge e = graph.direct(UEdge(), true); 1023 e = graph.direct(UEdge(), n); 1024 1025 ignore_unused_variable_warning(b); 1026 } 1027 1028 Graph graph; 1029 Edge e; 1030 Node n0; 1031 UEdge ue; 1032 }; 1033 1034 }; 1035 1036 1037 struct IterableUGraphConcept { 1038 1039 template <typename Graph> 1040 struct Constraints { 1041 void constraints() { 1042 /// \todo we don't need the iterable component to be base iterable 1043 /// Don't we really??? 1044 //checkConcept< BaseIterableUGraphConcept, Graph > (); 1045 1046 checkConcept<IterableGraphComponent, Graph> (); 1047 1048 typedef typename Graph::UEdge UEdge; 1049 typedef typename Graph::UEdgeIt UEdgeIt; 1050 typedef typename Graph::IncEdgeIt IncEdgeIt; 1051 1052 checkConcept<GraphIterator<Graph, UEdge>, UEdgeIt>(); 1053 checkConcept<GraphIncIterator<Graph, UEdge>, IncEdgeIt>(); 1054 } 1055 }; 1056 1057 }; 1058 1059 struct MappableUGraphConcept { 1060 1061 template <typename Graph> 1062 struct Constraints { 1063 1064 struct Dummy { 1065 int value; 1066 Dummy() : value(0) {} 1067 Dummy(int _v) : value(_v) {} 1068 }; 1069 1070 void constraints() { 1071 checkConcept<MappableGraphComponent, Graph>(); 1072 1073 typedef typename Graph::template UEdgeMap<int> IntMap; 1074 checkConcept<GraphMap<Graph, typename Graph::UEdge, int>, 1075 IntMap >(); 1076 1077 typedef typename Graph::template UEdgeMap<bool> BoolMap; 1078 checkConcept<GraphMap<Graph, typename Graph::UEdge, bool>, 1079 BoolMap >(); 1080 1081 typedef typename Graph::template UEdgeMap<Dummy> DummyMap; 1082 checkConcept<GraphMap<Graph, typename Graph::UEdge, Dummy>, 1083 DummyMap >(); 1084 } 1085 }; 1086 1013 1087 }; 1014 1088
Note: See TracChangeset
for help on using the changeset viewer.