当前位置: 首页>>代码示例>>C#>>正文


C# Graph.AddNode方法代码示例

本文整理汇总了C#中Microsoft.Msagl.Drawing.Graph.AddNode方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.AddNode方法的具体用法?C# Graph.AddNode怎么用?C# Graph.AddNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Msagl.Drawing.Graph的用法示例。


在下文中一共展示了Graph.AddNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessLine

        static void ProcessLine(Graph graph, string str) {
            if (String.IsNullOrEmpty(str))
                return;
            if (str[0] == '*') return;

            var arrayStr = str.Split(new []{' '},StringSplitOptions.RemoveEmptyEntries).ToArray();
            if (arrayStr.Length == 0)
                return;
            var source = graph.AddNode(arrayStr[0]);
            for (int i = 1; i < arrayStr.Length; i++) {
                var e = new Edge(source, graph.AddNode(arrayStr[i]), ConnectionToGraph.Connected);
                graph.AddPrecalculatedEdge(e);
            }
        }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:14,代码来源:NetParser.cs

示例2: CopyGraph

        /// <summary>
        /// Copies a graph and its GeometryGraph.
        /// </summary>
        /// <param name="parentGraph"></param>
        /// <returns></returns>
        public static Graph CopyGraph(Graph parentGraph)
        {
            GeometryGraph geometryCopy = CopyGraph(parentGraph.GeometryGraph);

            Graph graph=new Graph();
            graph.GeometryGraph = geometryCopy;

            Dictionary<Node,int> nodeId=new Dictionary<Node, int>(geometryCopy.Nodes.Count);
            for (int i = 0; i < geometryCopy.Nodes.Count; i++) {
                nodeId[geometryCopy.Nodes[i]] = i;
                String id = i.ToString();

               graph.AddNode(id);
                var node = graph.FindNode(id);
                node.GeometryNode = geometryCopy.Nodes[i];
                geometryCopy.Nodes[i].UserData = node;

            }

            foreach (var edge in geometryCopy.Edges) {
                String sourceId = nodeId[edge.Source].ToString();
                String targetId = nodeId[edge.Target].ToString();

                var edgeCopy=graph.AddEdge(sourceId, "", targetId);
                edgeCopy.GeometryEdge = edge;
                edge.UserData = edgeCopy;
            }
            return graph;
        }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:34,代码来源:Helper.cs

示例3: ModulesGraph

        private void ModulesGraph()
        {
            Graph g = new Graph();

            using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
            {
                command.CommandText = @"select name from modules";

                SQLiteDataReader DataReader = command.ExecuteReader();
                while (DataReader.Read())
                    g.AddNode(DataReader["name"].ToString());
            }

            using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
            {
                command.CommandText = @"select * from moddeps";
                SQLiteDataReader DataReader = command.ExecuteReader();
                while (DataReader.Read())
                {
                    Microsoft.Msagl.Drawing.Edge e = g.AddEdge(DataReader["used"].ToString(), "", DataReader["uses"].ToString());
                    e.Attr.LineWidth = int.Parse(DataReader["count"].ToString());
                    //e.Attr.Color = Microsoft.Msagl.Drawing.Color.Yellow;
                    e.LabelText = DataReader["rate"].ToString();
                }
            }
            gViewer.Graph = g;
        }
开发者ID:asdanilenk,项目名称:Bakalavr,代码行数:27,代码来源:GraphForm.cs

示例4: UpdateGraph

 public virtual void UpdateGraph(Graph graph)
 {
     Node graphNode = graph.AddNode(NodeFile.Id);
     graphNode.LabelText = NodeFile.Name;
     UpdateGraphNode(graphNode);
     UpdateOutEdges(graph);
 }
开发者ID:stonehearth,项目名称:stonehearth-editor,代码行数:7,代码来源:NodeData.cs

示例5: CreateDrawingGraph

 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;
 }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:30,代码来源:FromGeometry.cs

示例6: AutomatonViewModel

 public AutomatonViewModel()
 {
     graph = new Graph();
     graph.Attr.LayerDirection = LayerDirection.LR;
     dummy = new Node(" ");
     dummy.IsVisible = false;
     graph.AddNode(dummy);
     ResetAll();
 }
开发者ID:phamhathanh,项目名称:Automata,代码行数:9,代码来源:AutomatonViewModel.cs

示例7: ReadNode

 static void ReadNode(Graph graph, StreamReader f) {
     f.ReadLine();
     var s=f.ReadLine();
     s = s.Trim(' ', '\t', '"');
     var id = s.Split(' ')[1];
     s = f.ReadLine();
     s = s.Trim(' ', '\t', '"');
     var split = s.Split(' ');
     var label = split[1].Trim('"');
     graph.AddNode(id).LabelText = label;
     f.ReadLine();            
 }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:12,代码来源:GmlParser.cs

示例8: PatchGraph

        private void PatchGraph(int id)
        {
            Graph g = new Graph();

            using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
            {
                command.CommandText = @"select name from modules";

                SQLiteDataReader DataReader = command.ExecuteReader();
                while (DataReader.Read())
                    g.AddNode(DataReader["name"].ToString());
            }

            using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
            {
                command.CommandText = @"select * from patchview where [email protected]_id";
                command.Parameters.Add(new SQLiteParameter("@patch_id", id));
                SQLiteDataReader DataReader = command.ExecuteReader();
                while (DataReader.Read())
                {
                    Microsoft.Msagl.Drawing.Edge e = g.AddEdge(DataReader["used"].ToString(), "", DataReader["uses"].ToString());
                    e.Attr.LineWidth = int.Parse(DataReader["count"].ToString());
                    e.Attr.Color = Microsoft.Msagl.Drawing.Color.Red;
                    e.LabelText = DataReader["rate"].ToString();
                }
            }
            using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
            {
                command.CommandText = @"select * from patchview2 where [email protected]_id";
                command.Parameters.Add(new SQLiteParameter("@patch_id", id));
                SQLiteDataReader DataReader = command.ExecuteReader();
                while (DataReader.Read())
                {
                    Microsoft.Msagl.Drawing.Edge e = g.AddEdge(DataReader["used"].ToString(), "", DataReader["uses"].ToString());
                    e.Attr.LineWidth = int.Parse(DataReader["count"].ToString());
                    e.Attr.Color = Microsoft.Msagl.Drawing.Color.Yellow;
                    e.LabelText = (int.Parse(DataReader["rate"].ToString())/10).ToString();
                }
            }
            gViewer.Graph = g;
        }
开发者ID:asdanilenk,项目名称:Bakalavr,代码行数:41,代码来源:GraphForm.cs

示例9: DrawAutoma

        private void DrawAutoma(AutomaFuzzy.Automa<Symbol> automma)
        {
            Graph graph = new Graph("Automa");
            //graph.GraphAttr.Backgroundcolor = Microsoft.Glee.Drawing.Color.Black;
            for (int i = 0; i < automma.States.Count; i++)
            {
                string str = automma.States[i].ToString();

                Node no = graph.AddNode(automma.States[i].Name);
                no.Attr.Shape = Shape.Box;
                no.LabelText = str;
            }

            foreach (var transition in automma.Transitions)
            {
                string symbol = ((CompilerWithFuzzy.AutomaFuzzy.Rules.SimpleIncludeRule<Symbol>)transition.Rule).Symbol.ToString();
                string label =
                    ((CompilerWithFuzzy.AutomaFuzzy.Rules.SimpleIncludeRule<Symbol>)transition.Rule).Symbol.ToString() +
                            " - " + transition.Rule.Pertinence.ToString();
                label = symbol;

                Edge arco = graph.AddEdge(transition.From.Name, label
                         , transition.To.Name);
                System.Drawing.Color c = Utils.GetColor(transition.Rule.Pertinence);
                var color = new Microsoft.Msagl.Drawing.Color((byte)c.R, (byte)c.G, (byte)c.B);
                arco.Attr.Color = color;
                //arco.Attr.Fontcolor = color;
                arco.Attr.AddStyle(Style.Bold);
                arco.Attr.LineWidth = 5;
            }

            GViewer viewer = new GViewer();
            viewer.NavigationVisible = false;
            viewer.OutsideAreaBrush = Brushes.White;
            viewer.ToolBarIsVisible = false;
            viewer.Graph = graph;
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            pnlAutoma.Controls.Clear();
            pnlAutoma.Controls.Add(viewer);
        }
开发者ID:rodvieirasilva,项目名称:Compiler-With-Fuzzy,代码行数:40,代码来源:UCAutomaSyn.cs

示例10: Draw

        private void Draw(Automa<char> automa, int indexTable = -1)
        {
            Graph graphAutoma = new Graph("Automa");

            for (int i = 0; i < automa.States.Count; i++)
            {
                State<char> state = automa.States[i];
                Node no = graphAutoma.AddNode(state.Name);
                no.Attr.Shape = Shape.Circle;

                if (state.PertinenceFinal > 0)
                {
                    no.Attr.Shape = Shape.DoubleCircle;
                }
                if (indexTable > -1)
                {
                    System.Drawing.Color c = Utils.GetColor(regexFuzzy.TableAutomaProcessing[indexTable][i]);
                    no.Attr.FillColor = new Microsoft.Msagl.Drawing.Color((byte)c.R, (byte)c.G, (byte)c.B);
                }
                else if (state.PertinenceInitial > 0)
                {
                    no.Attr.FillColor = Microsoft.Msagl.Drawing.Color.LightGray;
                }
            }
            foreach (var transition in automa.Transitions)
            {
                Edge arco = graphAutoma.AddEdge(transition.From.Name, transition.To.Name);
                arco.LabelText = transition.ToString();
            }
            GViewer viewer = new GViewer();
            viewer.NavigationVisible = false;
            viewer.OutsideAreaBrush = Brushes.White;
            viewer.ToolBarIsVisible = false;
            viewer.Graph = graphAutoma;
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            pnlAutoma.Controls.Clear();
            pnlAutoma.Controls.Add(viewer);
        }
开发者ID:rodvieirasilva,项目名称:Compiler-With-Fuzzy,代码行数:38,代码来源:FrmAutomaFuzzy.cs

示例11: GetTypeGraph

        Graph GetTypeGraph() {
            var g = new Graph("Types", "id");
            var table = new Hashtable();
            foreach (XmlSchemaType st in set.GlobalTypes.Values) {
                if (st != null) {
                    if (st.QualifiedName == null || st.QualifiedName.Namespace != "http://www.w3.org/2001/XMLSchema") {
                        table[st] = null;
                    }
                }
            }
            foreach (XmlSchemaType ct in new ArrayList(table.Keys)) {
                XmlSchemaType baseType = ct.BaseXmlSchemaType;
                if (baseType != null && baseType.QualifiedName.Namespace != "http://www.w3.org/2001/XMLSchema") {
                    var b1 = table[ct] as Node;
                    if (b1 == null) {
                        b1 = g.AddNode(GetId(ct));
                        b1.LabelText = GetLabel(ct);
                        b1.Attr.Shape = Shape.Box;
                        b1.Attr.XRadius = b1.Attr.YRadius = 2; // rounded box.
                        b1.Attr.LabelMargin = 5;
                        SetNodeColors(b1);
                        table[ct] = b1;
                    }
                    Node b2 = g.AddNode(GetId(baseType));
                    b2.LabelText = GetLabel(baseType);
                    b2.Attr.Shape = Shape.Box;
                    b2.Attr.XRadius = b2.Attr.YRadius = 2; // rounded box.
                    SetNodeColors(b2);
                    b2.Attr.LabelMargin = 5;

                    g.AddEdge(b1.Attr.Id, b2.Attr.Id);
                }
            }
            g.Attr.LayerDirection = direction;

            return g;
        }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:37,代码来源:ReadingXSD.cs

示例12: UpdateOutEdges

        protected override void UpdateOutEdges(Graph graph)
        {
            foreach (GameMasterNode node in mArcTriggers.Values)
            {
                if (node.NodeType == GameMasterNodeType.ARC)
                {
                    Node triggerNode = graph.AddNode(NodeFile.Id + "#trigger");
                    triggerNode.LabelText = "trigger";
                    MakeNodePrivate(triggerNode);
                    graph.AddEdge(NodeFile.Id, triggerNode.Id);
                    graph.AddEdge(triggerNode.Id, node.Id);
                }
            }

            foreach (GameMasterNode node in mArcChallenges.Values)
            {
                if (node.NodeType == GameMasterNodeType.ARC)
                {
                    Node triggerNode = graph.AddNode(NodeFile.Id + "#challenge");
                    triggerNode.LabelText = "challenge";
                    MakeNodePrivate(triggerNode);
                    graph.AddEdge(NodeFile.Id, triggerNode.Id);
                    graph.AddEdge(triggerNode.Id, node.Id);
                }
            }

            foreach (GameMasterNode node in mArcClimaxes.Values)
            {
                if (node.NodeType == GameMasterNodeType.ARC)
                {
                    Node triggerNode = graph.AddNode(NodeFile.Id + "#climax");
                    triggerNode.LabelText = "climax";
                    MakeNodePrivate(triggerNode);
                    graph.AddEdge(NodeFile.Id, triggerNode.Id);
                    graph.AddEdge(triggerNode.Id, node.Id);
                }
            }
        }
开发者ID:stonehearth,项目名称:stonehearth-editor,代码行数:38,代码来源:CampaignNodeData.cs

示例13: addNode

 private void addNode(Graph g, string label)
 {
     g.AddNode(label);
     g.FindNode(label).UserData = new NodeData();
 }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:5,代码来源:Form1.cs

示例14: Desenha

 /// <summary>
 /// Desenha o autômato.
 /// </summary>
 private void Desenha(StackAutoma automato)
 {
     Graph grafoAutomato = new Graph("Autômato");
     transicoes = new List<Transition>();
     // Adiciona elementos com base nas transições
     foreach (KeyValuePair<string, State> estado in automato.States)
     {
         Node no = grafoAutomato.AddNode(estado.Key);
         no.Attr.Shape = Shape.Circle;
         // Faz marcações no grafo..
         if (estado.Value.Final)
         {
             no.Attr.Shape = Shape.DoubleCircle;
         }
         if (estado.Value == automato.StartState)
         {
             no.Attr.FillColor = Microsoft.Msagl.Drawing.Color.LightGray;
         }
         transicoes.AddRange(estado.Value.Transitions);
     }
     foreach (Transition transicao in transicoes)
     {
         Edge arco = grafoAutomato.AddEdge(transicao.Source.Name, transicao.Destiny.Name);
         arco.LabelText = string.Format("({0}, {1}, {{{2}}})", transicao.Symbol, transicao.ConsumingStack[0], string.Join(",", transicao.PushStack.ToArray().Select(c => c.Name).ToArray()));
     }
     GViewer viewer = new GViewer();
     viewer.NavigationVisible = false;
     viewer.OutsideAreaBrush = Brushes.White;
     //viewer.RemoveToolbar();
     viewer.Graph = grafoAutomato;
     viewer.Dock = System.Windows.Forms.DockStyle.Fill;
     pnlAutomato.Controls.Clear();
     pnlAutomato.Controls.Add(viewer);
 }
开发者ID:rodvieirasilva,项目名称:Compiler-With-Fuzzy,代码行数:37,代码来源:FormGrammar.cs

示例15: Draw

        private void Draw(Graph<Symbol, double> g)
        {
            treeViewSyn.Nodes.Clear();
            if (g != null && g.Root != null)
            {
                Graph graph = new Graph("Graph");
                //graph.Attr.LayerDirection = LayerDirection.TB;
                Node<Symbol, double> node = g.Root;
                TreeNode treeNode;
                Stack<Node<Symbol, double>> stack = new Stack<Node<Symbol, double>>();
                Stack<TreeNode> stackTreeNode = new Stack<TreeNode>();
                stackTreeNode.Push(null);

                stack.Push(node);
                while (stack.Count > 0)
                {
                    node = stack.Pop();
                    treeNode = stackTreeNode.Pop();
                    var treeNodeNext = AddNode(node, treeNode);

                    string str = "Root";
                    if (node.Info != null)
                        str = node.Info.Name;
                    var no = graph.AddNode(node.Name);
                    no.Attr.Shape = Shape.Circle;
                    no.LabelText = str;

                    foreach (var transition in System.Linq.Enumerable.Reverse(node.Edges))
                    {
                        Edge arco = graph.AddEdge(node.Name, "", transition.Destiny.Name);

                        System.Drawing.Color c = Utils.GetColor(transition.Cost);
                        var color = new Microsoft.Msagl.Drawing.Color((byte)c.R, (byte)c.G, (byte)c.B);
                        arco.Attr.Color = color;
                        arco.Attr.AddStyle(Style.Bold);
                        arco.Attr.LineWidth = 5;
                        arco.LabelText = transition.Cost.ToString("n2");

                        stack.Push(transition.Destiny);
                        stackTreeNode.Push(treeNodeNext);
                    }
                }

                GViewer viewer = new GViewer();
                // viewer.CurrentLayoutMethod = LayoutMethod.Ranking;

                viewer.NavigationVisible = false;
                viewer.OutsideAreaBrush = Brushes.White;
                viewer.ToolBarIsVisible = false;
                viewer.Graph = graph;
                viewer.Dock = System.Windows.Forms.DockStyle.Fill;

                pnlGraph.Controls.Clear();
                pnlGraph.Controls.Add(viewer);
                treeViewSyn.ExpandAll();
            }
        }
开发者ID:rodvieirasilva,项目名称:Compiler-With-Fuzzy,代码行数:57,代码来源:UCGraphSyn.cs


注:本文中的Microsoft.Msagl.Drawing.Graph.AddNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。