From db12045421f9822b7882a595f1091640cd9936e3 Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Fri, 28 Nov 2025 21:43:10 +0300 Subject: [PATCH 1/5] =?UTF-8?q?=D0=A2=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests_graph.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/tests_graph.yml diff --git a/.github/workflows/tests_graph.yml b/.github/workflows/tests_graph.yml new file mode 100644 index 0000000..28d2755 --- /dev/null +++ b/.github/workflows/tests_graph.yml @@ -0,0 +1,33 @@ +sname: Python application + +on: [push] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.13 + uses: actions/setup-python@v3 + with: + python-version: "3.13" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + pip install hypothesis + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest \ No newline at end of file From 6e1926e6cdf3b6d7c9bd45cbd73d234bb86a777e Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Fri, 28 Nov 2025 21:45:10 +0300 Subject: [PATCH 2/5] =?UTF-8?q?dfs=20=D0=B8=20=D1=82=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D1=8B=20=D0=B4=D0=BB=D1=8F=20=D0=BD=D0=B5=D0=B3=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw_10/dfs.py | 39 +++++++++++++++++++++++++++++++++++++ hw_10/tempCodeRunnerFile.py | 1 + hw_10/test_dfs.py | 11 +++++++++++ 3 files changed, 51 insertions(+) create mode 100644 hw_10/dfs.py create mode 100644 hw_10/tempCodeRunnerFile.py create mode 100644 hw_10/test_dfs.py diff --git a/hw_10/dfs.py b/hw_10/dfs.py new file mode 100644 index 0000000..a8d09bc --- /dev/null +++ b/hw_10/dfs.py @@ -0,0 +1,39 @@ +class Graph: + def __init__(self, vertices: list[int], edges: list[tuple[int, int]]) -> None: + self.vertices = vertices + self.edges = edges + self.visited_order = [] + + def __iter__(self): + if not self.visited_order: + self.dfs() + return iter(self.visited_order) + + def dfs(self) -> list[int]: + states = {"w": [v for v in self.vertices], "g": list(), "b": list()} + + def dfs_step(vertex): + if vertex in states["w"]: + states["g"].append(vertex) + states["w"].remove(vertex) + for edge in self.edges: + if edge[0] == vertex: + dfs_step(edge[1]) + if edge[1] == vertex: + dfs_step(edge[0]) + + for vertex in self.vertices: + dfs_step(vertex) + + self.visited_order = states["g"] + return self.visited_order + + +g = Graph([1, 2, 3], [(1, 3), (2, 3), (2, 1)]) + +a = g.dfs() +b = list(iter(g)) +print(a, b) + + + diff --git a/hw_10/tempCodeRunnerFile.py b/hw_10/tempCodeRunnerFile.py new file mode 100644 index 0000000..0095cbc --- /dev/null +++ b/hw_10/tempCodeRunnerFile.py @@ -0,0 +1 @@ +1, \ No newline at end of file diff --git a/hw_10/test_dfs.py b/hw_10/test_dfs.py new file mode 100644 index 0000000..609f781 --- /dev/null +++ b/hw_10/test_dfs.py @@ -0,0 +1,11 @@ +from dfs import Graph + +graph = Graph([1, 2, 3], [(1, 3), (2, 3), (2, 1)]) + +def test_1(): + g = graph.dfs() + assert g == [1, 3, 2] + +def test_2(): + g = list(iter(graph)) + assert g == [1, 3, 2] \ No newline at end of file From 709f96959b76fbfe95a8f046fe25ccf4c4f62a57 Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Fri, 28 Nov 2025 21:48:42 +0300 Subject: [PATCH 3/5] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20temp?= =?UTF-8?q?CodeRunnerFile.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw_10/tempCodeRunnerFile.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 hw_10/tempCodeRunnerFile.py diff --git a/hw_10/tempCodeRunnerFile.py b/hw_10/tempCodeRunnerFile.py deleted file mode 100644 index 0095cbc..0000000 --- a/hw_10/tempCodeRunnerFile.py +++ /dev/null @@ -1 +0,0 @@ -1, \ No newline at end of file From e388f64f096c139251dd5beb915f9510ab402eec Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Fri, 28 Nov 2025 21:55:12 +0300 Subject: [PATCH 4/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB?= =?UTF-8?q?=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20tests=5Fg?= =?UTF-8?q?raph.yml=20=D0=BD=D0=B0=20run=5Ftests.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/tests_graph.yml => .githab/workflows/run_tests.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/tests_graph.yml => .githab/workflows/run_tests.yml (100%) diff --git a/.github/workflows/tests_graph.yml b/.githab/workflows/run_tests.yml similarity index 100% rename from .github/workflows/tests_graph.yml rename to .githab/workflows/run_tests.yml From 0589e1925a3445cb44b28a2b9db9f833362a554c Mon Sep 17 00:00:00 2001 From: Andrew-Kochanov Date: Sat, 6 Dec 2025 14:43:46 +0300 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=20=D0=B4=D0=BB=D1=8F=20CI,=20=D1=87?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D1=8B=20=D0=BE=D0=BD=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .githab/workflows/run_tests.yml | 33 --------------------------------- .github/workflows/run_tests.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 33 deletions(-) delete mode 100644 .githab/workflows/run_tests.yml create mode 100644 .github/workflows/run_tests.yml diff --git a/.githab/workflows/run_tests.yml b/.githab/workflows/run_tests.yml deleted file mode 100644 index 28d2755..0000000 --- a/.githab/workflows/run_tests.yml +++ /dev/null @@ -1,33 +0,0 @@ -sname: Python application - -on: [push] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.13 - uses: actions/setup-python@v3 - with: - python-version: "3.13" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - pip install hypothesis - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest \ No newline at end of file diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml new file mode 100644 index 0000000..0695e93 --- /dev/null +++ b/.github/workflows/run_tests.yml @@ -0,0 +1,29 @@ +name: Python application + +on: [push] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.13 + uses: actions/setup-python@v3 + with: + python-version: "3.13" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ruff + pip install pytest + - name: Lint with ruff + run: | + ruff check --output-format=github + - name: Test with pytest + run: | + pytest \ No newline at end of file