From aa824c313d0d1a91cfe6ce7b89121bc6faf7b77c Mon Sep 17 00:00:00 2001 From: FilippoFantinato Date: Mon, 9 Sep 2024 16:48:57 +0200 Subject: [PATCH] Updated ci --- .github/workflows/build.yml | 4 ++++ .vscode/settings.json | 6 ++++++ Cargo.toml | 2 -- src/algorithms/cycles.rs | 2 +- src/algorithms/cycles/is_acyclic.rs | 15 ++++++++------- src/graph.rs | 2 +- src/graph/undirected_weighted_graph.rs | 2 +- src/main.rs | 8 +++----- 8 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78813bd..4ed4730 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,8 +17,12 @@ jobs: uses: actions/checkout@v4 - name: rust-toolchain uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt - name: cache uses: Swatinem/rust-cache@v2 + - name: iinstall tarpaulin + run: cargo install cargo-tarpaulin - name: Build run: cargo build --verbose - name: Run tests and code coverage diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0196fd7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer", + "editor.formatOnSave": true + } +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 64fdb72..3cf6c37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,5 +2,3 @@ name = "algorithms-on-graphs" version = "0.1.0" edition = "2021" - -[dependencies] diff --git a/src/algorithms/cycles.rs b/src/algorithms/cycles.rs index 5ea2436..db61025 100644 --- a/src/algorithms/cycles.rs +++ b/src/algorithms/cycles.rs @@ -1 +1 @@ -pub mod is_acyclic; \ No newline at end of file +pub mod is_acyclic; diff --git a/src/algorithms/cycles/is_acyclic.rs b/src/algorithms/cycles/is_acyclic.rs index caef881..1fb61dc 100644 --- a/src/algorithms/cycles/is_acyclic.rs +++ b/src/algorithms/cycles/is_acyclic.rs @@ -7,7 +7,9 @@ pub fn is_acyclic(g: &dyn Graph, start: usize) -> bool { if !visited[u] { let cycle = dfs_cycle(g, start, None, &mut visited); - if cycle { return false; } + if cycle { + return false; + } } } @@ -20,14 +22,13 @@ fn dfs_cycle(g: &dyn Graph, u: usize, parent: Option, visited: &mut Vec> + adj_matrix: Vec>, } impl Graph for UndirectedWeightedGraph { diff --git a/src/main.rs b/src/main.rs index 3a1cb37..15e9d62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,9 @@ -mod graph; mod algorithms; +mod graph; +use crate::algorithms::cycles::is_acyclic::is_acyclic; use crate::graph::graph::Graph; use crate::graph::undirected_weighted_graph::UndirectedWeightedGraph; -use crate::algorithms::cycles::is_acyclic::is_acyclic; use std::collections::VecDeque; -fn main() { - -} +fn main() {}