private Network ReadNetwork(string content, FileType fileType)
 {
     return(fileType switch
     {
         FileType.MPX => _mpxReader.FromString(content),
         FileType.EdgeList => _edgeListReader.FromString(content),
         _ => throw new ArgumentException($"File type '{fileType}' is not supported.")
     });
Esempio n. 2
0
        public void TestLoadFloretine()
        {
            var florentine = File.ReadAllText("SampleData/florentine.edgelist");
            var network    = reader.FromString(florentine);

            var actorsNamesExpected = new List <string>
            {
                "Acciaiuoli",
                "Albizzi",
                "Barbadori",
                "Bischeri",
                "Castellani",
                "Ginori",
                "Guadagni",
                "Lamberteschi",
                "Medici",
                "Pazzi",
                "Peruzzi",
                "Ridolfi",
                "Salviati",
                "Strozzi",
                "Tornabuoni"
            };

            actorsNamesExpected.Sort();
            var actorsNamesActual = network.Actors.Select(a => a.Name).ToList();

            actorsNamesActual.Sort();

            Assert.Equal(2, network.Layers.Count);
            Assert.Empty(network.InterLayerEdges);

            Assert.Equal(15, network.Actors.Count);
            Assert.Equal(actorsNamesExpected, actorsNamesActual);

            Assert.Equal("marriage", network.Layers[0].Name);
            Assert.Equal(20, network.Layers[0].Edges.Count);

            Assert.Equal("business", network.Layers[1].Name);
            Assert.Equal(15, network.Layers[1].Edges.Count);
        }
Esempio n. 3
0
        public string ReadEdgeListToString(string content)
        {
            var network = _edgeListReader.FromString(content);

            return(_edgeListWriter.ToString(network, true));
        }