-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bc7d35b
Showing
25 changed files
with
2,587 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
# dot files | ||
.vscode | ||
.DS_Store | ||
|
||
# bazel | ||
bazel-* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Bazel Build File For Type system | ||
|
||
|
||
cc_library( | ||
name="graph", | ||
visibility = ["//visibility:public"], | ||
hdrs=glob([ | ||
"src/**/*.h*", | ||
]), | ||
srcs=glob([ | ||
"src/**/*.c*" | ||
]), | ||
includes=[ | ||
"src" | ||
], | ||
copts = select({ | ||
"@bazel_tools//src/conditions:windows": ["/std:c++17"], | ||
"@bazel_tools//src/conditions:darwin": ["-std=c++17"], | ||
"//conditions:default": ["-std=c++17"], | ||
}), | ||
deps=[ | ||
"@stdext//:stdext", | ||
"@spdlog//:headers", | ||
] | ||
) | ||
|
||
|
||
|
||
cc_test( | ||
name = "test", | ||
srcs = glob([ | ||
"test/**/*.h*", | ||
"test/**/*.cpp" | ||
]), | ||
copts = select({ | ||
"@bazel_tools//src/conditions:windows": ["/std:c++17"], | ||
"@bazel_tools//src/conditions:darwin": ["-std=c++17"], | ||
"//conditions:default": ["-std=c++17"], | ||
}), | ||
deps = [ | ||
":graph", | ||
"@catch//:single_include", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "catch", | ||
url = "https://github.com/cgrinker/Catch2/archive/5e6488fd9949cb41d717a72c8c4603b7e37d68cd.zip", | ||
sha256 = "91e3e0610572adefa301a6e55ac48ab0a3c8ff61787ce6930e346ff36e86905c", | ||
strip_prefix = "Catch2-5e6488fd9949cb41d717a72c8c4603b7e37d68cd", | ||
) | ||
|
||
######################## | ||
# spdlog: | ||
|
||
http_archive( | ||
name = "spdlog", | ||
urls = ["https://github.com/cgrinker/spdlog/archive/3bf4a07dc286e10fa32d6503fded647c9ee02d26.zip"], | ||
strip_prefix = "spdlog-3bf4a07dc286e10fa32d6503fded647c9ee02d26", | ||
sha256 = "d00ccd202e2abae832441b9121330a4b8b82fdc60564edb315c89506fa3772c3", | ||
) | ||
|
||
######################## | ||
# stdext | ||
http_archive( | ||
name = "stdext", | ||
urls = ["https://github.com/cultlang/stdext/archive/v1.0.0.zip"], | ||
strip_prefix = "stdext-1.0.0", | ||
sha256 = "2c008ad1de4e520c2b7ef24ea6d20e677afd1cf411274cb89da7aa08e853b3f1", | ||
) | ||
|
||
######################## | ||
# Fmt | ||
http_archive( | ||
name = "fmt", | ||
urls = ["https://github.com/cgrinker/fmt/archive/f16f77297e6bb4df38d4c858edb3295f55716cb4.zip"], | ||
strip_prefix = "fmt-f16f77297e6bb4df38d4c858edb3295f55716cb4", | ||
sha256 = "edcacda20bf46be208fbc49cedee2a8a321005dd833752ccc6aa7a1a9d75dc23", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include <vector> | ||
|
||
#include "util.hpp" | ||
|
||
/* | ||
* This file contains the various minor algorithms and is laid out as follows: | ||
* | ||
* - edgeIsIncoming | ||
* - findNode | ||
* - collectEdges | ||
* - collectNodes | ||
* - copyGraph (TODO) | ||
*/ | ||
|
||
namespace graph | ||
{ | ||
template<typename TGraph> | ||
bool edgeIsIncoming(typename TGraph::Node const* n, typename TGraph::Edge const* e) | ||
{ | ||
return (e->nodes[0] != n) != TGraph::isEdgeInverted(e); | ||
} | ||
template<typename TGraph> | ||
bool edgeIsOutgoing(typename TGraph::Node const* n, typename TGraph::Edge const* e) | ||
{ | ||
return (e->nodes[0] == n) != TGraph::isEdgeInverted(e); | ||
} | ||
|
||
template<typename TGraph> | ||
typename TGraph::Node const* findNode(TGraph const& g, typename TGraph::CoreData const& v) | ||
{ | ||
typename TGraph::Node const* res = nullptr; | ||
g.forAllNodes([&](auto n) | ||
{ | ||
if (n->data == v) | ||
res = n; | ||
return n->data != v; | ||
}); | ||
return res; | ||
} | ||
|
||
template<typename TGraph, typename Func> | ||
typename std::vector<typename TGraph::Edge const*> collectEdges(TGraph const& g, typename TGraph::Node const* n, Func const& func) | ||
{ | ||
typename std::vector<typename TGraph::Edge const*> res; | ||
g.forAllEdgesOnNode(n, [&](auto e) | ||
{ | ||
if (func(e)) | ||
res.push_back(e); | ||
}); | ||
return res; | ||
} | ||
|
||
template<typename TGraph, typename Func> | ||
typename std::vector<typename TGraph::Node const*> collectNodes(TGraph const& g, typename TGraph::Edge const* e, Func const& func) | ||
{ | ||
typename std::vector<typename TGraph::Node const*> res; | ||
g.forAllNodesInEdge(e, [&](auto n) | ||
{ | ||
if (func(n)) | ||
res.push_back(n); | ||
}); | ||
return res; | ||
} | ||
|
||
template<typename TGraph> | ||
void copyGraph(TGraph& dst, TGraph const& src) | ||
{ | ||
// TODO: need a copy data-section function to copy types and other data | ||
//std::map<TGraph::Label*, TGraph::Label*> _labelMap; | ||
|
||
src.forAllLabels([&](auto l) | ||
{ | ||
dst.addLabel(l->data); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include <vector> | ||
#include <deque> | ||
|
||
/* | ||
This header only graph library has some very specific design constraints: | ||
* Highly configurable, it should be usable in a lot of circumstances. | ||
* C friendly potential. | ||
* Supports node labels, properties, and sorted n-ary edges. | ||
* Supports parent graphs, which it can override locally. | ||
* This necessitates component style storage. | ||
* Supports type based helper lookups. | ||
*/ | ||
|
||
#include "util.hpp" | ||
|
||
#include "model/core.hpp" | ||
#include "model/typed.hpp" | ||
#include "model/todo.hpp" | ||
#include "model/final.hpp" | ||
|
||
#include "algo.hpp" | ||
|
||
#include "query/engine.hpp" | ||
#include "query/query.hpp" | ||
#include "query/query_library_core.hpp" | ||
|
||
namespace graph | ||
{ | ||
template<typename TGraph, template <typename, typename> typename TGraphQueryLibrary = GraphQueryLibraryCore> | ||
GraphQuery<TGraph, TGraphQueryLibrary> query(TGraph* g) | ||
{ | ||
return GraphQuery<TGraph, TGraphQueryLibrary>(g); | ||
} | ||
} |
Oops, something went wrong.