Skip to content

Commit

Permalink
Add initial version of gfd validation
Browse files Browse the repository at this point in the history
Algorithm for checking if a graph functional dependency
satisfies a given graph.
The primitive interface has not yet been implemented, there is
no reading data from a file, graphs are not from the boost lib.
  • Loading branch information
AntonChern committed Nov 29, 2022
1 parent 89ef452 commit d14534e
Show file tree
Hide file tree
Showing 15 changed files with 1,055 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ include_directories(SYSTEM "lib/easyloggingpp/src" "lib/better-enums/")

# adding submodules
add_subdirectory("lib/googletest")
add_subdirectory("lib/eigen")

set( CMAKE_BUILD_TYPE_COPY "${CMAKE_BUILD_TYPE}" )
set( CMAKE_BUILD_TYPE "Release" )
Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cd lib
git clone https://github.com/google/googletest/ --branch release-1.10.0
git clone https://github.com/amrayn/easyloggingpp/ --branch v9.97.0
git clone https://github.com/aantron/better-enums.git --branch 0.11.3
git clone https://github.com/libigl/eigen
cd ..
mkdir build
cd build
Expand Down
Binary file modified datasets/datasets.zip
Binary file not shown.
12 changes: 12 additions & 0 deletions src/algorithms/gfd/const_literal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once
#include "literal.h"

class ConstLiteral : public Literal {
public:
ConstLiteral(std::pair<int, std::string> node, std::string value) {
this->vars.push_back(node.first);

this->values.push_back(node.second);
this->values.push_back(value);
}
};
33 changes: 33 additions & 0 deletions src/algorithms/gfd/gfd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>

#include "gfd.h"

void GFD::print() const {
this->pattern.print();
std::cout << std::endl << "Premises: ";
for (const Literal& l : this->premises) {
std::vector<int> vars = l.getVars();
std::vector<std::string> values = l.getValues();
if (vars.size() == 1) {
// ConstLiteral
std::cout << vars.at(0) << "." << values.at(0) << "=" << values.at(1) << "; ";
} else {
// VarLiteral
std::cout << vars.at(0) << "." << values.at(0) << "="
<< vars.at(1) << "." << values.at(1) << "; ";
}
}
std::cout << std::endl << "=>" << std::endl << "Conclusion: ";
for (const Literal& l : this->conclusion) {
std::vector<int> vars = l.getVars();
std::vector<std::string> values = l.getValues();
if (vars.size() == 1) {
// ConstLiteral
std::cout << vars.at(0) << "." << values.at(0) << "=" << values.at(1) << "; ";
} else {
// VarLiteral
std::cout << vars.at(0) << "." << values.at(0) << "="
<< vars.at(1) << "." << values.at(1) << "; ";
}
}
}
20 changes: 20 additions & 0 deletions src/algorithms/gfd/gfd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include <vector>

#include "pattern.h"
#include "literal.h"

class GFD {
private:
Pattern pattern;
std::vector<Literal> premises;
std::vector<Literal> conclusion;
public:
GFD(Pattern& pattern_, std::vector<Literal>& premises_, std::vector<Literal>& conclusion_) : pattern(pattern_), premises(premises_), conclusion(conclusion_) {}

Pattern getPattern() const { return this->pattern; }
std::vector<Literal> getPremises() const { return this->premises; }
std::vector<Literal> getConclusion() const { return this->conclusion; }

void print() const;
};
Loading

0 comments on commit d14534e

Please sign in to comment.