public static async void AnalyseWord() { string initialWord = "matter"; Stopwatch sw = new Stopwatch(); sw.Start(); // Get initial entry EntryDTO entry = await APIManager.GetWordEntry(initialWord); WordNode root = new WordNode(entry); List <string> tested = new List <string> { initialWord }; GetWordTree(root); var a = root.Traverse().Select(n => n.Entry.Word); sw.Stop(); var time = sw.Elapsed; }
public static void ToGephiCSV(this WordNode node, string filenameNodes, string filenameEdges, bool fromRoot = true) { WordNode initialNode = fromRoot ? node.GetRoot() : node; string nodecsv = "Id,Label,Size\n"; string edgecsv = "Source,Target\n"; initialNode.Traverse().Where(n => n.Parent != null).OrderBy(n => n.Depth).ToList().AssignIds().ForEach(n => { nodecsv = string.Concat(nodecsv, n.Id, ",", n.Entry.Word, ",", n.Depth, "\n"); edgecsv = string.Concat(edgecsv, n.Parent.Id, ",", n.Id, "\n"); }); using (StreamWriter sw = new StreamWriter(filenameNodes)) { sw.Write(nodecsv); } using (StreamWriter sw = new StreamWriter(filenameEdges)) { sw.Write(edgecsv); } }