Suspicious control chain through off-shore companies in factforge.net

The following example fetches suspicious control chain through off-shore companies, which is another saved query in factforge.net rewritten as a graph query. The entities, their RDF Rank, and their type are fetched. Node size is based on RDF Rank and node color on its type. All examples use a commons.js file with some common function, i.e., data model conversion.

<html>
<body>
<!-- Include the library -->
<script src="../lib/ogma.min.js"></script>
<script src="../lib/jquery-3.2.0.min.js"></script>
<script src="commons.js"></script>
<script src="../lib/lodash.js"></script>

<!-- This div is the DOM element containing the graph. The style ensures that it takes the whole screen. -->
<div id="graph-container" style="position: absolute; left: 0; top: 0; bottom: 0; right: 0;"></div>

<script>

// Which namespace to chose types from
var dboNamespace = "http://dbpedia.org/ontology"

var suspiciousOffshore = `
# F05: Suspicious control chain through off-shore company

PREFIX onto: <http://www.ontotext.com/>
PREFIX fibo-fnd-rel-rel: <http://www.omg.org/spec/EDMC-FIBO/FND/Relations/Relations/>
PREFIX ff-map: <http://factforge.net/ff2016-mapping/>
PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
PREFIX dbo: <http://dbpedia.org/ontology/>

CONSTRUCT  {
    ?c1 fibo-fnd-rel-rel:controls ?c2 .
    ?c2 fibo-fnd-rel-rel:controls ?c3 .
    ?c1 ff-map:primaryCountry ?c1_country .
    ?c2 ff-map:primaryCountry ?c2_country .
    ?c3 ff-map:primaryCountry ?c3_country .
    ?c1 sesame:directType ?t1 .
    ?c2 sesame:directType ?t2 .
    ?c3 sesame:directType ?t3 .
    ?c1_country sesame:directType dbo:Country .
    ?c3_country sesame:directType dbo:Country .
    ?c3_country sesame:directType dbo:Country .

} FROM onto:disable-sameAs
WHERE {
    ?c1 fibo-fnd-rel-rel:controls ?c2 .
    ?c2 fibo-fnd-rel-rel:controls ?c3 .
    ?c1 sesame:directType ?t1 .
    ?c2 sesame:directType ?t2 .
    ?c3 sesame:directType ?t3 .
    ?c1 ff-map:primaryCountry ?c1_country .
    ?c2 ff-map:primaryCountry ?c2_country .
    ?c3 ff-map:primaryCountry ?c1_country .
    FILTER (?c1_country != ?c2_country)

    ?c2_country ff-map:hasOffshoreProvisions true .
} `

var postData = {
	query: suspiciousOffshore,
	infer: true,
	sameAs: true,
	limit: 1000,
	offset: 0
}


$.ajax({
	url: graphDBRepoLocation,
	type: 'POST',
	data: postData,
	headers: {
		'Accept': 'application/rdf+json'
	},
	success: function (data) {

		var triples = convertData(data);

		// Get all nodes uris
		var linkTriples = _.filter(triples, function (triple) {
			return triple[1] !== typePredicate
		});
		var nodesUris = _.uniq(_.union(_.map(linkTriples, function (t) {
			return t[0]
		}), _.map(linkTriples, function (t) {
			return t[2]
		})));

		// Get triples for types
		var typeTriples = _.filter(triples, function (triple) {
			return triple[1] === typePredicate && triple[2].indexOf(dboNamespace) === 0
		});

		// Create node objects
		var nodes = _.map(nodesUris, function (nUri) {
			var type = _.find(typeTriples, function (typeTriple) {
				return typeTriple[0] === nUri && typeTriple[1] === typePredicate
			});
			return {
				id: nUri,
				text: getLocalName(nUri) + (type != undefined ? " (" + getLocalName(type[2]) + ")" : ""),
				size: 5,
				color: ((type != undefined) ? stringToColour(type[2]) : "#eceeef"),
			}
		});

		// Create edge objects
		var edges = _.map(linkTriples, function (triple, index) {
			return {
				id: index,
				source: triple[0],
				target: triple[2],
				text: getLocalName(triple[1]),
				shape: 'arrow',
				size: 0.5
			}
		});

		// Initialize ogma with the data
		var ogma = new Ogma({
			container: 'graph-container',
			settings: {
				texts: {
					nodeFontSize: 20,
					edgeFontSize: 15,
					nodeSizeThreshold: 0,
					edgeSizeThreshold: 0
				}
			},
			graph: {
				nodes: nodes,
				edges: edges
			}
		});

		ogma.locate.center();

		ogma.layouts.start('forceLink', {}, {
			onEnd: endLayout
		});

		function endLayout() {
			ogma.locate.center({
				easing: 'linear',
				duration: 300
			});
		}
	}
})
</script>
</body>
</html>

Which produces the following graph:

_images/offshore.png