24 template <
typename Type>
29 template <
typename Type>
32 std::vector<DynGraphNode<Type>>
nodes_;
48 void alloc()
override;
66 return std::distance(&(
nodes_[0]), node);
70 getNode(nid)->findRoot()->setRootArc(arc);
79 return node !=
nullptr ? node->findRootArc() : nullSuperArc;
83 return getNode(nid)->getCorArc();
93 return !
getNode(nid)->hasParent();
108 std::vector<DynGraphNode<Type> *>
110 std::vector<DynGraphNode<Type> *> roots;
111 roots.reserve(nodes.size());
112 for(
auto *n : nodes) {
115 std::sort(roots.begin(), roots.end());
116 const auto it = std::unique(roots.begin(), roots.end());
117 roots.erase(it, roots.end());
122 std::vector<DynGraphNode<Type> *>
123 findRoot(std::initializer_list<std::size_t> nodesIds) {
124 std::vector<DynGraphNode<Type> *> roots;
125 roots.reserve(nodesIds.size());
126 for(
auto n : nodesIds) {
129 std::sort(roots.begin(), roots.end());
130 const auto it = std::unique(roots.begin(), roots.end());
131 roots.erase(it, roots.end());
136 template <
typename type>
137 std::set<DynGraphNode<Type> *>
140 std::set<DynGraphNode<Type> *> roots;
141 for(
auto n : nodesIds) {
158 const std::size_t n2,
181 int removeEdge(
const std::size_t nid1,
const std::size_t nid2) {
189 std::string
print(
const std::function<std::string(std::size_t)> &);
199 template <
typename Type>
220 for(
auto &node : this->
nodes_) {
221 node.parent_ =
nullptr;
225 nbCC_ = this->nodes_.size();
242 const std::size_t n2,
275 int removeEdge(
const std::size_t nid1,
const std::size_t nid2) {
290 template <
typename Type>
341#ifdef TTK_ENABLE_OPENMP
342#pragma omp atomic read
void setNumberOfElmt(const idVertex nbVerts)
TTK fTRGraph dynamic graph tracking the evolution of level sets.
void removeEdge(DynGraphNode< Type > *const n)
remove the link btwn n and its parent
std::set< DynGraphNode< Type > * > findRoot(const std::vector< type > &nodesIds)
findRoot but using ids of the nodes in a vector
std::vector< DynGraphNode< Type > * > findRoot(std::initializer_list< DynGraphNode< Type > * > nodes)
recover the root of several nodes once, using brace initializers style: findRoot({n1,...
void removeEdge(const std::size_t nid)
remove the link btwn n and its parent
void setSubtreeArc(const std::size_t nid, const idSuperArc arc)
std::vector< DynGraphNode< Type > * > findRoot(std::initializer_list< std::size_t > nodesIds)
findRoot but using ids of the nodes
idSuperArc getCorArc(const std::size_t nid) const
void setNumberOfNodes(const std::size_t nbNodes)
int removeEdge(const std::size_t nid1, const std::size_t nid2)
DynGraphNode< Type > * findRoot(const std::size_t nid)
recover the root of a node using its id
DynGraphNode< Type > * findRoot(const DynGraphNode< Type > *const node)
recover the root of a node
std::vector< DynGraphNode< Type > > nodes_
void setCorArc(const std::size_t nid, idSuperArc arc)
idSuperArc getSubtreeArc(const std::size_t nid) const
bool isDisconnected(const DynGraphNode< Type > *const node) const
bool insertEdge(DynGraphNode< Type > *const n1, DynGraphNode< Type > *const n2, const Type w, const idSuperArc corArc)
DynGraphNode< Type > * getNode(const std::size_t nid)
get the node with the id: nid
bool isDisconnected(const std::size_t nid)
const DynGraphNode< Type > * getNode(const std::size_t nid) const
bool insertEdge(const std::size_t n1, const std::size_t n2, const Type w, const idSuperArc corArc)
inert or replace existing edge between n1 and n2
std::size_t getNodeId(DynGraphNode< Type > *node)
get the id of the node: node
std::size_t getNbCC() const
count the number of connected component in a list of nodes
bool insertEdge(const std::size_t n1, const std::size_t n2, const Type w, const idSuperArc corArc)
inert or replace existing edge between n1 and n2
bool insertEdge(DynGraphNode< Type > *const n1, DynGraphNode< Type > *const n2, const Type w, const idSuperArc corArc)
void setNbCC(const std::size_t nb)
void setNumberOfNodes(const std::size_t nbNodes)
void removeEdge(DynGraphNode< Type > *const n)
remove the link btwn n and its parent
void removeEdge(const std::size_t nid)
remove the link btwn n and its parent
int removeEdge(const std::size_t nid1, const std::size_t nid2)
int removeEdge(DynGraphNode< Type > *const n1, DynGraphNode< Type > *const n2)
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
class representing a node of a tree and the link to its parent if not the root
void evert()
Make this node the root of its tree.
DynGraphNode * findRoot() const
Get representative node.
std::tuple< DynGraphNode< Type > *, DynGraphNode< Type > * > findMinWeightRoot() const
bool insertEdge(DynGraphNode *const n, const Type weight, const idSuperArc corArc)
void setRootArc(const idSuperArc arcId)
idSuperArc findRootArc() const
idSuperArc getCorArc() const
Get the arcs corresponding to this subtree.
DynGraphNode & operator=(const DynGraphNode &other)
DynGraphNode(const DynGraphNode &other)