The code is a visual representation of a process using Graphviz, comprising a single 'digraph' statement with a name 'apply' and several nodes and edges that outline the steps from registering a new customer to upgrading a plan. The code includes various attributes for nodes and edges, a subgraph for available plans, and a specific layout direction and edge color specification.
%%
dot
digraph
apply
{
label = '2017 Updated'
rankdir = LR;
fontname = Helvetica
node[fontname = Helvetica, width = 1.8, height = 0.8]
edge[fontname = Helvetica, fontsize = 12, fontcolor = blue, labeldistance = 1.8]
start [shape = box, style = rounded, label = 'Register New\nCustomer'];
selectrp[shape = 'box', label = 'Select Rate Plan'];
subgraph
cluster_available_plans
{
label = 'Available Plans'
style = filled;
fillcolor = grey92
rank = same;
monthly [shape = box, label = 'Act! Premium 2017\nUpdate - Monthly\nSubscription\n$30']
annual [shape = box, label = 'Act! Premium 2017\nUpdate - Annual\nSubscription\n$300']
perpetual [shape = box, label = 'Act! Premium 2017\nUpdate - Perpetual\nLicense\n$600']
year2 [shape = box, label = 'Act! Premium 2017\nUpdate - Annual\nSubscription (2 Year\nContract)\n$540']
}
upgrade[shape = 'diamond', label = 'Upgrade\nNew\nCustomer', rank = min];
node [shape = box];
{
start->selectrp->upgrade [color = invis];
rankdir = LR;
}
start:e -> selectrp
:
w
selectrp:e -> monthly
:
w
selectrp:e -> annual
:
w
selectrp:e-> perpetual
:
w
selectrp:e -> year2
:
w
monthly:e -> upgrade
:
w
annual:e -> upgrade
:
w
perpetual:e -> upgrade
:
w
year2:e -> upgrade
:
w
upgrade:s -> selectrp
:
s
}
import graphviz
# Define the graph
dot = graphviz.Digraph(
name='rate_plan_selection',
engine='dot',
format='png',
direction='LR',
graph_attr={
'fontname': 'Helvetica',
'fontsize': 12
},
node_attr={
'fontname': 'Helvetica',
'width': 1.8,
'height': 0.8
},
edge_attr={
'fontname': 'Helvetica',
'fontsize': 12,
'fontcolor': 'blue',
'labeldistance': 1.8
}
)
# Define nodes
start_node = dot.node(name='start', label='Register New\nCustomer', shape='box', style='rounded')
select_rp_node = dot.node(name='selectrp', label='Select Rate Plan')
# Define subgraph for available plans
available_plans_cluster = dot.subgraph(name='cluster_available_plans', label='Available Plans', style='filled', fillcolor='grey92')
dot.node('monthly', label='Act! Premium 2017\nUpdate - Monthly\nSubscription\n$30', shape='box', parent=available_plans_cluster, rank='same')
dot.node('annual', label='Act! Premium 2017\nUpdate - Annual\nSubscription\n$300', shape='box', parent=available_plans_cluster, rank='same')
dot.node('perpetual', label='Act! Premium 2017\nUpdate - Perpetual\nLicense\n$600', shape='box', parent=available_plans_cluster, rank='same')
dot.node('year2', label='Act! Premium 2017\nUpdate - Annual\nSubscription (2 Year\nContract)\n$540', shape='box', parent=available_plans_cluster, rank='same')
# Define upgrade node
upgrade_node = dot.node(name='upgrade', label='Upgrade\nNew\nCustomer', shape='diamond', rank='min')
# Add edges
dot.edge('start','selectrp')
dot.edge('selectrp','monthly')
dot.edge('selectrp', 'annual')
dot.edge('selectrp', 'perpetual')
dot.edge('selectrp', 'year2')
dot.edge('monthly', 'upgrade')
dot.edge('annual', 'upgrade')
dot.edge('perpetual', 'upgrade')
dot.edge('year2', 'upgrade')
dot.edge('upgrade','selectrp')
# Render the graph
dot.render('rate_plan_selection')
# TODO: improve graph visualization, e.g., adjust node positions, add more labels
Graphviz Code
This code is written in Graphviz, a tool for visualizing and drawing graphs.
The code consists of a single digraph
statement with a name apply
and the label '2017 Updated'
.
The code defines several attributes for nodes and edges:
fontname
, width
, height
fontname
, fontsize
, fontcolor
, labeldistance
The code defines several nodes:
start
: a rounded box with the label 'Register New Customer'selectrp
: a box with the label 'Select Rate Plan'monthly
, annual
, perpetual
, year2
: boxes representing available plans with their respective labels and attributesThe code defines a subgraph cluster_available_plans
with the label 'Available Plans'. This subgraph contains the four available plan nodes.
The code defines several edges between nodes, including:
start
-> selectrp
selectrp
-> monthly
, annual
, perpetual
, year2
monthly
, annual
, perpetual
, year2
-> upgrade
upgrade
-> selectrp
The code uses the rankdir
attribute to specify the layout direction (left-to-right) and the rank
attribute to specify the rank of nodes within the subgraph.
The code uses the color
attribute to set the edge color to invisible for a specific edge.