当前位置: 首页>>代码示例>>C#>>正文


C# Graph.GetNode方法代码示例

本文整理汇总了C#中Graph.GetNode方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.GetNode方法的具体用法?C# Graph.GetNode怎么用?C# Graph.GetNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph.GetNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnEnable

    void OnEnable()
    {
        grid = GameObject.Find("PathFinder").GetComponent<Graph>();

        Node node = grid.GetNode(this.transform.position);
        nodes  = grid.GetAdjacents(node);
        nodes.Add(node);

        foreach(Node n in nodes)
        {
            print(n.myWorldPosition);
            n.walkable = false;
        }
    }
开发者ID:Ashen-Vaults,项目名称:Unity-Path-Finder,代码行数:14,代码来源:BlockingEntity.cs

示例2: BuildGraph

 // build a directed graph from a series of strings
 //    each contains two node names and indicate a directed edge
 //    between the nodes from the first one to the second one
 public void BuildGraph(List<String> listOfEdges)
 {
     myGraph = new Graph<Char>();
     foreach (String s in listOfEdges)
     {
         Match m = ParseInputLine(s);
         if (m.Success)
         {
             Char nodeName = Char.Parse(m.Groups["fromNode"].Value);
             GraphNode<Char> fromNode = myGraph.GetNode(nodeName);
             if (fromNode == null)
             {
                 fromNode = myGraph.AddNode(nodeName);
             }
             nodeName = Char.Parse(m.Groups["toNode"].Value);
             GraphNode<Char> toNode = myGraph.GetNode(nodeName);
             if (toNode == null)
             {
                 toNode = myGraph.AddNode(nodeName);
             }
             myGraph.AddEdge(fromNode, toNode, true);
         }
     }
 }
开发者ID:WaterClown,项目名称:walkscore,代码行数:27,代码来源:GraphUser.cs

示例3: GetNodeByPos

		public static Graph<TilingNodeInfo, TilingEdgeInfo>.Node GetNodeByPos(Graph<TilingNodeInfo, TilingEdgeInfo> graph, int x, int y, int width)
		{
			 return graph.GetNode(GetNodeIdFromPos(x, y,width));
		}
开发者ID:Rydra,项目名称:HierarchicalPathfinder,代码行数:4,代码来源:GraphFactory.cs

示例4: readbuildfile

        public KeyValuePair<Graph<string>, Dictionary<string, BuildElement>> readbuildfile(string absfilepath)
        {
            XmlTextReader reader = new XmlTextReader(absfilepath);
            Graph<string> buildgraph = new Graph<string>();
            Dictionary<string, BuildElement> buildelements = new Dictionary<string, BuildElement>();
            string name = "";
            string extension = "";
            string instruction = "";
            string source = "";
            string target = "";
            bool dep = false;
            bool command = false;
            BuildElement element = null;
            try
            {
                while (reader.Read())
                {

                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element: // The node is an element.
                            Console.Write("<" + reader.Name);
                            if (reader.Name == "file")
                            {
                                element = new BuildElement();
                                while (reader.MoveToNextAttribute())// Read the attributes.
                                {
                                    if (reader.Name == "name")
                                    {
                                        name = reader.Value;
                                        source = reader.Value;
                                        extension = System.IO.Path.GetExtension(reader.Value);
                                        element.setName(name);
                                        element.setExtension(extension);
                                        buildelements.Add(name, element);
                                        //buildgraph.AddNode(name);
                                    }
                                    Console.Write(" " + reader.Name + "='" + reader.Value + "'");
                                }
                            }
                            if (reader.Name == "dep")
                            {
                                dep = true;
                            }
                            if (reader.Name == "command")
                            {
                                command = true;
                            }

                            Console.WriteLine(">");
                            break;
                        case XmlNodeType.Text: //Display the text in each element.
                            if (dep)
                            {
                                target = reader.Value;
                                if (!buildgraph.Contains(source))
                                    buildgraph.AddNode(source);
                                if (!buildgraph.Contains(target))
                                    buildgraph.AddNode(target);

                                buildgraph.AddDirectedEdge((GraphNode<string>)buildgraph.GetNode(source), (GraphNode<string>)buildgraph.GetNode(target), 1);
                                buildelements[source].dependencies.Add(target);
                                target = "";
                                dep = false;
                            }
                            if (command)
                            {
                                buildelements[name].setBuildInstruction(reader.Value);
                                command = false;
                            }
                            Console.WriteLine(reader.Value);
                            break;
                        case XmlNodeType.EndElement: //Display the end of the element.
                            if (reader.Name == "file")
                            {
                                element = null;
                            }
                            Console.Write("</" + reader.Name);
                            Console.WriteLine(">");
                            break;
                    }
                }
            }

            catch (Exception e)
            {
                Console.WriteLine("Exception in XmlReader: "+e.Message);
            }
            return new KeyValuePair<Graph<string>, Dictionary<string, BuildElement>>(buildgraph, buildelements);
        }
开发者ID:mheise,项目名称:Unmake,代码行数:90,代码来源:XmlReader.cs

示例5: LoadLayout


//.........这里部分代码省略.........
            else if ((category & 2) == 2) {
                nodeObject = Instantiate(heapPrefab, new Vector3(x, y, z), Quaternion.identity) as Function;
                scale = 2.0f;
            } else {
                nodeObject = Instantiate(defaultPrefab, new Vector3(x, y, z), Quaternion.identity) as Function;
            }

            nodeObject.funcname = j[i]["name"];
            nodeObject.address = ulong.Parse(j[i]["address"]);
            nodeObject.attributes = category;
            if (j[i]["size"] != null) {
                nodeObject.size = int.Parse(j[i]["size"]);
            } else {
                nodeObject.size = 0;
            }
            nodeObject.module_name   = j[i]["module_name"];
            nodeObject.functag		 = j[i]["tag"];
            nodeObject.comment		 = j[i]["comment"];
            nodeObject.longname		 = j[i]["long_name"];
            nodeObject.basic_blk_cnt = int.Parse(j[i]["basic_blk_cnt"]);

            if (j[i]["dangerous_list"] != null) {
                nodeObject.dangerous_calls = new string[j[i]["dangerous_list"].Count];
                for (int c = 0; c < j[i]["dangerous_list"].Count; c++) {
                    nodeObject.dangerous_calls[c] = j[i]["dangerous_list"][c];
                }
            }

            if (j[i]["strings"] != null) {
                nodeObject.strings = new string[j[i]["strings"].Count];
                for (int c = 0; c < j[i]["strings"].Count; c++) {
                    nodeObject.strings[c] = j[i]["strings"][c];
                }
            }

            nodeObject.transform.localScale += new Vector3(scale, scale, scale);
            nodes.Add(nodeObject.address, nodeObject);

            // For force directed graph
            NodeData data = new NodeData();
            data.label = nodeObject.address.ToString();
            data.mass = (float)nodeObject.size / 50.0f + 10.0f;
            graph.CreateNode(data);

            statusText.text = "Loading Functions: Function " + nodeObject.funcname;

            if(i % 100 == 0)
                yield return true;
        }

        j = JSON.Parse(rawJson);
        j = j["callgraph"];

        for(int i = 0; i < j.Count; i++) {
            ulong srcid = ulong.Parse(j[i]["source"]);
            ulong dstid = ulong.Parse(j[i]["target"]);

            if (FindDupLink (srcid, dstid)) {
                continue;
            }

            Link linkObject = Instantiate(linkPrefab, new Vector3(0, 0, 0), Quaternion.identity) as Link;
            linkObject.id       = i+1;
            linkObject.sourceId = srcid;
            linkObject.targetId = dstid;
            links.Add(linkObject.id, linkObject);

            // For force directed graph
            Node node1 = graph.GetNode(linkObject.sourceId.ToString());
            Node node2 = graph.GetNode(linkObject.targetId.ToString());
            EdgeData data = new EdgeData();
            data.label = linkObject.sourceId.ToString()+"-"+linkObject.targetId.ToString();
            data.length = 1.0f;
            graph.CreateEdge(node1, node2, data);

            statusText.text = "Loading Callgraph: Call " + linkObject.id.ToString();

            if(i % 100 == 0)
                yield return true;
        }

        // Map node edges
        MapLinkFunctions();

        // For force directed graph
        physics = new ForceDirected3D(graph, // instance of Graph
                                      stiffness, // stiffness of the spring
                                      repulsion, // node repulsion rate
                                      damping    // damping rate
                                     );
        render = new FDRenderer(physics);
        render.setController(this);

        statusText.text = "";

        Camera.main.transform.LookAt (new Vector3 (0f, 0f, 0f));

        renderThread = new Thread(new ThreadStart(FDRenderThread));
        renderThread.Start ();
    }
开发者ID:zoebear,项目名称:Radia,代码行数:101,代码来源:GameController.cs


注:本文中的Graph.GetNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。