928 |
928 |
929 _Graph& graph; |
929 _Graph& graph; |
930 }; |
930 }; |
931 }; |
931 }; |
932 |
932 |
933 /// \brief An empty extendable extended graph class. |
933 |
934 /// |
934 // /// Skeleton class which describes an edge with direction in \ref |
935 /// This class provides beside the core graph features |
935 // /// UGraph "undirected graph". |
936 /// item addition interface for the graph structure. |
936 template <typename UGraph> |
937 /// The difference between this class and the |
937 class UGraphEdge : public UGraph::UEdge { |
938 /// \c BaseExtendableGraphComponent is that it should |
938 typedef typename UGraph::UEdge UEdge; |
939 /// notify the item alteration observers. |
939 typedef typename UGraph::Node Node; |
940 class ExtendableGraphComponent : virtual public BaseGraphComponent { |
940 public: |
941 public: |
941 |
942 |
942 /// \e |
943 typedef ExtendableGraphComponent Graph; |
943 UGraphEdge() {} |
944 |
944 |
945 typedef BaseGraphComponent::Node Node; |
945 /// \e |
946 typedef BaseGraphComponent::Edge Edge; |
946 UGraphEdge(const UGraphEdge& e) : UGraph::UEdge(e) {} |
947 |
947 |
948 /// \brief Add a node to the graph. |
948 /// \e |
949 /// |
949 UGraphEdge(Invalid) {} |
950 /// Add a node to the graph and notify the observers. |
950 |
951 Node addNode() { |
951 /// \brief Directed edge from undirected edge and a source node. |
952 return INVALID; |
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. |
994 |
956 /// |
995 struct BaseIterableUGraphConcept { |
957 /// Add an edge to the graph and notify the observers. |
996 |
958 Edge addEdge(const Node&, const Node&) { |
997 template <typename Graph> |
959 return INVALID; |
998 struct Constraints { |
960 } |
999 |
961 |
1000 typedef typename Graph::UEdge UEdge; |
962 template <typename _Graph> |
1001 typedef typename Graph::Edge Edge; |
963 struct Constraints { |
1002 typedef typename Graph::Node Node; |
964 void constraints() { |
1003 |
965 checkConcept<BaseGraphComponent, _Graph >(); |
1004 void constraints() { |
966 typename _Graph::Node node_a, node_b; |
1005 checkConcept<BaseIterableGraphComponent, Graph>(); |
967 node_a = graph.addNode(); |
1006 checkConcept<GraphItem<>, UEdge>(); |
968 node_b = graph.addNode(); |
1007 //checkConcept<UGraphEdge<Graph>, Edge>(); |
969 typename _Graph::Edge edge; |
1008 |
970 edge = graph.addEdge(node_a, node_b); |
1009 graph.first(ue); |
971 } |
1010 graph.next(ue); |
972 _Graph& graph; |
1011 |
973 }; |
1012 const_constraints(); |
974 }; |
1013 } |
975 |
1014 void const_constraints() { |
976 /// \brief An empty erasable extended graph class. |
1015 Node n; |
977 /// |
1016 n = graph.target(ue); |
978 /// This class provides beside the core graph features |
1017 n = graph.source(ue); |
979 /// item erase interface for the graph structure. |
1018 n = graph.oppositeNode(n0, ue); |
980 /// The difference between this class and the |
1019 |
981 /// \c BaseErasableGraphComponent is that it should |
1020 bool b; |
982 /// notify the item alteration observers. |
1021 b = graph.direction(e); |
983 class ErasableGraphComponent : virtual public BaseGraphComponent { |
1022 Edge e = graph.direct(UEdge(), true); |
984 public: |
1023 e = graph.direct(UEdge(), n); |
985 |
1024 |
986 typedef ErasableGraphComponent Graph; |
1025 ignore_unused_variable_warning(b); |
987 |
1026 } |
988 typedef BaseGraphComponent::Node Node; |
1027 |
989 typedef BaseGraphComponent::Edge Edge; |
1028 Graph graph; |
990 |
1029 Edge e; |
991 /// \brief Erase the Node and notify the node alteration observers. |
1030 Node n0; |
992 /// |
1031 UEdge ue; |
993 /// Erase the Node and notify the node alteration observers. |
1032 }; |
994 void erase(const Node&) {} |
1033 |
995 |
1034 }; |
996 /// \brief Erase the Edge and notify the edge alteration observers. |
1035 |
997 /// |
1036 |
998 /// Erase the Edge and notify the edge alteration observers. |
1037 struct IterableUGraphConcept { |
999 void erase(const Edge&) {} |
1038 |
1000 |
1039 template <typename Graph> |
1001 template <typename _Graph> |
1040 struct Constraints { |
1002 struct Constraints { |
1041 void constraints() { |
1003 void constraints() { |
1042 /// \todo we don't need the iterable component to be base iterable |
1004 checkConcept<BaseGraphComponent, _Graph >(); |
1043 /// Don't we really??? |
1005 typename _Graph::Node node; |
1044 //checkConcept< BaseIterableUGraphConcept, Graph > (); |
1006 graph.erase(node); |
1045 |
1007 typename _Graph::Edge edge; |
1046 checkConcept<IterableGraphComponent, Graph> (); |
1008 graph.erase(edge); |
1047 |
1009 } |
1048 typedef typename Graph::UEdge UEdge; |
1010 |
1049 typedef typename Graph::UEdgeIt UEdgeIt; |
1011 _Graph& graph; |
1050 typedef typename Graph::IncEdgeIt IncEdgeIt; |
1012 }; |
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 |
1015 } |
1089 } |
1016 |
1090 |
1017 } |
1091 } |