Esempio n. 1
0
        static void Main(string[] args)
        {
            string filename = "D:\\SystemColors.xml";
            var xdoc = System.Xml.Linq.XDocument.Load( filename );
            var root = xdoc.Root;
            var xcolors = root.Element("Colors").Elements("Color");

            var colordata = xcolors.Select(el => ColorInfo.FromXml(el)).ToList();


            var distances = get_distances(colordata);


            var fp = System.IO.File.CreateText("D:\\y.txt");
            var gw = new Isotope.GraphViz.GraphVizWriter(fp);

            var go = new Isotope.GraphViz.GraphVizWriter.GraphOptions();
            go.Overlap = false;
            gw.WriteStartGraph( "so" , go);


            var nodeoptions = new Isotope.GraphViz.GraphVizWriter.NodeOptions();
            var edgeoptions = new Isotope.GraphViz.GraphVizWriter.EdgeOptions();
            int row = 0;

            var cur_distances = new double[colordata.Count];

            foreach (var color0 in colordata)
            {
                nodeoptions.Label = color0.Name.ToUpper();
                nodeoptions.FillColor = color0.rgb;
                nodeoptions.Style = Isotope.GraphViz.GraphVizWriter.NodeStyle.Filled;
                gw.WriteStartNode(color0.Name, nodeoptions);
                gw.WriteEndNode();


                for (int col = 0; col < colordata.Count; col++)
                {
                    cur_distances[col] = distances[row, col];
                }

                var pairs = cur_distances.Select((d, i) => new { color = i, distance = d }).Where( i => i.distance>0.0) ;
                var unique_ordered_distances = cur_distances.Where(d=>d > 0.0).Distinct().OrderBy(d=>d).ToList();

                foreach (var d in unique_ordered_distances.Take(1))
                {
                    foreach (var p in pairs.Where( pair => pair.distance==d))
                    {
                        var color1 = colordata[p.color];
                        gw.WriteStartEdge(color0.Name, color1.Name, edgeoptions);
                        gw.WriteEndEdge();

                    }

                }
 

                
                row++;
            }
            gw.WriteEndGraph();
            fp.Flush();
            fp.Close();

            
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string filename = "D:\\SystemColors.xml";
            var    xdoc     = System.Xml.Linq.XDocument.Load(filename);
            var    root     = xdoc.Root;
            var    xcolors  = root.Element("Colors").Elements("Color");

            var colordata = xcolors.Select(el => ColorInfo.FromXml(el)).ToList();


            var distances = get_distances(colordata);


            var fp = System.IO.File.CreateText("D:\\y.txt");
            var gw = new Isotope.GraphViz.GraphVizWriter(fp);

            var go = new Isotope.GraphViz.GraphVizWriter.GraphOptions();

            go.Overlap = false;
            gw.WriteStartGraph("so", go);


            var nodeoptions = new Isotope.GraphViz.GraphVizWriter.NodeOptions();
            var edgeoptions = new Isotope.GraphViz.GraphVizWriter.EdgeOptions();
            int row         = 0;

            var cur_distances = new double[colordata.Count];

            foreach (var color0 in colordata)
            {
                nodeoptions.Label     = color0.Name.ToUpper();
                nodeoptions.FillColor = color0.rgb;
                nodeoptions.Style     = Isotope.GraphViz.GraphVizWriter.NodeStyle.Filled;
                gw.WriteStartNode(color0.Name, nodeoptions);
                gw.WriteEndNode();


                for (int col = 0; col < colordata.Count; col++)
                {
                    cur_distances[col] = distances[row, col];
                }

                var pairs = cur_distances.Select((d, i) => new { color = i, distance = d }).Where(i => i.distance > 0.0);
                var unique_ordered_distances = cur_distances.Where(d => d > 0.0).Distinct().OrderBy(d => d).ToList();

                foreach (var d in unique_ordered_distances.Take(1))
                {
                    foreach (var p in pairs.Where(pair => pair.distance == d))
                    {
                        var color1 = colordata[p.color];
                        gw.WriteStartEdge(color0.Name, color1.Name, edgeoptions);
                        gw.WriteEndEdge();
                    }
                }



                row++;
            }
            gw.WriteEndGraph();
            fp.Flush();
            fp.Close();
        }