aboutsummaryrefslogtreecommitdiff
path: root/graphviz.py
blob: f4350387ae7fcce7c38ffe0e3961777ac1ac1546 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Paste output into https://dreampuf.github.io/GraphvizOnline/
#
# 'circo' or 'dot' tend to look best

COLORS = ['#1E88E5', '#D81B60', '#FFC107', '#004D40']
USE_EDGE_COLORS = False

graph = [(0,1),(0,2),(0,3),(0,4),(0,5),(1,2),(2,3),(3,4),(4,5),(5,1)]
graph = [(0,1),(0,2),(0,3),(0,4),(1,2),(1,3),(2,3),(2,4),(3,4)]
coloring = '0001101101'

node_count = len(coloring) // 2
node_colors = [COLORS[int(coloring[i*2:i*2+2], 2)] for i in range(node_count)]

print('graph G {')
print('    node [style="filled" label="" color="white" shape="circle"]')
for i in range(len(coloring) // 2):
    print(f'    {i} [fillcolor="{node_colors[i]}"];')
for a, b in graph:
    if USE_EDGE_COLORS:
        print(f'    {a} -- {b} [color="{node_colors[a]};0.5:{node_colors[b]}"];')
    else:
        print(f'    {a} -- {b};')
print('}')