• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GraphNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: AddImplementedSymbols

 private static async Task AddImplementedSymbols(GraphBuilder graphBuilder, GraphNode node, IEnumerable<ISymbol> implementedSymbols)
 {
     foreach (var interfaceType in implementedSymbols)
     {
         var interfaceTypeNode = await graphBuilder.AddNodeForSymbolAsync(interfaceType, relatedNode: node).ConfigureAwait(false);
         graphBuilder.AddLink(node, CodeLinkCategories.Implements, interfaceTypeNode);
     }
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:ImplementsGraphQuery.cs


示例17: Test_AddChild_CircularReferenceOneLevel

 public void Test_AddChild_CircularReferenceOneLevel()
 {
     GraphNode<string> parent = new GraphNode<string>("parent");
     GraphNode<string> child = new GraphNode<string>("child");
     parent.AddChild(child);
     Assert.That(() => child.AddChild(parent),
         Throws.ArgumentException.And.Property("ParamName").EqualTo("graphNode"));
 }
开发者ID:anthonylangsworth,项目名称:GammaWorldCharacter,代码行数:8,代码来源:TestGraphNode.cs


示例18: Edge

 /// <summary>
 /// Creates a new instance of <see cref="Edge"/>.
 /// </summary>
 public Edge(GraphNode id, string label, IDictionary<string, GraphNode> properties, 
     GraphNode inV, string inVLabel, GraphNode outV, string outVLabel)
     : base(id, label, properties)
 {
     InV = inV;
     InVLabel = inVLabel;
     OutV = outV;
     OutVLabel = outVLabel;
 }
开发者ID:datastax,项目名称:csharp-driver-dse,代码行数:12,代码来源:Edge.cs


示例19: DependencyManager

 private DependencyManager(
     GraphNode<Library> graph,
     Dictionary<string, Library> librariesByName,
     Dictionary<string, ISet<Library>> librariesByType)
 {
     _graph = graph;
     _librariesByName = librariesByName;
     _librariesByType = librariesByType;
 }
开发者ID:elanwu123,项目名称:dnx,代码行数:9,代码来源:DependencyManager.cs


示例20: LinkToNode

    public bool LinkToNode(GraphNode to)
    {
        if (to.graph != graph)
            return false;

        graph.AddLink(this, to);

        return true;
    }
开发者ID:yatagarasu25,项目名称:GraphBuilder,代码行数:9,代码来源:GraphNode.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GraphState类代码示例发布时间:2022-05-24
下一篇:
C# Graph类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap