![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 00022 #ifndef Tulip_SUPERGRAPHVIEW_H 00023 #define Tulip_SUPERGRAPHVIEW_H 00024 00025 #ifndef DOXYGEN_NOTFOR_USER 00026 00027 #include <tulip/GraphAbstract.h> 00028 #include <tulip/GraphImpl.h> 00029 #include <tulip/MutableContainer.h> 00030 00031 namespace tlp { 00032 00033 /** 00034 * This class is one the implementation of the Graph Interface 00035 * It only filters the elements of its parents. 00036 */ 00037 class GraphView:public GraphAbstract { 00038 00039 friend class GraphImpl; 00040 public: 00041 GraphView(Graph *supergraph, BooleanProperty *filter, unsigned int id = 0); 00042 ~GraphView(); 00043 //======================================================================== 00044 node addNode(); 00045 void addNodes(unsigned int nb, std::vector<node>& addedNodes); 00046 void addNode(const node); 00047 void addNodes(Iterator<node>* nodes); 00048 edge addEdge(const node n1,const node n2); 00049 void addEdges(const std::vector<std::pair<node, node> >& edges, 00050 std::vector<edge>& addedEdges); 00051 void addEdge(const edge); 00052 void addEdges(Iterator<edge>* edges); 00053 void delNode(const tlp::node n, bool deleteInAllGraphs = false); 00054 void delEdge(const tlp::edge e, bool deleteInAllGraphs = false); 00055 void setEdgeOrder(const node,const std::vector<edge> & ); 00056 void swapEdgeOrder(const node,const edge , const edge ); 00057 //========================================================================= 00058 bool isElement(const node ) const; 00059 bool isElement(const edge ) const; 00060 edge existEdge(const node source, const node target, 00061 bool directed) const; 00062 unsigned int numberOfNodes() const; 00063 unsigned int numberOfEdges() const; 00064 //========================================================================= 00065 unsigned int deg(const node) const; 00066 unsigned int indeg(const node) const; 00067 unsigned int outdeg(const node) const; 00068 //========================================================================= 00069 Iterator<node>* getNodes() const; 00070 Iterator<node>* getInNodes(const node) const; 00071 Iterator<node>* getOutNodes(const node) const; 00072 Iterator<node>* getInOutNodes(const node) const; 00073 Iterator<edge>* getEdges() const; 00074 Iterator<edge>* getInEdges(const node) const; 00075 Iterator<edge>* getOutEdges(const node) const; 00076 Iterator<edge>* getInOutEdges(const node) const; 00077 std::vector<edge> getEdges(const node source, const node target, 00078 bool directed = true) const; 00079 //========================================================================= 00080 // only implemented on a root graph 00081 virtual void reserveNodes(unsigned int nbNodes); 00082 virtual void reserveEdges(unsigned int nbEdges); 00083 //========================================================================= 00084 // updates management 00085 virtual void push(bool unpopAllowed = true, 00086 std::vector<PropertyInterface*>* propertiesToPreserveOnPop= NULL); 00087 virtual void pop(bool unpopAllowed = true); 00088 virtual void unpop(); 00089 virtual bool canPop(); 00090 virtual bool canUnpop(); 00091 virtual bool canPopThenUnpop(); 00092 00093 protected: 00094 // designed to reassign an id to a previously deleted elt 00095 // used by GraphUpdatesRecorder 00096 virtual node restoreNode(node); 00097 virtual void restoreNodes(const std::vector<node>&); 00098 virtual edge restoreEdge(edge, node source, node target); 00099 virtual void restoreEdges(const std::vector<edge>& edges, 00100 const std::vector<std::pair<node, node> >& ends); 00101 // designed to only update own structures 00102 // used by GraphUpdatesRecorder 00103 virtual void removeNode(const node); 00104 virtual void removeEdge(const edge); 00105 void removeNode(const node n, const std::vector<edge>& edges); 00106 void removeEdges(const std::vector<edge>& edges); 00107 00108 private: 00109 MutableContainer<bool> nodeAdaptativeFilter; 00110 MutableContainer<bool> edgeAdaptativeFilter; 00111 MutableContainer<unsigned int> outDegree; 00112 MutableContainer<unsigned int> inDegree; 00113 mutable int nNodes; 00114 mutable int nEdges; 00115 edge addEdgeInternal(edge); 00116 void delEdgeInternal(const edge); 00117 void delNodeInternal(const node); 00118 void reverseInternal(const edge, const node src, const node tgt); 00119 void setEndsInternal(const edge, const node src, const node tgt, 00120 const node newSrc, const node newTgt); 00121 }; 00122 00123 } 00124 #endif 00125 00126 #endif 00127 00128 00129 00130 ///@endcond