亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? twolevel.w,v

?? Lin-Kernighan heuristic for the TSP and minimum weight perfect matching
?? W,V
?? 第 1 頁 / 共 5 頁
字號:
any longer.  So the pair of assignments |ca=cb,cc=cd| is safe in place of a set of full |SWAP|s.  If these assignments {\it are\/} performed, then|ca| still lies on or to the left of |cc|.  @@<Rename so that the |a-c| portion lies entirely in one segment@@>=if ( ca == cc ) return;	/* Rerversing a length-1 list is trivial */if ( ca->seq > cc->seq ) SWAP(ca,cc,tcn),SWAP(cb,cd,tcn);	/* Make $a$ come before $c$ */if ( ca->next == cb ) ca=cb,cc=cd;	/* Make $a-c$ lie entirely in this segment */@@ Now we can get down to the business of flipping the $a-c$ portion of the tour.If it is long enough, thenit makes sense to implictly rebalance:split the ends off and turnon its parent's reversal bit.Otherwise, we physically move the cities.@@<Flip: |ca| to |cc| lies entirely within one segment@@>=if ( abs(ca->seq-cc->seq) > implicit_balance_threshhold ) {	@@<Split the ends off and flip the parent's reversal bit@@>@@;} else {	@@<Reverse the list from |ca| to |cc|@@>@@;}@@ The variable |implicit_balance_threshhold| is set when we set upthe data structure.  It is given the value of $3/4\times groupsize$,as prescribed by Fredman \etal.@@<Set up the two-level data structure@@>=implicit_balance_threshhold = (3 * groupsize)/4;@@ It is local to this module.@@<Module variables@@>=static int implicit_balance_threshhold;@@ Lets do the simpler part: moving links around to flip a tour segment.First we reverse the sequence  numbers, then we reverse the list bypermuting pointers.There will be several places where we'll need to reverse a sequence ofcities.  That code is generalized by using variables |u|  and |v| todenote the first and last cities to be reversed; city |u| occurs on or tothe left of |v|.  We already assume that |ca| occurs on or to theleft of |cc|.We reverse a segment by swapping each city's |next| and |prev| pointers.This way, what was a city's predecessor is now its successor, andvice versa.  We must ensure thatpointers from outside the reversed segment get updated to point to the appropriateend cities.  The outbound sibling pointers inside the segment are fixed bythe |SWAP(u->prev,v->next)| code: remember they will be swapped appropriatelywhen all the sibling links are swapped.@@<Reverse the list from |ca| to |cc|@@>={ city_node_t *u = ca, *v = cc;@@<Reverse the city sequence numbers from |u| to |v|@@>@@;@@<Make external pointers point to the other of |u|, |v|@@>@@;SWAP(u->prev,v->next,tcn);		/* Fix outbound sibling pointers */@@<Swap links from |u| to |v|@@>@@;}@@ Now, |u| and |v| have been chosen so that |v| may be found by followingzero or more |next| pointers from |u| without leaving this segment.Also, sequence numbers increase as we follow |next| pointers.This allows usto just overwrite the sequence numbers; we don't need to do any swapping.@@<Reverse the city sequence numbers from |u| to |v|@@>={	city_node_t *i=u, *done=v->next;	int s;	for ( s=v->seq,i=u; i!=done ; i=i->next,s-- ){		i->seq=s;	}}@@ Now that we've updated sequence numbers, we can update pointers.The pointers that might need updating are |head| and |tail| pointers,and |prev| and |next| pointers.The code for updating the |prev| and |next| pointers is just a parallel assignment.  Unfortunately, parallelassignment is awkward in \CEE/; parallel bindings are easy in \ML/.@@^ML@@>We need parallel assignment because we might be in the degenerate casewhere we are flipping the entire tour except for one node.   In that case,we shouldn't change its |next| pointer from |ca|, say, to |cc|, {\it andthen back again.}  Think about it.Similarly, there might only be one node in the segment; it would beboth the head and the tail.  But then updating it twice doesn't poseany problems, for then |ca==cc|!.  So we don't need a parallel assignmentin fixing the head and tail pointers.Recall that we assume that |u| and |v| are in the same segment, and therefore have the same parent.  Furthermore, |u| comes on or before|v|. @@<Make external pointers point to the other of |u|, |v|@@>={ parent_node_t *p = u->parent;const int upn_to_v = u->prev->next == u, upp_to_v = u->prev->prev == u,vnp_to_u = v->next->prev == v, vnn_to_u = v->next->next == v;if ( upn_to_v ) u->prev->next = v;if ( upp_to_v ) u->prev->prev = v;if ( vnp_to_u ) v->next->prev = u; if ( vnn_to_u ) v->next->next = u;if ( p->head == ca ) p->head=cc;	/* Now fix |head| and |tail| */else if ( p->head== cc ) p->head=ca;if ( p->tail == ca ) p->tail=cc;else if ( p->tail== cc ) p->tail=ca;}@@ This code requires that sequence numbers increase as we follow |next| pointers.  It assumes that |u| occurs at the same point or to the left of |v|.%%I've used fresh variables |i| and |j| because I want to be as hygienic %%as possible:%%don't destroy values unnecessarily.  A good optimizing compiler will%% reuse the registers anyway.@@<Swap links from |u| to |v|@@>={	city_node_t *i=u, *done = v->next;	for ( i=u; i != done; i=i->prev ) {	/* Yes, |prev|: it's the old |next| pointer. */		SWAP(i->next,i->prev,tcn);	}}@@ Let's do the other part: implict rebalancing. This involvessplitting the ends off the $a-c$ segment, merging those endswith their neighbours, swapping the inbound sibling pointers, andthen flipping their parent's reversal bit.We've already arranged things so that that |ca|'s sequence number isno greater than |cc|'s sequence number, \ie, that we can find |cc| byfollowing zero or more |next| pointers starting at node |ca| withoutleaving the segment.@@<Split the ends off and flip the parent's reversal bit@@>=@@<Split off the end to the left of |ca|@@>@@;@@<Split off the end to the right of |cc|@@>@@;@@<Fix sibling pointers to and from |ca| and |cc|@@>@@;ca->parent->reverse ^= 1;@@<Verbose: implicit rebalance done@@>@@;@@ The part of the segment to the left of |ca| is split off and mergedwith the segment to its left (left according to the |prev| link of thehead of this segment).  We must be careful for a few reasons.First, thereare four possible combined settings for the reversal bits of thissegment and the segment to the left.  Second, we must set the city |prev| and |next| links so that theyare correct {\it after\/} the parent's reversal bit is flipped.@@<Split off the end to the left of |ca|@@>=@@<Verbose: split off the end to the left of |ca| begin@@>@@;{ 	parent_node_t *p = ca->parent;	city_node_t *lc=p->head; 		/* City at left end of split off segment. */	city_node_t *rc=ca->prev;		/* City at right end of split off segment */	city_node_t *llc=lc->prev;		/* New sibling of |lc|: ``left of |lc|'' */	parent_node_t *lp=llc->parent;	/* Parent of the segment to be merged into */	int lpr = lp->reverse, pr=p->reverse;	errorif(lp==p,"Bug");	if ( lc != ca ) {	/* There is work to do. */		@@<Split left: set the end city links@@>@@;		@@<Split left: set the per-city data in the split off segment@@>@@;	}}@@<Verbose: split off the end to the left of |ca| end@@>@@;@@ This section updates any pointers to the end cities of the split offportion of the segment.  It helps to look at the input and outputpointer ``flows'' to/from this split off portion.  This way we canhopefully avoid missing updating a pointer.The pointers coming {\it into\/} this split off portion of the segment are asfollows:there is one sibling pointer pointing to the left end of thelist, |llc->link[lpr^LINK_NEXT]|; there is one sibling pointer pointing to theright end of the list, |ca->prev|; finally there is a head pointer fromthe old parent, |p->head|, and a head/tail pointer from thenew parent, |lp->city_link[pr^lpr^CITY_LINK_TAIL]|.  Interestingly, the sibling pointers need to be changed depending on thecontext in which this code is used, so we won't change them here.The pointers coming {\it out of\/} this split off portion of the segment are asfollows:there is one sibling pointer pointing from the left end of thelist, |lc->prev|; there is one sibling pointer pointing from theright end of the list, |rc->next|; finally there are parent pointers at each node in the list.All these outgoing pointers will be handled as part of the per-city changes.@@<Split left: set the end city links@@>=p->head = ca;lp->city_link[(pr==lpr)?CITY_LINK_TAIL:CITY_LINK_HEAD] = rc;@@ Each city node in the split off segment must be updated in thefollowing ways.First, we must set the sequence numbers so they are consecutive with those in the segment to the left.    We use two variablesto set them: |seq_num| begins as the sequence number that city |lc|should be set to; |seq_inc| is the increment in sequence numbers thatshould take effect in traversing the list from |lc| through to |rc|.There are two cases to consider.  If the two segments have the same orientation, then we're appending the |lc| to |rc| list to the right end of the segmentto the left.So|lc|'s new sequence number should be |llc->seq+1| and they should increase,\ie\ |seq_inc| should be 1.Otherwise, the segments have different orientations: |llc| is thehead of its and we'll be moving the |lc| to |rc| listto the left of |llc|.  In this case, |lc|'s new sequence number shouldbe |llc->seq-1| and they should decrease, \ie\ |seq_num| should be -1.Second, if the orientations of the old and the new segments are different,then we must reverse the links of the moved portion of the linked list.I've combined these functions into one segment because thetraversal code changes according whether we change the senseof |prev| and |next|.  In particular, |link[succ_link]| traverses thelist from |u| to |v|, which is left to right in the original list.@@<Split left: set the per-city data in the split off segment@@>={ city_node_t *i, *u=lc, *v=rc;int succ_link, seq_inc, seq_num;if ( lpr==pr ) {	/* Move to right end. */	succ_link=LINK_NEXT;	seq_inc = 1;	seq_num = llc->seq + 1;} else {	/* Move to left end. */	succ_link = LINK_PREV;	seq_inc = -1;	seq_num = llc->seq - 1;	@@<Swap links from |u| to |v|@@>@@;}for ( i=lc;i!=rc;i=i->link[succ_link], seq_num+= seq_inc ) {	/* Set parent pointers andsequence numbers */	i->parent = lp;	i->seq = seq_num;}i->parent = lp;i->seq = seq_num;}@@ Splitting off the right end is analogous to splitting off the left end,but with a slight twist.First, we make the following exchanges:|next|$\leftrightarrow$|prev|;|head|$\leftrightarrow$|tail|; |l|$\leftrightarrow$|r|, in variable names;and |cc|$\leftrightarrow$|ca|.  The twist comes when setting sequence numbers;its explained below.Here's righthand version of the top-level section.  @@<Split off the end to the right of |cc|@@>=@@<Verbose: split off the end to the right of |cc| begin@@>@@;{ 	parent_node_t *p = cc->parent;	city_node_t *rc=p->tail; 		/* City at right end of split off segment */	city_node_t *lc=cc->next;		/* City at left end of split off segment */	city_node_t *rrc=rc->next;		/* New sibling of |rc|: ``right of |rc|'' */	parent_node_t *rp=rrc->parent;	/* Parent of the segment to be merged into */	int rpr = rp->reverse, pr=p->reverse;	errorif(rp==p,"Bug");	if ( rc != cc ) {	/* There is work to do. */		@@<Split right: set the end city links@@>@@;		@@<Split right: set the per-city data in the split off segment@@>@@;	}}@@<Verbose: split off the end to the right of |cc| end@@>@@;@@ Setting the end city links on the right is analogous to setting themon the left.@@<Split right: set the end city links@@>=p->tail = cc;rp->city_link[(pr==rpr)?CITY_LINK_HEAD:CITY_LINK_TAIL] = lc;@@ Setting the per-city data on the right hand side is also analogous.  As in splitting a segment to the left, |seq_num| is again the new sequence number of |lc|and |seq_inc| is the increment on sequence numbers as we travel from|lc| to |rc|.  The twist in setting the sequence numbers that I mentioned earlier is as follows.  When the orientations of the two segments are thesame, then we're moving the |lc| to |rc| list to the {\it left\/}end of the new segment, and so |lc| must start out as |rrc->seq-1|minus the length of the |lc| to |rc| segment; the increment shouldagain be 1.  When the orientations are different, we'll be addingto the right end of the new segment, with |rc| at the beginning and|lc| becoming the new tail.  In this case, |lc|'s new sequence number should be |rrc->seq| plus the lengthof the |lc| to |rc| list, and |seq_inc| should be -1.@@<Split right: set the per-city data in the split off segment@@>={ city_node_t *i, *u=lc, *v=rc;int succ_link, seq_inc, seq_num;if ( rpr==pr ) {	/* Move to left end. */	succ_link=LINK_NEXT;	seq_inc = 1;	seq_num = rrc->seq + u->seq-v->seq - 1;} else {	/* Move to right end. */	succ_link = LINK_PREV;	seq_inc = -1;	seq_num = rrc->seq + v->seq-u->seq + 1;	@@<Swap links from |u| to |v|@@>@@;}for ( i=lc;i!=rc;i=i->link[succ_link], seq_num+= seq_inc ) {		/* Set parent pointers and sequence numbers */	i->parent = rp;	i->seq = seq_num;}i->parent = rp;i->seq = seq_num;}@@ We're reversing a single segment and must therefore swap the two inboundsibling pointers and the two outbound pointers.  In more detail, there are four pointers to change.The sibling pointer that used to point to |cc| shouldnow point to |ca|, and vice versa.  The code is only tricky because wemust handle all combinations of reversal bits of the two bordering segments.Then, |ca->prev| and |cc->next| should be swapped; these are the outboundsibling pointers.This section completes the codeto handle the first case in flipping.@@<Fix sibling pointers to and from |ca| and |cc|@@>={	city_node_t *l=ca->prev, *r = cc->next;	parent_node_t *lp= l->parent, *rp = r->parent;	const int ac_rev=ca->parent->reverse;	city_node_t **inbound_l = &l->link[LINK_NEXT^lp->reverse^ac_rev],		**inbound_r = &r->link[LINK_PREV^rp->reverse^ac_rev];	errorif(*inbound_l != ca,		"Inbound left %d != ca %d", 		*inbound_l - city_node, ca-city_node);	errorif(*inbound_r != cc,		"Inbound right %d != cc %d", 		*inbound_r - city_node, cc-city_node);	SWAP(*inbound_l,*inbound_r,tcn);	SWAP(ca->prev,cc->next,tcn);}@@ Now we can move on to handling the third case for flipping:either $a$ and $b$ are in the same segment, or $c$ and $d$ are.We handle this case by reducing it to the second case.  That is,we split segments so that $a$ and $b$ are in different segments,and $d$ and $c$ are in different segments.@@ Let's tackle splitting the $a-b$ segment first.Thankfully, we can reuse much of the code we've just written for implicit

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕在线观看不卡| 亚洲激情一二三区| 色999日韩国产欧美一区二区| 欧美三级日韩三级| 国产精品视频在线看| 午夜欧美电影在线观看| 成人高清免费在线播放| 日韩午夜精品视频| 亚洲激情网站免费观看| 国产精品99久久久久久久女警| 欧美美女直播网站| 亚洲综合一二三区| 99视频精品在线| 久久久午夜精品| 麻豆91精品视频| 欧美色中文字幕| 国产精品久久久久久亚洲伦| 精彩视频一区二区| 91精品国产高清一区二区三区| 一卡二卡三卡日韩欧美| k8久久久一区二区三区| 久久久久久亚洲综合影院红桃| 日韩精品欧美成人高清一区二区| 91婷婷韩国欧美一区二区| 国产精品午夜春色av| 国产精品一区二区在线观看不卡| 欧美一二三区在线| 三级一区在线视频先锋| 欧美性生活影院| 一区二区三区欧美视频| 色综合久久99| 亚洲欧美日韩在线| 日本丰满少妇一区二区三区| 亚洲欧洲精品一区二区三区不卡| 国产成人av资源| 欧美国产97人人爽人人喊| 国产成人亚洲综合色影视| 国产视频亚洲色图| 成人爽a毛片一区二区免费| 久久精品在线免费观看| 国产aⅴ综合色| 亚洲图片激情小说| 欧美性大战久久久久久久蜜臀| 一区二区三区四区在线免费观看| 91福利精品第一导航| 亚洲精品国产精品乱码不99| 色狠狠av一区二区三区| 亚洲成人三级小说| 日韩一级片网址| 国产伦精品一区二区三区在线观看| 久久午夜免费电影| 99re6这里只有精品视频在线观看| 综合久久一区二区三区| 欧美天堂亚洲电影院在线播放| 亚洲国产欧美一区二区三区丁香婷| 欧美日韩亚洲综合| 国产一区二区三区黄视频 | 一本久久精品一区二区| 一区二区三区四区不卡在线| 欧美日韩激情在线| 久久精工是国产品牌吗| 国产蜜臀av在线一区二区三区| 丁香婷婷综合色啪| 中文字幕中文字幕一区二区 | 精品久久久久久久一区二区蜜臀| 久久99精品国产.久久久久| 国产偷国产偷亚洲高清人白洁| 成人永久看片免费视频天堂| 国产精品二三区| 欧美日产国产精品| 国产美女av一区二区三区| 亚洲久本草在线中文字幕| 日韩一区二区免费电影| gogogo免费视频观看亚洲一| 亚洲第四色夜色| 亚洲国产成人私人影院tom| 欧美三级电影网| 国产99久久精品| 视频一区二区不卡| 国产精品久久久久久久久动漫| 欧美色欧美亚洲另类二区| 国产一区二区三区免费观看| 亚洲成人免费视频| 亚洲视频免费在线| www国产精品av| 欧美日韩综合一区| 91免费版在线| 国产精品911| 毛片基地黄久久久久久天堂| 亚洲欧美日韩中文字幕一区二区三区 | 成人毛片在线观看| 极品美女销魂一区二区三区 | 欧美性xxxxxxxx| 成人av网站免费| 国产一区二区福利视频| 日韩精品乱码免费| 亚洲一区二区四区蜜桃| 国产精品乱人伦| 欧美电影免费观看高清完整版在线 | 欧美精品精品一区| 一本色道a无线码一区v| 成人一二三区视频| 国产美女主播视频一区| 美女任你摸久久| 日本女优在线视频一区二区| 亚洲一区二区在线视频| 亚洲色图色小说| 中文字幕的久久| 欧美国产成人在线| 国产欧美日韩在线观看| 久久综合国产精品| 日韩欧美国产一区二区三区| 欧美肥妇bbw| 日韩欧美另类在线| 精品噜噜噜噜久久久久久久久试看 | 91视频www| 99久久精品免费精品国产| 菠萝蜜视频在线观看一区| 丰满少妇在线播放bd日韩电影| 国产综合久久久久久久久久久久| 奇米影视7777精品一区二区| 免费观看一级欧美片| 久久se这里有精品| 国模少妇一区二区三区| 国产精选一区二区三区| 国产成人在线视频免费播放| 丁香一区二区三区| 波多野结衣中文一区| 不卡一区二区三区四区| 91尤物视频在线观看| 99re这里只有精品首页| 欧美在线观看一二区| 欧美老女人在线| 日韩欧美一区二区久久婷婷| 日韩美一区二区三区| av一区二区不卡| 成人三级在线视频| 91在线看国产| 欧洲精品一区二区三区在线观看| 欧美日精品一区视频| 欧美一二三区在线| 国产三级久久久| 一区二区三区在线播| 视频一区视频二区中文字幕| 久久精品国产成人一区二区三区| 国产传媒欧美日韩成人| 91论坛在线播放| 欧美精品久久久久久久久老牛影院| 日韩欧美国产不卡| 国产精品免费av| 亚洲国产中文字幕| 国产精品一品二品| 在线免费观看一区| 日韩欧美国产综合一区| 亚洲国产综合人成综合网站| 免费看欧美女人艹b| 成人国产精品免费观看视频| 欧美色图第一页| 国产日产欧产精品推荐色| 一区二区三区中文在线观看| 蜜桃视频免费观看一区| 91在线精品一区二区| 精品成a人在线观看| 亚洲精品视频观看| 国产乱对白刺激视频不卡| 色狠狠综合天天综合综合| 久久影院午夜论| 午夜精品福利一区二区三区蜜桃| 国产高清精品在线| 欧美一区日本一区韩国一区| 国产精品久久精品日日| 日本少妇一区二区| 在线观看网站黄不卡| 国产欧美一区视频| 美国毛片一区二区| 欧美日韩国产免费一区二区| 国产精品久久久久久亚洲伦| 精品亚洲成a人在线观看| 欧美日韩色一区| 亚洲欧美在线高清| 国产资源在线一区| 欧美一级视频精品观看| 亚洲国产一区二区三区| 91麻豆国产香蕉久久精品| 中文av一区特黄| 国产美女一区二区| 欧美成人乱码一区二区三区| 亚洲国产日产av| 在线观看网站黄不卡| 亚洲人精品一区| 国产91对白在线观看九色| 精品国产百合女同互慰| 麻豆精品在线看| 日韩三级视频在线看| 免费成人小视频| 日韩免费观看高清完整版在线观看| 午夜久久久影院| 欧美日韩一区在线| 亚洲成av人片在www色猫咪| 在线观看亚洲成人|