Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special "instance or subclass" mode #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vostrnad
Copy link

Fixes #13

When the traversal property is set to "instance of", a checkbox appears that changes the behavior from traversing the property "instance of" (which is rarely useful) to traversing superclasses of direct superclasses in the forward direction, and traversing subclasses to direct instances in the reverse direction (instances are connected with dashed lines to distinguish them from subclasses). Bidirectional mode is supported, though undirected isn't–right now the graph simply crashes–and neither are maximum iterations and the size property. I've also made some pretty invasive changes to the code to make this feature easier to implement, so all in all I don't think this should be merged in the current state, but I'm sharing it for anyone who might find it useful, and I'd be more than happy to implement suggestions that would make this fit for merging.

@AngryLoki
Copy link
Owner

Hi, thank you for your pull-request!
This change looks additive and does not break other flows. I think I can merge it.
What it is currently missing is some good example in https://github.com/AngryLoki/wikidata-graph-builder/blob/master/src/routes/About.svelte - could you add it?

Regarding overall approach, I think somewhat better query is

SELECT DISTINCT ?item ?itemLabel ?linkTo ?linkType {
  {
    ?item wdt:P279* wd:Q169470 .
    OPTIONAL { ?item wdt:P279 ?linkTo }
  }
  UNION
  {
    ?class wdt:P279* wd:Q169470 .
    ?item wdt:P31 ?class .
    OPTIONAL { ?item wdt:P31 ?linkTo . BIND("alt" AS ?linkType) }
  }
  SERVICE wikibase:label {bd:serviceParam wikibase:language "en" }
}

i. e. output pairs into ?item ?linkTo and connection type to ?linkType. This approach is common in graph formats (maps to Gephi, graphviz, etc.).

@vostrnad
Copy link
Author

I changed the query as per your suggestion and added two examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instance or subclass of
2 participants