Tails method query

37 views
Skip to first unread message

Aethelred

unread,
Mar 5, 2014, 2:05:13 PM3/5/14
to spar...@googlegroups.com
Hi,

For my research, I am developing a declarative graph query language.

I need to obtain the list of nodes which have outgoing edges of a set of edge types known only at runtime; i.e. I need the tails of all edges having a type in one of {sector_edge_type, level_edge_type} (as an example).

From the documentation, the Tails method appears to return exactly what I need. 

I am creating the required "Objects" object, to be passed in as a parameter to Tails, as follows:

===================
public static Objects GetDEXEdgeTypes(List<char> elist)     //e.g. (elist contains "sector" and "level")
        {
            Objects edges = _Session.NewObjects();

            foreach (char e in elist)
                edges.Add(long.Parse(_Graph.FindType(e.ToString()).ToString()));

            return edges;
        }
===================

The method above works fine, but when I actually invoke Tails**, passing in the Objects object obtained from GetDEXEdgeTypes, it fails with a ": [SPARKSEE: 12] Invalid object identifier." error. 

**The code is: 
===========================
Objects tailNodes = DEXManager.Graph.Tails(DEXManager.GetDEXEdgeTypes(labels));
==============================

I had previously populated Objects with *integers* rather than *longs*, but the same error occurred. The documentation appears to infer that longs are needed, hence the cast.

I have looked extensively at the documentation, but have not had any success. 

Please could you advise where I am going wrong?

Many thanks,
Petra

Aethelred

unread,
Mar 5, 2014, 6:11:05 PM3/5/14
to spar...@googlegroups.com
Hi

I have just realised, after careful re-reading of the documentation, that Tails requires a collection of edge IDs as opposed to edge types - this is where my error lies.

My question is therefore whether it is possible to obtain all node IDs having certain outgoing edge types only (as I only know the edge types at runtime). Looking through the API, it does not seem like there is anything which would do this outright, but I would very much appreciate to have this confirmed as the case.

Many thanks
Petra

c3po.ac

unread,
Mar 6, 2014, 4:40:24 AM3/6/14
to spar...@googlegroups.com
Hi,

We currently don't have the api method that you need, but we may consider adding it in the future.
You could do this:

For each edge type in the set

  • Get all the edges from that type with this method:
public Objects select(int type)

  • And then use the Tails method on that Objects:
public Objects tails(Objects edges)

  • Finally you just need to use the union (or combineUnion) Objects method to join the resulting Objects got from each edge type.

Another option could be to join all the edge identifiers (from calling the select as many times as edge types) first and only call tails once. I think that the first option may be better, but both should take similar time.

Best regards.

El dijous 6 de març de 2014 0:11:05 UTC+1, Aethelred va escriure:

Aethelred

unread,
Mar 6, 2014, 7:18:11 AM3/6/14
to spar...@googlegroups.com
Hi

Thanks very much for the info - I will use the first method you described.

Best wishes
Petra 
Reply all
Reply to author
Forward
0 new messages