public Graph(Graph graph) { adjacency_list = new List<KeyValuePair<Node, List<int>>>(); foreach (var items in graph.adjacency_list) adjacency_list.Add(new KeyValuePair<Node, List<int>>(new Node(items.Key), new List<int>(items.Value))); }
static public Graph FileReading(string filepath, int size) { StreamReader sr = new StreamReader(filepath, Encoding.GetEncoding(1251)); Graph graph = new Graph(); for (int i = 0; i < size; i++) graph.adjacency_list.Add(new KeyValuePair<Node, List<int>>(new Node(i + 1), new List<int>())); while (!sr.EndOfStream) { List<string> list = sr.ReadLine().Split(' ').Where(x => x != "").ToList(); graph.adjacency_list[Parse(list[0]) - 1].Value.Add(Parse(list[1])); } return graph; }