Reputation: 620
I have task. I have array of point. I know time, which need spent to go from one point to second. For me reccomended use neo4j to search shortest path . First I create in c# point(s):
public bool AddPoint(Point point)
{
bool sucess = false;
try
{
client.Cypher
.Create("(point:Point {newPoint})")
.WithParam("newPoint", point)
.ExecuteWithoutResults();
sucess = true;
Console.WriteLine("The point was added!");
}
catch (Exception exception)
{
Console.WriteLine("Error! " + exception);
}
return sucess;
}
Second function link two points:
public void LinkTwoPoint(string firstName, string secondName, string time)
{
try
{
client.Cypher
.Match("(point1:Point)", "(point2:Point)")
.Where((Point point1) => point1.Name == firstName)
.AndWhere((Point point2) => point2.Name == secondName)
.Create(string.Format("point1-[r:Time{0}time:{1}{2}]->point2","{", time,"}"))
.ExecuteWithoutResults();
Console.WriteLine("Ok. Point was connected!");
}
catch (Exception exception)
{
Console.WriteLine("Error! " + exception);
}
}
But when I try search shortest path (query in browser. This is not c# code), the system doesn't found anything:
MATCH (pointStart:Point { name:"Point_B" }),(pointEnd:Point { name:"Point_E" }),
p = allShortestPaths((pointStart)-[*]-(pointEnd))
RETURN p
Can you suggest anything to fix it?
P.S. After execute this query:
MATCH (pointStart:Point { name:"Point_B" })-[r]-(pointEnd:Point { name:"Point_E" })
RETURN pointStart, pointEnd, r
No rows was founded.
Upvotes: 0
Views: 59
Reputation: 45023
First, try following query
MATCH (pointStart:Point { name:"Point_B" })-[r]-(pointEnd:Point { name:"Point_E" })
RETURN pointStart, pointEnd, r
Upvotes: 1