# -*- coding: utf-8 -*-
"""PyRGG params."""
from textwrap import dedent, fill
import os

PYRGG_VERSION = "2.0"

os.environ["PYRGG_TEST_MODE"] = "0"

MENU_ITEMS = {
    1: ["engine", dedent(
        """\
        - Select generation engine :
        1- PyRGG
        2- Erdos-Renyi-Gilbert - G(n, p)
        3- Erdos-Renyi - G(n, m)
        4- Stochastic Block Model - G(C, P)
        5- Barabasi-Albert - G(n, k)
        6- Watts-Strogatz - G(n, k, p)
        7- Random Geometric Graph - G(d, r)
        """
    )],
    2: ["file_name", "- File Name (Not Empty) : "],
    3: ["number_of_files", "- Number of Files (>=0) : "],
    4: ["output_format", dedent(
        """\
        - Graph Formats :
        1- DIMACS(.gr)
        2- JSON(.json)
        3- CSV(.csv)
        4- YAML(.yaml)
        5- WEL(.wel)
        6- ASP(.lp)
        7- Pickle(.p)
        8- UCINET DL(.dl)
        9- TGF(.tgf)
        10- TSV(.tsv)
        11- Matrix Market(.mtx)
        12- Graph Line(.gl)
        13- GDF(.gdf)
        14- GML(.gml)
        15- GEXF(.gexf)
        16- DOT(.gv)
        """
    )],
    5: ["config", "- Save Config[1] or Not[0]"],
}

SUFFIX_MENU = {
    1: ".gr",
    2: ".json",
    3: ".csv",
    4: ".yaml",
    5: ".wel",
    6: ".lp",
    7: ".p",
    8: ".dl",
    9: ".tgf",
    10: ".tsv",
    11: ".mtx",
    12: ".gl",
    13: ".gdf",
    14: ".gml",
    15: ".gexf",
    16: ".gv"
}

ENGINE_MENU = {
    1: "pyrgg",
    2: "erg",
    3: "er",
    4: "sbm",
    5: "ba",
    6: "ws",
    7: "gg",
}

ENGINE_MENU_INV = {v: k for k, v in ENGINE_MENU.items()}

PYRGG_ENGINE_PARAMS = {
    1: ["vertices", "- Vertices Number (n >= 0) : "],
    2: ["min_edges", "- Min Edge Number - Connected to Each Vertex (>=0) : "],
    3: ["max_edges", "- Max Edge Number - Connected to Each Vertex (>=0) : "],
    4: ["weight", "- Unweighted[0] or Weighted[1]"],
    5: ["min_weight", "- Min Weight : "],
    6: ["max_weight", "- Max Weight : "],
    7: ["sign", "- Unsigned[0] or Signed[1]"],
    8: ["direct", "- Undirected[0] or Directed[1]"],
    9: ["self_loop", "- No Self Loop[0] or Self Loop[1]"],
    10: ["multigraph", "- Simple[0] or Multigraph[1]"],
}

ERG_ENGINE_PARAMS = {
    1: ["vertices", "- Vertices Number (n >= 0) : "],
    2: ["probability", "- Probability (0 <= p <= 1) : "],
    3: ["direct", "- Undirected[0] or Directed[1]"],
}

ER_ENGINE_PARAMS = {
    1: ["vertices", "- Vertices Number (n >= 0) : "],
    2: ["edge_number", "- Edge Number (m >= 0) : "],
    3: ["direct", "- Undirected[0] or Directed[1]"],
}

SBM_ENGINE_PARAMS = {
    1: ["vertices", "- Vertices Number (n >= 0) : "],
    2: ["blocks", "- Blocks Number (k >= 0) : "],
    3: ["intra_probability", "- Within Block Probability (0 <= p <= 1): "],
    4: ["inter_probability", "- Between Block Probability (0 <= p <= 1): "],
    5: ["direct", "- Undirected[0] or Directed[1]"],
    6: ["self_loop", "- No Self Loop[0] or Self Loop[1]"],
}

BA_ENGINE_PARAMS = {
    1: ["vertices", "- Vertices Number (n >= 0) : "],
    2: ["attaching_edge_number", "- Number of Edges to Attach to a New Node (0 < k < n) : "],
}

WS_ENGINE_PARAMS = {
    1: ["vertices", "- Vertices Number (n >= 0) : "],
    2: ["mean_degree", "- Mean Degree (should be a positive even number) : "],
    3: ["rewiring_probability", "- Rewiring Probability (0 <= p <= 1) : "],
}

GG_ENGINE_PARAMS = {
    1: ["vertices", "- Vertices Number (n >= 0) : "],
    2: ["space_dimension", "- The space dimension (d > 0) : "],
    3: ["cutoff_threshold", "- Cutoff threshold distance (0 <= r <= 1) : "],
}

ENGINE_PARAM_MAP = {
    1: PYRGG_ENGINE_PARAMS,
    2: ERG_ENGINE_PARAMS,
    3: ER_ENGINE_PARAMS,
    4: SBM_ENGINE_PARAMS,
    5: BA_ENGINE_PARAMS,
    6: WS_ENGINE_PARAMS,
    7: GG_ENGINE_PARAMS,
}

OUTPUT_FORMAT = {i: output_format[1:].upper()
                 for i, output_format in SUFFIX_MENU.items()}

OUTPUT_FORMAT_INV = {v: k for k, v in OUTPUT_FORMAT.items()}


SOURCE_DIR = os.getcwd()

CONFIG_FILE_FORMAT = "{file_name}.pyrgg.config.json"

PYRGG_LINKS = """
Webpage : https://www.pyrgg.site
Repository : https://github.com/sepandhaghighi/pyrgg
Paper : https://doi.org/10.21105/joss.00331
* If you use PyRGG in your research, please cite our paper
"""

_description = """\
PyRGG is a user-friendly synthetic random graph generator that is written in Python and supports multiple graph file formats, such as DIMACS-Graph files.
It can generate graphs of various sizes and is specifically designed to create input files for a wide range of graph-based research applications, including testing,
benchmarking, and performance analysis of graph processing frameworks.
PyRGG is aimed at computer scientists who are studying graph algorithms and graph processing frameworks.
"""

PYRGG_DESCRIPTION = fill(_description, width=113)

PYRGG_INPUT_ERROR_MESSAGE = "[Error] Bad input!"

PYRGG_FILE_ERROR_MESSAGE = "[Error] Bad input file!"

PYRGG_INVALID_ENGINE_ERROR_MESSAGE = "[Error] Invalid engine!"

PYRGG_YAML_ERROR_MESSAGE = "[Error] Failed to generate YAML file!"

PYRGG_PICKLE_ERROR_MESSAGE = "[Error] Failed to generate Pickle file!"

PYRGG_LOGGER_ERROR_MESSAGE = "[Error] Logger failed!"

PYRGG_CONFIG_LOAD_ERROR_MESSAGE = "[Error] Failed to load config file!"

PYRGG_CONFIG_SAVE_ERROR_MESSAGE = "[Error] Failed to save config file!"

PYRGG_UNDIVISIBLE_WARNING_MESSAGE = "[Warning] Number of vertices is not divisible by the number of blocks. The last block would contain the remainder."

PYRGG_SBM_WARNING_MESSAGE = "[Warning] Stochastic block model gets the number of blocks and between/within block probabilities. To get more detailed configuration, please save and edit the config file."

PYRGG_CONFIG_LIST_MESSAGE = "Config files detected in the current directory are listed below:"

PYRGG_CONFIG_LOAD_MESSAGE = "Press the config index to load or any other keys to start with the new one:"

DIMACS_FIX = dedent(
    """\
    c FILE                  :{file_name}.gr
    c No. of vertices       :{vertices_number}
    c No. of edges          :{edge_number}
    c Max. weight           :{max_weight}
    c Min. weight           :{min_weight}
    p sp {vertices_number} {edge_number}
    """
)
