Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Clippy

on:
pull_request:
branches-ignore: [ "dev*" ]
tags: [ "v*.*.*" ]
push:
branches: [ "main", "master", "prod" ]
tags: ["v*.*.*"]
branches-ignore: [ "dev*" ]
tags: [ "v*.*.*" ]
release:
schedule:
- cron: '30 9 * * 5'
- cron: "30 9 * * *"
workflow_dispatch:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ env:

on:
pull_request:
branches: [ "main", "master", "prod" ]
branches-ignore: [ "dev*" ]
tags: [ "v*.*.*" ]
push:
branches: [ "main", "master", "prod" ]
branches-ignore: [ "dev*" ]
tags: [ "v*.*.*" ]
schedule:
- cron: "30 9 * * *"
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ keywords = ["algorithms", "data-structures"]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/scattered-systems/algae"
version = "0.1.18"
version = "0.1.19"

[workspace.dependencies]
decanter = { features = ["derive", "wasm"], version = "0.1.3" }
scsys = { features = [], version = "0.1.41" }
decanter = { features = ["derive", "wasm"], git = "https://github.com/FL03/decanter", branch = "v0.1.5", version = "0.1.5" }

anyhow = "1"
itertools = "0.10"
serde = { features = ["derive"], version = "1" }
serde_json = "1"
Expand Down
17 changes: 3 additions & 14 deletions algae/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,11 @@ test = true
[build-dependencies]

[dependencies]
algae-graph = { features = [], optional = true, path = "../graph", version = "0.1.18" }
algae-merkle = { features = [], optional = true, path = "../merkle", version = "0.1.18" }
algae-mmr = { features = [], optional = true, path = "../mmr", version = "0.1.18" }

decanter.workspace = true
itertools.workspace = true
scsys.workspace = true
serde.workspace = true
serde_json.workspace = true
smart-default.workspace = true
strum.workspace = true
algae-graph = { features = [], optional = true, path = "../graph", version = "0.1.19" }
algae-merkle = { features = [], optional = true, path = "../merkle", version = "0.1.19" }
algae-mmr = { features = [], optional = true, path = "../mmr", version = "0.1.19" }

[dev-dependencies]
decanter.workspace = true
hex-literal = "0.3"
vrf = "0.2"

[package.metadata.docs.rs]
all-features = true
Expand Down
94 changes: 0 additions & 94 deletions algae/tests/merkle.rs

This file was deleted.

14 changes: 11 additions & 3 deletions graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,27 @@ version.workspace = true
[features]
default = []

wasm = []

[lib]
crate-type = ["cdylib", "rlib"]

[build-dependencies]

[dev-dependencies]

[dependencies]
decanter.workspace = true
itertools.workspace = true
scsys.workspace = true
serde.workspace = true
serde_json.workspace = true
smart-default.workspace = true
strum.workspace = true

[dev-dependencies]

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]

[target.wasm32-unknown-unknown]

[target.wasm32-wasi]
50 changes: 38 additions & 12 deletions graph/src/cmp/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,60 @@
Contrib: FL03 <jo3mccain@icloud.com>
Description: an edge consists of two nodes and an optional edge value
*/
use super::{Node, Pair};
use super::Pair;
use crate::{Node, Weight};
use serde::{Deserialize, Serialize};

pub trait Related<N: Node, V> {}

#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct Edge<N: Node, V: Clone>(N, N, V);
pub struct Edge<N = String, V = i64>
where
N: Node,
V: Weight,
{
pair: Pair<N>,
weight: V,
}

impl<N: Node, V: Clone> Edge<N, V> {
pub fn new(a: N, b: N, v: V) -> Self {
Self(a, b, v)
impl<N, V> Edge<N, V>
where
N: Node,
V: Weight,
{
pub fn new(pair: Pair<N>, weight: V) -> Self {
Self { pair, weight }
}
pub fn pair(&self) -> Pair<N> {
Pair::new(self.0.clone(), self.1.clone())
self.pair.clone()
}
pub fn value(&self) -> V {
self.2.clone()
pub fn value(&self) -> &V {
&self.weight
}
}

impl<N: Node, V: Clone> From<(N, N, V)> for Edge<N, V> {
impl<N, V> From<(N, N, V)> for Edge<N, V>
where
N: Node,
V: Weight,
{
fn from(data: (N, N, V)) -> Self {
Self(data.0, data.1, data.2)
Self {
pair: Pair::new(data.0, data.1),
weight: data.2,
}
}
}

impl<N: Node, V: Clone> From<(Pair<N>, V)> for Edge<N, V> {
impl<N, V> From<(Pair<N>, V)> for Edge<N, V>
where
N: Node,
V: Weight,
{
fn from(data: (Pair<N>, V)) -> Self {
Self(data.0.0, data.0.1, data.1)
Self {
pair: data.0,
weight: data.1,
}
}
}
17 changes: 4 additions & 13 deletions graph/src/cmp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,8 @@
Contrib: FL03 <jo3mccain@icloud.com>
Description: components (cmp) for building effecient graph data-structures
*/
pub use self::{atable::*, edge::*, pair::*};
pub use self::{edge::*, neighbors::*, pair::*};

pub(crate) mod atable;
pub(crate) mod edge;
pub(crate) mod pair;

/// [Node] describes compatible vertices of the [super::Graph]
pub trait Node: Clone + Eq + std::hash::Hash {}

impl Node for char {}

impl Node for &str {}

impl Node for String {}
mod edge;
mod neighbors;
mod pair;
4 changes: 1 addition & 3 deletions mmr/src/actors/mod.rs → graph/src/cmp/neighbors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
Appellation: actors <module>
Appellation: neighbors <module>
Contrib: FL03 <jo3mccain@icloud.com>
Description: ... summary ...
*/

pub mod builders;
18 changes: 16 additions & 2 deletions graph/src/cmp/pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct Pair<T: Clone>(pub T, pub T);
pub struct Pair<T>(pub T, pub T)
where
T: Default;

impl<T: Clone> Pair<T> {
impl<T> Pair<T>
where
T: Default,
{
pub fn new(a: T, b: T) -> Self {
Self(a, b)
}
}

impl<T> From<(T, T)> for Pair<T>
where
T: Default,
{
fn from(data: (T, T)) -> Self {
Self(data.0, data.1)
}
}
Loading