Skip to content

Commit

Permalink
adjust the node color
Browse files Browse the repository at this point in the history
  • Loading branch information
peter0627ustc committed Dec 25, 2023
1 parent 8fdf8e0 commit 34565c9
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/backend/to_dot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ function to_dotstatic(::Type{ComputationalGraphs.Sum}, id::Int, factor::F, subgr
if factor != 1
# opr_fac = "factor$(id)[label=$(factor), style=filled, fillcolor=lavender]\n"
# opr_name = "g$(id)_t"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# arrow_temp *= "factor$(id)->g$(id)[arrowhead=vee,]\ng$(id)_t->g$(id)[arrowhead=vee,]\n"
# node_temp *= opr_fac * node_str
opr_node = "g$(id)[shape=box, label = <($factor)*<b>&oplus;</b>>, style=filled, color = orange, fontsize=18, width = 0.8, height = 0.4]\n"
opr_node = "g$(id)[shape=box, label = <($factor)*<b>&oplus;</b>>, style=filled, color = darkturquoise, fontsize=18, width = 0.8, height = 0.4]\n"
else
opr_node = "g$(id)[shape=box, label = <<b>&oplus;</b>>, style=filled, color= orange, fontsize=18, width = 0.5, height = 0.4]\n"
opr_node = "g$(id)[shape=box, label = <<b>&oplus;</b>>, style=filled, color= darkturquoise, fontsize=18, width = 0.5, height = 0.4]\n"
# opr_name = "g$id"
end
opr_name = "g$id"
# opr_node = opr_name * "[shape=box, label = <<b>&oplus;</b>>, style=filled, fillcolor=cyan,]\n"
# opr_node = opr_name * "[shape=box, label = <<b>&oplus;</b>>, style=filled, fillcolor=lightcyan,]\n"
node_temp *= opr_node
for (gix, (g, gfactor)) in enumerate(zip(subgraphs, subgraph_factors))
if gfactor != 1
# factor_str = "factor$(g.id)_$(id)_$gix[label=$(gfactor), style=filled, fillcolor=lavender]\n"
# subg_str = "g$(g.id)_$(id)_$gix[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# subg_str = "g$(g.id)_$(id)_$gix[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# node_temp *= factor_str * subg_str
# arrow_temp *= "factor$(g.id)_$(id)_$gix->g$(g.id)_$(id)_$gix[arrowhead=vee,]\ng$(g.id)->g$(g.id)_$(id)_$gix[arrowhead=vee,]\n"
# arrow_temp *= "g$(g.id)_$(id)_$gix->$opr_name[arrowhead=vee,]\n"
Expand All @@ -42,14 +42,14 @@ function to_dotstatic(::Type{ComputationalGraphs.Prod}, id::Int, factor::F, subg
if factor != 1
# opr_fac = "factor$(id)[label=$(factor), style=filled, fillcolor=lavender]\n"
# opr_name = "g$(id)_t"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# arrow_temp *= "factor$(id)->g$(id)[arrowhead=vee,]\ng$(id)_t->g$(id)[arrowhead=vee,]\n"
# node_temp *= opr_fac * node_str
opr_node = "g$id[shape=box, label = <($factor)<b>&otimes;</b>>, style=filled, color=lightpink , fontsize=18, width = 0.8, height = 0.4]\n"
else
opr_node = "g$id[shape=box, label = <<b>&otimes;</b>>, style=filled, color=lightpink, fontsize=18, width = 0.5, height = 0.4]\n"
end
# opr_node = opr_name * "[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# opr_node = opr_name * "[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
node_temp *= opr_node
# if length(subgraphs) == 1
# if subgraph_factors[1] == 1
Expand All @@ -63,7 +63,7 @@ function to_dotstatic(::Type{ComputationalGraphs.Prod}, id::Int, factor::F, subg
for (gix, (g, gfactor)) in enumerate(zip(subgraphs, subgraph_factors))
if gfactor != 1
# factor_str = "factor$(g.id)_$(id)_$gix[label=$(gfactor), style=filled, fillcolor=lavender]\n"
# subg_str = "g$(g.id)_$(id)_$gix[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# subg_str = "g$(g.id)_$(id)_$gix[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# node_temp *= factor_str * subg_str
# arrow_temp *= "factor$(g.id)_$(id)_$gix->g$(g.id)_$(id)_$gix[arrowhead=vee,]\ng$(g.id)->g$(g.id)_$(id)_$gix[arrowhead=vee,]\n"
# arrow_temp *= "g$(g.id)_$(id)_$gix->$opr_name[arrowhead=vee,]\n"
Expand All @@ -82,7 +82,7 @@ function to_dotstatic(::Type{ComputationalGraphs.Power{N}}, id::Int, factor::F,
if factor != 1
# opr_fac = "factor$(id)[label=$(factor), style=filled, fillcolor=lavender]\n"
# opr_name = "g$(id)_t"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# arrow_temp *= "factor$(id)->g$(id)[arrowhead=vee,]\ng$(id)_t->g$(id)[arrowhead=vee,]\n"
# node_temp *= opr_fac * node_str
opr_node = "g$id[shape=box, label = <($factor)*Pow($N)>, style=filled, color=darkolivegreen, fontsize=18, width = 1.0, height = 0.4]\n"
Expand All @@ -96,7 +96,7 @@ function to_dotstatic(::Type{ComputationalGraphs.Power{N}}, id::Int, factor::F,
# arrow_temp *= "order$(id)->$opr_name[arrowhead=vee,]\n"
if subgraph_factors[1] != 1
# factor_str = "factor$(subgraphs[1].id)_$(id)[label=$(subgraph_factors[1]), style=filled, fillcolor=lavender]\n"
# subg_str = "g$(subgraphs[1].id)_$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# subg_str = "g$(subgraphs[1].id)_$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# node_temp *= factor_str * subg_str
# arrow_temp *= "factor$(subgraphs[1].id)_$(id)->g$(subgraphs[1].id)_$(id)[arrowhead=vee,]\ng$(subgraphs[1].id)->g$(subgraphs[1].id)_$(id)[arrowhead=vee,]\n"
arrow_temp *= "g$(subgraphs[1].id)->$opr_name[arrowhead=vee,label=$gfactor,fontsize=16, penwidth = 0.2,arrowsize = 0.3]\n"
Expand All @@ -112,21 +112,21 @@ function to_dotstatic(::Type{ComputationalGraphs.Sum}, id::Int, factor::F, subgr
if factor != 1
# opr_fac = "factor$(id)[label=$(factor), style=filled, fillcolor=lavender]\n"
# opr_name = "g$(id)_t"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# arrow_temp *= "factor$(id)->g$(id)[arrowhead=vee,]\ng$(id)_t->g$(id)[arrowhead=vee,]\n"
# node_temp *= opr_fac * node_str
opr_node = "g$(id)[shape=box, label = <($factor)*<b>&oplus;</b>>, style=filled, color=orange,fontsize=18, width = 0.8, height = 0.4]\n"
opr_node = "g$(id)[shape=box, label = <($factor)*<b>&oplus;</b>>, style=filled, color=darkturquoise,fontsize=18, width = 0.8, height = 0.4]\n"
else
opr_node = "g$(id)[shape=box, label = <<b>&oplus;</b>>, style=filled, color=orange ,fontsize=18, width = 0.5, height = 0.4]\n"
opr_node = "g$(id)[shape=box, label = <<b>&oplus;</b>>, style=filled, color=darkturquoise ,fontsize=18, width = 0.5, height = 0.4]\n"
# opr_name = "g$id"
end
opr_name = "g$id"
# opr_node = opr_name * "[shape=box, label = <<b>&oplus;</b>>, style=filled, fillcolor=cyan,]\n"
# opr_node = opr_name * "[shape=box, label = <<b>&oplus;</b>>, style=filled, fillcolor=lightcyan,]\n"
node_temp *= opr_node
for (gix, (g, gfactor)) in enumerate(zip(subgraphs, subgraph_factors))
if gfactor != 1
# factor_str = "factor$(g.id)_$(id)_$gix[label=$(gfactor), style=filled, fillcolor=lavender]\n"
# subg_str = "g$(g.id)_$(id)_$gix[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# subg_str = "g$(g.id)_$(id)_$gix[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# node_temp *= factor_str * subg_str
# arrow_temp *= "factor$(g.id)_$(id)_$gix->g$(g.id)_$(id)_$gix[arrowhead=vee,]\ng$(g.id)->g$(g.id)_$(id)_$gix[arrowhead=vee,]\n"
# arrow_temp *= "g$(g.id)_$(id)_$gix->$opr_name[arrowhead=vee,]\n"
Expand All @@ -144,14 +144,14 @@ function to_dotstatic(::Type{ComputationalGraphs.Prod}, id::Int, factor::F, subg
if factor != 1
# opr_fac = "factor$(id)[label=$(factor), style=filled, fillcolor=lavender]\n"
# opr_name = "g$(id)_t"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# arrow_temp *= "factor$(id)->g$(id)[arrowhead=vee,]\ng$(id)_t->g$(id)[arrowhead=vee,]\n"
# node_temp *= opr_fac * node_str
opr_node = "g$id[shape=box, label = <($factor)<b>&otimes;</b>>, style=filled, color=lightpink,fontsize=18, width = 0.8, height = 0.4]\n"
else
opr_node = "g$id[shape=box, label = <<b>&otimes;</b>>, style=filled, color=lightpink,fontsize=18, width = 0.5, height = 0.4]\n"
end
# opr_node = opr_name * "[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# opr_node = opr_name * "[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
node_temp *= opr_node
# if length(subgraphs) == 1
# if subgraph_factors[1] == 1
Expand All @@ -165,7 +165,7 @@ function to_dotstatic(::Type{ComputationalGraphs.Prod}, id::Int, factor::F, subg
for (gix, (g, gfactor)) in enumerate(zip(subgraphs, subgraph_factors))
if gfactor != 1
# factor_str = "factor$(g.id)_$(id)_$gix[label=$(gfactor), style=filled, fillcolor=lavender]\n"
# subg_str = "g$(g.id)_$(id)_$gix[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# subg_str = "g$(g.id)_$(id)_$gix[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# node_temp *= factor_str * subg_str
# arrow_temp *= "factor$(g.id)_$(id)_$gix->g$(g.id)_$(id)_$gix[arrowhead=vee,]\ng$(g.id)->g$(g.id)_$(id)_$gix[arrowhead=vee,]\n"
# arrow_temp *= "g$(g.id)_$(id)_$gix->$opr_name[arrowhead=vee,]\n"
Expand All @@ -184,7 +184,7 @@ function to_dotstatic(::Type{ComputationalGraphs.Power{N}}, id::Int, factor::F,
if factor != 1
# opr_fac = "factor$(id)[label=$(factor), style=filled, fillcolor=lavender]\n"
# opr_name = "g$(id)_t"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# node_str = "g$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# arrow_temp *= "factor$(id)->g$(id)[arrowhead=vee,]\ng$(id)_t->g$(id)[arrowhead=vee,]\n"
# node_temp *= opr_fac * node_str
opr_node = "g$id[shape=box, label = <($factor)*Pow($N)>, style=filled, fillcolor=darkolivegreen,fontsize=18, width = 1.0, height = 0.4]\n"
Expand All @@ -198,7 +198,7 @@ function to_dotstatic(::Type{ComputationalGraphs.Power{N}}, id::Int, factor::F,
# arrow_temp *= "order$(id)->$opr_name[arrowhead=vee,]\n"
if subgraph_factors[1] != 1
# factor_str = "factor$(subgraphs[1].id)_$(id)[label=$(subgraph_factors[1]), style=filled, fillcolor=lavender]\n"
# subg_str = "g$(subgraphs[1].id)_$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
# subg_str = "g$(subgraphs[1].id)_$(id)[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
# node_temp *= factor_str * subg_str
# arrow_temp *= "factor$(subgraphs[1].id)_$(id)->g$(subgraphs[1].id)_$(id)[arrowhead=vee,]\ng$(subgraphs[1].id)->g$(subgraphs[1].id)_$(id)[arrowhead=vee,]\n"
arrow_temp *= "g$(subgraphs[1].id)->$opr_name[arrowhead=vee,label=$gfactor,fontsize=16, penwidth = 0.2, arrowsize = 0.3]\n"
Expand All @@ -219,7 +219,7 @@ end
"""
function to_dot_str(graphs::AbstractVector{<:AbstractGraph}, name::String="")
head = "digraph ComputationalGraph { \nlabel=\"$name\"\n"
head *= "ReturnNode[shape=box, label = \"Return\", style=filled, color=crimson, fontsize=18]\n"
head *= "ReturnNode[shape=box, label = \"Return\", style=filled, color=wheat3, fontsize=18]\n"
body_node = ""
body_arrow = ""
leafidx = 1
Expand All @@ -238,21 +238,21 @@ function to_dot_str(graphs::AbstractVector{<:AbstractGraph}, name::String="")
g_id in inds_visitedleaf && continue
leafname = get_leafname(g, leafidx)
if factor(g) == 1
gnode_str = "g$g_id[label=<$leafname>, style=filled, color=cyan,fontsize=18]\n"
gnode_str = "g$g_id[label=<$leafname>, style=filled, color=lightcyan,fontsize=18]\n"
body_node *= gnode_str
elseif factor(g) == -1
# println("BareInteraction with -1 factor!")
# @assert typeof(g.properties) == BareInteractionId
# leafname = "<<i>-V</i><sub>$leafidx</sub>>"
# gnode_str = "g$g_id[label=$leafname, style=filled, fillcolor=paleturquoise]\n"
# body_node *= gnode_str
gnode_str = "g$g_id[label=<-$leafname>, style=filled, color=cyan,fontsize=18]\n"
gnode_str = "g$g_id[label=<-$leafname>, style=filled, color=lightcyan, fontsize=18]\n"
body_node *= gnode_str
else
# factor_str = "factor$(leafidx)_inp[label=$(factor(g)), style=filled, fillcolor=lavender]\n"
# leaf_node = "l$(leafidx)[label=$leafname, style=filled, fillcolor=paleturquoise]\n"
# gnode_str = "g$g_id[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=cornsilk,]\n"
gnode_str = "l$(leafidx)[label=<$(factor(g))$leafname>, style=filled, color=cyan,fontsize=18]\n"
# gnode_str = "g$g_id[shape=box, label = <<b>&otimes;</b>>, style=filled, fillcolor=lightcyan,]\n"
gnode_str = "l$(leafidx)[label=<$(factor(g))$leafname>, style=filled, color=lightcyan,fontsize=18]\n"
# body_node *= factor_str * leaf_node * gnode_str
# body_node *= gnode_str
# body_arrow *= "factor$(leafidx)_inp->g$g_id[arrowhead=vee,]\nl$(leafidx)->g$g_id[arrowhead=vee,]\n"
Expand Down

0 comments on commit 34565c9

Please sign in to comment.