Пример #1
0
 public KnowledgeGraphNode(KnowledgeGraphNode node)
 {
     this.Index             = node.Index;
     this.OriginalGraphType = node.OriginalGraphType;
     this.Label             = node.Label;
     this.HtmlName          = node.HtmlName;
     this.LinkToPage        = node.LinkToPage;
     this.Neighbors         = new List <KnowledgeGraphNode>(node.Neighbors);
 }
        private static void DFSRecursive(KnowledgeGraph graph, List <bool> visited, KnowledgeGraphNode currentNode, int level, ref StringBuilder sb)
        {
            sb.Append(currentNode.Label);
            sb.AppendLine();
            visited[currentNode.Index] = true;

            level++;

            foreach (KnowledgeGraphNode neighbor in graph.KnGraph[currentNode.Index].Neighbors)
            {
                if (!visited[neighbor.Index])
                {
                    PrintLevelSpaces(level, ref sb);
                    DFSRecursive(graph, visited, neighbor, level, ref sb);
                }
            }

            level--;
        }
 private static void AddEdgeToKnowledgeGraph(ref KnowledgeGraph graph, int nodeIndex, KnowledgeGraphNode nodeToAdd)
 {
     graph.KnGraph[nodeIndex].Neighbors.Add(new KnowledgeGraphNode(nodeToAdd));
 }