Exemple #1
0
        public static void WriteGraphJson(LnScraper scraper, int size = 1)
        {
            var         lnNodes = scraper.CreateLnComp(size);
            List <Node> nodes   = new List <Node>();
            List <Link> links   = new List <Link>();

            lnNodes.ForEach(n => nodes.Add(new Node()
            {
                id    = n.Id,
                group = Int32.Parse(n.Id.Substring(n.Id.Length - 1))
            }));

            lnNodes.ForEach(n =>
            {
                n.Connections.ForEach(c => links.Add(new Link()
                {
                    source = n.Id, target = c, value = 1
                }));
            });

            var obj = new RootObject()
            {
                nodes = nodes, links = links
            };

            File.WriteAllText(Path + @"Visual/network.json", JsonConvert.SerializeObject(obj));
        }
Exemple #2
0
        public static void WriteNodesLinksData(LnScraper scraper, string prefix, int size = 1)
        {
            var lnNodes = scraper.CreateLnComp(size);

            using (StreamWriter file = new StreamWriter(Path + prefix + "Hist/nodes.csv"))
            {
                lnNodes.ForEach(n => file.WriteLine($"{n.Id},{n.Connections.Count}"));
            }

            using (StreamWriter file = new StreamWriter(Path + prefix + "Hist/links.csv"))
            {
                lnNodes.ForEach(n => n.Connections.ForEach(c => file.WriteLine($"{n.Id},{c}")));
            }
        }