static ErdosVertex InstallAuthor(string author, Dictionary <string, ErdosVertex> authorDict) { if (authorDict.ContainsKey(author)) { return(authorDict[author]); } var ret = new ErdosVertex(author); authorDict[author] = ret; return(ret); }
public Scenario() { // ReSharper disable once PossibleNullReferenceException var counts = ReadLine().Split(' ').Select(int.Parse).ToArray(); var cPapers = counts[0]; var cAuthors = counts[1]; for (var iPaper = 0; iPaper < cPapers; iPaper++) { var curPaper = new Paper(); _papers.Add(curPaper); foreach (var author in curPaper.Authors) { ErdosVertex.AddCollaborators(author, curPaper.Authors, _authorDict); } } for (var iAuthor = 0; iAuthor < cAuthors; iAuthor++) { _authors.Add(ReadLine()); } }