Esempio n. 1
0
 private void InsertCharacter(ref Node startNode, int startIndex, int endIndex)
 {
     if (startNode != null)
     {
         Node       leaf = null;
         NormalEdge edge = new NormalEdge(startIndex, endIndex, startNode, leaf);
         edge.text = suffixString.Substring(edge.startCharacterIndex, edge.endCharacterIndex - edge.startCharacterIndex + 1);
         startNode.AddEdge(edge);
     }
     else
     {
         startNode = new Node(nodeNumber);
         nodeNumber++;
         Node       leaf = null;
         NormalEdge edge = new NormalEdge(startIndex, endIndex, startNode, leaf);
         edge.text = suffixString.Substring(edge.startCharacterIndex, edge.endCharacterIndex - edge.startCharacterIndex + 1);
         startNode.AddEdge(edge);
     }
     //this is true only at the very first beginning, at the time the after first edge was inserted
     if (activePoint.activeEdge == null && startNode == root)
     {
         activePoint.activeEdge = startNode.GetAllNormalEdges()[0];
         activePoint.length     = 1;
     }
 }
Esempio n. 2
0
 //For TreeView GUI control
 private void TreeViewDraw(TreeView treeView, Node node, TreeNode parentNode)
 {
     if (node != null)
     {
         List <Edge> edges = node.GetAllEdges().ToList();
         foreach (Edge edge in edges)
         {
             if (edge.GetType() == typeof(NormalEdge))
             {
                 NormalEdge nedge = edge as NormalEdge;
                 TreeNode   tn    = new TreeNode(suffixString.Substring(nedge.startCharacterIndex, nedge.endCharacterIndex - nedge.startCharacterIndex + 1));
                 parentNode.Nodes.Add(tn);
                 TreeViewDraw(treeView, nedge.EndNode(), tn);
             }
         }
     }
     else
     {
         return;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Create part of js script for dracula graph visualization
        /// </summary>
        /// <param name="node"></param>
        /// <param name="edge">This is edge that comes into Node</param>
        /// <returns></returns>
        private string DraculaGraphLibraryDraw(Node node)
        {
            string s = "";

            if (node != null)
            {
                List <Edge> edges = node.GetAllEdges().ToList();
                foreach (Edge edge in edges)
                {
                    if (edge.GetType() == typeof(NormalEdge))
                    {
                        NormalEdge nedge    = edge as NormalEdge;
                        string     edgeName = suffixString.Substring(nedge.startCharacterIndex, nedge.endCharacterIndex - nedge.startCharacterIndex + 1);
                        string     start    = nedge.StartNode().number.ToString();
                        string     end      = "";
                        if (nedge.EndNode() != null)
                        {
                            end = nedge.EndNode().number.ToString();
                        }
                        else
                        {
                            end = "#" + nedge.startNode.number;
                        }
                        s += "g.addEdge(\"" + start + "\", \"" + end + "\", {label: \"" + edgeName + "\", directed:true});\n";
                        s += DraculaGraphLibraryDraw(nedge.EndNode());
                    }
                    else
                    {
                        string start = edge.startNode.number.ToString();
                        string end   = edge.endNode.number.ToString();
                        s += "g.addEdge(\"" + start + "\", \"" + end + "\", {directed:true, stroke: \"#FF0000\"});\n";
                    }
                }
            }
            else
            {
                return("");
            }
            return(s);
        }
Esempio n. 4
0
 public Triple(Node _activeNode, NormalEdge _activeEdge, int _length)
 {
     this.activeNode = _activeNode;
     this.activeEdge = _activeEdge;
     this.length     = _length;
 }