Sequence of Operators

The sequence operators need to be used in when using CGE graph algorithms

The PRODUCING operator needs to immediately follow the INVOKE operator, which in turn needs to immediately follow the WHERE clause containing the CONSTRUCT operator. The CONSTRUCT-INVOKE-PRODUCING combination should always appear as a nested subquery inside a SELECT clause’s associated WHERE clause. Graph algorithms, like SELECT clauses themselves, can be nested arbitrarily deep in a query. Hence the sequence of operators that are involved in calling a graph algorithm is:

  1. CONSTRUCT-WHERE
  2. INVOKE
  3. PRODUCING
  4. SELECT-WHERE
Note: As mentioned earlier, the graph that is created by the CONSTRUCT clause that is part of a CONSTRUCT-INVOKE-PRODUCING combination is never produced as output of the query; it is thrown away after it is used as input to the graph algorithm. If you want to see the graph that this CONSTRUCT clause builds, you must write a separate CONSTRUCT query.

Example: Sequence of Operators

The following example illustrates the use of both spam and non-spam vertices with Bad Rank:
PREFIX cray: <http://cray.com/>
SELECT ?vertex ?ranking {
  CONSTRUCT {
   ?sub ?pred ?obj .
  } WHERE{
       {
         ?sub <http://bgf/isLinked> ?obj .
         ?sub <http://bgf/hasWeightLink> ?weightURI .
         ?obj <http://bgf/hasWeightLink> ?weightURI .
         ?weightURI <http://bgf/hasWeight> ?pred
       } UNION {
         ?sub <http://bgf/hasClassification> <http://bgf/spam> .
         BIND (<http://bgf/hasClassification> as ?pred) .
         BIND (<http://bgf/spam> as ?obj)
       } UNION {
         ?sub <http://bgf/hasClassification> <http://bgf/nonspam> .
         BIND (<http://bgf/hasClassification> as ?pred) .
         BIND (<http://bgf/nonspam> as ?obj)
       }
   }
  INVOKE cray:graphAlgorithm.badrank (0.0001, .84, 0.01,  
  <http://bgf/spam>, <http://bgf/nonspam>, <http://bgf/hasClassification>)
  PRODUCING ?vertex ?ranking
}
ORDER BY DESC (?ranking)
LIMIT 100