Skip to content
Snippets Groups Projects
Commit 70cc7ace authored by Robotka István Adrián's avatar Robotka István Adrián
Browse files

rename to er-graph

parent c7d8b897
No related branches found
No related tags found
No related merge requests found
Showing
with 9 additions and 120 deletions
.*
!.git*
.idea/
.gradle/
build/
gradle/
File moved
File moved
File moved
File moved
db/
#!/bin/bash
docker_cmd=docker
# use podman if possible
command -v podman >/dev/null 2>&1 && docker_cmd=podman
console() {
$docker_cmd exec -i grakn-srv \
/grakn-core-all-linux/grakn console $*
}
db() {
console --keyspace sch $*
}
wipe() {
echo 'keyspace delete sch' | console
}
###
wipe
db --file /data/schema.gql
#db --file /data/data.gql
#!/bin/sh
docker_cmd=docker
# use podman if possible
command -v podman >/dev/null 2>&1 && docker_cmd=podman
$docker_cmd exec -it grakn-srv \
/grakn-core-all-linux/grakn console $*
define
################
## Attributes ##
################
label sub attribute,
value string;
annotation sub attribute,
value string;
identifier sub label;
name sub label;
nick sub label;
#fqdn sub label;
#ip sub label;
operating-system sub annotation,
regex "^(linux|ios|windows)$";
number sub annotation;
color sub annotation;
cableLabel sub annotation;
################
## Entities ##
################
abstractInfraItem sub entity, abstract,
key identifier,
has name,
plays container,
plays containee;
node sub abstractInfraItem,
has nick,
has operating-system;
port sub abstractInfraItem,
has number;
# TODO check out https://docs.grakn.ai/docs/schema/concepts#define-a-relation-to-play-a-role
cable sub abstractInfraItem,
has color,
has cableLabel;
################
## Realtions ##
################
containment sub relation,
relates container,
relates containee;
hasPort sub containment;
################
## Rules ##
################
nodes-has-ports sub rule,
when {
$a isa node;
$b isa port;
}, then {
(container: $a, containee: $b) isa hasPort;
};
version: "3.4"
services:
grakn:
container_name: grakn-srv
image: graknlabs/grakn:1.8.4
volumes:
- ./:/app
- ./data:/data
- ./db:/grakn-core-all-linux/server/db/
ports:
- 127.0.0.1:48555:48555
rootProject.name = "moder"
rootProject.name = "er-graph"
......@@ -17,13 +17,11 @@ fun Entity.traverse(
terminals: Set<KClass<out Entity>>
): Set<Entity> {
// TODO exception on loop
val visited = mutableSetOf<Entity>() // to prevent loop
val output = mutableSetOf<Entity>()
val queue = mutableListOf(this) // to visit still
val visited = mutableSetOf<Entity>() // prevents loop
val queue = mutableListOf(this)
while (queue.isNotEmpty()) {
val entityIter = queue.removeLast()
visited.add(entityIter)
output.add(entityIter)
if (terminals.terminatesIn(entityIter))
continue
......@@ -34,7 +32,7 @@ fun Entity.traverse(
relatives.filter { !visited.contains(it) }
)
}
return output
return visited
}
private fun Entity.allowedRelatives(allowedPath: Set<KClass<out Relation>>): Map<Relation, Entity> =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment