I have a function to create a graph and add some values to a few other data structures using a StreamReader
to read in lines from a .txt file.
public static DirectedGraph<string, bool> GetGraph(string fn)
{
DirectedGraph<string, bool> dg = new DirectedGraph<string, bool>();
ITrie trie = null;
List<string> list = new List<string>();
try
{
using (StreamReader sr = new StreamReader(fn))
{
string l;
while((l = sr.ReadLine()) != null)
{
dg.AddNode(l);
trie.Add(l);
list.Add(l);
GetEdges(list, trie, dg);
}
return dg;
}
} catch
{
throw new ArgumentException();
}
}
I expect the StreamReader
to add the read values to a list, trie
and nodes in a graph. GetEdges()
is a function that gets strings from the given list and adds edges to the graph data structure.