Knowledge Ring Application
The Ring application ("Ring of knowledge") allows to draw relations between wiki pages. For instance, the relation has author can be created to state that page The Jungle Book has relation has author with page Rudyard Kipling. Relations are stored in the wiki as any other page, with the only specificity that they have relation is a with the page Relation. Each page connections can be browsed using a widget showing up under their title, allowing also to add new connections.
The application allows to:
 Create types and relations as wiki pages
 Use these relations to interlink pages with one another, hence creating "rings": a ring joins a page, a relation and another page. In addition, a ring can have internal properties (work in progress).
 Explore pages via their relations, using facets.
 Define relations constraints and properties.
A ring is an ordered set consisting of:
 An origin page
 A relation
 A destination page or a scalar value (string, date, number, etc.)
 A set of properties
For example, The Jungle Book has author Rudyard Kipling or The Jungle Book has publication date 1894 are rings.
Relations can have specific constraints, such as a constraint about the pages they can bind to one another. For instance, the relation has author will typically accept as destination pages only those of type person or organization. A page type is defined by linking it to the builtin Type page via relation is a, builtin as well. For example: Book is a Type.
Representation of a graph. Source: Textgraphs.org
User interface
Once installed, the application adds a block to each page header which displays the list of pages that are linked with the current one. This list can be ordered by page title or by last modification date.
This additional block also includes crosses for removing existing connections, and a button for adding new ones. When hitting this button, a form shows up, displaying the list of relations that the current page can use, and a search input field for selecting a destination page. For instance, on page The Jungle Book, once declared as a book, the form will typically propose the relations has author, has publication date, has publisher, etc. When selecting the relation has author, the search input field will suggest all the wiki pages of type person that match the entered input. The form supports only the addition of edges linking two pages together, not yet a page and a scalar value.
The user interface also includes a Filter buton which makes it possible to restrict the list of related pages by their own types or relations. All relations available in the wiki are automatically added to the faceting system for easy navigation across the graph of pages.
In order to draw a relation between two pages, the user needs to have at least edit right on the origin page. On a given page, a user will see all the related pages even whatever his access rights on them: in case he has no view access on a given connected page, he will get a denied access only when trying the view the content of that page.
Page "The Jungle Book" and its related pages
Form for connecting pages
Example: Nobel Prize laureates
The application includes a Wikidata data importer which creates a set of relations and types corresponding to Nobel Prizes Laureates data – in particular the relations has award, has country, and the types person and organization – and import data into the wiki.
Wikidata is a project that stores data using a graph structure as well, and provides interfaces for browsing the graph visually and for entering new statements.
Once imported into the wiki, the Nobel Prize laureate pages can be browsed using facets. For instance, all organizations and persons who received the Nobel Peace Prize can be browsed by country.
Facet filtering on page "Person"
Data model
Concept  Definition  

Term  A Term simply wraps a wiki page. It can have inward and outward rings.  
Ring  A a ring typically links together two vertices – an origin and a destination – and a relation. The Jungle Book has author Rudyard Kipling is an ring that has referent page The Jungle Book, related page Rudyard Kipling, and relation has author. A ring can be a vertex, so that it's also possible to create rings involving rings, such as: Anna says that "The Jungle Book has author Rudyard Kipling", where says is a relation used by the edge having origin Anna and destination The Jungle Book has author Rudyard Kipling.  
Relation  A relation has a domain and an image. Its domain is the set of terms on which it can be applied to, and its domain is the set of terms it can accept as values. For instance, has award is a relation. Its domain is the set of pages representing a person or an organization. Its image is the set of pages that represent an award.  
RingSet  A RingSet is a set of terms, rings and relations. 
Ring application class diagram
Builtin relations
The application includes a set of predefined relations described below, and one type.
Relation or Type  Description  Example 

Is connected to  Can be used to express that two pages are related to one another.  The Jungle Book is connected to RikkiTikkiTavi. 
Is a  Can be used to declare that a page has a specific type.  Rudyard Kipling is a journalist. 
Is transitive  Can be used to specify whether a relation is transitive or not.  Relation is a is transitive: if Rudyard Kipling is a journalist, and journalist is a person, then Rudyard Kipling is a person. This property is not used by the application at the moment. 
Has domain  Can be used to specify the set of pages a relation can take as first parameter. It is similar to the RDF schema domain property, except that rdfs:domain only accept class names, while the has domain relation can accept any set definition.  Relation has head office has domain organization. 
Has image  Can be used to specify the set of pages a relation can have as destination. It is similar to the RDF schema range property. The terms domain and image come from the mathematical definition of a relation.  Relation has author has image person. 
Type  Represents a type.  The page Type has relation is a with itself: a type is a type. Book is a type. 
Visual representation of an example set of terms, relations and rings. Rings are circles connecting an origin, a relation and a destination.
Script service
The application includes a script service that can be accessed via $services.graph and which exposes the functions below.
 void addRing(DocumentReference origin, DocumentReference relation, DocumentReference destination)
 List<XWikiRelation> getRelations(DocumentReference vertex)
 List<DocumentReference> getDirectPredecessors(DocumentReference vertex, DocumentReference relation)
 String getDomain(DocumentReference relation)
 String getImage(DocumentReference relation)
 List<XWikiRelation> getRelations()
 removeRing(DocumentReference origin, DocumentReference relation, DocumentReference destination)
 List<DocumentReference> search(String text)
 List<DocumentReference> search(String text, DocumentReference relation)
Implementation
The application hinges on the XWiki classes below.
XWiki class  Properties 

Ring 

StringRing 

DateRing 

BooleanRing 

An additional index field is added automatically by Solr when indexing Ring objects, via a SolrMetadataExtractor component having a higher priority than the default one provided by xwikiplatform. For instance, "The Jungle Book has author Rudyard Kipling" is indexed as follows in Solr:
property.ring.Graph.HasAuthor_string:[Ring.Rudyard Kipling].
In addition, all converse rings are indexed, but only partially at this stage, using the generic relation is connected to, because inverse relations are not handled at this stage, so that we have, for page wiki.Rudyard Kipling the following index entry:
property.ring.Ring.IsConnectedTo_string:[Ring.The Jungle Book].
The implementation consists in particular of the following components:
 XWikiRing: allows to create terms, relations and rings
 SolrRingIndexer: manages the index of rings
 SolrRingTraverser: runs queries across terms, rings and relations
Installation
 Requirement: XWiki 11.8RC1, Java 11
 Clone repository https://framagit.org/aeka/xwikiring: git clone [email protected]:aeka/xwikiring.git
 Run mvn clean install
 Deploy the generated jar and import the generated xar
Next steps
 Ability to add ring scalar values via a form.
 See if the default EmbeddedSolrInstance can expose a method for accessing an indexed SolrDocument by its id.
 Support relation transitivity.
 Associate types with XWiki sheets.
 Store the graph in a graph database.
 Create rings using wiki syntax or macros: {{ring relation="wiki.HasAuthor" destination="wiki.Rudyard Kipling"}}The author of this book is Rudyard Kipling.{{/ring}}
 Handle inverse relations. For example the inverse of relation "has author" is relation "has authored".
 Display pages in livetables with ability to filter them by their rings.
Application name and related concepts
The application uses concepts which are at the crossroads of linguistics (sentences connecting words), logic (predicates) and mathematics (graphs). The main structure on which it builds on consists of a triple (a,R,b) comprising three terms:
 a referent: "in logic, the word referent is sometimes used to denote one of the two objects participating in a relation, the other being called the relatum.".
 a binary relation: "a binary relation over two sets A and B is a set of ordered pairs (a, b) consisting of elements a of A and elements b of B".
 a relatum.
A tuple (a,R,b) – more commonly noted R(a,b) – has different namings depending on the theoretical or usage context:
 Atomic formula in logic: "an atomic formula or atom is simply a predicate applied to a tuple of terms; that is, an atomic formula is a formula of the form P (t1 ,…, tn) for P a predicate, and the tn terms.".
 Statement in the semantic web community: an RDF statement is a triple of resources subject / predicate / object, where the predicate is a binary relation.
 Hyperedge in graph theory: an hyperedge is an nuple connecting several vertices together. The terms a, R, b mentioned above can be seen as vertices, and (a,R,b) as an hyperedge, with the specificy that "R" is a relation.
The structure currently used by the application actually involves a fourth term, named "properties", in order to describe the triple (a,R,b) itself: properties are a handy shortcut for adding metadata about a triple, just like what property graphs propose. Properties could actually rather be represented as individual atomic formula (rings) on their own, but this introduces some implementation complexity which might not be necessary at this stage.
So far, the word ring has been chosen to represent the core structure and for naming the application itself, mostly because it has a simple visual representation (however visually the circle should not be closed, since the ring can be navigated only in a given direction), it catches well the semantics of tying several terms together, and it it's easy to imagine a ring connecting several rings. Formally, a ring is just an atomic formula involving 3 terms (a relation and a pair of terms), with some properties. It's probably not a great idea to have chosen a new term but "atomic formula" might sound a bit scary to non logicians and is lacking a visual hint.
Hypergraph and hyperedges  Source: Wikipedia:Hypergraph
The higherlevel structure consisting of a set of rings corresponds to an hypergraph, since each edge ties together several terms. It's currently a uniform 4hypergraph since all edges have four vertices (referent, relation, relatum, properties), even though some are allowed to be empty (e.g. properties). The relatum term can either have an identifier or be a scalar (e.g. a given date or number). Each edge is also a vertex, so that edges can be involved in other edges.
Related projects
Resources
Graphs and hypergraphs
The data structure of the application is an hypergraph.
 Articles
 Graph databases go mainstream – Kurt Cagle, Forbes, July 2019
 Graphs in mathematics – Wikipedia
 Graph traversal / search – Wikipedia
 Hypergraph definition – Wikipedia – A hypergraph is a generalization of a graph in which an edge can join any number of vertices.
 Modelling data with hypergraphs – Szymon Klarman
 Tim Berners Lee mail about a Giant Global Graph (2007)
 Books
 Graphes et hypergraphes – Claude Berge
 Graph databases in action – Dave Bechberger, Josh Perryman
 Hypergraph theory, an introduction – Alain Bretto
 The Practitioner's Guide to Graph Data – Denise Gosnell, Matthias Broecheler
 Libraries and models
 Databases
 User interface libraries
 GRANDstack framework  "Build full stack graph applications with GraphQL, React, Apollo, Neo4j", Demo: https://movies.grandstack.io/ with example queries, more examples
 SigmaJS
 Neo4j Bloom