Skip to content

Instantly share code, notes, and snippets.

@matthen
Last active April 20, 2024 19:44
Show Gist options
  • Save matthen/246902ee928b43860393277c1b1f1d92 to your computer and use it in GitHub Desktop.
Save matthen/246902ee928b43860393277c1b1f1d92 to your computer and use it in GitHub Desktop.
Chinese numerals
characters = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一",
"十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "二十一", "二十二",
"二十三", "二十四", "二十五", "二十六", "二十七", "二十八", "二十九", "三十", "三十一",
"三十二", "三十三", "三十四", "三十五", "三十六", "三十七", "三十八", "三十九", "四十",
"四十一", "四十二", "四十三", "四十四", "四十五", "四十六", "四十七", "四十八", "四十九",
"五十", "五十一", "五十二", "五十三", "五十四", "五十五", "五十六", "五十七", "五十八",
"五十九", "六十", "六十一", "六十二", "六十三", "六十四", "六十五", "六十六", "六十七",
"六十八", "六十九", "七十", "七十一", "七十二", "七十三", "七十四", "七十五", "七十六",
"七十七", "七十八", "七十九", "八十", "八十一", "八十二", "八十三", "八十四", "八十五",
"八十六", "八十七", "八十八", "八十九", "九十", "九十一", "九十二", "九十三", "九十四",
"九十五", "九十六", "九十七", "九十八", "九十九", "一百"};
strokes = {"一" -> 1, "七" -> 2, "三" -> 3, "九" -> 2, "二" -> 2, "五" -> 4,
"八" -> 2, "六" -> 4, "十" -> 2, "四" -> 5, "百" -> 6};
edges = Table[
With[{c = characters[[i]] },
i -> Total[StringSplit[c, ""] /. strokes]
],
{i, 100}];
labels = Table[
i -> StringJoin[{characters[[i]], "(", ToString[i], ")"}], {i,
100}];
GraphPlot[
edges,
VertexShapeFunction ->
Function[{p, i},
Inset[Style[Text[i /. labels], 14,
ColorData["StarryNightColors"][1 - i/200], Bold], p]],
DirectedEdges -> True,
VertexSize -> 0.8,
GraphLayout -> "GravityEmbedding",
EdgeStyle -> Directive[White, Arrowheads[0.02]],
Background -> RGBColor[0., 0.05, 0.1],
ImageSize -> 1024,
ImageMargins -> 32
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment