לדלג לתוכן

קובץ:Critical graph sample.svg

תוכן הדף אינו נתמך בשפות אחרות.
מתוך ויקיפדיה, האנציקלופדיה החופשית

לקובץ המקורי(קובץ SVG, הגודל המקורי: 600 × 600 פיקסלים, גודל הקובץ: 17 ק"ב)

ויקישיתוף זהו קובץ שמקורו במיזם ויקישיתוף. תיאורו בדף תיאור הקובץ המקורי (בעברית) מוצג למטה.

תקציר

תיאור
English: Example of Vertex Critical Graph: on the left-top the original vc08-chi06 with chromatic number=6, next all the N-1 subgraphs with chromatic number= 5
תאריך יצירה
מקור נוצר על־ידי מעלה היצירה
יוצר Claudio Rocchini

Thanks

Many thanks to Gordon Royles [1] for the graph example.

Source Code

Dirty C++ generating code:

/* (C)2013 Claudio Rocchini CC-BY 3.0 */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
const double PI = 3.1415926535897932384626433832795;
typedef std::pair<int,int> edge;

int greedy_color( int N, const std::vector<edge> & edges, std::vector<int> & colors ) {
	std::vector< std::vector<int> > stars(N);
	std::vector<edge>::const_iterator ii;
	for(ii=edges.begin();ii!=edges.end();++ii) {
		stars[(*ii).first ].push_back( (*ii).second );
		stars[(*ii).second].push_back( (*ii).first  );
	}
	colors.resize(N);
	for(int nc=2;;++nc) {
		std::fill(colors.begin(),colors.end(),-1); colors[0] = 0;
		int p = 1;
		for(;;) {
			if(++colors[p]==nc) {
				colors[p] = -1;
				if(--p<1) break; else continue;
			}
			std::vector<int>::const_iterator jj;
			for(jj=stars[p].begin();jj!=stars[p].end();++jj)
				if(colors[*jj]==colors[p])  break;
			if(jj==stars[p].end()) if(++p==N) break;
		}
		if(p==N) return nc;
	}
}

int main() {
	const int S = 600;	
	const int rgb[][3] = {
		{255,8,8},{8,255,8},{8,8,255},{255,255,8},{255,8,255},{255,255,255}
	};
	/* Than's to for this graph:
	http://school.maths.uwa.edu.au/~gordon/remote/graphs/ */
	const int N = 8;
	const int pe[N] = {0,2,4,1,3,5,6,7};
	const int gr[N][7]= {
		{2,3,5,6,7,-1,-1}, {3,4,5,6,7,-1,-1}, {0,4,5,6,7,-1,-1},
		{0,1,5,6,7,-1,-1}, {1,2,5,6,7,-1,-1},
		{0,1,2,3,4,6,7}, {0,1,2,3,4,5,7}, {0,1,2,3,4,5,6}
	};
	int i,j,k;
	const double R1=S/7, R2=R1*2/3, R3=8;
	double x[N],y[N];
	for(i=0;i<5;++i) {
		x[pe[i]] = +sin(2*PI*i/5)*R1;
		y[pe[i]] = -cos(2*PI*i/5)*R1;
	}
	for(i=0;i<3;++i) {
		x[i+5] = +sin(2*PI*i/3)*R2;
		y[i+5] = -cos(2*PI*i/3)*R2;
	}
	
	FILE * fo = fopen("critical.svg","w");
	fprintf(fo,
		"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
		"<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.0\" width=\"%d\" height=\"%d\" id=\"criticalg\">\n"
		,S,S
	);
	
	for(k=-1;k<N;++k) {
		double lx = S/6+((k+1)%3)*S/3; double ly = S/6+((k+1)/3)*S/3;
		std::vector<edge> edges;
		for(i=0;i<N;++i) if(i!=k)
			for(j=0;j<7;++j)
				if(gr[i][j]>i && gr[i][j]!=k)
					edges.push_back( edge(i,gr[i][j]) );
		std::vector<int> colors;
		int nc = greedy_color(N,edges,colors);
		printf("colors = %d\n",nc);
	
		fprintf(fo,"<g style=\"stroke:#000000;stroke-width:1.5;fill:none\">\n");
		for(i=0;i<int(edges.size());++i)
		if(edges[i].first!=k && edges[i].second!=k)
			fprintf(fo,"<line x1=\"%6.2f\" y1=\"%6.2f\" x2=\"%6.2f\" y2=\"%6.2f\"/>\n"
				,lx+x[edges[i].first ],ly+y[edges[i].first]
				,lx+x[edges[i].second],ly+y[edges[i].second]
			);
		fprintf(fo,"</g>\n");

		fprintf(fo,"<g>\n");
		for(i=0;i<N;++i) if(i!=k)
			fprintf(fo,"<circle cx=\"%6.2f\" cy=\"%6.2f\" r=\"%g\" "
			           "style=\"stroke:#000000;stroke-width:1;stroke-opacity:1.0;fill:#%02X%02X%02X\"/>\n"
				,lx+x[i],ly+y[i],R3
				,rgb[colors[i]][0],rgb[colors[i]][1],rgb[colors[i]][2]
			);
		fprintf(fo,"</g>\n");
	}
	
	fprintf(fo,"</svg>\n");
	
	fclose(fo);
	
	
	return 0;
}

רישיון

אני, בעל זכויות היוצרים על עבודה זו, מפרסם בזאת את העבודה תחת הרישיון הבא:
w:he:Creative Commons
ייחוס שיתוף זהה
הקובץ הזה מתפרסם לפי תנאי רישיון קריאייטיב קומונז ייחוס-שיתוף זהה 3.0 לא מותאם.
הנכם רשאים:
  • לשתף – להעתיק, להפיץ ולהעביר את העבודה
  • לערבב בין עבודות – להתאים את העבודה
תחת התנאים הבאים:
  • ייחוס – יש לתת ייחוס הולם, לתת קישור לרישיון, ולציין אם נעשו שינויים. אפשר לעשות את זה בכל צורה סבירה, אבל לא בשום צורה שמשתמע ממנה שמעניק הרישיון תומך בך או בשימוש שלך.
  • שיתוף זהה – אם תיצרו רמיקס, תשנו, או תבנו על החומר, חובה עליכם להפיץ את התרומות שלך לפי תנאי רישיון זהה או תואם למקור.

כיתובים

נא להוסיף משפט שמסביר מה הקובץ מייצג

פריטים שמוצגים בקובץ הזה

מוצג

image/svg+xml

checksum אנגלית

aa4981aad5587fc1bb542568141797f21fe411ae

הוגדר לפי: SHA-1 אנגלית

17,089 בית

600 פיקסל

600 פיקסל

היסטוריית הקובץ

ניתן ללחוץ על תאריך/שעה כדי לראות את הקובץ כפי שנראה באותו זמן.

תאריך/שעהתמונה ממוזערתממדיםמשתמשהערה
נוכחית14:52, 4 ביוני 2013תמונה ממוזערת לגרסה מ־14:52, 4 ביוני 2013‪600 × 600‬ (17 ק"ב)RocchiniUser created page with UploadWizard

אין בוויקיפדיה דפים המשתמשים בקובץ זה.

שימוש גלובלי בקובץ

אתרי הוויקי השונים הבאים משתמשים בקובץ זה:

מטא־נתונים