sampo.userinput.parser.general_build#

Overview#

Classes#

Graph

-

Function#

break_loops_in_input_graph(works_info)

Eliminate all cycles in received work graph. Algo breaks cycle by removing edge with the lowest weight

fix_df_column_with_arrays(column, cast, none_elem)

-

preprocess_graph_df(frame)

-

add_graph_info(frame)

-

topsort_graph_df(frame)

Sort DataFrame of works in topological order

build_work_graph(frame, resource_names)

-

get_graph_contractors(path, contractor_name)

-

Attributes#

UNKNOWN_CONN_TYPE

-

NONE_ELEM

-

Classes#

class sampo.userinput.parser.general_build.Graph#
add_edge(u, v, weight=None)#
dfs_cycle(u, visited)#
find_cycle()#
eliminate_cycle(cycle)#
eliminate_cycles(eliminate_cycle: bool = True) list | None#

Functions#

sampo.userinput.parser.general_build.break_loops_in_input_graph(works_info: pandas.DataFrame) pandas.DataFrame#

Eliminate all cycles in received work graph. Algo breaks cycle by removing edge with the lowest weight (e.x. frequency of occurrence of the link in historical data).

Parameters:

works_info – given work info

Returns:

work info without cycles

sampo.userinput.parser.general_build.fix_df_column_with_arrays(column: pandas.Series, cast: Callable[[str], Any] | None = str, none_elem: Any | None = NONE_ELEM) pandas.Series#
sampo.userinput.parser.general_build.preprocess_graph_df(frame: pandas.DataFrame) pandas.DataFrame#
sampo.userinput.parser.general_build.add_graph_info(frame: pandas.DataFrame) pandas.DataFrame#
sampo.userinput.parser.general_build.topsort_graph_df(frame: pandas.DataFrame) pandas.DataFrame#

Sort DataFrame of works in topological order

Parameters:

frame – DataFrame of works

Returns:

topologically sorted DataFrame

sampo.userinput.parser.general_build.build_work_graph(frame: pandas.DataFrame, resource_names: list[str]) sampo.schemas.graph.WorkGraph#
sampo.userinput.parser.general_build.get_graph_contractors(path: str, contractor_name: str | None = 'ООО "***"')#

Attributes#

sampo.userinput.parser.general_build.UNKNOWN_CONN_TYPE = 0#
sampo.userinput.parser.general_build.NONE_ELEM = '-1'#