Ejemplo n.º 1
0
        // Syntax: makePathWithRelProperty( "weight", "a-4-b-2.3-c-3-d" )
        public virtual Path MakePathWithRelProperty(string relPropertyName, string dashSeparatedNodeNamesAndRelationshipProperty)
        {
            string[] nodeNamesAndRelationshipProperties = dashSeparatedNodeNamesAndRelationshipProperty.Split("-", true);
            Node     startNode = GetNode(nodeNamesAndRelationshipProperties[0], true);

            PathImpl.Builder builder = new PathImpl.Builder(startNode);

            if (nodeNamesAndRelationshipProperties.Length < 1)
            {
                return(builder.Build());
            }

            for (int i = 0; i < nodeNamesAndRelationshipProperties.Length - 2; i += 2)
            {
                string       from         = nodeNamesAndRelationshipProperties[i];
                string       to           = nodeNamesAndRelationshipProperties[i + 2];
                string       prop         = nodeNamesAndRelationshipProperties[i + 1];
                Relationship relationship = MakeEdge(from, to, relPropertyName, prop);
                builder = builder.Push(relationship);
            }
            return(builder.Build());
        }
Ejemplo n.º 2
0
        private static ICollection <Path> HitToPaths(Hit hit, Node start, Node end, bool stopAsap)
        {
            ICollection <Path> paths = new List <Path>();
            IEnumerable <LinkedList <Relationship> > startPaths = GetPaths(hit.ConnectingNode, hit.Start, stopAsap);
            IEnumerable <LinkedList <Relationship> > endPaths   = GetPaths(hit.ConnectingNode, hit.End, stopAsap);

            foreach (LinkedList <Relationship> startPath in startPaths)
            {
                PathImpl.Builder startBuilder = ToBuilder(start, startPath);
                foreach (LinkedList <Relationship> endPath in endPaths)
                {
                    PathImpl.Builder endBuilder = ToBuilder(end, endPath);
                    Path             path       = startBuilder.Build(endBuilder);
                    paths.Add(path);
                }
            }
            return(paths);
        }