Esempio n. 1
0
        static void Main(string[] args)
        {
            
            BoBox.Graph.Graph root = new BoBox.Graph.Graph();
            

            
            BoBox.Graph.Subgraph s1 = new BoBox.Graph.Subgraph();
            BoBox.Graph.Subgraph s2 = new BoBox.Graph.Subgraph();

            BoBox.Graph.Subgraph s3 = new BoBox.Graph.Subgraph();

            var s = new V(0) { L = "1" };
            root.AddVertex(s);

            s1.AddVertex(new V(1) { L = "3" });
            s1.AddVertex(new V(2) { L = "14" });
            
            s2.AddVertex(new V(3) { L = "10" });
            s2.AddVertex(new V(4) { L = "11" });
            s2.AddVertex(new V(5) { L = "12" });
            s2.AddVertex(new V(6) { L = "13" });

            s1.AddVertex(new V(7) { L = "6" });

            
            var t = new V(8) { L = "15" };
            root.AddVertex(t);

            s3.AddVertex(new V(9) { L = "N" });

            root.AddVertex(s1);
            root.AddVertex(s3);
            s1.AddVertex(s2);            

            root.AddEdge(0, 1);
            root.AddEdge(1, 2);
            root.AddEdge(2, 3);
            root.AddEdge(3, 4);
            root.AddEdge(3, 5);
            root.AddEdge(4, 6);
            root.AddEdge(5, 6);
            root.AddEdge(5, 9);
            root.AddEdge(6, 7);
            root.AddEdge(7, 8);
           
            // topology order
            // Ziskat z grafu, s a t a nasmerovat na ne source a target
            root.Source.AddOutEdge(s);
            t.AddOutEdge(root.Target);

            BFS(root.Source);
            GraphBuilder.Serialize<BoBox.Graph.Graph>(root, "kuk3.bab");


            //MakeGraph("kuk.bab");
            //var g2 = GraphBuilder.Deserialize<GraphJson>("kuk2.bab");                      
        }
Esempio n. 2
0
        public MainWindow()
        {
            InitializeComponent();
            
            BoBox.Graph.Graph root = new BoBox.Graph.Graph();
            var v1 = new BoBox.Graph.Box();
            root.AddVertex(v1);

            BoBox.Graph.Subgraph s1 = new BoBox.Graph.Subgraph();
            var sv1 = new BoBox.Graph.Box();
            s1.AddVertex(sv1);
            BoBox.Graph.Subgraph s2 = new BoBox.Graph.Subgraph();
            var sv2 = new BoBox.Graph.Box();
            s2.AddVertex(sv2);

            s1.AddVertex(s2);

            root.AddVertex(s1);
            var v2 = new BoBox.Graph.Box();
            root.AddVertex(v2);
            root.AddVertex(new BoBox.Graph.Via());

            root.AddEdge(v1.VertexId, sv1.VertexId);
            root.AddEdge(sv1.VertexId, sv2.VertexId);
            //root.AddEdge(sv2.VertexId, v2.VertexId);
            try
            {
                MyCanvas.Graph = root;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
            //var v = new BoBox.Controls.VertexControl() { Label = "Kuk svete", Background = Brushes.Aqua };
            //MyCanvas.Children.Add(v);
            
        }