Graph.getNode C# (CSharp) Method

getNode() public method

public getNode ( int p_id ) : Node
p_id int
return Node
    public Node getNode(int p_id)
    {
        if(debug)
            Debug.Log("Getting Node: "+p_id);
        foreach (KeyValuePair<Node, ArrayList> pair in graph)
        {
            if(pair.Key.getId() == p_id)
                return pair.Key;
        }
        return null;
    }

Usage Example

示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void withState()
        public virtual void WithState()
        {
            /* Graph
             *
             * (a)-[1]->(b)-[2]->(c)-[5]->(d)
             */

            Graph.makeEdgeChain("a,b,c,d");
            SetWeight("a", "b", 1);
            SetWeight("b", "c", 2);
            SetWeight("c", "d", 5);

            InitialBranchState <int> state = new Org.Neo4j.Graphdb.traversal.InitialBranchState_State <int>(0, 0);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.Map<org.neo4j.graphdb.Node, int> encounteredState = new java.util.HashMap<>();
            IDictionary <Node, int> encounteredState = new Dictionary <Node, int>();
            PathExpander <int>      expander         = new PathExpanderAnonymousInnerClass(this, state, encounteredState);

            PathFinder <WeightedPath> finder = new Dijkstra(expander, state, CommonEvaluators.doubleCostEvaluator("weight"));

            AssertPaths(finder.FindAllPaths(Graph.getNode("a"), Graph.getNode("d")), "a,b,c,d");
            assertEquals(1, encounteredState[Graph.getNode("b")]);
            assertEquals(3, encounteredState[Graph.getNode("c")]);
            assertEquals(8, encounteredState[Graph.getNode("d")]);
        }
All Usage Examples Of Graph::getNode