0
我有任务。我有一些点。我知道时间,需要从一点到二点。对我来说,建议使用neo4j来搜索最短路径。 首先我C#创建点(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;
}
第二功能链接两点:
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);
}
}
但是当我尝试寻找最短路径(在浏览器查询这不是C#代码。)该系统没有发现任何东西:
MATCH (pointStart:Point { name:"Point_B" }),(pointEnd:Point { name:"Point_E" }),
p = allShortestPaths((pointStart)-[*]-(pointEnd))
RETURN p
你能提出任何解决方法吗?
P.S.执行此查询后:
MATCH (pointStart:Point { name:"Point_B" })-[r]-(pointEnd:Point { name:"Point_E" })
RETURN pointStart, pointEnd, r
没有行建立。
是,C#在过去的代码? –
没有。这是查询,我在Neo4j的用户界面中调用。在我的情况下:http:// localhost:7474/browser/ – user3231442
C#tho中没有“RETURN”关键字。你可能想要格式化它,这是确实是C# –