Skip to content

Commit f0ae687

Browse files
committed
refac: rest of docstrings, improve VTree API
Also moved datasets under `/static/`.
1 parent 5ef5794 commit f0ae687

18 files changed

+149
-183
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Cargo.lock
2020

2121
# Generated .dot files for Graphviz
2222
*.dot
23+
*.svg
2324

2425
# PGO profiling data
2526
*.profdata

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# :books: sddrs: Bottom-Up Sentential Decision Diagram Compiler
22

3-
<img align="right" width="150" height="200" src="static/sdd.svg" alt="SDD for (A ∧ B) ∨ C">
3+
<img style="display: block; margin: auto;" width="150" height="200" src="static/sdd.png" alt="SDD for (A ∧ B) ∨ C">
44

55
**Incrementally build, manipualate, and optimize
66
[Sentential Decision Diagrams (SDD)](https://en.wikipedia.org/wiki/Sentential_decision_diagram):
@@ -21,7 +21,6 @@ The compiler currently supports:
2121
* SDD compilation from CNF in
2222
[DIMACS](https://www21.in.tum.de/~lammich/2015_SS_Seminar_SAT/resources/dimacs-cnf.pdf) format
2323

24-
2524
## Usage
2625

2726
### :package: Library
@@ -48,7 +47,7 @@ fn main() {
4847
// Create right-linear vtree.
4948
.vtree_strategy(options::VTreeStragey::RightLinear)
5049
// Initialize the manager with variables A, B, and C.
51-
.variables(!arr["A", "B", "C"])
50+
.variables(["A".to_string(), "B".to_string(), "C".to_string()])
5251
.build();
5352
let manager = SddManager::new(options);
5453

sdd-rs-lib/dot_writer/dot_writer.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ impl std::fmt::Display for Edge {
1919
}
2020
}
2121

22+
/// [`DotWriter`] is responsible for drawing SDDs and vtrees
23+
/// in the .DOT Graphviz format.
2224
#[derive(Default)]
2325
pub struct DotWriter {
2426
graph_name: String,
@@ -29,19 +31,17 @@ pub struct DotWriter {
2931
}
3032

3133
#[derive(Debug)]
32-
pub enum NodeType {
33-
Box(String),
34+
pub(crate) enum NodeType {
3435
Circle(String, Option<usize>),
35-
CircleStr(String, u32),
3636
Record(String, String),
3737
}
3838

3939
impl NodeType {
4040
fn shape(&self) -> String {
4141
let shape_type = match self {
42-
NodeType::Box(_) => "box",
42+
// NodeType::Box(_) => "box",
4343
NodeType::Record(_, _) => "record",
44-
NodeType::Circle(_, _) | NodeType::CircleStr(_, _) => "circle",
44+
NodeType::Circle(_, _) => "circle",
4545
}
4646
.to_owned();
4747

@@ -55,8 +55,6 @@ impl NodeType {
5555
format!("label=<{label}>, xlabel=<<FONT POINT-SIZE=\"7\">{idx}</FONT>>, fillcolor=white, style=filled")
5656
}
5757
NodeType::Circle(label, _) => format!("label=<{label}>"),
58-
NodeType::CircleStr(label, idx) => format!("label=\"{label} ({idx})\""),
59-
NodeType::Box(_) => String::new(),
6058
}
6159
}
6260

@@ -67,19 +65,19 @@ impl NodeType {
6765

6866
impl DotWriter {
6967
#[must_use]
70-
pub fn new(graph_name: String, show_ids: bool) -> DotWriter {
68+
pub(crate) fn new(graph_name: String, show_ids: bool) -> DotWriter {
7169
DotWriter {
7270
graph_name,
7371
show_ids,
7472
..Default::default()
7573
}
7674
}
7775

78-
pub fn add_node(&mut self, node_idx: usize, node_type: NodeType) {
76+
pub(crate) fn add_node(&mut self, node_idx: usize, node_type: NodeType) {
7977
self.nodes.push((node_idx, node_type));
8078
}
8179

82-
pub fn add_edge(&mut self, edge: Edge) {
80+
pub(crate) fn add_edge(&mut self, edge: Edge) {
8381
for other in &self.edges {
8482
if *other == edge {
8583
// We have already added this edge.
@@ -92,7 +90,7 @@ impl DotWriter {
9290

9391
/// # Errors
9492
/// Function returns an error if the writing to a file or flushing fails.
95-
pub fn write(&self, writer: &mut dyn std::io::Write) -> Result<(), String> {
93+
pub(crate) fn write(&self, writer: &mut dyn std::io::Write) -> Result<(), String> {
9694
write!(
9795
writer,
9896
"digraph {} {{\n overlap=false\n ordering=out",

sdd-rs-lib/dot_writer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
mod dot_writer;
22

3-
pub use crate::dot_writer::dot_writer::*;
3+
pub(crate) use crate::dot_writer::dot_writer::*;

0 commit comments

Comments
 (0)