radial sugiyama positioning integration

This commit is contained in:
Oxy8
2026-03-23 11:13:27 -03:00
parent 6b9115e43b
commit 696844f341
51 changed files with 10089 additions and 364 deletions

View File

@@ -17,38 +17,42 @@ func subclassesQuery(selectedNodes []NodeRef, includeBNodes bool) string {
}
if len(valuesTerms) == 0 {
return "SELECT ?nbr WHERE { FILTER(false) }"
return "SELECT ?s ?p ?o WHERE { FILTER(false) }"
}
bnodeFilter := ""
if !includeBNodes {
bnodeFilter = "FILTER(!isBlank(?nbr))"
bnodeFilter = "FILTER(!isBlank(?s) && !isBlank(?o))"
}
values := strings.Join(valuesTerms, " ")
return fmt.Sprintf(`
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?nbr
SELECT DISTINCT ?s ?p ?o
WHERE {
VALUES ?sel { %s }
?nbr rdfs:subClassOf ?sel .
FILTER(!isLiteral(?nbr))
FILTER(?nbr != ?sel)
VALUES ?p { rdfs:subClassOf }
?s ?p ?sel .
BIND(?sel AS ?o)
FILTER(!isLiteral(?o))
FILTER(?s != ?o)
%s
}
`, values, bnodeFilter)
}
func runSubclasses(ctx context.Context, q Querier, idx Index, selectedIDs []uint32, includeBNodes bool) ([]uint32, error) {
func runSubclasses(ctx context.Context, q Querier, idx Index, selectedIDs []uint32, includeBNodes bool) (Result, error) {
selectedNodes, selectedSet := selectedNodesFromIDs(idx, selectedIDs, includeBNodes)
if len(selectedNodes) == 0 {
return []uint32{}, nil
return Result{NeighborIDs: []uint32{}, Triples: []Triple{}}, nil
}
raw, err := q.Query(ctx, subclassesQuery(selectedNodes, includeBNodes))
query := subclassesQuery(selectedNodes, includeBNodes)
raw, err := q.Query(ctx, query)
if err != nil {
return nil, err
logQueryExecutionFailure("subclasses", selectedIDs, includeBNodes, query, err)
return Result{}, err
}
return idsFromBindings(raw, "nbr", idx, selectedSet, includeBNodes)
return resultFromTripleBindings(raw, idx, selectedSet, includeBNodes)
}