Broken, don't understand why yet
This commit is contained in:
		
							parent
							
								
									971a791339
								
							
						
					
					
						commit
						a412b5d8aa
					
				| @ -621,14 +621,48 @@ function nice_icosa(nodes, icosa) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // New approach with tetrahedral coloring
 | ||||||
|  | 
 | ||||||
|  | function find_edges(links, nid) { | ||||||
|  | 	return links.filter((l) => l.source === nid || l.target === nid ); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function find_adjacent(links, nid) { | ||||||
|  | 	return find_edges(links, nid).map((l) => { | ||||||
|  | 		if( l.source === nid ) { | ||||||
|  | 			return l.target; | ||||||
|  | 		} else { | ||||||
|  | 			return l.source; | ||||||
|  | 		} | ||||||
|  | 	}); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function iterate_graph(nodes, links, n, fn) { | ||||||
|  | 	const queue = []; | ||||||
|  | 	const seen = {}; | ||||||
|  | 	const nodes_id = {}; | ||||||
|  | 	nodes.map((n) => nodes_id[n.id] = n); | ||||||
|  | 
 | ||||||
|  | 	queue.push(n.id); | ||||||
|  | 	seen[n.id] = true; | ||||||
|  | 	fn(n); | ||||||
|  | 
 | ||||||
|  | 	while( queue.length > 0 ) { | ||||||
|  | 		const v = queue.shift(); | ||||||
|  | 		find_adjacent(links, v).map((aid) => { | ||||||
|  | 			if( !(aid in seen) ) { | ||||||
|  | 				seen[aid] = true; | ||||||
|  | 				queue.push(aid); | ||||||
|  | 				fn(nodes_id[aid]); | ||||||
|  | 			} | ||||||
|  | 		}) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| const nodes = make_120cell_vertices(); | const nodes = make_120cell_vertices(); | ||||||
| // const chords = find_all_chords(nodes);
 |  | ||||||
| // const chord3 = chords["1.74806"];  // these are edges of the 600-cells;
 |  | ||||||
| 
 |  | ||||||
| //const pairs60 = neighbour_angles(chord3, nodes[0], "60.000");
 |  | ||||||
| //const icosas = partition_nodes(pairs60);
 |  | ||||||
| 
 |  | ||||||
| make_120_partition(nodes, nodes[0]) |  | ||||||
| 
 | 
 | ||||||
|  | const links = auto_detect_edges(nodes, 4); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										102
									
								
								polytopes.js
									
									
									
									
									
								
							
							
						
						
									
										102
									
								
								polytopes.js
									
									
									
									
									
								
							| @ -1,4 +1,3 @@ | |||||||
| 
 |  | ||||||
| import * as PERMUTE from './permute.js'; | import * as PERMUTE from './permute.js'; | ||||||
| 
 | 
 | ||||||
| function index_nodes(nodes, scale) { | function index_nodes(nodes, scale) { | ||||||
| @ -185,13 +184,13 @@ function make_120cell_vertices() { | |||||||
| 
 | 
 | ||||||
| 	const nodes = [ | 	const nodes = [ | ||||||
| 		PERMUTE.coordinates([0, 0, 2, 2],  0), | 		PERMUTE.coordinates([0, 0, 2, 2],  0), | ||||||
| 		PERMUTE.coordinates([1, 1, 1, r5], 1), | 		PERMUTE.coordinates([1, 1, 1, r5], 0), | ||||||
| 		PERMUTE.coordinates([phi, phi, phi, phi2inv], 2), | 		PERMUTE.coordinates([phi, phi, phi, phi2inv], 0), | ||||||
| 		PERMUTE.coordinates([phiinv, phiinv, phiinv, phi2], 3), | 		PERMUTE.coordinates([phiinv, phiinv, phiinv, phi2], 0), | ||||||
| 
 | 
 | ||||||
| 		PERMUTE.coordinates([phi2, phi2inv, 1, 0], 4, true), | 		PERMUTE.coordinates([phi2, phi2inv, 1, 0], 0, true), | ||||||
| 		PERMUTE.coordinates([r5, phiinv, phi, 0], 5, true), | 		PERMUTE.coordinates([r5, phiinv, phi, 0], 0, true), | ||||||
| 		PERMUTE.coordinates([2, 1, phi, phiinv], 6, true), | 		PERMUTE.coordinates([2, 1, phi, phiinv], 0, true), | ||||||
| 		].flat(); | 		].flat(); | ||||||
| 	index_nodes(nodes); | 	index_nodes(nodes); | ||||||
| 	scale_nodes(nodes, 0.5); | 	scale_nodes(nodes, 0.5); | ||||||
| @ -209,6 +208,9 @@ function label_nodes(nodes, ids, label) { | |||||||
| export const cell120 = () => { | export const cell120 = () => { | ||||||
| 	const nodes  = make_120cell_vertices(); | 	const nodes  = make_120cell_vertices(); | ||||||
| 	const links = auto_detect_edges(nodes, 4); | 	const links = auto_detect_edges(nodes, 4); | ||||||
|  | 
 | ||||||
|  | 	naive_label_120cell(nodes, links); | ||||||
|  | 
 | ||||||
| 	return { | 	return { | ||||||
| 		nodes: nodes, | 		nodes: nodes, | ||||||
| 		links: links, | 		links: links, | ||||||
| @ -391,6 +393,90 @@ function audit_link_labels(nodes, links) { | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | function find_edges(links, nid) { | ||||||
|  | 	return links.filter((l) => l.source === nid || l.target === nid ); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function find_adjacent(links, nid) { | ||||||
|  | 	return find_edges(links, nid).map((l) => { | ||||||
|  | 		if( l.source === nid ) { | ||||||
|  | 			return l.target; | ||||||
|  | 		} else { | ||||||
|  | 			return l.source; | ||||||
|  | 		} | ||||||
|  | 	}); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function iterate_graph(nodes, links, n, fn) { | ||||||
|  | 	const queue = []; | ||||||
|  | 	const seen = {}; | ||||||
|  | 	const nodes_id = {}; | ||||||
|  | 	nodes.map((n) => nodes_id[n.id] = n); | ||||||
|  | 
 | ||||||
|  | 	queue.push(n.id); | ||||||
|  | 	seen[n.id] = true; | ||||||
|  | 	fn(n); | ||||||
|  | 
 | ||||||
|  | 	while( queue.length > 0 ) { | ||||||
|  | 		const v = queue.shift(); | ||||||
|  | 		find_adjacent(links, v).map((aid) => { | ||||||
|  | 			if( !(aid in seen) ) { | ||||||
|  | 				seen[aid] = true; | ||||||
|  | 				queue.push(aid); | ||||||
|  | 				fn(nodes_id[aid]); | ||||||
|  | 			} | ||||||
|  | 		}) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function dumb_label_120cell(nodes, links) { | ||||||
|  | 	let l = 0; | ||||||
|  | 
 | ||||||
|  | 	iterate_graph(nodes, links, nodes[0], (n) => { | ||||||
|  | 		n.label = l; | ||||||
|  | 		console.log(`Labelled ${n.id} ${n.label}`); | ||||||
|  | 		l++; | ||||||
|  | 		if( l > 2 ) { | ||||||
|  | 			l = 0; | ||||||
|  | 		} | ||||||
|  | 	}) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // stupid tetrahedral labelling
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function naive_label_120cell(nodes, links, n) { | ||||||
|  | 	const nodes_id = {}; | ||||||
|  | 	nodes.map((n) => nodes_id[n.id] = n); | ||||||
|  | 	iterate_graph(nodes, links, nodes[0], (n) => { | ||||||
|  | 		const cols = new Set(); | ||||||
|  | 		const nbors = find_adjacent(links, n.id); | ||||||
|  | 		for( const nb of nbors ) { | ||||||
|  | 			if( nodes_id[nb].label > 0 ) { | ||||||
|  | 				cols.add(nodes_id[nb].label); | ||||||
|  | 			} | ||||||
|  | 			for( const nb2 of find_adjacent(links, nb) ) { | ||||||
|  | 				if( nb2 !== n.id && nodes_id[nb].label > 0 ) { | ||||||
|  | 					cols.add(nodes_id[nb2].label); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		const pcols = [ 1, 2, 3, 4, 5 ].filter((c) => !cols.has(c)); | ||||||
|  | 		if( pcols.length < 1 ) { | ||||||
|  | 			console.log(`Got stuck, no options at ${n.id}`); | ||||||
|  | 		} else { | ||||||
|  | 			n.label = pcols[0]; | ||||||
|  | 			console.log(`applied ${pcols[0]} to node ${n.id}`); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| export const cell600 = () => { | export const cell600 = () => { | ||||||
| 	const nodes  = make_600cell_vertices(); | 	const nodes  = make_600cell_vertices(); | ||||||
| 	const links = auto_detect_edges(nodes, 12); | 	const links = auto_detect_edges(nodes, 12); | ||||||
| @ -406,5 +492,3 @@ export const cell600 = () => { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user