I put following code (based on this answer) for "Graph Expansion".
Updated. Now round brackets and spaces are replaced by hyphens when constructing a URI for the Literal Nodes as these are not allowed. If you have other illegal characters in your literals you would have to add those to the REPLACE statements too!
# Note that ?node is the node you clicked and must be used in the query
PREFIX rank: <http://www.ontotext.com/owlim/RDFRank#>
PREFIX ent: <http://www.ontotext.com/owlim/entity#>
CONSTRUCT
{
# The triples that will be added to the visual graph
?newNodeLX ?edge ?newNodeRX .
}
WHERE
{
{
{
# Left to right relations (starting IRI is the subject)
?node ?edge ?newNodeR .
# ?node is always an IRI, ?newNodeR must be checked for IRI or Blank
FILTER(isIRI(?newNodeR) || isBlank(?newNodeR) || isLiteral(?newNodeR))
BIND(IF(isBlank(?newNodeR), URI(CONCAT("BNode:", STR(ent:id(?newNodeR)))),
IF(isLiteral(?newNodeR),URI(CONCAT("L:", REPLACE(STR(?newNodeR), "[ \\(\\)]", "-"))),
?newNodeR))
AS ?newNodeRX)
BIND(?node AS ?newNodeLX)
}
UNION
{
# Right to left relations (starting IRI is the object)
?newNodeL ?edge ?node .
# ?node is always an IRI, ?newNodeL is always an IRI or Blank
BIND(IF(isBlank(?newNodeL), URI(CONCAT("BNode:", STR(ent:id(?newNodeL)))),
IF(isLiteral(?newNodeL), URI(CONCAT("L:", REPLACE(STR(?newNodeL), "[ \\(\\)]", "-"))),
?newNodeL))
AS ?newNodeLX)
BIND(?node AS ?newNodeRX)
}
}
UNION
{
{
# Left to right relations (starting Blank is the subject)
?nodeC ?edge ?newNodeR .
# ?nodeC must be checked for Blank, ?newNodeR must be checked for IRI or Blank
FILTER(isBlank(?nodeC))
FILTER(isIRI(?newNodeR) || isBlank(?newNodeR) || isLiteral (?newNodeR))
BIND(IF(isBlank(?newNodeR), URI(CONCAT("BNode:", STR(ent:id(?newNodeR)))),
IF(isLiteral(?newNodeR),URI(CONCAT("L:", REPLACE(STR(?newNodeR), "[ \\(\\)]", "-"))),
?newNodeR))
AS ?newNodeRX)
BIND(URI(CONCAT("BNode:", STR(ent:id(?nodeC)))) AS ?newNodeLX)
FILTER(?newNodeLX = ?node)
}
UNION
{
# Right to left relations (starting Blank is the object)
?newNodeL ?edge ?nodeC .
# ?nodeC must be checked for Blank, ?newNodeL is always an IRI or Blank
FILTER(isBlank(?nodeC))
BIND(IF(isBlank(?newNodeL), URI(CONCAT("BNode:", STR(ent:id(?newNodeL)))),
IF(isLiteral(?newNodeL), URI(CONCAT("L:", REPLACE(STR(?newNodeL), "[ \\(\\)]", "-"))),
?newNodeL))
AS ?newNodeLX)
BIND(URI(CONCAT("BNode:", STR(ent:id(?nodeC)))) AS ?newNodeRX)
FILTER(?newNodeRX = ?node)
}
}
}
#ORDER BY ?edge
and following for Node Basics:
# Note that ?node is the relevant node's IRI and must be used in the query
PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
PREFIX ent: <http://www.ontotext.com/owlim/entity#>
SELECT ?type {
{
# Get node direct type
?node sesame:directType ?type.
}
UNION
{
# Get node direct type
?nodeB sesame:directType ?type.
FILTER(isBlank(?nodeB) && URI(CONCAT("BNode:", STR(ent:id(?nodeB)))) = ?node)
}
UNION
{
# Get node direct type
?nodeB sesame:directType ?type.
FILTER(isLiteral(?nodeB) && URI(CONCAT("L:", ?nodeB)) = ?node)
}
} ORDER BY ?type