public static void CompareConnections(WeightedDirectedConnection <double> x,
                                       int ySrcId, int yTgtId, double yWeight)
 {
     Assert.AreEqual(x.SourceId, ySrcId);
     Assert.AreEqual(x.TargetId, yTgtId);
     Assert.AreEqual(x.Weight, yWeight);
 }
        /// <summary>
        /// Read an connections section.
        /// </summary>
        /// <param name="sr">The stream reader to read from.</param>
        /// <returns>A list of <see cref="WeightedDirectedConnection{Double}"/></returns>
        public static IList <WeightedDirectedConnection <double> > ReadConnectionsSection(StreamReader sr)
        {
            var connList = new List <WeightedDirectedConnection <double> >();

            for (string line = ReadNextLine(sr); !string.IsNullOrEmpty(line); line = ReadNextLine(sr))
            {
                string[] fieldArr = line.Split(' ', '\t');
                if (fieldArr.Length != 3)
                {
                    throw new Exception("Invalid network tsv format.");
                }

                if (int.TryParse(fieldArr[0], out int srcNodeId))
                {
                    throw new Exception("Invalid network tsv format.");
                }

                if (int.TryParse(fieldArr[1], out int tgtNodeId))
                {
                    throw new Exception("Invalid network tsv format.");
                }

                if (double.TryParse(fieldArr[2], out double weight))
                {
                    throw new Exception("Invalid network tsv format.");
                }

                var conn = new WeightedDirectedConnection <double>(srcNodeId, tgtNodeId, weight);
                connList.Add(conn);
            }
            return(connList);
        }