Public
Edited
Feb 10, 2023
1 fork
Importers
3 stars
A Julia set on the Riemann sphereThe Z-CurveBarnsley's fernA stochastic digraph IFS algorithmSelf-affine tilesThe TwindragonThe Eisenstein fractionsA self-affine tile with holesSelf-affine tiles via polygon mergeGolden rectangle fractalsBifurcation diagram with critical curvesThe tame twindragonIllustrations for the proof of Green's theoremNon-orientability of a Mobius stripExamples of parametric surfacesPenrose tilingThe extended unit circlePenrose three coloringNewtons's method on the Riemann sphereConic sectionsDivisor graphsThe dance of Earth and VenusIterating multiples of the sine functionBorderline fractalsSelf-similar intersectionsBox-counting dimension examplesMandelbrot by dimensionInverse iteration for quadratic Julia setsInteger Apollonian PackingsIllustrations of two-dimensonal heat flowThe logistic bifurcation locusThe eleven unfoldings of the cubeA unimodal function with fractal level curvesGreen's theorem and polygonal areaThe geometry and numerics of first order ODEsThe xxx^xxx-spindleAnimated beatsRauzy FractalsHilbert's coordinate functionsPluckNot PiDrum strikeThe Koch snowflakeFractalized squareA Taylor series about π/4\pi/4π/4PlotX3D HyperboloidA PlotX3D animationModular arithmetic in 5th grade artSimple S-I-R ModelThe Poisson KernelPoly-gasketsClassification of 2D linear systems via trace and determinantJulia sets and the Mandelbrot setWater wavesFourier SeriesDisks for a solid of revolutionOrbit detection for the Mandelbrot setTracing a path on a spherePlot for mathematiciansFunctions of two variablesPartial derivativesDijkstra's algorithm on an RGGGradient ascentUnfolding polyhedraTangent plane to a level surfaceA strange discontinuityExamples of level surfacesMcMullen carpetsHills and valleysThe definition of ⇒Double and iterated integralsMST in an RGGTrees are bipartiteFractal typesettingd3.hierarchy and d3.treeK23 is PlanarPolar CoordinatesParametric region generatorParametric Plot 2DContour plotsGreedy graph coloring
Graph6
A few hundred interesting graphsThe Kings ProblemFirst order, autonomous systems of ODEsRunge-Kutta for systems of ODEs
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
simple_graph = ({
n: 5,
edges: [[0,1],[0,2],[3,4]]
})
Insert cell
Insert cell
dot`graph{
${d3.range(simple_graph.n).join(";")}
${simple_graph.edges.map(([i, j]) => `${i}--${j}`).join(";")}
}`
Insert cell
Insert cell
function random_graph(n, p) {
let edges = d3
.range(n)
.map((i) =>
d3
.range(i + 1, n)
.map((j) => (d3.randomUniform(0, 1)() < p ? [[i, j]] : []))
)
.flat(2);

return { n, edges };
}
Insert cell
Insert cell
G = {
let n = d3.randomInt(10, 15)();
return random_graph(n, 0.8 / Math.sqrt(n));
}
Insert cell
Insert cell
function encode_graph(G) {
let x = encode_edges(G.edges, G.n);
let bytes = N(G.n).concat(R(x));
return bytes.map((c) => String.fromCharCode(c)).join("");
}
Insert cell
function encode_edges(e, n) {
let ee = e.map(([i, j]) => `${i}--${j}`);
let bits = [];
for (let j = 1; j < n; j++) {
for (let i = 0; i < j; i++) {
if (ee.indexOf(`${i}--${j}`) > -1) {
bits.push(1);
} else {
bits.push(0);
}
}
}
return bits.join("");
}
Insert cell
function pad6(s) {
let r = s.length % 6;
if (r == 0) {
return s;
} else {
let p = Array(6 - r)
.fill(0)
.join("");
return s + p;
}
}
Insert cell
function R(x) {
let s;
if (typeof x == "number") {
s = x.toString(2);
s = s.split("").reverse().join("");
s = pad6(s);
s = s.split("").reverse().join("");
} else {
s = pad6(x);
}
let parts = [];
while (s.length > 0) {
parts.push(s.slice(0, 6));
s = s.slice(6);
}
return parts.map((s) => +`0b${s}` + 63);
}
Insert cell
function N(n) {
if (0 <= n && n <= 62) {
return [n + 63];
} else if (63 <= n && n <= 258047) {
let r = R(n);
if (r.length == 1) {
r = [126, 63, 63].concat(r);
} else if (r.length == 2) {
r = [126, 63].concat(r);
} else if (r.length == 3) {
r = [126].concat(r);
}
return r;
} else if (258048 <= n) {
let r = R(n);
if (r.length == 3) {
r = [126, 126, 63, 63, 63].concat(r);
} else if (r.length == 4) {
r = [126, 126, 63, 63].concat(r);
} else if (r.length == 5) {
r = [126, 126, 63].concat(r);
}
return r;
}
}
Insert cell
Insert cell
function decode_graph(g6) {
let n = get_n(g6);
let bit_string;
if (n < 63) {
bit_string = get_bit_string(g6.slice(1), n);
} else if (n < 258048) {
bit_string = get_bit_string(g6.slice(4), n);
} else {
bit_string = get_bit_string(g6.slice(8), n);
}
let edges = [];
let idx = 0;
for (let j = 1; j < n; j++) {
for (let i = 0; i < j; i++) {
if (bit_string[idx] == "1") {
edges.push([i, j]);
}
idx++;
}
}
return { n, edges };
}
Insert cell
function get_bit_string(bytes, n) {
return bytes
.split("")
.map((ss) => ss.charCodeAt(0))
.map(function (x) {
let xx = (x - 63).toString(2);
if (xx.length < 6) {
xx = pad6Left(xx);
// xx = xx.split("").reverse().join("");
// xx = pad6(xx);
// xx = xx.split("").reverse().join("");
}
return xx;
})
.join("")
.slice(0, (n * (n - 1)) / 2);
}
Insert cell
function get_n(s) {
let first_byte = s.charCodeAt(0);
let second_byte = s.charCodeAt(1);
if (first_byte < 126) {
return first_byte - 63;
} else if (second_byte < 126) {
let bits = s
.slice(1, 4)
.split("")
.map((c) => c.charCodeAt(0) - 63)
.map((b) => pad6Left(`${b.toString(2)}`))
.join("");
return +`0b${bits}`;
} else {
let bits = s
.slice(4)
.split("")
.map((c) => c.charCodeAt(0) - 63)
.map((b) => pad6Left(`${b.toString(2)}`))
.join("");
return +`0b${bits}`;
}
}
Insert cell
pad6Left = (s) =>
pad6(s.split("").reverse().join("")).split("").reverse().join("")
Insert cell
Insert cell
graphs = (await FileAttachment("graphs.g6").text()).split("\n").slice(0, -1)
Insert cell
d3 = require("d3@7", "d3-graphviz@2")
Insert cell
import { step_slider } from "59730aabd7354b99"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more