Exemple #1
0
        public void VisualizeNeuralNetToFile(string neuralNetPicFilePath)
        {
            FastIncrementalLayoutSettings fastSettings = new FastIncrementalLayoutSettings
            {
                AvoidOverlaps  = true,
                NodeSeparation = 30,
                RouteEdges     = true
            };

            SugiyamaLayoutSettings settings = new SugiyamaLayoutSettings
            {
                FallbackLayoutSettings = fastSettings
            };

            m_opsViz.LayoutAlgorithmSettings = settings;

            Microsoft.Msagl.GraphViewerGdi.GraphRenderer renderer = new Microsoft.Msagl.GraphViewerGdi.GraphRenderer(m_opsViz);
            renderer.CalculateLayout();

            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap((int)m_opsViz.Width, (int)m_opsViz.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            renderer.Render(bitmap);

            bitmap.Save(neuralNetPicFilePath);

            bitmap.Dispose();
        }
Exemple #2
0
        private void printGraph()
        {
            Microsoft.Msagl.GraphViewerGdi.GraphRenderer renderer = new Microsoft.Msagl.GraphViewerGdi.GraphRenderer(graph);
            //graph.Attr.  .ArrowheadAtTarget = ArrowStyle.None;
            renderer.CalculateLayout();

            int    width  = 150;
            Bitmap bitmap = new Bitmap(width, (int)(graph.Height * (width / graph.Width)), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

            renderer.Render(bitmap);
            bitmap.Save("graph.png");
            pictureBox1.Image = bitmap;
        }
        int ProcessDotFile(string inputFile) {
            Graph graph;
            int i = CreateGraphFromDotFile(inputFile, out graph);
            graph.Attr.LayerDirection = GetLayerDirection();

            if (i != 0)
                return i;
            graph.LayoutAlgorithmSettings = PickLayoutAlgorithmSettings(graph.EdgeCount, graph.NodeCount);
            if (argsParser.OptionIsUsed(NoArrowheads))
                RemoveArrowheadsFromGraph(graph);
            EnlargeLabelMargins(graph);
            SetConsolasFontAndSize(graph, 13);

            // rendering
            var renderer = new GraphRenderer(graph);
            renderer.CalculateLayout();
            SetBoxRadiuses(graph);

            var outputFile = Path.ChangeExtension(inputFile, ".svg");
            string outputDir = argsParser.GetValueOfOptionWithAfterString(OutputDirOption);
            if (outputDir != null) {
                var name = Path.GetFileName(outputFile);
                if (name != null)
                    outputFile = Path.Combine(outputDir, name);
            }


            SetConsolasFontAndSize(graph, 11);
            if (argsParser.OptionIsUsed(NoLabelsOption))
                RemoveLabelsFromGraph(graph);

            var svgWriter = new SvgGraphWriter(File.Create(outputFile), graph) 
            { NodeSanitizer = AntiXss.HtmlAttributeEncode, AttrSanitizer = AntiXss.HtmlAttributeEncode,
                Precision = precision, AllowedToWriteUri = !argsParser.OptionIsUsed(NoUrls)};
            svgWriter.Write();
            DumpFileToConsole(outputFile);


            if(msaglOutput) {
                outputFile = SetMsaglOutputFileName(inputFile);
                var geomGraph = graph.GeometryGraph;
                WriteGeomGraph(outputFile, geomGraph);
            }
            return 0;
        }
Exemple #4
0
    protected void Read1(object sender, EventArgs e)
    {
        try
        {
            textview3.Buffer.Text += "[INFO]Reading File 1...\n";
            string   U, V;
            double   peluang;
            int      pointer = 0;
            string[] text    = textview1.Buffer.Text.Split('\n', ' ');

            int edges = int.Parse(text[pointer++]);
            textview3.Buffer.Text += "Jumlah Edges: " + edges + "\n";
            Dictionary <string, List <Tuple <string, double> > > adj = new Dictionary <string, List <Tuple <string, double> > >();

            for (int i = 0; i < edges; i++)
            {
                U = text[pointer++];
                textview3.Buffer.Text += U + " ";
                V = text[pointer++];
                textview3.Buffer.Text += V + " ";
                double.TryParse(text[pointer++], NumberStyles.Any, CultureInfo.InvariantCulture, out peluang);
                textview3.Buffer.Text += peluang + "\n";
                var tuple1 = new Tuple <string, double>(V, peluang);
                if (!adj.ContainsKey(U))
                {
                    List <Tuple <string, double> > tempList = new List <Tuple <string, double> >();
                    tempList.Add(tuple1);
                    adj[U] = tempList;
                }
                else
                {
                    adj[U].Add(tuple1);
                }
            }

            Microsoft.Msagl.Drawing.Graph peta = new Microsoft.Msagl.Drawing.Graph("");
            Microsoft.Msagl.GraphViewerGdi.GraphRenderer renderer = new Microsoft.Msagl.GraphViewerGdi.GraphRenderer(peta);

            this.adj = adj;
            textview3.Buffer.Text += "\nIlustrasi Graph :\n";
            foreach (KeyValuePair <string, List <Tuple <string, double> > > kvp in adj)
            {
                textview3.Buffer.Text += kvp.Key + "\n";
                foreach (Tuple <string, double> el in kvp.Value)
                {
                    textview3.Buffer.Text += kvp.Key + " ->  " + el.Item1 + " : " + el.Item2 + "\n";
                }
            }
            textview3.Buffer.Text += "[INFO]Read File 1 done\n";

            renderer.CalculateLayout();
            int    width  = 1000;
            Bitmap bitmap = new Bitmap(width, (int)(peta.Height * (width / peta.Width)), PixelFormat.Format32bppPArgb);
            renderer.Render(bitmap);
            bitmap.Save("peta.png");
        } catch (Exception err)
        {
            textview3.Buffer.Text += err.Message + "\n";
            textview3.Buffer.Text += "[ERROR]Reading File 1 failed\n";
        }
    }