I have a graph at neo4j that looks like this : (1)->(2)->(3)->(4)->(5)->(6) I want to start iterating start from the third node to the fifth node and get them how can I do this ?

I have a graph at neo4j that looks like this : (1)->(2)->(3)->(4)->(5)->(6) I want to start iterating start from the third node to the fifth node and get them how can I do this ?

This one can probably answered many ways but here is one example.

Consider this test data...

```
create (t1:Test {name:'1'})
create (t2:Test {name:'2'})
create (t3:Test {name:'3'})
create (t4:Test {name:'4'})
create (t5:Test {name:'5'})
create (t6:Test {name:'6'})
create t1-[:JOINED_TO]->t2
create t2-[:JOINED_TO]->t3
create t3-[:JOINED_TO]->t4
create t4-[:JOINED_TO]->t5
create t5-[:JOINED_TO]->t6
```

Then you can return the 3rd to 5th nodes with the following query...

```
match p=(:Test {name:'3'})-[:JOINED_TO*]->(:Test {name:'5'})
return p
```

This will find c in an arbitrarily long path where c has not outgoing relationships. MATCH p=(a)-[*]->(c:Prime) WHERE a.name='Object' AND not( c-->() ) RETURN c It is generally advisable to use relationship types (if possible / practical) in your query and put an upward boundary on the number of hops...

Your query returns feed as f, a node, and rel as r, a relationship. But the FeedsIterableResult expects them to be collections. Each "row" returned by that query will contain a feed node and a rel relationship. To match your QueryResult, you would have to change your Cypher query to...

IIUC, this is the classic Minimum Vertex Cover problem, which is, unfortunately, NP Complete. Fortunately, the most intuitive and greedy possible algorithm is as good as it gets in this case....

python,numpy,matplotlib,graph,plot

You can use the condition z=='some tag' to index the x and y array Here's an example (based on the code in your previous question) that should do it. Use a set to automate the creation of tags: import csv import datetime as dt import numpy as np import matplotlib.pyplot...

You can re-use the same csv file but use two different header files, with different columns used as :ID and columns you don't want for this node as :IGNORED As the header is independent from the data you can use that approach to pull in the same file several times...

Both of your links are to the 'development' part of networkx (check the url), so I don't think it's in the standard release yet. Probably your best option is to copy the relevant code into a file in your working directory and import it separately. Otherwise, look to download the...

python,graph,dataframes,networkx

You could use B.add_weighted_edges_from( [(row['domain'], row['subdomain'], 1) for idx, row in df.iterrows()], weight='weight') to add weighted edges, or you could use B.add_edges_from( [(row['domain'], row['subdomain']) for idx, row in df.iterrows()]) to add edges without weights. You may not need weights since the node degree is the number of edges adjacent to...

The GraphAware framework and modules will work on Windows only if you've installed Neo4j from the zip and not the installer.

WHERE can only be used with the MATCH clause. The expected I is because for cypher the possible clause after a CREATE is a WITH clause, so the second letter is a I instead of a H. You should then first MATCH the two nodes and create the unique relationship...

neo4j,recommendation-engine,graphaware

No, the neo4j-reco has been built starting from Neo4j 2.1.5, see here : http://mvnrepository.com/artifact/com.graphaware.neo4j/recommendation-engine And some methods use the Neo4j 2.0+ API. In the meantime, we can just recommend you to upgrade to Neo4j 2.2...

Here is the graph I propose: Two kinds of vertices: departure vertex: airport+departure time arrival vertex: airport + arrival time. Two kind of edges: flight edge: from a departure vertex to an arrival vertex wait edge: from an arrival vertex to a departure vertex of later time in the same...

This exact scenario is in the documentation: https://github.com/Readify/Neo4jClient/wiki/cypher-examples#create-a-user

Replacing the following code: if(movei == (N*N)+1){ return true; } ...with a hardcoded value... if(movei == 62){ return true; } ...gave me a good result after 0.1 seconds. (A field with only three "zeroes" remaining.) So your overall algorithm works. Hint for better looks of the output: #include <iomanip> cout...

Or you could place a rectangle on the region of interest: rect(xleft=1994,xright = 1998,ybottom=range(CVD$cvd)[1],ytop=range(CVD$cvd)[2], density=10, col = "blue") ...

Yes, you can do this: Iterator<Node> javaNodes = execResult.columnAs( "java"); for (Node node : IteratorUtil.asIterable(javaNodes)) { //do something with the node } More info including what to do when you have many columns is detailed in http://neo4j.com/docs/2.1.8/tutorials-cypher-java.html Update based on comment: The Cypher query is MATCH (java:Java) return java so...

Instead of using xlabel and ylabel, you may want to go with set label. For example, #!/usr/local/bin/gnuplot datafile='tmp.dat' # file to plot set xlabel " " # no x-label set ylabel " " # no y-label # assuming all plots have same x and y range set xrange [-2:2] set...

python,csv,matplotlib,graph,plot

you need to turn x and y into type np.array before you calculate above_threshold and below_threshold, and then it works. In your version, you don't get an array of bools, but just False and True. I added comma delimiters to your input csv file to make it work (I assume...

No, there shouldn't be an infinite cycle. Visited and unvisited nodes in the graph are kept track of, and a visited node will never be visited again. In your example: Mark all nodes as unvisited, except for the starting node which is visited Starting with A, visit B, mark B...

algorithm,graph,tree,runtime,big-o

Since everything is still connected and only one edge has been removed, then most (and maybe all) of the spanning tree remains the same. Attempt to construct the same minimum spanning tree, and if the edge that was removed was part of the spanning tree, grab the next smallest edge...

Why do you use bidirectional relationships in the first place? In Neo4j you can always navigate on both directions. update to a recent Neo4j version (2.2.2) use single directional relationships use labels create label indexes the with in between doesn't help as it separates the conditions from the pattern as...

Basically you can model it using each city/airport as a node and the flights as the connections in between. The weight of the connections/flights is then the time. If you assume that all stopovers are 30 minutes (in a simplified model) then you can add an additional cost per visited...

As @nicole and @cybersam have indicated, the value can be stored on Population and FertilityRate nodes. It can also be stored directly on the relationships between the country and year if the Population and FertilityRate have no real use in the graph except to carry their values. ...

I've written some code that might be helpful: neo4j-fti It basically hooks into the startup process and creates manual indexes with customizable analyzers. ...

MATCH (a) WHERE a.name =~ '(?i).*bob.+' RETURN a.name should find John McBobberson, but I don't think it will find John McBob. This one should find both. MATCH (a) WHERE a.name =~ '(?i).*bob.*' RETURN a.name ...

In set theory notation |A| is the cardinality of set A, in other words the number of elements contained in set A. For Reference: http://www.mathsisfun.com/sets/symbols.html...

jpa,neo4j,datanucleus,kundera,hibernate-ogm

I have a sample app I've been playing with for a while, and was using DataNucleus v4.1 with the Neo4j it pulls in by default (2.1.3 IIRC). I just tried it with v2.0.0 and all runs fine for me. Just put the version of neo4j you want in the CLASSPATH...

python,sql,r,graph,connected-components

In R, you could use the package igraph: library(igraph) gg <- graph.edgelist(as.matrix(d), directed=F) split(V(gg)$name, clusters(gg)$membership) #$`1` #[1] "a" "b" "c" "u" "e" # #$`2` #[1] "f" "g" "h" "j" # #$`3` #[1] "z" "y" And you can look at the graph using: plot(gg) This is based on an excellent answer...

To find this out, you just need to run simple DFS or BFS algorithm on one of the nodes, it'll find all reachable nodes within a continuous component of the graph, so you just mark it down if you've found the other node during the run of algorithm.

If I understand your domain correctly, I would recommend making your Categorys into nodes themselves. MERGE (:Category {name:"Food"}) MERGE (:Category {name:"Bar"}) MERGE (:Category {name:"Park"}) And connecting each Place node to the Categorys it belongs to. MERGE (:Place {name:"Central Park"})-[:IS_A]->(:Category {name:"Park"}) MERGE (:Place {name:"Joe's Diner"})-[:IS_A]->(:Category {name:"Food"}) MERGE (:Place {name:"Joe's Diner"})-[:IS_A]->(:Category {name:"Bar"})...

You may use a recursive procedure, e.g.: for (int i=0;i<Points.Count;i++) { // Paths[i] contains all paths from start to Point[i] Paths.Add(new List<List<list<int>>>()) ; } int startIndex= ... ; int targetIndex=... ; ProcessPoint(startIndex) ; That's all: you will get in Paths[startIndex] all possible paths. Select those ending at target. The recursive...

r,graph,plot,ggplot2,time-series

Two ways of doing this: If sample data created as follows: Full.df <- data.frame(Date = as.Date("2006-01-01") + as.difftime(0:364, units = "days")) Full.df$Month <- as.Date(format(Full.df$Date, "%Y-%m-01")) Full.df[paste0("Count.", c("S", "G", "W", "F"))] <- matrix(sample(100, 365 * 4, replace = TRUE), ncol = 4) Optimal way using reshape2 package: molten <- melt(Full.df, id.vars...

An execution result is essentially an iterator of a map, its type definition is something like: Iterable<Map<String,Object>> So you can easily just do: result.iterator().hasNext(); I think that its strictly a ResourceIterator, so if you get an iterator you are supposed to close it if you don't exhaust it. Check the...

javascript,svg,d3.js,graph,charts

This isn't possible with D3. The axis component will generate an axis that corresponds to the associated range, i.e. to make it any particular size, you have to modify the output range of the associated scale. You can do this quite easily in a responsive manner though by computing the...

This is not yet possible, but there is already an open neo4j issue that requests the ability to do post-UNION processing, which includes what you are asking about. You can add a comment to that neo4j issue if you support having it resolved.

algorithm,graph,graph-algorithm

If you allow preprocessing, there is a fast method: Construct the bridge-block forest, whose vertices are 2-connected components, and whose edges are bridges. (It's a tree if the graph is connected.) When you add an edge, if this connects points in the same 2-connected component, nothing happens. If you connect...

It sounds like you’re taking the shortest path from wherever you find yourself currently, and not calculating the total distance to get to a node. Let’s step through it in detail. Dijkstra’s algorithm sets up two sets of nodes: visited (with known distances) and unvisited (with tentative distances). We start...

That example creates and then deletes the data so that is one reason why your graph is empty. Another observation is your DB_PATH. If you've set DB_PATH='data/graph.db', then that path is relative to your project path. If your code is located in /projects/example then this embedded database should be created...

algorithm,graph,graph-algorithm

To get an overall result I'll report what I did. I implemented the in the question mentioned algorithm. (Lets call it thigg's algorithm, because noone mentioned a name) Thigg's algorithm: for each node in the graph: if there is a path from src to this node and a path from...

With the GraphAware TimeTree, you are not limited to the rest api. Since version 2.2 you have automatic event attachment configurable in the neo4j.properties file https://github.com/graphaware/neo4j-timetree/blob/master/README.md#automatic-event-attachment While this does not remove you the fact that you will need to convert your event times in milliseconds, there are a number of...

algorithm,graph,tree,runtime,big-o

Don't know if your algorithm is correct, but it doesn't seem O(|V|) at least, because getting the "smallest edge not in T" of a vertex cannot be done in O(1). The most usual way to add an edge e=(u, v) into a MST T is: Run a BFS in T...

You can just create a singleton node (I'll give it the label IdCounter in my example) to hold the "next-valid ID counter" value. There is no need for it be part of any "tree" or for it to have any relationships at all. When you create the singleton, initialize it...

If and only if, at some point during kahn's algorithm has no source to choose (and the remaining graph is still none empty), there is a cycle Proof: Direction1 <--: If there is a cycle, let it be v1->v2->v3->vk->v1. At each step of the algorithm, none of v1,v2,...,vk is a...

The neo4j doesn't provide endpoint for dbinfo -g. for High Availability (HA), Its provides three REST endpoint /db/manage/server/ha/master /db/manage/server/ha/slave /db/manage/server/ha/available To check more on this read their official docs on HA....

In Jersey 1.x you can supply your client instance with a filter dealing with authentication: Client client = Client.create() client.addFilter(new HTTPBasicAuthFilter("neo4j","<mypwd>")); // <-- that's it! WebResource resource = client.resource( "http://localhost:7474/db/data/transaction/commit" ); ClientResponse response = resource.accept( MediaType.APPLICATION_JSON ) .type( MediaType.APPLICATION_JSON ) .post( ClientResponse.class, someStringContainingJsonPayload); ...

Py2neo supports transactions and of course you can use parameters in the cypher queries, a simple code I just tested : from py2neo import Graph import time graph = Graph("http://neo4j:[email protected]:7474/db/data/"); tx = graph.cypher.begin() for x in range(0,100): tx.append("CREATE (m:Method {id:{id}})", {"id": x}) tx.append("CREATE (p:Parameter {id:{id}})", {"id": x}) tx.append("MATCH (m:Method {id:{mid}}),...

c++,class,c++11,data-structures,graph

I advise you to use a Link structure, to represent an edge in the graph: struct Link { Node *N; float weight; } Then each Node can contain vector<Link> neighbors; This way there is no duplication of Nodes. There is a duplication of weights, since if Node A has a...

The first optimization is to read the whole file in memory in one shot. Accessing memory in the loops will be faster than calling fread. The second optimization is to do less arythmetic operations, even if it means more code. Third optimization is treating the data from file as characters...

algorithm,graph,graph-algorithm,linear-programming,np-complete

It's possible to formulate this as the following problem. Suppose each vertex v in the graph has weight w(v). You define a variable x(v), and use some out-of-the-box linear programming solver to solve max \sum_v w(v) x(v) (maximize the weight of chosen vertices) subject to x(u) + x(v) <= 1,...

You have some version confusion. Spring Data Neo4j 2.2.2 works with Neo4j 1.9 or so. SDN 3.0 with Neo4j 2.0 and only SDN 3.3.1 (to be released) with Neo4j 2.2.2. SDN 3.3.0 works with Neo4j 2.1.x That's why it asks you for the allow_store_upgrade=true configuration setting in conf/neo4j.properties. But I...