Graph Difference
See original GitHub issueWas trying to do the graph difference operation in LevelGraph , but its not working as expected.
var level = require("level-browserify");
var levelgraph = require("levelgraph");
var g1 = levelgraph(level("G1"));
var g2 = levelgraph(level("G2"));
var t1 = {
subject : "a",
predicate : "b",
object : "c"
};
var t2 = {
subject : "c",
predicate : "d",
object : "e"
};
function display(graph, subject_id) {
graph.get({
subject : subject_id
}, function(err, list) {
for(object of list){
console.log(object)
}
});
}
function displayAll(graph){
graph.search({
subject: graph.v("x"),
predicate: graph.v("y"),
object: graph.v("z")
}, function(err, list) {
for(object of list){
console.log(object)
}
}
);
}
function remove(graph, triple){
graph.del(triple, function(err) {
console.log("@remove :: Removed ", triple)
});
}
function graphDifference(graph1, graph2){
// graph1 - graph2
graph2.search({
subject: graph2.v("x"),
predicate: graph2.v("y"),
object: graph2.v("z")
}, function(err, list) {
for(entry of list){
console.log("@graphDifference :: Entry", entry)
triple = {
subject : entry["x"],
predicate : entry["y"],
object : entry["z"]
}
remove(graph1, triple)
}
}
);
displayAll(graph1)
}
var triples = ""
function getTriples(graph){
graph.search({
subject: graph.v("x"),
predicate: graph.v("y"),
object: graph.v("z")
}, function(err, list) {
for(entry of list){
console.log("@getTriples :: Entry", entry)
triple = {
subject : entry["x"],
predicate : entry["y"],
object : entry["z"]
}
triples += entry["x"]+"::"+entry["y"]+"::"+entry["z"]+"\n"
}
}
);
}
g2.put(t1, function(err) {
console.log("inserted triple1 into graph2", err);
//displayAll(g2)
});
g1.put([t1,t2], function(err) {
console.log("inserted triple1,2 into graph1", err);
//displayAll(g1)
});
function doDifference(){
graphDifference(g1,g2)
console.log("Done Differencing")
}
setTimeout(doDifference, 1000)
function doGetTriples(){
getTriples(g1)
console.log("Done getting triples")
}
setTimeout(doGetTriples, 2000)
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(triples);
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
I found out that g1 and g2 have the same triples, even before difference(g1,g2) is called.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
Graph Difference -- from Wolfram MathWorld
The graph difference of graphs G and H is the graph with adjacency matrix given by the difference of adjacency matrices of G...
Read more >Difference graphs - ScienceDirect.com
A graph G=(V, E) is said to be a difference graph if there exist real numbers a1, a2,…, an associated with the vertices...
Read more >Symbol for Graph Difference? - Mathematics Stack Exchange
Is there any well-defined symbol to denote the difference between the two graphs. The difference between two graphs G and H is defined...
Read more >What Is the Difference Between a Chart and a Graph?
Charts show how data items relate to the story, while graphs illustrate the change over time. Thinking to yourself “what is the difference ......
Read more >Different types of graphs and 3 steps how to choose the ideal ...
comparison is made when you analyse things to see similarities and differences. · contrast is the difference between two sets of information. ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
in the browser you might have to delete the indexeddb databases yourself. Maybe you have some bad stuff in there:
After changing the code to run on Node, it has started to work as expected !!! Is there a difference in how LevelGraph works in Node and in browser ?