Skip to content

Commit

Permalink
Updated ci
Browse files Browse the repository at this point in the history
  • Loading branch information
FilippoFantinato committed Sep 9, 2024
1 parent 668a82a commit aa824c3
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
}
}
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
name = "algorithms-on-graphs"
version = "0.1.0"
edition = "2021"

[dependencies]
2 changes: 1 addition & 1 deletion src/algorithms/cycles.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod is_acyclic;
pub mod is_acyclic;
15 changes: 8 additions & 7 deletions src/algorithms/cycles/is_acyclic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand All @@ -20,14 +22,13 @@ fn dfs_cycle(g: &dyn Graph, u: usize, parent: Option<usize>, visited: &mut Vec<b
let adj_list = g.get_adj_list(u);
for v in 0..adj_list.len() {
if (parent.is_none() || v != parent.unwrap()) && g.get_weight(u, v) != 0 {
if visited[v]
{
if visited[v] {
return true;
}
else
{
} else {
let cycle = dfs_cycle(g, v, Some(u), visited);
if cycle { return true; }
if cycle {
return true;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/graph.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod graph;
pub mod undirected_weighted_graph;
pub mod undirected_weighted_graph;
2 changes: 1 addition & 1 deletion src/graph/undirected_weighted_graph.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::graph::graph::Graph;

pub struct UndirectedWeightedGraph {
adj_matrix: Vec<Vec<i128>>
adj_matrix: Vec<Vec<i128>>,
}

impl Graph for UndirectedWeightedGraph {
Expand Down
8 changes: 3 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit aa824c3

Please sign in to comment.