it would be appreciated to if anyone can answer that is there any way to add an LOOP function to cypher?
i can find loops in graph by use of traversal. but i want to know is there anyway to pass obtained result to a customized user defined Cypher function?
Not yet. They're talking about UDFs (User Defined Functions) in an upcoming release of Neo4j, though. You might consider refining your use case and asking for it as a feature of Cypher itself in github issues, as well.
Until UDFs are possible with Cypher, you might consider using unmanaged extensions.
It seems that you are asking two different questions.
About whether you can use loops in Cypher, yes you can, with FOREACH or UNWIND, depending on what you want to achieve. This is a good resource for when you don't quite know which is the right one for your case. It compares the two and tries them with different example queries.
As for whether you can write user defined function, as of Neo4j 3.0, you can. They are however written in Java.
Look into this link for more details: https://neo4j.com/developer/procedures-functions/
Related
I am going to store all nodes and relations changes without impact existing code, what is the best way to do that?
I've noticed APOC might fit this issue, can't find any example here.
You can create your custom trigger using the APOC library, according to your use case. The whole process is described here: Triggers In APOC
Or you can use the module suggested here.
Lets say, my data set is a shopping mall.
I have to build a graph for it. Whenever asked, I have to generate a path (shortest path) from one shop to another.
Now my question is,
Is it efficient to build a graph of the whole building and generate
the path?
Or build a graph (something like a subgraph) between
only the 2 nodes and all its connectors (edges) when a user needs to
find the path?
I have to implement this for a mobile application where all the data is loaded from a server.
My current code builds the whole graph. But I want to use this as a library for future use.
If it is only for the current building, then it works fine.
But assuming that in the future another type of data set is used which is way too big that the current one, then which one of these methods is more efficient?
These are the only 2 ways I can think of implementing it. If there is any other solution then that would be highly appreciated!
Secondly, I am using Dijkstra's Algorithm for path finding, is that suitable for this kind of a case?
Any help would be highly appreciated,
Thanks.
Is it efficient to build a graph of the whole building and generate the path?
Or build a graph (something like a subgraph) between only the 2 nodes and all its connectors (edges) when a user needs to find the
path?
If the graph is known a priori, the most efficient solution, in regards to query times, will be to generate the whole graph and preprocess it. Then, you will query the contracted graph and have a very fast query time. Look for example at Contraction hierarchies, since it is one of the most widely used techniques. Otherwise, when the graph has to be built in runtime, I think it is what you mean with your second point, you could use A* or bidirectional Dijkstra. In the first one I guess the best heuristic you can come up is the straight line distance, so probably not very helpful.
Secondly, I am using Dijkstra's Algorithm for path finding, is that
suitable for this kind of a case?
Yes it is, but I would always use bidirectional Dijkstra, it's not difficult to implement and, generally, a great improvement in time requirements over unidirectional Djikstra. Some related questions in SO: 1, 2
I would like to modify the way Cypher processes queries sent to it for pattern matching. I have read about Execution plans and how Cypher chooses the best plan with the least number of operations and all. This is pretty good. However I am looking into implementing a Similarity Search feature that allows you to specify a Query graph that would be matched if not exact, close (similar). I have seen a few examples of this in theory. I would like to implement something of this sort for Neo4j. Which I am guessing would require a change in how the Query Engine deals with queries sent to it. Or Worse :)
Here are some links that demonstrate the idea
http://www.cs.cmu.edu/~dchau/graphite/graphite.pdf
http://www.cidrdb.org/cidr2013/Papers/CIDR13_Paper72.pdf
I am looking for ideas. Anything at all in relation to the topic would be helpful. Thanks in advance
(:I)<-[:NEEDING_HELP_FROM]-(:YOU)
From my point of view, better for you is to create Unmanaged Extensions.
Because you can create you own custom functionality into Neo4j server.
You are not able to extend Cypher Language without your own fork of source code.
I'm trying to write a mapreduce query in erlang for riak but I'm having trouble getting my head around it. Does anyone know where I can find an example of an erlang mapreduce query, or can write one, that will perform the SQL equivalent of a count operation? It would also be helpful if someone could explain what the actual query does line-by-line too. I've managed to write one in js but erlang is pretty different. Thank you.
Riak comes with a set of predefined mapreduce functions implemented in Erlang that you can use as a guide if you are trying to write your own functions. One of the functions provided is
reduce_count_inputs, which counts inputs (as long as the input are not integers) and might be useful for your scenario.
I have also created a library of map phase functions implemented in Erlang that you can look at.
Although I believe it is possible to pass in Erlang functions as part of the mapreduce job specification in a similar way to how you send anonymous JavaScript function, it is usually not recommended, and I have not done this myself.
I always look into riak sources to find some good examples.
Here module which implement standard mapreduce funs: riak_kv_mapreduce
This is a simples one, which just returns value of the object.
I am working on a number of Rails-based projects which require spreadsheet-like functionality, so I would like to know if anyone ever tried to implement the Natural Order Recalculation algorithm in Ruby. If not, could you point out where can I find any guidelines so I can implement if myself. Oh, if anyone is interested, we will also open-source this part of our system :D
Best regards!
The term "natural ordering" in spreadsheets is a special case of a more general idea called topological sorting, in which a set of objects with dependencies are sorted in a way such that each object is processed only after the objects on which it depends. On this topic, I managed to find a few Ruby pages that describe topological sorting; this one might be a good starting point. Although this isn't exactly what you need, the fact that there appears to be some kind of library support may make your job substantially easier.
Hope this helps!