匹配没有找到最短路径

时间:2015-11-15 18:34:20

标签: c# neo4j

我有任务。我有一点意见。我知道时间,需要花费的时间从一点到第二点。建议我使用neo4j来搜索最短路径。 首先我在c#point中创建:

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

没有成立行。

http://elinux.org/images/d/d0/Instrumented_printk.patch

1 个答案:

答案 0 :(得分:1)

首先,尝试以下查询

MATCH (pointStart:Point { name:"Point_B" })-[r]-(pointEnd:Point { name:"Point_E" })
RETURN pointStart, pointEnd, r