14#include <unordered_map>
18 template <
typename ScalarType>
20 std::unordered_map<idSuperArc, idSuperArc> mapArcs;
21 std::map<std::pair<idVertex, idVertex>,
idSuperArc> masterArcs;
32 for(
idSuperArc arcId = 0; arcId < nbArcs; ++arcId) {
34 if(
getArc(arcId).isVisible()) {
37 if(upNodeId == nullNode) {
38 if(
getArc(arcId).getEnd() != nullVertex) {
40 if(upNodeId == nullNode) {
49 std::pair<idVertex, idVertex> arcVerts;
50 if(
getArc(arcId).isEmpty()) {
52 = std::make_pair(
getNode(upNodeId).getVertexIdentifier(),
53 getNode(downNodeId).getVertexIdentifier());
55 arcVerts = std::make_pair(
56 getArc(arcId).getFirstReg(),
getArc(arcId).getLastReg());
59 = std::make_pair(std::get<1>(arcVerts), std::get<0>(arcVerts));
60 if(masterArcs.count(revertArcVerts)) {
63 <<
printArc(masterArcs[revertArcVerts]));
64 DEBUG(
" using " << std::get<0>(revertArcVerts) <<
" "
65 << std::get<1>(revertArcVerts));
67 masterArcs[arcVerts] = arcId;
73 if(mapArcs.count(target) == 0) {
74 mapArcs[arcId] = target;
75 consolidateArc<ScalarType>(target, arcId, s);
83#ifdef TTK_ENABLE_OPENMP
84#pragma omp parallel for
87 const idSuperArc vArc = segmentation_[v].corArc;
88 if(mapArcs.count(vArc)) {
89 segmentation_[v].corArc = mapArcs[vArc];
94 template <
typename ScalarType>
100 for(
idSuperArc arcId = 0; arcId < nbArcs; ++arcId) {
101 if(!
getArc(arcId).isVisible())
107#ifndef TTK_ENABLE_KAMIKAZE
108 if(upNodeId == nullNode || downNodeId == nullNode) {
116 if(s->
isLower(upVertId, downVertId)) {
126 std::vector<valence> upVal(nbNodes, 0), downVal(nbNodes, 0);
128 for(
idSuperArc arcId = 0; arcId < nbArcs; ++arcId) {
129 if(!
getArc(arcId).isVisible())
135#ifndef TTK_ENABLE_KAMIKAZE
136 if(upNodeId == nullNode || downNodeId == nullNode) {
145 for(
idNode nodeId = 0; nodeId < nbNodes; ++nodeId) {
151 for(
idSuperArc arcId = 0; arcId < nbArcs; ++arcId) {
152 if(!
getArc(arcId).isVisible())
158#ifndef TTK_ENABLE_KAMIKAZE
159 if(upNodeId == nullNode || downNodeId == nullNode) {
169 template <
typename ScalarType>
174 this->
printMsg(
"Building arc segmentation");
176#ifdef TTK_ENABLE_OPENMP
177#pragma omp parallel for
179 for(
idVertex v = 0; v < nbVerts; ++v) {
180#ifndef TTK_ENABLE_KAMIKAZE
181 if(segmentation_[v].corArc == nullSuperArc) {
182 std::cout <<
"[Graph]: build segmentation, null arc on vertex: " << v
187#ifdef TTK_ENABLE_OPENMP
188#pragma omp atomic update
190 arcSizes[segmentation_[v].corArc]++;
199 for(
idVertex v = 0; v < nbVerts; ++v) {
201 const idSuperArc corArc = segmentation_[regV].corArc;
206 template <
typename ScalarType>
207 void Graph::consolidateArc(
const idSuperArc mainArc,
213#ifndef TTK_ENABLE_KAMIKAZE
214 if(mainDown == nullNode || mergedDown == nullNode) {
215 std::cout <<
"[Graph]: consolidate error, arc have a null down node"
224 if(s->
isLower(vMainDown, vMergedDown)) {
idVertex nbElmt_
Allocation may depends on the number of vertices.
idNode makeNode(const idVertex v)
idNode getNumberOfNodes() const
void arcs2nodes(const Scalars< ScalarType > *const s)
void buildArcSegmentation(const Scalars< ScalarType > *const s)
idSuperArc getNumberOfArcs() const
std::string printArc(const idSuperArc arcId) const
const SuperArc & getArc(const idSuperArc id) const
const Node & getNode(const idNode id) const
idNode getNodeId(const idVertex v) const
void mergeArcs(const Scalars< ScalarType > *const s)
idVertex getVertexIdentifier() const
void addUpArc(const idSuperArc arcId)
void reserveDownArc(const idSuperArc nbDownArcs)
void reserveUpArc(const idSuperArc nbUpArc)
void addDownArc(const idSuperArc arcId)
idVertex getSortedVert(const idVertex i) const
bool isLower(const idVertex a, const idVertex b) const
void setUpNodeId(const idNode id)
idSuperArc mergedIn() const
idNode getUpNodeId() const
idNode getDownNodeId() const
const decltype(segmentation_) & segmentation() const
void setDownNodeId(const idNode id)
void merge(const idSuperArc arc)
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
SimplexId idVertex
Vertex index in scalars_.
unsigned int idNode
Node index in vect_nodes_.
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)