Skip to content
This repository was archived by the owner on Oct 8, 2020. It is now read-only.

Commit f62fc10

Browse files
Minor changes and extended comments
1 parent c65cf66 commit f62fc10

2 files changed

Lines changed: 52 additions & 9 deletions

File tree

sansa-inference-common/src/main/scala/net/sansa_stack/inference/rules/RuleDependencyGraph.scala

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,75 @@ import scalax.collection.mutable.DefaultGraphImpl
88
import org.apache.jena.reasoner.rulesys.Rule
99

1010
/**
11-
* Given a set of rules R, a rule dependency graph (RDG) is a directed graph G = (V, E) such that
11+
* Given a set of rules R, a rule dependency graph (RDG) is a directed graph
12+
* G = (V, E) such that
1213
* <ol>
13-
* <li>each vertex in V represents a rule r_i from R and </li>
14-
* <li>each edge (r_i, r_j) in E denotes the dependency between them </li>
14+
* <li>each vertex in V represents a rule r_i from R and </li>
15+
* <li>each edge (r_i, r_j) in E denotes the dependency between them </li>
1516
* </ol>
1617
*
17-
* The dependency between two rules r_i and r_j, denoted as r_i -> r_j resp. "r_i depends on r_j"
18-
* indicates that the result r_j is used as input of r_i. In particular, that means we use the
19-
* same direction in the graph although one would expect to have an edge from the rule r_j producing the data
20-
* to the rule r_i consuming the data.
18+
* The dependency between two rules r_i and r_j, denoted as r_i -> r_j,
19+
* resp. "r_i depends on r_j" indicates that the result of r_j is used as
20+
* input of r_i. In particular, that means we use the same direction in the
21+
* graph although one would expect to have an edge from the rule r_j producing
22+
* the data to the rule r_i consuming the data.
23+
*
24+
* Some notes about the types used:
25+
* The Rule class stems from org.apache.jena.reasoner.rulesys and comprises a
26+
* list of antecedents (body) and a list of consequents (head), i.e.
27+
*
28+
* consequent [, consequent] <- antecedent [, antecedent]
29+
*
30+
* where each consequent or antecedent can be a TriplePattern (i.e. a triple of
31+
* Nodes, themselves being either variables, wildcards, embedded functors, uri
32+
* or literal graph nodes), a Functor or a Rule.
33+
*
34+
* The Graph and LDiEdge ('labeled directed edge') classes stem from
35+
* scalax.collection which provides the main graph functionality.
36+
* Considering a scalax.collection.Graph two kinds of Nodes are distinguished:
37+
*
38+
* - Outer Nodes
39+
* Outer nodes exist outside of the context of any particular graph and must
40+
* be provided by the library user. When added to a graph, they will be
41+
* transparently wrapped by a corresponding inner node. Outer nodes must
42+
* satisfy the upper bound of the node type parameter of the graph
43+
* - Inner Nodes
44+
* Inner nodes are objects bound to a particular graph. They are
45+
* transparently created on graph instantiation or on adding nodes to a
46+
* graph. Inner nodes are instances of the inner class NodeT, hence the
47+
* term, and are implementing the InnerNodeLike interface. An inner node
48+
* acts as a container of the corresponding outer node also providing a
49+
* wealth of graph functionality such as diSuccessors or pathTo. Inner nodes
50+
* always equal to the contained, user-provided outer node thus facilitating
51+
* interchangeability of inner and outer nodes in many situations. Note that
52+
* NodeT is a path dependent type such as g.NodeT with g denoting a single
53+
* graph instance.
54+
*
55+
* (Descriptions taken from http://www.scala-graph.org/guides/core-inner-outer.html)
2156
*
2257
* @author Lorenz Buehmann
58+
* @author Patrick Westphal
2359
*/
2460
class RuleDependencyGraph(iniNodes: Iterable[Rule] = Set[Rule](),
2561
iniEdges: Iterable[LDiEdge[Rule]] = Set[LDiEdge[Rule]]())
26-
extends DefaultGraphImpl[Rule, LDiEdge](iniNodes, iniEdges)(implicitly, DefaultGraphImpl.defaultConfig) {
62+
extends DefaultGraphImpl[Rule, LDiEdge](iniNodes, iniEdges)(
63+
implicitly, DefaultGraphImpl.defaultConfig) {
2764

2865
def this(graph: Graph[Rule, LDiEdge]) = {
2966
this(graph.nodes.toOuter, graph.edges.toOuter)
3067
}
3168

3269
/**
70+
* This converts the graph-specific inner nodes to its corresponding outer
71+
* nodes which may exist outside a graph context.
72+
*
3373
* @return the set of rules contained in this graph
3474
*/
3575
def rules(): Set[Rule] = nodes.toOuter
3676

77+
/**
78+
* @return a simple string representation of this graph
79+
*/
3780
def printNodes(): String = rules().map(r => r.getName).mkString("G(", "|", ")")
3881

3982
/**

sansa-inference-common/src/main/scala/net/sansa_stack/inference/utils/Logging.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import scala.language.implicitConversions
1111
*/
1212
trait Logging {
1313

14-
@transient var log_ : Logger = null
14+
@transient private var log_ : Logger = null
1515

1616
// Method to get or create the logger for this object
1717
protected def log: Logger = {

0 commit comments

Comments
 (0)