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


C# GraphNode类代码示例

本文整理汇总了C#中GraphNode的典型用法代码示例。如果您正苦于以下问题:C# GraphNode类的具体用法?C# GraphNode怎么用?C# GraphNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DrawGraphNodeGizmo

    public static void DrawGraphNodeGizmo(GraphNode node, GizmoType type)
    {
        using (new GizmosColor(GraphEditorWindow.GetGraphColor(node.graph))) {
            if (node.graph == null) {
                Vector3 nodePinPosition = node.transform.position + GraphEditorWindow.GetGraphNodePinShift(node);
                Gizmos.DrawLine(node.transform.position, nodePinPosition);
                Gizmos.DrawWireSphere(nodePinPosition, GraphEditorWindow.GraphNodePinRadius * 1.1f);

                return;
            }

            if ((type & GizmoType.Selected) != 0) {
                GraphEditor.DrawGraphGizmo(node.graph, GizmoType.NonSelected);

                Vector3 pinShift = GraphEditorWindow.GetGraphNodePinShift(node);
                Vector3 nodePinPosition = node.transform.position + pinShift;
                Gizmos.DrawLine(node.transform.position, nodePinPosition);
                Gizmos.DrawWireSphere(nodePinPosition, GraphEditorWindow.GraphNodePinRadius * 1.1f);

                foreach (GraphNode linkedNode in node.EnumLinkedNodes()) {
                    Gizmos.DrawLine(nodePinPosition, linkedNode.transform.position + pinShift);
                }
            }
            else if (type == GizmoType.NonSelected) {
                Vector3 pinShift = GraphEditorWindow.GetGraphNodePinShift(node);
                Vector3 nodePinPosition = node.transform.position + pinShift;
                Gizmos.DrawLine(node.transform.position, nodePinPosition);
                Gizmos.DrawSphere(nodePinPosition, GraphEditorWindow.GraphNodePinRadius);
            }
        }
    }
开发者ID:yatagarasu25,项目名称:GraphBuilder,代码行数:31,代码来源:GraphNodeEditor.cs

示例2: SetCurrentNode

	public void SetCurrentNode(GraphNode gn) {
		if(currentNode != null)
			currentNode.SetActive(false);

		currentNode = gn;
		currentNode.SetActive(true);
	}
开发者ID:LatexBotox,项目名称:SPACE,代码行数:7,代码来源:MapController.cs

示例3: GraphEdge

        public GraphEdge(GraphNode source, GraphNode destination)
        {
            this._source = source;
            this._destination = destination;

            source.AdjecentEdges.Add(this);
        }
开发者ID:Gluestick,项目名称:AIssignment,代码行数:7,代码来源:GraphEdge.cs

示例4: findLinkV5

 public static bool findLinkV5(GraphNode start, GraphNode end)
 {
     System.Collections.Generic.Queue<GraphNode> searched = new System.Collections.Generic.Queue<GraphNode>();
     searched.Enqueue(start);
     start.state = Visiting;
     while (searched.Count!=0)
     {
         GraphNode gn = searched.Dequeue();
         if (gn!=null)
         {
             gn.state = Visited;
             foreach (GraphNode node in gn.Nodes)
             {
                 if (node.state == Unvisitied)
                 {
                     if (node == end)
                     {
                         return true;
                     }
                     node.state = Visiting;
                     searched.Enqueue(node);
                 }
             }
         }
     }
     return false;
 }
开发者ID:Sanqiang,项目名称:Algorithm-Win,代码行数:27,代码来源:CC4_2.cs

示例5: ShouldFindShortesPathWhen1PathExists

        public void ShouldFindShortesPathWhen1PathExists()
        {
            //http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
            var one = new GraphNode<int>(1);
            var two = new GraphNode<int>(2);
            var three = new GraphNode<int>(3);
            var four = new GraphNode<int>(4);
            var five = new GraphNode<int>(5);
            var six = new GraphNode<int>(6);

            one.AddNeighbour(six, 14);
            one.AddNeighbour(three, 9);
            one.AddNeighbour(two, 7);

            two.AddNeighbour(three, 10);
            two.AddNeighbour(four, 15);

            three.AddNeighbour(six, 2);
            three.AddNeighbour(four, 11);

            four.AddNeighbour(five, 6);

            five.AddNeighbour(six, 9);

            var graph = new List<GraphNode<int>> {one, two, three, four, five, six};

            var dijkstra = new Dijkstra<int>(graph);
            var path = dijkstra.FindShortestPathBetween(one, five);

            path[0].Value.ShouldBe(1);
            path[1].Value.ShouldBe(3);
            path[2].Value.ShouldBe(6);
            path[3].Value.ShouldBe(5);
        }
开发者ID:valantonini,项目名称:GraphCollection,代码行数:34,代码来源:TestDijkstra.cs

示例6: TestMatrixGraph

      public void TestMatrixGraph()
      {
         var emptyGraph = new MatrixGraph<int>();

         var root = new GraphNode<int>(10);
         var expandedGraph = root.MakeEdges<int>(null);
      }
开发者ID:helios2k6,项目名称:DSA,代码行数:7,代码来源:GraphTests.cs

示例7: PopulateMapsForFileInputNode

        private void PopulateMapsForFileInputNode(GraphNode inputNode)
        {
            using (_gate.DisposableWait())
            {
                var projectPath = inputNode.Id.GetNestedValueByName<Uri>(CodeGraphNodeIdName.Assembly);
                var filePath = inputNode.Id.GetNestedValueByName<Uri>(CodeGraphNodeIdName.File);

                if (projectPath == null || filePath == null)
                {
                    return;
                }

                var project = _solution.Projects.FirstOrDefault(
                    p => string.Equals(p.FilePath, projectPath.OriginalString, StringComparison.OrdinalIgnoreCase));
                if (project == null)
                {
                    return;
                }

                _nodeToContextProjectMap.Add(inputNode, project);

                var document = project.Documents.FirstOrDefault(
                    d => string.Equals(d.FilePath, filePath.OriginalString, StringComparison.OrdinalIgnoreCase));
                if (document == null)
                {
                    return;
                }

                _nodeToContextDocumentMap.Add(inputNode, document);
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:31,代码来源:GraphBuilder.cs

示例8: ConstructDependencyGraph

        /// <summary>
        /// Construct a depdenency graph of the <see cref="Character"/>'s <see cref="ModifierSource"/>s.
        /// </summary>
        /// <param name="character">
        /// The <see cref="Character"/> to generate the dependency graph for. This cannot be null.
        /// </param>
        /// <param name="modifierSources">
        /// The already extracted list of <see cref="ModifierSource"/>s to use. This cannot be null.
        /// </param>
        /// <returns>
        /// A <see cref="GraphNode{ModifierSource}"/> that is the root node of a dependency graph. The root
        /// node can be ignored and is not part of the graph itself.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// No argument can be null.
        /// </exception>
        internal static GraphNode<ModifierSource> ConstructDependencyGraph(Character character, IList<ModifierSource> modifierSources)
        {
            if (character == null)
            {
                throw new ArgumentNullException("character");
            }
            if (modifierSources == null)
            {
                throw new ArgumentNullException("modifierSources");
            }

            GraphNode<ModifierSource> root;
            IEqualityComparer<ModifierSource> comparer;
            Dictionary<ModifierSource, GraphNode<ModifierSource>> graphNodeLookup;

            // Rather than use "EqualityComparer<ModifierSource>.Default", use identity equality.
            // This allows two instances of the same modifier source with the same name to be used
            // within the graph. This can occur frequently with powers.
            comparer = new IdentityEqualityComparer<ModifierSource>();

            // Optimization for GraphNode.Find().
            graphNodeLookup = new Dictionary<ModifierSource, GraphNode<ModifierSource>>();

            // Construct a dependency graph.
            root = new GraphNode<ModifierSource>(new NullModifierSource(), comparer);
            foreach (ModifierSource modifierSource in modifierSources)
            {
                List<KeyValuePair<ModifierSource, ModifierSource>> dependencies;
                GraphNode<ModifierSource> parentGraphNode;
                GraphNode<ModifierSource> childGraphNode;

                // Get the dependencies
                dependencies = modifierSource.GetDependencies(character);

                // For each dependency, find the source ModifierSource and add
                // the destination under it.
                foreach (KeyValuePair<ModifierSource, ModifierSource> dependency in dependencies)
                {
                    // Find the parent of the dependency
                    if (!graphNodeLookup.TryGetValue(dependency.Key, out parentGraphNode))
                    {
                        parentGraphNode = new GraphNode<ModifierSource>(dependency.Key, comparer);
                        root.AddChild(parentGraphNode);
                        graphNodeLookup[dependency.Key] = parentGraphNode;
                    }

                    // Find the child of the dependency
                    if (!graphNodeLookup.TryGetValue(dependency.Value, out childGraphNode))
                    {
                        childGraphNode = new GraphNode<ModifierSource>(dependency.Value, comparer);
                        graphNodeLookup[dependency.Value] = childGraphNode;
                    }

                    // Add the child to the parent
                    parentGraphNode.AddChild(childGraphNode);
                }
            }

            return root;
        }
开发者ID:anthonylangsworth,项目名称:GammaWorldCharacter,代码行数:76,代码来源:ModifierSourceGraphNodeHelper.cs

示例9: Save

    public static void Save(PlanerCore planer, GraphNode node, int direction, bool onPlaySave)
    {
        //Debug.Log("OnSave");
        //PlayerPrefs.DeleteAll();
        PlayerPrefs.SetInt("MineCount", planer.MineController.Mines.Count);
        //Debug.Log(Application.loadedLevelName);
        string currentLevel = Application.loadedLevelName;
        if (currentLevel == "GlobalMap")
          currentLevel = Creator.PreviousLevel;
        PlayerPrefs.SetString("CurrentLevel", currentLevel);

        for (int i = 0; i < planer.MineController.Mines.Count; i++)
        {
          PlayerPrefs.SetInt("Mine" + i, Armory.WeaponIndex(planer.MineController.Mines[i].GetType().Name));
        }
        if (onPlaySave)
        {
          PlayerPrefs.SetInt("XCoord", node.X);
          PlayerPrefs.SetInt("YCoord", node.Y);
          PlayerPrefs.SetInt("IndexCoord", node.Index);
          PlayerPrefs.SetInt("LevelCoord", node.Level);
          if(direction<0)
        direction=planer.Direction;
          PlayerPrefs.SetInt("Direction", direction);
        }
    }
开发者ID:crassus0,项目名称:Edge-drivers,代码行数:26,代码来源:PlayerSaveData.cs

示例10: AStarNode

 public AStarNode(GraphNode<StateConfig> state, AStarNode parent, float pathCost, float estCost)
 {
     this.state = state;
     this.parent = parent;
     this.pathCost = pathCost;
     this.estCost = estCost;
 }
开发者ID:heuristicus,项目名称:DD2438,代码行数:7,代码来源:AStarNode.cs

示例11: Main

        static void Main(string[] args)
        {
            GraphNode rootGraph = new GraphNode(null, "Root");
            GraphNode child1 = new GraphNode(null, "Child1");
            GraphNode child2 = new GraphNode(null, "Child2");
            rootGraph.AddChildNode(child1);
            rootGraph.AddChildNode(child2);

            // physics update frame 1 ----------------------------

            Console.WriteLine("*** Frame 1 ***");
            child2.SetTransform(new Transform(child2.Local.Name)); // simulates some kind of physical force

            Console.WriteLine("----- Simple traversal -----");
            rootGraph.SimpleRender(Transform.Origin);

            Console.WriteLine();

            Console.WriteLine("----- Dirty-flag traversal -----");
            rootGraph.DirtyFlagRender(Transform.Origin, rootGraph.Dirty);

            Console.WriteLine();
            Console.WriteLine();

            // physics update frame 2 ----------------------------

            Console.WriteLine("*** Frame 2 ***");
            child1.SetTransform(new Transform(child1.Local.Name)); // simulates some kind of physical force

            Console.WriteLine();

            Console.WriteLine("----- Simple traversal -----");
            rootGraph.SimpleRender(Transform.Origin);

            Console.WriteLine();

            Console.WriteLine("----- Dirty-flag traversal -----");
            rootGraph.DirtyFlagRender(Transform.Origin, rootGraph.Dirty);

            Console.WriteLine();
            Console.WriteLine();

            // physics update frame 3 ----------------------------

            Console.WriteLine("*** Frame 3 ***");
            rootGraph.SetTransform(new Transform(rootGraph.Local.Name)); // simulates some kind of physical force

            Console.WriteLine();

            Console.WriteLine("----- Simple traversal -----");
            rootGraph.SimpleRender(Transform.Origin);

            Console.WriteLine();

            Console.WriteLine("----- Dirty-flag traversal -----");
            rootGraph.DirtyFlagRender(Transform.Origin, rootGraph.Dirty);

            Console.ReadLine();
        }
开发者ID:Wikzo,项目名称:gameprogrammingpatterns,代码行数:59,代码来源:Program.cs

示例12: AddNode

    public void AddNode(Vector3 neighborPoint, ref GraphNode currentNode, ref Queue<GraphNode> q )
    {
        RaycastHit hitInfo;
        Vector3 rayDirection = Vector3.zero;
        #if USE_XZ
        rayDirection = new Vector3(0, -1, 0);
        #else
        rayDirection = new Vector3(0, 0, 1);
        #endif //USE_XZ
        int layerMask = 1 << 8;
        layerMask = ~layerMask;
        if ( Physics.Raycast(neighborPoint, rayDirection, out hitInfo, Mathf.Infinity, layerMask) )
        {
            if (hitInfo.transform.tag == "Ground")
            {
                GraphNode newNode = new GraphNode(mNumOfNodes, hitInfo.point); // make a new node for this point
                GraphEdge newEdge = new GraphEdge(currentNode.GetIndex(), newNode.GetIndex()); // creat a new edge

                int index = 0;
                bool nodeFound = false;
                while ( !nodeFound && index <= mNumOfNodes )
                {
                    //Debug.Log (index + " out of " + NavigationGraph.Length + " thinks there's only" + mNumOfNodes);
                    nodeFound = ( NavigationGraph[index] == hitInfo.point );

                    ++index;
                }

                if ( !nodeFound ) // if we have not found this node before, add it
                {
                    Nodes.Add(newNode);
                    NavigationGraph[mNumOfNodes] = hitInfo.point;
                    ++mNumOfNodes;

                    q.Enqueue(newNode);
                }
                else
                {
                    newEdge.SetToIndex(index-1);
                }

                // If the raycast hit then we will always want to add the edge, since we want edges
                // in both directions and there won't ever be duplicates.

                // check if there is a clear path to add an edge
                Vector3 heightOffset = Vector3.zero;
        #if USE_XZ
                heightOffset = new Vector3(0, 0.5f, 0);
        #else
                heightOffset = new Vector3(0, 0, -0.5f);
        #endif // USE_XZ
                if ( !Physics.Linecast(currentNode.GetPosition() + heightOffset, newNode.GetPosition() + heightOffset, out hitInfo, layerMask) )
                {
                    Edges.Add(newEdge);
                    currentNode.AddEdge(newEdge);
                }
            }
        }
    }
开发者ID:jordanajlouni,项目名称:ProjectAccountingSoftware-1,代码行数:59,代码来源:NavGraphConstructor.cs

示例13: AddNode

 public int AddNode(Vector3 position)
 {
     Nodes.Add(new GraphNode(NextNodeIndex, position));
     Edges.Add(new List<GraphEdge>());
     GraphNode n = new GraphNode(NextNodeIndex, position);
     NextNodeIndex++;
     return NextNodeIndex - 1;
 }
开发者ID:johnh8888,项目名称:SpokenBlackTiles,代码行数:8,代码来源:SparseGraph.cs

示例14: SetState

	public void SetState(MshipState s, GraphNode n) {
		state = s;
		gn = n;

		if(s == MshipState.TRAVEL)
			travelDist = (gn.transform.position - transform.position).magnitude - orbitDist;

	}
开发者ID:LatexBotox,项目名称:SPACE,代码行数:8,代码来源:MapMothership.cs

示例15: Awake

 void Awake()
 {
     foreach (Anchor anchor in GetComponentsInChildren<Anchor>()) {
         anchorList.Add(anchor);
     }
     graphNode = GetComponentInChildren<GraphNode> ();
     renderers = GetComponentsInChildren<Renderer> ();
 }
开发者ID:tomhettinger,项目名称:PirateStorm,代码行数:8,代码来源:Piece.cs


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