How to add "labels" to SPARQL output

Dear SPARQL gurus,
I have a graph, composed by nodes and link joining them, represented as 
triples. Now for a specific node I want to list the nodes that are 
pointed FROM the given node or that point TO the given node. This is easy:

SELECT  ?node_in ?node_out
WHERE {

 ?central_node a <node> ;
  <id> 123 .
 {
  [] <output_node_link> ?central_node ;
     <input_node_link> ?node_in .
 }
 UNION
 {
  [] <input_node_link> ?central_node ;
     <output_node_link> ?node_out .
 }
}

My question: instead of having two columns to distinguish linked node as 
IN or OUT, is it possible to have a single ?node_related column and a 
variable that says "IN" or "OUT"?

I think I have to put before my query a CONSTRUCT that adds this field 
to the related nodes, but I don't know if this field could be defined 
"temporary" and does not modify the db content.

Thanks for your help!
   mario

-- 
Ing. Mario Valle
Swiss National Supercomputing Centre (CSCS)
v. Trevano 131, 6900 Lugano, Switzerland
Tel: +41 (91) 610.82.60

Received on Thursday, 10 November 2016 05:34:02 UTC