public void AddPath(string path) { string[] map = path.Split(CustomPath.PathDiff); string now = map[0]; for (int i = 0; i < map.Length - 1; i++) { if (GetNode(now) == default) { AddPath(now); } if (i < map.Length - 2) { now += $"{CustomPath.PathDiff}{map[i + 1]}"; } } FileNode node = new FileNode(path, this); AllNodes.Add(node.Id, node); FileNode parent = GetNode(now); node.Parent = parent.Id; parent.Children.Add(node.Id); node.Depth = parent.Depth + 1; }
///<inheritdoc/> public NodeGene CreateNode() { NodeGene node = new NodeGene(AllNodes.Count + 1); AllNodes.Add(node); return(node); }
private TreeNode AddNode(TreeNode parent, string nodeID, string text, int imageIndex = NoneIndex, int selectedImageIndex = NoneIndex, string tooltip = "", object tag = null) { if (parent != null && parent.Nodes != null) { TreeNode trnNode = parent.Nodes.Add(nodeID, text); if (imageIndex > NoneIndex) { trnNode.ImageIndex = imageIndex; } if (selectedImageIndex > NoneIndex) { trnNode.SelectedImageIndex = selectedImageIndex; } if (!string.IsNullOrWhiteSpace(tooltip)) { trnNode.ToolTipText = tooltip; } if (tag != null) { trnNode.Tag = tag; } // using for decorate if (AllNodes == null) { AllNodes = new System.Collections.Generic.List <TreeNode>(); } AllNodes.Add(trnNode); return(trnNode); } return(null); }
public void AddNode(_Node node) { lock (AllNodesLock) { NodeCount++; AllNodes.Add(node); } }
/// <summary> /// If word already exists anywhere in map, just increase its occurrence. /// Otherwise inserts word into word map as the child of the node we're currently working on. /// </summary> /// <param name="word">Word to insert</param> private void InsertWord(string word) { _previouslyWorkingOn = _currentlyWorkingOn; // If map doesn't already contain word, add it if (AllNodes.Exists(x => x.Word == word) == false) { _currentlyWorkingOn = new WordMapNode(word, _nextNodeId); _nextNodeId++; if (_previouslyWorkingOn != null) { //Debug.Log($"Inserted {_currentlyWorkingOn.Word}"); _previouslyWorkingOn.Next.Add(_currentlyWorkingOn); _currentlyWorkingOn.Previous.Add(_previouslyWorkingOn); } else { StartingNodes.Add(_currentlyWorkingOn); } AllNodes.Add(_currentlyWorkingOn); } else { // If map already contains word, find it and increase its occurrence rate _currentlyWorkingOn = AllNodes.Find(x => x.Word == word); if (_currentlyWorkingOn == null) { return; } _currentlyWorkingOn.Occurrences++; if (_previouslyWorkingOn == null) { return; } //Debug.Assert(_previouslyWorkingOn.Next.Contains(_currentlyWorkingOn) == false, $"{_previouslyWorkingOn.Word} already had {_currentlyWorkingOn.Word} as NEXT"); //Debug.Assert(_currentlyWorkingOn.Previous.Contains(_previouslyWorkingOn) == false, $"{_currentlyWorkingOn.Word} already had {_previouslyWorkingOn.Word} as PREVIOUS"); if (_previouslyWorkingOn.Next.Contains(_currentlyWorkingOn) == false) { _previouslyWorkingOn.Next.Add(_currentlyWorkingOn); } if (_currentlyWorkingOn.Previous.Contains(_previouslyWorkingOn) == false) { _currentlyWorkingOn.Previous.Add(_previouslyWorkingOn); } } }
/// <summary> /// Sets the root of this tree <para/> /// Should only be called if the root has not already been set /// </summary> /// <param name="data">The value the root of the tree will have</param> /// <returns>A reference to the created root node</returns> public TreeNode <T> SetRoot(T data) { if (Root != null) { throw new Exception("Root is already set!"); } Root = new TreeNode <T>(null, data); AllNodes.Add(Root); return(Root); }
/// <summary> /// Adds a node with the given data to the tree as a child of a given parent node /// </summary> /// <param name="parent">The parent of this new node</param> /// <param name="data">The value the new node will contain</param> /// <returns>A reference to the newly created node</returns> public TreeNode <T> Add(TreeNode <T> parent, T data) { if (!AllNodes.Contains(parent)) { throw new Exception("Parent node not found in list of all nodes!"); } var newNode = new TreeNode <T>(parent, data); AllNodes.Add(newNode); return(newNode); }
public void AddNode(GraphNode node, bool onScrolledPosition = false) { if (onScrolledPosition) { node.Position += scrollPos; } node.Editor = this; node.Id = AllNodes.Count; node.UniqueName = $"{node.Id}::{node.Name}"; AllNodes.Add(node); }
public PosNode Add(PosNode node) { if (!AllNodes.ContainsKey(node.AccountID)) { AllNodes.Add(node.AccountID, node); } else { AllNodes[node.AccountID].IPAddress = node.IPAddress; // support for dynamic IP address } node.LastStaking = DateTime.Now; return(node); }
public string AddNode(State node) { if (node.Name == "say") { throw new Exception(); } if (AllNodesDict.ContainsKey(node.Name)) { throw new Exception(); } AllNodesDict.Add(node.Name, node); AllNodes.Add(node); return(node.Name); }
//this handles all the node select, add, remove commands a user would need public Node AddNodes(String Label = "", UnityVisualProperties opVisProp = null) { //Overide the default UserID if Label has been provided //This ensures that the lookup from edge to Node matches!!! Node node = this.gameObject.AddComponent <Node>(); if (Label != "") //added to match node labels to Unity Names { node.Label = Label; } //if (Label != "") // node.UserID = Label; AllNodes.Add(node.UserID, node); //FlatGraph.addNode(node); return(node); }
public void AddNode(Node node) { if (AllNodes.Contains(node)) { return; } AllNodes.Add(node); if (!DirectContingents.ContainsKey(node)) { DirectContingents.Add(node, new List <Node>()); } if (!DirectDependents.ContainsKey(node)) { DirectDependents.Add(node, new List <Node>()); } }
private void CreateTree(List <HATNode <T> > nodes) { if (nodes.Count <= 1) { Root = nodes[0]; return; } else { List <HATNode <T> > AllNodesTemp = new List <HATNode <T> >(); for (int i = 0; i < nodes.Count; i = i + 2) { HATNode <T> parent = new HATNode <T>(); parent.Left = nodes[i]; if (i + 1 < nodes.Count) { parent.Right = nodes[i + 1]; } parent.IsBlockNode = false; parent.FileBlockIndex = -1; parent.Version = 0; if (i + 1 < nodes.Count) { parent.Hash = Utility.ComputeHashAsString(nodes[i].Hash + nodes[i + 1].Hash); } else { parent.Hash = Utility.ComputeHashAsString(nodes[i].Hash); } AllNodes.Add(parent); AllNodesTemp.Add(parent); } CreateTree(AllNodesTemp); } }
public void CreateTree(List <FileBlock> fileBlocks) { fileBlocks = fileBlocks.OrderBy(x => x.Index).ToList(); for (int i = 0; i < fileBlocks.Count; i = i + 2) { MerkleTreeNode left = new MerkleTreeNode(); left.Hash = fileBlocks[i].ContentHash; left.IsBlockNode = true; left.Index = i; MerkleTreeNode right = new MerkleTreeNode(); if (i + 1 < fileBlocks.Count) { right.Hash = fileBlocks[i + 1].ContentHash; right.IsBlockNode = true; right.Index = i + 1; } MerkleTreeNode parent = new MerkleTreeNode(); parent.Left = left; parent.Right = right; parent.IsBlockNode = false; parent.Index = -1; if (i + 1 < fileBlocks.Count) { parent.Hash = Utility.ComputeHashAsString(left.Hash + right.Hash); } else { parent.Hash = Utility.ComputeHashAsString(left.Hash); } AllNodes.Add(parent); } CreateTree(); }
public async Task <PosNode> AddAsync(PosNode node) { if (!AllNodes.ContainsKey(node.AccountID)) { AllNodes.Add(node.AccountID, node); } else { AllNodes[node.AccountID].IP = node.IP; // support for dynamic IP address } node.LastStaking = DateTime.Now; // lookup balance var block = await BlockChain.Singleton.FindLatestBlockAsync(node.AccountID); if (block != null && block.Balances != null && block.Balances.ContainsKey(LyraGlobal.LYRATICKERCODE)) { node.Balance = block.Balances[LyraGlobal.LYRATICKERCODE]; } return(node); }
public void AddNode(Node node) { AllNodes.Add(node); }
public void CreateTree(List <FileBlock> fileBlocks) { AllNodes.Clear(); List <HATNode <T> > AllParentsNodeTemp = new List <HATNode <T> >(); ServerBob server = new ServerBob(); AliceUser user = new AliceUser(); server.User = user; user.Server = server; server.setKeysWithUser(); fileBlocks = fileBlocks.OrderBy(x => x.Index).ToList(); for (int i = 0; i < fileBlocks.Count; i = i + 2) { HATNode <T> left = new HATNode <T>(); left.Hash = fileBlocks[i].ContentHash; left.Tag = user.EncryptMessage(left.Hash); left.IsBlockNode = true; left.FileBlockIndex = i; left.Version = 1; AllNodes.Add(left); HATNode <T> right = new HATNode <T>(); if (i + 1 < fileBlocks.Count) { right.Hash = fileBlocks[i + 1].ContentHash; right.Tag = user.EncryptMessage(right.Hash); right.IsBlockNode = true; right.FileBlockIndex = i + 1; right.Version = 1; AllNodes.Add(right); } HATNode <T> parent = new HATNode <T>(); parent.Left = left; parent.Right = right; parent.IsBlockNode = false; parent.FileBlockIndex = -1; if (i + 1 < fileBlocks.Count) { parent.Hash = Utility.ComputeHashAsString(left.Hash + right.Hash); } else { parent.Hash = Utility.ComputeHashAsString(left.Hash); } AllNodes.Add(parent); AllParentsNodeTemp.Add(parent); } CreateTree(AllParentsNodeTemp); SetNodeIndexes(); SetLeafNodeCount(); }
public void AddOpen(Node node) { AllNodes.Add(node); }
static void Main(string[] args) { N = 17; #region nodepop Node n0 = new Node(0); Node n1 = new Node(0); Node n2 = new Node(0); Node n3 = new Node(0); Node n4 = new Node(0); Node n5 = new Node(0); Node n6 = new Node(0); Node n7 = new Node(0); Node n8 = new Node(0); Node n9 = new Node(0); Node n10 = new Node(0); Node n11 = new Node(0); Node n12 = new Node(0); Node n13 = new Node(0); Node n14 = new Node(0); Node n15 = new Node(0); Node n16 = new Node(0); Node n17 = new Node(0); n0.Connections.Add(4); n0.Connections.Add(8); n0.Connections.Add(13); n0.Connections.Add(14); n1.Connections.Add(5); n2.Connections.Add(9); n2.Connections.Add(15); n3.Connections.Add(9); n4.Connections.Add(0); n4.Connections.Add(8); n5.Connections.Add(1); n5.Connections.Add(16); n5.Connections.Add(17); n6.Connections.Add(7); n6.Connections.Add(11); n7.Connections.Add(6); n7.Connections.Add(11); n8.Connections.Add(0); n8.Connections.Add(4); n8.Connections.Add(14); n9.Connections.Add(2); n9.Connections.Add(3); n9.Connections.Add(15); n10.Connections.Add(15); n11.Connections.Add(6); n11.Connections.Add(7); n13.Connections.Add(0); n13.Connections.Add(14); n14.Connections.Add(0); n14.Connections.Add(8); n14.Connections.Add(13); n15.Connections.Add(2); n15.Connections.Add(9); n15.Connections.Add(10); n16.Connections.Add(5); n17.Connections.Add(5); AllNodes.Add(n0); AllNodes.Add(n1); AllNodes.Add(n2); AllNodes.Add(n3); AllNodes.Add(n4); AllNodes.Add(n5); AllNodes.Add(n6); AllNodes.Add(n7); AllNodes.Add(n8); AllNodes.Add(n9); AllNodes.Add(n10); AllNodes.Add(n11); AllNodes.Add(n12); AllNodes.Add(n13); AllNodes.Add(n14); AllNodes.Add(n15); AllNodes.Add(n16); AllNodes.Add(n17); #endregion nodepop for (int i = 0; i < Visited.Length; i++) { Visited[i] = false; Console.Write($"{i} false "); } for (int i = 0; i < 18; i++) { Result.Add(i, new List <int>()); } FindComponents(); }