using CSV
using DataFrames
using Plots
using StatsPlots
using LaTeXStrings

if (length(ARGS) < 2)
    println("Please use with \"input_file.csv\" \"input_file_onesided.csv\"")
end

function proc_to_n(str::AbstractString)
    parts = split(str, "->")
    k_count = count(c -> c == 'k', parts[2])
    return k_count
end

input_file = ARGS[1]
input_file_onesided = ARGS[2]
df = CSV.read(input_file, DataFrame)
df2 = CSV.read(input_file_onesided, DataFrame)


df_filt = filter(:process_name => x -> proc_to_n(x) >= 1, df)
df_filt.process_size = @. proc_to_n(df_filt.process_name)

df_filt2 = filter(:process_name => x -> proc_to_n(x) >= 1, df2)
df_filt2.process_size = @. proc_to_n(df_filt2.process_name)


# graph size
title_string = "n-photon Compton reduced graph size"

@df df_filt scatter(:process_size, :graph_nodes_reduced, label = "nodes, two-sided generation", markershape = :circle)
@df df_filt2 scatter!(:process_size, :graph_nodes_reduced, label = "nodes, one-sided generation", markershape = :square)

plot!(
    title = title_string,
    yscale = :log10,
    legend = :outerbottom,
    yminorgrid = true,
    xticks = :process_size,
    yticks = [1e1, 1e2, 1e3, 1e4, 1e5, 1e6],
    xgrid = false,
    xminorticks = false,
    legendcolumns = 2,
    legend_font_pointsize = 10,
    size = (800, 600),
    ylabel = "(#)",
    xlabel = "process size (#)",
)

savefig("compton_diagram_gen_comparison.pdf")
