<jupyter_start><jupyter_text>DAGVIZ Metro styling optionsThis notebook demonstrates the various Metro styling options.In order to apply styling we need to call `render_svg` by hand with the appropriate renderer and style configuration.<jupyter_code>from dagviz import render_svg
from dagviz.style.metro import svg_renderer, StyleConfig
from IPython.display import HTML
import networkx as nx<jupyter_output><empty_output><jupyter_text>First we construct a simple graph that demonstrates all the visual aspects a rendering may have.<jupyter_code>g = nx.DiGraph()
g.add_node("a", label="switch(value)")
g.add_node("b", label="case 1")
g.add_node("c", label="case 2")
g.add_node("d", label="case 3")
g.add_node("e", label="end")

g.add_edge("a", "b")
g.add_edge("a", "c")
g.add_edge("a", "d")

g.add_edge("b", "e")
g.add_edge("c", "e")
g.add_edge("d", "e")<jupyter_output><empty_output><jupyter_text>Default renderingWithout any configuration, we get (of course) the default rendering:<jupyter_code>HTML(render_svg(g))<jupyter_output><empty_output><jupyter_text>ScaleThe *scale* setting determines the amount of space each node has:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(scale=20))))<jupyter_output><empty_output><jupyter_text>Node radiusThe *node radius* determines the size of the bubbles:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(node_radius=10))))<jupyter_output><empty_output><jupyter_text>Node fillBy default the node fill color is automatically selected. This can be overriden by specifying a fixed color:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(node_fill="black"))))<jupyter_output><empty_output><jupyter_text>Node strokeThe *node stroke* specifies the color of the border of the bubble:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(node_stroke="black"))))<jupyter_output><empty_output><jupyter_text>Node stroke widthThe *node stroke width* determines the width of the border of the bubbles:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(node_stroke="black", node_stroke_width=4))))<jupyter_output><empty_output><jupyter_text>Edge stroke widthThe *edge stroke width* determines the width of the edges:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(node_fill="black", edge_stroke_width=10))))<jupyter_output><empty_output><jupyter_text>Label font familyThe default font family for labels is "sans-serif". This can be changes too:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(label_font_family="serif"))))<jupyter_output><empty_output><jupyter_text>Label arrow strokeThe *label arrow stroke* determines the color of the line from node to label:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(label_arrow_stroke="black"))))<jupyter_output><empty_output><jupyter_text>Label arrow dash arrayThe *label arrow dash array* determines how the label arrow is dashed:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(label_arrow_dash_array="0"))))<jupyter_output><empty_output><jupyter_text>Arc radiusThe *arc radius* determines the radius of the arc from vertical line to a node:<jupyter_code>HTML(render_svg(g, style=svg_renderer(StyleConfig(arc_radius=5))))
[".."]*4
"../"*4<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12048929663608562, 'fraction_numerical': 0.004281345565749235, 'mean_word_length': 11.07011070110701, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '667481', 'license': 'Apache-2.0', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1100, 'n_words': 242, 'path': 'notebooks/Metro styling.ipynb', 'repo_name': 'WimYedema/dagviz', 'size': '3270'}