Hi all,

I successfully use core.logic to query a custom Java graph structure.
That is, I have these core relations:

,----
| (typeo g e t)
| e is a vertex or edge of graph g with type t
| 
| (vertexo g v)
| v is a vertex of graph g
| 
| (edgeo g e s t)
| e is an edge of graph g starting at vertex s and targeting t
| 
| (valueo g e a v)
| e is a vertex or edge of graph g whose a-attribute has the value v
`----

The graph arg g always needs to be ground.  That works like a charm, and
I can query like

,----
| (let [g (gimme-my-graph)]
|   (run* [q]
|     (fresh [v e ov]
|       (typeo g v 'Bar)
|       (vertexo g v)
|       (valueo g v :name "Foo")
|       (typeo g e 'Bar2Baz)
|       (edgeo g e v ov)
|       (valueo c ov :bar 17)
|       (== q [v e ov])))
`----

resulting in a seq of triples where v is a Bar-vertex with name Foo, ov
is a vertex with bar set to 17, and e is a Bar2Baz-edge starting at v
and ending at ov.  So far, so good.

Now I'd also like to have some "non-strict" querying mode (enabled by
binding some dynamic var).  Using the example above: Say, the graph g
has vertices v and ov matching the goals above, but there're no Bar2Baz
edges in between, I envision that the query would return triples [v e
ov] where v and ov are matching vertices, and e is some synthetic
deftype-instance (?) that exibits the properties such an edge would need
to posses, e.g., its type must be Bar2Baz, and it needs to start at v
and end at ov.

Any ideas and pointers how to implement that?

I think this should be doable with a deftype with mutable fields.  Then
my relations would emit a final instance of this type (or modify a given
instance) with the known properties set (e.g., typeo sets the type
field, vertexo sets the kind fild to vertex, valueo sets an entry of
some attributes map, etc).

However, that doesn't sound very clean, and it'll probably be overly
complicated, because every relation needs to check every arg for being
ground and synthetical or "real" with tons of distinctions on
handling...

Bye,
Tassilo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to