Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") public static org.neo4j.graphdb.PathExpander describeRelationships(java.util.Map<String, Object> description)
        public static PathExpander DescribeRelationships(IDictionary <string, object> description)
        {
            PathExpanderBuilder expander = PathExpanderBuilder.allTypesAndDirections();

            object relationshipsDescription = description["relationships"];

            if (relationshipsDescription != null)
            {
                ICollection <object> pairDescriptions;
                if (relationshipsDescription is System.Collections.ICollection)
                {
                    pairDescriptions = (ICollection <object>)relationshipsDescription;
                }
                else
                {
                    pairDescriptions = Arrays.asList(relationshipsDescription);
                }

                foreach (object pairDescription in pairDescriptions)
                {
                    System.Collections.IDictionary map = (System.Collections.IDictionary)pairDescription;
                    string           name          = ( string )map["type"];
                    RelationshipType type          = RelationshipType.withName(name);
                    string           directionName = ( string )map["direction"];
                    expander = (string.ReferenceEquals(directionName, null)) ? expander.Add(type) : expander.Add(type, StringToEnum(directionName, typeof(RelationshipDirection), true).@internal);
                }
            }
            return(expander.Build());
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void filtersTouchesAllIntermediateNodes()
        public virtual void FiltersTouchesAllIntermediateNodes()
        {
            // Layout:
            //
            // (a)-->(b)-->(c)-->(d)
            //
            Graph.makeEdgeChain("a,b,c,d");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Node a = graph.getNode("a");
            Node a = Graph.getNode("a");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Node d = graph.getNode("d");
            Node d = Graph.getNode("d");
            ICollection <Node> touchedByFilter = new HashSet <Node>();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final System.Predicate<org.neo4j.graphdb.Node> filter = item ->
            System.Predicate <Node> filter = item =>
            {
                touchedByFilter.Add(item);
                return(true);
            };
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.PathExpander expander = org.neo4j.graphdb.PathExpanderBuilder.empty().add(R1, OUTGOING).addNodeFilter(filter).build();
            PathExpander expander = PathExpanderBuilder.empty().add(R1, OUTGOING).addNodeFilter(filter).build();
            //final PathExpander expander = ((StandardExpander) PathExpanders.forTypeAndDirection(R1, OUTGOING)).addNodeFilter( filter );
            Path path = Iterables.single(GraphAlgoFactory.shortestPath(expander, 10).findAllPaths(a, d));

            assertEquals(3, path.Length());

            IList <Node> nodes             = Iterables.asList(path.Nodes());
            IList <Node> intermediateNodes = nodes.subList(1, nodes.Count - 1);

//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method:
            assertTrue("touchedByFilter: " + touchedByFilter, touchedByFilter.containsAll(intermediateNodes));
            assertTrue("startNode was not filtered", !touchedByFilter.Contains(a));
            assertTrue("endNode was not filtered", !touchedByFilter.Contains(d));
        }