For the two properties of a normal diagram:
Maximum number of groups ≤ Minimum number of colors
Maximum independent set ≤ Minimum group coverage
And in the chord chart it becomes:
Maximum number of clusters = minimum number of colors
Maximum independent set = Minimum Group coverage
(Though I don't know what it's for
Perfect elimination Sequence:
To the point vi in the sequence, after VI and the point connected to VI is a regiment
The perfect elimination sequence of a graph is a necessary and sufficient condition for it to be a chord graph
So what's the use of perfect elimination sequences? It's very useful.
For the maximum number of clusters/minimum chromatic number of the chord graph, the greedy dyeing can be obtained from the backward-forward in the perfect elimination sequence.
When the maximum independent set/minimum group coverage is required, the greedy pick-up point can be obtained from the past in the perfect elimination sequence.
So here comes a series of questions, first of all the determinant of the chord chart, and we need to determine if this diagram has a perfect elimination sequence.
MCS algorithm
The point of the sequence is determined from the back to the next, each point is not added to the sequence and its connected points of the label +1, each pick point select one of the largest points.
The concrete implementation is very difficult to describe don't want to say = = code below, complexity O (m+n)
It is said that if the graph is a string graph, the sequence obtained by this algorithm can guarantee the perfect elimination sequence.
So when we need to determine the chord graph, we have to decide if the sequence is perfect.
The method of judging is:
The next step is to determine whether each point V in the sequence satisfies the condition: the point set at the end of the V connected to V is recorded as the first point in N (v) to see if it is connected to other points in N (v).
The specific implementation is, the number of points is directly linked to the adjacent Matrix O (m+n), the point of the list of the side table and then two O (mlogm+n).
Now that we know how to solve the problem of determining the chord graph and how to get the perfect elimination sequence, let's look at the specific examples
ZOJ1015:
Bare string figure, point 1000, directly follow the above practice blind
Code:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <string>#include <iomanip>#include <vector>#include <set>#include <map>#include <queue>using namespace STD;typedef Long LongLL;typedef unsigned Long LongULL;#define REP (i,k,n) for (int i= (k); i<= (n); i++)#define REP0 (i,n) for (int i=0;i< (n); i++)#define RED (i,k,n) for (int i= (k); i>= (n); i--)#define SQR (x) ((x) * (x))#define CLR (x, Y) memset ((×), (y), sizeof (x) )#define PB Push_back#define MOD 1000000007Const intmaxn=1010;Const intmaxm=3500010;structlist{intV,next;}List[MAXM];intEH[MAXN],TOT,MH[MAXN];inline voidAddintH[],intUintV) {List[Tot].v=v;List[Tot].next=h[u]; h[u]=tot++;}intN,m,best;intQ[MAXN],F[MAXN],G[MAXN];BOOLVIS[MAXN];voidMCS () {CLR (mh,-1); CLR (Vis,0); CLR (F,0); for(intI=1; i<=n;i++) Add (MH,0, i); best=0; for(intj=n;j;j--) { while(1) {intI for(i=mh[best];~i;i=List[I].next) {if(!vis[List[I].V]) Break;Elsemh[best]=List[I].next; }if(~i) {intx=List[I].V; Q[j]=x;g[x]=j; vis[x]=1; for(i=eh[x];~i;i=List[I].next]if(!vis[List[I].V]) {f[List[i].v]++; Add (mh,f[List[I].V],List[I].V]; Best=max (best,f[List[I].V]); } Break; }Elsebest--; } }}intSt[maxn],top;BOOLE[MAXN][MAXN];BOOLCheckq () { for(intj=n-1; j;j--) {intU=Q[J]; top=0;intming=n+1, MINV; for(intI=eh[u];~i;i=List[I].next]if(g[List[i].v]>j) {st[++top]=List[I].V;if(g[List[i].v]<ming) {ming=g[List[I].V]; minv=List[I].V; } }if(ming==n+1)Continue; for(intI=1; i<=top;i++)if(ST[I]!=MINV) {if(!e[minv][st[i]])return 0; } }return 1;}intMain () { while(scanf("%d%d", &n,&m), N) {clr (eh,-1); tot=0; CLR (E,0);intU,v; for(intI=1; i<=m;i++) {scanf("%d%d", &u,&v); Add (EH,U,V); Add (Eh,v,u); e[u][v]=e[v][u]=1; } MCS ();puts(Checkq ()?"Perfect":"Imperfect");puts(""); }return 0;}
BZOJ1006:
The minimum number of staining of a bare string graph, just follow the above practice blind
Code:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <string>#include <iomanip>#include <vector>#include <set>#include <map>#include <queue>using namespace STD;typedef Long LongLL;typedef unsigned Long LongULL;#define REP (i,k,n) for (int i= (k); i<= (n); i++)#define REP0 (i,n) for (int i=0;i< (n); i++)#define RED (i,k,n) for (int i= (k); i>= (n); i--)#define SQR (x) ((x) * (x))#define CLR (x, Y) memset ((×), (y), sizeof (x) )#define PB Push_back#define MOD 1000000007Const intmaxn=10010;Const intmaxm=4000010;structlist{intV,next;}List[MAXM];intEH[MAXN],TOT,MH[MAXN];inline voidAddintH[],intUintV) {List[Tot].v=v;List[Tot].next=h[u]; h[u]=tot++;}intN,M,BEST,Q[MAXN],F[MAXN],COLOR[MAXN],MARK[MAXN];BOOLVIS[MAXN];voidMCS () {CLR (mh,-1); CLR (Vis,0); CLR (F,0); Rep (I,1, n) Add (MH,0, i); best=0; Red (J,n,1) { while(1) {intI for(i=mh[best];~i;i=List[I].next) {if(!vis[List[I].V]) Break;Elsemh[best]=List[I].next; }if(~i) {intx=List[I].V; q[j]=x;vis[x]=1; for(i=eh[x];~i;i=List[I].next) {intv=List[I].V;if(Vis[v])Continue; f[v]++; Add (MH,F[V],V); Best=max (Best,f[v]); } Break; }Elsebest--; } }}intMain () {scanf("%d%d", &n,&m);intU,v; CLR (eh,-1); tot=0; Rep (I,1, m) {scanf("%d%d", &u,&v); Add (EH,U,V); Add (Eh,v,u); } MCS (); CLR (Mark,0); CLR (color,0);intans=0; Red (J,n,1) { for(intI=eh[q[j]];~i;i=List[I].next] mark[color[List[I].v]]=j;intI for(i=1; mark[i]==j;i++); Color[q[j]]=i; Ans=max (Ans,i); }printf("%d\n", ans);return 0;}
In particular, the maximum independent set and the minimum group cover is to seek the perfect elimination of the sequence, the rest of the thing is similar, and temporarily did not find the topic, not detailed said
In addition, there is the problem of finding all the great groups of strings. It is necessary to use the above mentioned N (v) and Next (v), it is clear that the great regiment must be V ∪ N (v) Form, then judge if it is not a maximal regiment as long as the judge exists a W, satisfies next (w) =v and | N (v) |+1 ≤ | N (W) |
It is said that the complexity of O (m+n) is not studied for the time being unclear ...
String graph perfect elimination sequence MCS algorithm