public static Graph CreateDrawingGraph(GeometryGraph gg)
 {
     counter = 0;
     localMap = new Dictionary<GeometryNode,Node>();
     dg = new Graph(counter++.ToString()) { GeometryGraph = gg };
     foreach (GeometryNode n in gg.Nodes)
     {
         Node node = new Node(counter++.ToString());
         node.Attr.Shape = Shape.Ellipse;
         node.GeometryNode = n;
         dg.AddNode(node);
         localMap[n]=node;
     }
     Subgraph cluster = new Subgraph(counter++.ToString());
     cluster.GeometryNode = gg.RootCluster;
     dg.RootSubgraph = cluster;
     PopulateClusters(cluster, gg.RootCluster);
 
     foreach (GeometryEdge e in gg.Edges)
     {
         Edge edge = new Edge(localMap[e.Source], localMap[e.Target], ConnectionToGraph.Disconnected);
         edge.Attr.ArrowheadAtSource = e.ArrowheadAtSource ? ArrowStyle.Normal : ArrowStyle.None;
         edge.Attr.ArrowheadAtTarget = e.ArrowheadAtTarget ? ArrowStyle.Normal : ArrowStyle.None;
         edge.GeometryEdge = e;
         dg.AddPrecalculatedEdge(edge);
     }
     //PopulateClusterEdges(dg.RootSubgraph, gg.RootCluster);
     
     return dg;
 }
 ///<summary>
 ///</summary>
 ///<param name="subgraph"></param>
 public void AddSubgraph(Subgraph subgraph)
 {
     if (subgraph.ParentSubgraph != null)
     {
         subgraph.ParentSubgraph.RemoveSubgraph(subgraph);
     }
     subgraph.ParentSubgraph = this;
     subgraphs.Insert(subgraph);
     IsUpdated = true;
 }
 private static void PopulateClusters(Subgraph cluster, GeometryCluster c)
 {
     foreach (GeometryNode n in c.Nodes)
         cluster.AddNode(localMap[n]);
     foreach (GeometryCluster c2 in c.Clusters)
     {
         Subgraph cluster2 = new Subgraph(counter++.ToString());
         cluster2.GeometryNode = c2;
         localMap[c2] = cluster2;
         cluster.AddSubgraph(cluster2);
         PopulateClusters(cluster2, c2);
     }
 }
示例#4
0
        Cluster ProcessSubGraphs(Subgraph subgraph)
        {
            var geomCluster = new Cluster(subgraph.Nodes.Select(n => nodeMapping[n]),
                                          subgraph.Subgraphs.Select(ProcessSubGraphs));

            foreach (Cluster sub in geomCluster.Clusters)
            {
                sub.GeometryParent = geomCluster;
            }
            subgraph.GeometryNode = geomCluster;
            geomCluster.UserData  = subgraph;
            nodeMapping[subgraph] = geomCluster;
            return(geomCluster);
        }
        static void ProcessNodes(DgmlGraph g,
                                 Dictionary<string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph) {
            foreach (GraphNode gn in g.Nodes) {
                Node drawingNode;
                if (subgraphTable.ContainsKey(gn.Id.LiteralValue)) {
                    var subgraph = new Subgraph(gn.Id.LiteralValue);
                    subgraphTable[subgraph.Id] = subgraph;
                    drawingNode = subgraph;
                }
                else
                    drawingNode = drawingGraph.AddNode(gn.Id.LiteralValue);

                drawingNode.Label = new Label(gn.Label) {Owner = drawingNode};
            }
        }
        void WriteSubgraph(Subgraph subgraph)
        {
            WriteStartElement(Tokens.Subgraph);
            var subgraphsString = String.Join(" ", subgraph.Subgraphs.Select(s => s.Id));

            WriteAttribute(Tokens.listOfSubgraphs, subgraphsString);
            var nodesString = String.Join(" ", subgraph.Nodes.Select(s => s.Id));

            WriteAttribute(Tokens.listOfNodes, nodesString);
            if (subgraph.UserData != null)
            {
                WriteUserData(subgraph.UserData);
            }
            WriteNodeAttr(subgraph.Attr);
            WriteLabel(subgraph.Label);
            WriteEndElement();
        }
示例#7
0
        Subgraph ReadSubgraphContent()
        {
            object userData = null;

            if (TokenIs(Tokens.UserData))
            {
                userData = ReadUserData();
            }
            var nodeAttr = new NodeAttr();

            ReadNodeAttr(nodeAttr);
            var subgraph = new Subgraph(nodeAttr.Id)
            {
                Label = null, Attr = nodeAttr, UserData = userData
            };

            ReadLabel(subgraph);
            ReadEndElement();
            return(subgraph);
        }
 private static void PopulateClusterEdges(Subgraph cluster, GeometryCluster c)
 {
     foreach (GeometryEdge e in c.InEdges)
     {
         Edge edge = new Edge(localMap[e.Source], localMap[e.Target], ConnectionToGraph.Disconnected);
         edge.Attr.ArrowheadAtSource = e.ArrowheadAtSource ? ArrowStyle.Normal : ArrowStyle.None;
         edge.Attr.ArrowheadAtTarget = e.ArrowheadAtTarget ? ArrowStyle.Normal : ArrowStyle.None;
         edge.GeometryEdge = e;
         dg.AddPrecalculatedEdge(edge);
         localMap[e.Source].AddOutEdge(edge);
         localMap[e.Target].AddInEdge(edge);
     }
     foreach (GeometryEdge e in c.OutEdges)
     {
         if (e.Target is GeometryCluster)
             continue;
         Edge edge = new Edge(localMap[e.Source], localMap[e.Target], ConnectionToGraph.Disconnected);
         edge.Attr.ArrowheadAtSource = e.ArrowheadAtSource ? ArrowStyle.Normal : ArrowStyle.None;
         edge.Attr.ArrowheadAtTarget = e.ArrowheadAtTarget ? ArrowStyle.Normal : ArrowStyle.None;
         edge.GeometryEdge = e;
         dg.AddPrecalculatedEdge(edge);
         localMap[e.Source].AddOutEdge(edge);
         localMap[e.Target].AddInEdge(edge);
     }
     foreach (GeometryEdge e in c.SelfEdges)
     {
         Edge edge = new Edge(localMap[e.Source], localMap[e.Target], ConnectionToGraph.Disconnected);
         edge.Attr.ArrowheadAtSource = e.ArrowheadAtSource ? ArrowStyle.Normal : ArrowStyle.None;
         edge.Attr.ArrowheadAtTarget = e.ArrowheadAtTarget ? ArrowStyle.Normal : ArrowStyle.None;
         edge.GeometryEdge = e;
         dg.AddPrecalculatedEdge(edge);
         localMap[e.Source].AddSelfEdge(edge);
     }
     foreach (GeometryCluster c2 in c.Clusters)
         PopulateClusterEdges(localMap[c2] as Subgraph, c2);
 }
        ICurve GetApproximateCollapsedBoundary(Subgraph subgraph) {
            if (textBoxForApproxNodeBoundaries == null)
                SetUpTextBoxForApproxNodeBoundaries();


            double width, height;
            if (String.IsNullOrEmpty(subgraph.LabelText))
                height = width = subgraph.DiameterOfOpenCollapseButton;
            else {
                double a = ((double) subgraph.LabelText.Length)/textBoxForApproxNodeBoundaries.Text.Length*
                           ((double) subgraph.Label.FontSize)/Label.DefaultFontSize;
                width = textBoxForApproxNodeBoundaries.Width*a + subgraph.DiameterOfOpenCollapseButton;
                height =
                    Math.Max(
                        textBoxForApproxNodeBoundaries.Height*subgraph.Label.FontSize/Label.DefaultFontSize,
                        subgraph.DiameterOfOpenCollapseButton);
            }

            if (width < _drawingGraph.Attr.MinNodeWidth)
                width = _drawingGraph.Attr.MinNodeWidth;
            if (height < _drawingGraph.Attr.MinNodeHeight)
                height = _drawingGraph.Attr.MinNodeHeight;

            return NodeBoundaryCurves.GetNodeBoundaryCurve(subgraph, width, height);
        }
 ICurve GetClusterCollapsedBoundary(Subgraph subgraph) {
     return GetApproximateCollapsedBoundary(subgraph);
 }
示例#11
0
        public DCluster AddCluster(DCluster parent, string id)
        {
            if (parent == null)
            {
                Graph.LayoutAlgorithmSettings = new FastIncrementalLayoutSettings();
                Graph.LayoutAlgorithmSettings.EdgeRoutingSettings.KeepOriginalSpline = true;
                var settings = Graph.LayoutAlgorithmSettings as FastIncrementalLayoutSettings;
                settings.AvoidOverlaps = true;
                settings.NodeSeparation = 30;
                settings.RouteEdges = true;
            }

            Subgraph cluster = new Subgraph(id == null ? GetNewNodeID() : id);
            Cluster geometryCluster = new Cluster() { GeometryParent = parent == null ? Graph.GeometryGraph : (GeometryObject)parent.GeometryNode };
            cluster.GeometryNode = geometryCluster;
            geometryCluster.UserData = cluster;

            DCluster ret = new DCluster((DObject)parent ?? this, cluster);
            cluster.LabelText = null;
            SetNodeBoundaryCurve(Graph, cluster);

            if (parent == null)
                m_RootCluster = ret;
            else
                parent.AddCluster(ret);

            if (UpdateGraphBoundingBoxPreservingCenter())
                Invalidate();

            AddCluster(ret, false);

            return ret;
        }
示例#12
0
 private void PopulateDClusterFromDrawing(DCluster dc, Subgraph drawingc)
 {
     foreach (var drawingn in drawingc.Nodes)
         dc.AddNode(NodeMap[drawingn.Id]);
     foreach (var drawingc2 in drawingc.Subgraphs)
     {
         DCluster dc2 = new DCluster(dc, drawingc2);
         dc.AddCluster(dc2);
         NodeMap[drawingc2.Id] = dc2;
         PopulateDClusterFromDrawing(dc2, drawingc2);
     }
 }
 Subgraph ReadSubgraphContent()
 {
     object userData = null;
     if (TokenIs(Tokens.UserData))
         userData = ReadUserData();
     var nodeAttr = new NodeAttr();
     ReadNodeAttr(nodeAttr);
     var subgraph = new Subgraph(nodeAttr.Id) {Label = null, Attr = nodeAttr, UserData = userData};
     ReadLabel(subgraph);
     ReadEndElement();
     return subgraph;
 }
示例#14
0
        private void Expand(string machine)
        {
            if(!CollapsedMachines.Contains(machine))
                return;
            CollapsedMachines.Remove(machine);

            // delete all edges on the subgraph node
            var outgoing = new List<Transition>(
                Transitions.Where(tr => tr.Key.machine_from == machine && tr.Key.machine_to != machine)
                .Select(tr => tr.Key));

            var incoming = new List<Transition>(
                Transitions.Where(tr => tr.Key.machine_from != machine && tr.Key.machine_to == machine)
                .Select(tr => tr.Key));

            var self = new List<Transition>(
                Transitions.Where(tr => tr.Key.machine_from == machine && tr.Key.machine_to == machine)
                .Select(tr => tr.Key));

            foreach (var t in outgoing.Concat(incoming))
                graph.RemoveEdge(Transitions[t]);

            graph.RemoveNode(graph.FindNode(machine));

            // re-create subgraph
            MachineToSubgraph[machine] = new Subgraph(machine);
            MachineToSubgraph[machine].Label.FontSize = SubgraphFontSize;

            graph.RootSubgraph.AddSubgraph(MachineToSubgraph[machine]);

            // add machine states
            foreach (var state in States[machine])
            {
                var old_node = StateToNode[Tuple.Create(state, machine)];

                var new_node = graph.AddNode(old_node.Id);
                new_node.Label.FontSize = NodeFontSize;
                new_node.LabelText = state;

                MachineToSubgraph[machine].AddNode(new_node);
                StateToNode[Tuple.Create(state, machine)] = new_node;
            }

            // Add intra-machine transitions
            foreach (var t in self)
            {
                var edge = graph.AddEdge(GetNode(t.state_from, t.machine_from).Id, t.edge_label, GetNode(t.state_to, t.machine_to).Id);
                edge.Label.FontSize = EdgeFontSize;
                Transitions[t] = edge;
            }

            // Add inter-machine transitions
            foreach (var t in outgoing.Concat(incoming))
            {
                var edge = graph.AddEdge(GetNode(t.state_from, t.machine_from).Id, t.edge_label, GetNode(t.state_to, t.machine_to).Id);
                edge.Label.FontSize = EdgeFontSize;
                Transitions[t] = edge;
            }
        }
 ///<summary>
 ///</summary>
 ///<param name="subgraph"></param>
 public void RemoveSubgraph(Subgraph subgraph)
 {
     subgraphs.Remove(subgraph);
     subgraph.ParentSubgraph = null;
     IsUpdated = true;
 }
 Cluster ProcessSubGraphs(Subgraph subgraph) {
     var geomCluster = new Cluster(subgraph.Nodes.Select(n => nodeMapping[n]),
                                   subgraph.Subgraphs.Select(ProcessSubGraphs));
     foreach (Cluster sub in geomCluster.Clusters)
         sub.GeometryParent = geomCluster;
     subgraph.GeometryNode = geomCluster;
     geomCluster.UserData = subgraph;
     nodeMapping[subgraph] = geomCluster;
     return geomCluster;
 }
示例#17
0
        /// <summary>
        /// Adds a new machine.
        /// </summary>
        /// <param name="machineName">Machine name</param>
        private void AddMachineInternal(string machineName)
        {
            if (!this.Machines.Contains(machineName))
            {
                this.Machines.Add(machineName);
                this.MachinesToStates.Add(machineName, new HashSet<string>());

                var subgraph = new Subgraph(machineName);
                subgraph.Label.FontSize = this.SubgraphFontSize;

                this.Graph.RootSubgraph.AddSubgraph(subgraph);
                this.MachineToSubgraph.Add(machineName, subgraph);
            }
        }
示例#18
0
        static void ProcessNodes(Dictionary<DrawingObject, IViewerObjectX> vObjectsMapping, Graph g, Dictionary<string, Subgraph> subgraphTable, Microsoft.Msagl.Drawing.Graph drawingGraph)
        {
            foreach (GraphNode gn in g.Nodes) {
                Node drawingNode;
                if (subgraphTable.ContainsKey(gn.Id.LiteralValue)) {
                    var subgraph = new Subgraph(gn.Id.LiteralValue);
                    subgraphTable[subgraph.Id] = subgraph;

                    drawingNode = subgraph;
                } else
                    drawingNode = drawingGraph.AddNode(gn.Id.LiteralValue);

                drawingNode.Label=new Label(gn.Label);

                string category = null;
                if (gn.Categories.Any())
                    category = gn.Categories.ElementAt(0).ToString().Replace("CodeSchema_", "");

                XNode vNode = new XNode(drawingNode, gn);
                vObjectsMapping[drawingNode] = vNode;
            }
        }
        void CreateAndLayoutAndDisplayGraph(object sender, ExecutedRoutedEventArgs ex)
        {
            try
            {
            //                Graph graph = new Graph();
            //
            //                //graph.LayoutAlgorithmSettings=new MdsLayoutSettings();
            //
            //                graph.AddEdge("1", "2");
            //                graph.AddEdge("1", "3");
            //                var e = graph.AddEdge("4", "5");
            //                e.LabelText = "Some edge label";
            //                e.Attr.Color = Color.Red;
            //                e.Attr.LineWidth *= 2;
            //
            //                graph.AddEdge("4", "6");
            //                e = graph.AddEdge("7", "8");
            //                e.Attr.LineWidth *= 2;
            //                e.Attr.Color = Color.Red;
            //
            //                graph.AddEdge("7", "9");
            //                e = graph.AddEdge("5", "7");
            //                e.Attr.Color = Color.Red;
            //                e.Attr.LineWidth *= 2;
            //
            //                graph.AddEdge("2", "7");
            //                graph.AddEdge("10", "11");
            //                graph.AddEdge("10", "12");
            //                graph.AddEdge("2", "10");
            //                graph.AddEdge("8", "10");
            //                graph.AddEdge("5", "10");
            //                graph.AddEdge("13", "14");
            //                graph.AddEdge("13", "15");
            //                graph.AddEdge("8", "13");
            //                graph.AddEdge("2", "13");
            //                graph.AddEdge("5", "13");
            //                graph.AddEdge("16", "17");
            //                graph.AddEdge("16", "18");
            //                graph.AddEdge("16", "18");
            //                graph.AddEdge("19", "20");
            //                graph.AddEdge("19", "21");
            //                graph.AddEdge("17", "19");
            //                graph.AddEdge("2", "19");
            //                graph.AddEdge("22", "23");
            //
            //                e = graph.AddEdge("22", "24");
            //                e.Attr.Color = Color.Red;
            //                e.Attr.LineWidth *= 2;
            //
            //                e = graph.AddEdge("8", "22");
            //                e.Attr.Color = Color.Red;
            //                e.Attr.LineWidth *= 2;
            //
            //                graph.AddEdge("20", "22");
            //                graph.AddEdge("25", "26");
            //                graph.AddEdge("25", "27");
            //                graph.AddEdge("20", "25");
            //                graph.AddEdge("28", "29");
            //                graph.AddEdge("28", "30");
            //                graph.AddEdge("31", "32");
            //                graph.AddEdge("31", "33");
            //                graph.AddEdge("5", "31");
            //                graph.AddEdge("8", "31");
            //                graph.AddEdge("2", "31");
            //                graph.AddEdge("20", "31");
            //                graph.AddEdge("17", "31");
            //                graph.AddEdge("29", "31");
            //                graph.AddEdge("34", "35");
            //                graph.AddEdge("34", "36");
            //                graph.AddEdge("20", "34");
            //                graph.AddEdge("29", "34");
            //                graph.AddEdge("5", "34");
            //                graph.AddEdge("2", "34");
            //                graph.AddEdge("8", "34");
            //                graph.AddEdge("17", "34");
            //                graph.AddEdge("37", "38");
            //                graph.AddEdge("37", "39");
            //                graph.AddEdge("29", "37");
            //                graph.AddEdge("5", "37");
            //                graph.AddEdge("20", "37");
            //                graph.AddEdge("8", "37");
            //                graph.AddEdge("2", "37");
            //                graph.AddEdge("40", "41");
            //                graph.AddEdge("40", "42");
            //                graph.AddEdge("17", "40");
            //                graph.AddEdge("2", "40");
            //                graph.AddEdge("8", "40");
            //                graph.AddEdge("5", "40");
            //                graph.AddEdge("20", "40");
            //                graph.AddEdge("29", "40");
            //                graph.AddEdge("43", "44");
            //                graph.AddEdge("43", "45");
            //                graph.AddEdge("8", "43");
            //                graph.AddEdge("2", "43");
            //                graph.AddEdge("20", "43");
            //                graph.AddEdge("17", "43");
            //                graph.AddEdge("5", "43");
            //                graph.AddEdge("29", "43");
            //                graph.AddEdge("46", "47");
            //                graph.AddEdge("46", "48");
            //                graph.AddEdge("29", "46");
            //                graph.AddEdge("5", "46");
            //                graph.AddEdge("17", "46");
            //                graph.AddEdge("49", "50");
            //                graph.AddEdge("49", "51");
            //                graph.AddEdge("5", "49");
            //                graph.AddEdge("2", "49");
            //                graph.AddEdge("52", "53");
            //                graph.AddEdge("52", "54");
            //                graph.AddEdge("17", "52");
            //                graph.AddEdge("20", "52");
            //                graph.AddEdge("2", "52");
            //                graph.AddEdge("50", "52");
            //                graph.AddEdge("55", "56");
            //                graph.AddEdge("55", "57");
            //                graph.AddEdge("58", "59");
            //                graph.AddEdge("58", "60");
            //                graph.AddEdge("20", "58");
            //                graph.AddEdge("29", "58");
            //                graph.AddEdge("5", "58");
            //                graph.AddEdge("47", "58");
            //
            //                var subgraph = new Subgraph("subgraph 1");
            //                graph.RootSubgraph.AddSubgraph(subgraph);
            //                subgraph.AddNode(graph.FindNode("47"));
            //                subgraph.AddNode(graph.FindNode("58"));
            //
            //                graph.AddEdge(subgraph.Id, "55");
            //
            //                var node = graph.FindNode("5");
            //                node.LabelText = "Label of node 5";
            //                node.Label.FontSize = 5;
            //                node.Label.FontName = "New Courier";
            //                node.Label.FontColor = Microsoft.Msagl.Drawing.Color.Blue;
            //
            //                node = graph.FindNode("55");
            //
            //
            //                graph.Attr.LayerDirection= LayerDirection.LR;
            //             //   graph.LayoutAlgorithmSettings.EdgeRoutingSettings.RouteMultiEdgesAsBundles = true;
            //                //graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling;
            //                //layout the graph and draw it
                Graph graph = new Graph();
                graph.AddEdge("47", "58");
                graph.AddEdge("70", "71");

                var subgraph = new Subgraph("subgraph1");
                graph.RootSubgraph.AddSubgraph(subgraph);
                subgraph.AddNode(graph.FindNode("47"));
                subgraph.AddNode(graph.FindNode("58"));

                var subgraph2 = new Subgraph("subgraph2");
                subgraph2.Attr.Color = Color.Black;
                subgraph2.Attr.FillColor = Color.Yellow;
                subgraph2.AddNode(graph.FindNode("70"));
                subgraph2.AddNode(graph.FindNode("71"));
                subgraph.AddSubgraph(subgraph2);
                graph.AddEdge("58", subgraph2.Id);
                graph.Attr.LayerDirection = LayerDirection.LR;
                graphViewer.Graph = graph;

            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Load Failed", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 void WriteSubgraph(Subgraph subgraph) {
     WriteStartElement(Tokens.Subgraph);
     var subgraphsString = String.Join(" ", subgraph.Subgraphs.Select(s => s.Id));
     WriteAttribute(Tokens.listOfSubgraphs, subgraphsString);
     var nodesString = String.Join(" ", subgraph.Nodes.Select(s => s.Id));
     WriteAttribute(Tokens.listOfNodes, nodesString);
     if (subgraph.UserData != null)
         WriteUserData(subgraph.UserData);
     WriteNodeAttr(subgraph.Attr);
     WriteLabel(subgraph.Label);
     WriteEndElement();
 }
        ICurve GetClusterCollapsedBoundary(Subgraph subgraph) {
            double width, height;

            FrameworkElement fe;
            if (drawingObjectsToFrameworkElements.TryGetValue(subgraph, out fe)) {

                width = fe.Width + 2*subgraph.Attr.LabelMargin + subgraph.DiameterOfOpenCollapseButton;
                height = Math.Max(fe.Height + 2*subgraph.Attr.LabelMargin, subgraph.DiameterOfOpenCollapseButton);
            } else
                return GetApproximateCollapsedBoundary(subgraph);

            if (width < _drawingGraph.Attr.MinNodeWidth)
                width = _drawingGraph.Attr.MinNodeWidth;
            if (height < _drawingGraph.Attr.MinNodeHeight)
                height = _drawingGraph.Attr.MinNodeHeight;
            return NodeBoundaryCurves.GetNodeBoundaryCurve(subgraph, width, height);
        }
 ///<summary>
 ///</summary>
 ///<param name="subgraph"></param>
 public void AddSubgraph(Subgraph subgraph) {
     if (subgraph.ParentSubgraph != null) 
         subgraph.ParentSubgraph.RemoveSubgraph(subgraph);
     subgraph.ParentSubgraph = this;
     subgraphs.Insert(subgraph);
     IsUpdated = true;
 }
 ///<summary>
 ///</summary>
 ///<param name="subgraph"></param>
 public void RemoveSubgraph(Subgraph subgraph)
 {
     subgraphs.Remove(subgraph);
     subgraph.ParentSubgraph = null;
     IsUpdated = true;
 }
示例#24
0
        void CreateGraph()
        {
            #if DEBUG
            DisplayGeometryGraph.SetShowFunctions();
            #endif
            Graph graph = new Graph();
            graph.AddEdge("47", "58");
            graph.AddEdge("70", "71");

            var subgraph = new Subgraph("subgraph1");
            graph.RootSubgraph.AddSubgraph(subgraph);
            subgraph.AddNode(graph.FindNode("47"));
            subgraph.AddNode(graph.FindNode("58"));

            var subgraph2 = new Subgraph("subgraph2");
            subgraph2.Attr.Color = Color.Black;
            subgraph2.Attr.FillColor = Color.Yellow;
            subgraph2.AddNode(graph.FindNode("70"));
            subgraph2.AddNode(graph.FindNode("71"));
            subgraph.AddSubgraph(subgraph2);
            graph.AddEdge("58", subgraph2.Id);
            graph.Attr.LayerDirection = LayerDirection.LR;
            gViewer.Graph = graph;
            //            Graph graph = new Graph("graph");
            //            //graph.LayoutAlgorithmSettings=new MdsLayoutSettings();
            //            gViewer.BackColor = System.Drawing.Color.FromArgb(10, System.Drawing.Color.Red);
            //
            //            /*
            //              4->5
            //5->7
            //7->8
            //8->22
            //22->24
            //*/
            //
            //            //int wm = 80;
            //            graph.AddEdge("1", "2");
            //            graph.AddEdge("1", "3");
            //            var e = graph.AddEdge("4", "5");
            //            //e.Attr.Weight *= wm;
            //            e.Attr.Color = Color.Red;
            //            e.Attr.LineWidth *= 2;
            //
            //            e = graph.AddEdge("4", "6");
            //            e.LabelText = "Changing label";
            //            this.labelToChange = e.Label;
            //            e=graph.AddEdge("7", "8");
            //            //e.Attr.Weight *= wm;
            //            e.Attr.LineWidth *= 2;
            //            e.Attr.Color = Color.Red;
            //
            //            graph.AddEdge("7", "9");
            //            e=graph.AddEdge("5", "7");
            //            //e.Attr.Weight *= wm;
            //            e.Attr.Color = Color.Red;
            //            e.Attr.LineWidth *= 2;
            //
            //            graph.AddEdge("2", "7");
            //            graph.AddEdge("10", "11");
            //            graph.AddEdge("10", "12");
            //            graph.AddEdge("2", "10");
            //            graph.AddEdge("8", "10");
            //            graph.AddEdge("5", "10");
            //            graph.AddEdge("13", "14");
            //            graph.AddEdge("13", "15");
            //            graph.AddEdge("8", "13");
            //            graph.AddEdge("2", "13");
            //            graph.AddEdge("5", "13");
            //            graph.AddEdge("16", "17");
            //            graph.AddEdge("16", "18");
            //            graph.AddEdge("19", "20");
            //            graph.AddEdge("19", "21");
            //            graph.AddEdge("17", "19");
            //            graph.AddEdge("2", "19");
            //            graph.AddEdge("22", "23");
            //
            //            e=graph.AddEdge("22", "24");
            //            //e.Attr.Weight *= wm;
            //            e.Attr.Color = Color.Red;
            //            e.Attr.LineWidth *= 2;
            //
            //            e = graph.AddEdge("8", "22");
            //            //e.Attr.Weight *= wm;
            //            e.Attr.Color = Color.Red;
            //            e.Attr.LineWidth *= 2;
            //
            //            graph.AddEdge("20", "22");
            //            graph.AddEdge("25", "26");
            //            graph.AddEdge("25", "27");
            //            graph.AddEdge("20", "25");
            //            graph.AddEdge("28", "29");
            //            graph.AddEdge("28", "30");
            //            graph.AddEdge("31", "32");
            //            graph.AddEdge("31", "33");
            //            graph.AddEdge("5", "31");
            //            graph.AddEdge("8", "31");
            //            graph.AddEdge("2", "31");
            //            graph.AddEdge("20", "31");
            //            graph.AddEdge("17", "31");
            //            graph.AddEdge("29", "31");
            //            graph.AddEdge("34", "35");
            //            graph.AddEdge("34", "36");
            //            graph.AddEdge("20", "34");
            //            graph.AddEdge("29", "34");
            //            graph.AddEdge("5", "34");
            //            graph.AddEdge("2", "34");
            //            graph.AddEdge("8", "34");
            //            graph.AddEdge("17", "34");
            //            graph.AddEdge("37", "38");
            //            graph.AddEdge("37", "39");
            //            graph.AddEdge("29", "37");
            //            graph.AddEdge("5", "37");
            //            graph.AddEdge("20", "37");
            //            graph.AddEdge("8", "37");
            //            graph.AddEdge("2", "37");
            //            graph.AddEdge("40", "41");
            //            graph.AddEdge("40", "42");
            //            graph.AddEdge("17", "40");
            //            graph.AddEdge("2", "40");
            //            graph.AddEdge("8", "40");
            //            graph.AddEdge("5", "40");
            //            graph.AddEdge("20", "40");
            //            graph.AddEdge("29", "40");
            //            graph.AddEdge("43", "44");
            //            graph.AddEdge("43", "45");
            //            graph.AddEdge("8", "43");
            //            graph.AddEdge("2", "43");
            //            graph.AddEdge("20", "43");
            //            graph.AddEdge("17", "43");
            //            graph.AddEdge("5", "43");
            //            graph.AddEdge("29", "43");
            //            graph.AddEdge("46", "47");
            //            graph.AddEdge("46", "48");
            //            graph.AddEdge("29", "46");
            //            graph.AddEdge("5", "46");
            //            graph.AddEdge("17", "46");
            //            graph.AddEdge("49", "50");
            //            graph.AddEdge("49", "51");
            //            graph.AddEdge("5", "49");
            //            graph.AddEdge("2", "49");
            //            graph.AddEdge("52", "53");
            //            graph.AddEdge("52", "54");
            //            graph.AddEdge("17", "52");
            //            graph.AddEdge("20", "52");
            //            graph.AddEdge("2", "52");
            //            graph.AddEdge("50", "52");
            //            graph.AddEdge("55", "56");
            //            graph.AddEdge("55", "57");
            //            graph.AddEdge("58", "59");
            //            graph.AddEdge("58", "60");
            //            graph.AddEdge("20", "58");
            //            graph.AddEdge("29", "58");
            //            graph.AddEdge("5", "58");
            //            graph.AddEdge("47", "58");
            //
            //            //ChangeNodeSizes(graph);
            //
            //            //var sls = graph.LayoutAlgorithmSettings as SugiyamaLayoutSettings;
            //            //if (sls != null)
            //            //{
            //            //    sls.GridSizeByX = 30;
            //            //    // sls.GridSizeByY = 0;
            //            //}
            //            var subgraph = new Subgraph("subgraph label");
            //            graph.RootSubgraph.AddSubgraph(subgraph);
            //            subgraph.AddNode(graph.FindNode("47"));
            //            subgraph.AddNode(graph.FindNode("58"));
            //            //layout the graph and draw it
            //            gViewer.Graph = graph;
            this.propertyGrid1.SelectedObject = graph;
        }
示例#25
0
        void AddMachineInternal(string machine)
        {
            if (Machines.Contains(machine)) return;
            Machines.Add(machine);
            States.Add(machine, new HashSet<string>());

            var subgraph = new Subgraph(machine);
            subgraph.Label.FontSize = SubgraphFontSize;

            graph.RootSubgraph.AddSubgraph(subgraph);
            MachineToSubgraph.Add(machine, subgraph);
        }