Skip to content

Find shortest Path between two nodes and return the paths. #427

@LouisBossekko

Description

@LouisBossekko

Hey there,

I am new to cypher and neo4j and looking for a sulution to find the shortest path between two nodes.

This code worked on planc cypher for me, but i need it for the client:

MATCH 
    (skill:ISkill {Id: '9d20aaa0-b5fd-46e2-ad80-a7fda1755401'}),
    (degree:IDegree {Id: '67caaa58-aa08-4a7e-9f76-800b804cb888'}),
    p = shortestPath((skill)-[*..15]-(degree))
RETURN p

I tried a different approach with this Method to match the Relations to ISkillRating but i only got return count = 0

public async Task<SkillRating> GetSkillRatingForSkillAndDegree(Guid skillId, Guid degreeId)
{
            try
            {
                var result = await _client.Cypher
                    .Match("(iSkill:ISkill)-[r]-(iSkillRating:ISkillRating)")
                    .OptionalMatch("(iSkillRating:ISkillRating)-[r]-(iDegree:IDegree)")
                    .Where((ISkill iSkill) => iSkill.Id == skillId)
                    .AndWhere((IDegree iDegree) => iDegree.Id == degreeId)
                    .Return(iSkillRating => iSkillRating.As<SkillRating>())
                    .ResultsAsync;
                return result.FirstOrDefault();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
}

Does anybody know the command or function, which has to be called?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions