23#define VerboseLoop(N,x) if(verboseLevel>=N){std::cout<<cyanColor<<x<<defaultColor;}
25#define VerboseLoop(N,x)
32 template<
typename Derived>
36 ,
private std::set<typename TypeTraits<Derived>::LoopLinkType*>
48 typedef std::deque<std::pair<std::shared_ptr<LoopNodeType>,std::shared_ptr<LoopNodeType>>>
LoopNodeSequenceType;
66 VerboseLoop(1,
"Creating Loop "<<
tag()<<std::endl);
71 VerboseLoop(1,
"Destroying Loop "<<
tag()<<std::endl);
96 VerboseLoop(2,
"Loop "<<
tag()<<
" addLoopLink "<<pL->tag()<<std::endl);
100 std::cout<<
"DislocationLoop "<<this->
sID<<
" cannot add LoopLink "<<pL->tag()<<std::endl;
107 VerboseLoop(2,
"Loop "<<
tag()<<
" removeLoopLink "<<pL->tag()<<std::endl);
108 const size_t erased=
loopLinks().erase(pL);
111 throw std::runtime_error(
"Cannot remove link "+pL->tag()+
" from loop "+
tag());
119 VerboseLoop(3,
"Loop "<<
tag()<<
" loopLinks().size()= "<<
loopLinks().size()<<std::endl);
129 if(!pL || link->source->sID<pL->source->sID)
146 VerboseLoop(3,
"Loop "<<
tag()<<
" linkSequence.size()= "<<
temp.size()<<std::endl);
155 temp.emplace_back(link->source,link->sink);
162 std::deque<size_t>
temp;
165 temp.emplace_back(link->source->sID);
170 std::pair<bool,LoopLinkType*>
linkStartingAt(
const std::shared_ptr<LoopNodeType>& Ni)
const
173 std::pair<bool,LoopLinkType*>
temp=std::make_pair(
false,
static_cast<LoopLinkType*
>(
nullptr));
178 temp=std::make_pair(
true,link);
188 bool temp(linkSeq.size()>=3);
189 for(
typename LoopLinkSequenceType::const_iterator iter=linkSeq.begin();iter!=linkSeq.end();++iter)
191 auto next=std::next(iter,1);
192 if(next==linkSeq.end())
194 next=linkSeq.begin();
197 temp=(
temp && ((*iter)->sink->sID==(*next)->source->sID));
210 if(link->networkLink())
212 if(link->networkLink()->loopLinks().size()!=1)
224 return std::to_string(this->
sID);
229 std::cout<<
"Loop "<<this->
sID<<std::endl;
231 for(
const auto& link : linkSeq)
233 std::cout<<
" "<<link->tag()
234 <<
" (prev "<<link->prev->tag()<<
")"
235 <<
" (next "<<link->next->tag()<<
")"<<std::endl;
241 template<
typename Derived>
CRTP()
The default constructor.
TypeTraits< Derived >::LoopNetworkType LoopNetworkType
LoopLinkContainerType & loopLinks()
TypeTraits< Derived >::LoopLinkType LoopLinkType
void removeLoopLink(LoopLinkType *const pL)
const LoopLinkContainerType & loopLinks() const
LoopLinkSequenceType linkSequence() const
LoopNodeSequenceType nodeSequence() const
Loop(LoopNetworkType *const loopNetwork_in, const FlowType &f)
std::deque< std::pair< std::shared_ptr< LoopNodeType >, std::shared_ptr< LoopNodeType > > > LoopNodeSequenceType
std::set< LoopLinkType * > LoopLinkContainerType
std::deque< size_t > nodeIDSequence() const
NetworkBase< Derived, size_t > NetworkBaseType
std::deque< const LoopLinkType * > LoopLinkSequenceType
std::pair< bool, LoopLinkType * > linkStartingAt(const std::shared_ptr< LoopNodeType > &Ni) const
void addLoopLink(LoopLinkType *const pL)
TypeTraits< LoopLinkType >::FlowType FlowType
const FlowType & flow() const
TypeTraits< Derived >::LoopNodeType LoopNodeType
NetworkBase(const NetworkBase< LoopNetworkType, KeyType > &)=delete
const size_t sID
The static ID of this.
function int_R syms a b c u real f
enum insertvertexresult success