diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..0b75d7e6fb38a139d5a2ca02cbaba830b1287d26 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,38 @@ +# This file is a template, and might need editing before it works on your project. +# To contribute improvements to CI/CD templates, please follow the Development guide at: +# https://docs.gitlab.com/ee/development/cicd/templates.html +# This specific template is located at: +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml + +# This is a sample GitLab CI/CD configuration file that should run without any modifications. +# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts, +# it uses echo commands to simulate the pipeline execution. +# +# A pipeline is composed of independent jobs that run scripts, grouped into stages. +# Stages run in sequential order, but jobs within stages run in parallel. +# +# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages + +# image: registry.forge.uclouvain.be/inl/containers/runner-python + +stages: # List of stages for jobs, and their order of execution + - test + +variables: + GOUTPUT: graph_test.bin + ROUTPUT: out_test.bin + +test-job: # This job runs in the test stage. + stage: test + script: + - echo "Running unit tests..." + - python3 create_graph.py --ntf sample_ntf/small.ntf --output $GOUTPUT + - python3 sp.py -f $ROUTPUT $GOUTPUT + - python3 verify_output.py $ROUTPUT + only: + - main + artifacts: + paths: + - $GOUTPUT + - $ROUTPUT + diff --git a/create_graph.py b/create_graph.py old mode 100644 new mode 100755 diff --git a/sample_ntf/small.ntf b/sample_ntf/small.ntf new file mode 100644 index 0000000000000000000000000000000000000000..eb10462b6a0470f4b3a2c7c7b26b67b3d2b2e15a --- /dev/null +++ b/sample_ntf/small.ntf @@ -0,0 +1,4 @@ +0 1 1 +1 0 4 +0 2 -1 +2 1 9 \ No newline at end of file diff --git a/sp.py b/sp.py old mode 100644 new mode 100755 index 56d20464eb6bf268d7afdc79d0984bbff3556367..b3ddaa499c976186ded057ed8926f6df8b3327f7 --- a/sp.py +++ b/sp.py @@ -104,7 +104,7 @@ def read_graph(filename): l1 = [from_node, to_node, cost] links.append(l1) - return links + return links, nb_nodes if __name__ == "__main__": @@ -128,9 +128,14 @@ if __name__ == "__main__": # Exemple de message que vous pouvez ecrire si le mode verbose est actif. print(args, file=sys.stderr) - graph = read_graph(args.input_file) + graph, nb_nodes = read_graph(args.input_file) + if output_fd == sys.stdout or output_fd == sys.stderr: + print("Nombre de noeuds: " + str(nb_nodes)) + else: + output_fd.write(nb_nodes.to_bytes(4, "big")) + for source in range(nb_nodes): - dist, path = bellman_ford(graph, source) + dist, path = bellman_ford(graph, source, verbose) # Ces messages ne sont pas des messages de debug. # Ils peuvent donc etre affiches (uniquement si la sortie choisie est stdout ou stderr) @@ -147,8 +152,8 @@ if __name__ == "__main__": else: output_fd.write(source.to_bytes(4, "big")) d, n = get_max(dist, source) - output_fd.write(d.to_bytes(4, "big", signed=True)) output_fd.write(n.to_bytes(4, "big")) + output_fd.write(d.to_bytes(8, "big", signed=True)) r = get_path(n, path, source) output_fd.write(len(r).to_bytes(4, "big", signed=True)) for j in range(len(r)): diff --git a/verify_output.py b/verify_output.py old mode 100644 new mode 100755 diff --git a/visualize_graph.py b/visualize_graph.py old mode 100644 new mode 100755