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


C# Graph.AddEdge方法代码示例

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


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

示例1: MainWindow_Loaded

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            GraphViewer graphViewer = new GraphViewer();
            graphViewer.BindToPanel(Panel);
            Graph graph = new Graph();

            graph.AddEdge("A", "B");
            graph.Attr.LayerDirection = LayerDirection.LR;
            graphViewer.Graph = graph; // throws exception
        }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:10,代码来源:MainWindow.xaml.cs

示例2: SomeClass

        public static void SomeClass()
        {
            var graph = new MSAGL.Drawing.Graph("");
            graph.AddEdge("A", "B");
            graph.AddEdge("A", "B");
            graph.FindNode("A").Attr.FillColor = MSAGL.Drawing.Color.BlanchedAlmond;
            graph.FindNode("B").Attr.FillColor = MSAGL.Drawing.Color.BurlyWood;
            var renderer = new MSAGL.GraphViewerGdi.GraphRenderer(graph);
            renderer.CalculateLayout();
            const int width = 50;
            int height = (int)(graph.Height * (width / graph.Width));
            const PixelFormat pixfmt = System.Drawing.Imaging.PixelFormat.Format32bppPArgb;
            using (var bitmap = new System.Drawing.Bitmap(width, height, pixfmt))
            {
                using (var gfx = System.Drawing.Graphics.FromImage(bitmap))
                {
                    gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                    gfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                    gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                    var rect = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
                    renderer.Render(gfx, rect);
                    bitmap.Save("test.png");

                }

            }
           
        }
开发者ID:Exclr8,项目名称:CloudCore,代码行数:29,代码来源:MsaglGraph.cs

示例3: DrawGraph

        void DrawGraph(Automaton automaton)
        {
            var graph = new Graph();
            graph.Attr.LayerDirection = LayerDirection.LR;
            int i = 0;
            foreach (var s in automaton.States)
            {
                foreach (var o in s.Output)
                {
                    var index = automaton.States.IndexOf(o.End);
                    var end = ReferenceEquals(automaton.StartState, o.End) ? "Start" : index.ToString();
                    if (ReferenceEquals(s, automaton.StartState))
                    {
                        graph.AddEdge("Start", o.ToString(), end);
                    }
                    else if (o.End.IsFinalState)
                    {
                        graph.AddEdge(i.ToString(), o.ToString(), "End");
                    }
                    else
                    {
                        graph.AddEdge(i.ToString(), o.ToString(), end);
                    }

                }
                i++;
            }
            graphViewer.Graph = graph;
        }
开发者ID:LYP951018,项目名称:FunnyThings,代码行数:29,代码来源:MainWindow.xaml.cs

示例4: 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

示例5: Form1

 public Form1()
 {
     InitializeComponent();
     GViewer gViewer = new GViewer() { Dock = DockStyle.Fill };
     SuspendLayout();
     Controls.Add(gViewer);
     ResumeLayout();
     Graph graph = new Graph();
     var sugiyamaSettings = (SugiyamaLayoutSettings)graph.LayoutAlgorithmSettings;
     sugiyamaSettings.NodeSeparation *= 2;
     graph.AddEdge("A", "B");
     graph.AddEdge("A", "C");
     graph.AddEdge("A", "D");
     graph.LayerConstraints.PinNodesToSameLayer(new[] { graph.FindNode("A"), graph.FindNode("B"), graph.FindNode("C") });
     gViewer.Graph = graph;
 }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:16,代码来源:Form1.cs

示例6: 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

示例7: ToMsaglGraph

 public static Microsoft.Msagl.Drawing.Graph ToMsaglGraph(this Graph g) {
     var msaglGraph = new Microsoft.Msagl.Drawing.Graph();
     for (var v = 0; v < g.V; v++) {
         foreach (var w in g.AdjacentVertices(v)) {
             var e = msaglGraph.AddEdge(v.ToString(), w.ToString());
             e.SourceNode.Attr.Shape = Shape.Circle;
             e.TargetNode.Attr.Shape = Shape.Circle;
         }
     }
     return msaglGraph;
 }
开发者ID:slieser,项目名称:sandbox,代码行数:11,代码来源:GraphExtensions.cs

示例8: ReadEdge

        static void ReadEdge(Graph graph, StreamReader f) {
            f.ReadLine();
            var s = f.ReadLine();
            s = s.Trim(' ', '\t', '"');
            var source = s.Split(' ')[1];
            s = f.ReadLine();

            s = s.Trim(' ', '\t', '"');
            var target = s.Split(' ')[1];
            graph.AddEdge(source, target);
            f.ReadLine();
        }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:12,代码来源:GmlParser.cs

示例9: 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

示例10: 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

示例11: 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

示例12: BindEdges

        static void BindEdges(Graph graph, GeometryGraph geomGraph, Dictionary<GeomNode, string> nodeIds) {
            foreach (var edge in geomGraph.Edges) {
                if (IsUnderCollapsedCluster(edge))
                    continue;

                var e = graph.AddEdge(nodeIds[edge.Source], nodeIds[edge.Target]);
                if (edge.EdgeGeometry != null && edge.EdgeGeometry.SourceArrowhead != null)
                    e.Attr.ArrowheadAtSource = ArrowStyle.Normal;

                e.Attr.ArrowheadAtTarget = edge.EdgeGeometry != null && edge.EdgeGeometry.TargetArrowhead != null
                    ? ArrowStyle.Normal
                    : ArrowStyle.None;

                e.GeometryEdge = edge;

                e.Attr.LineWidth = edge.LineWidth;

                if (edge.Label != null && edge.Label.Width != 0) {
                    e.LabelText = "label";
                    e.Label.GeometryLabel = edge.Label;
                    e.Label.Owner = e;
                }
            }
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:24,代码来源:DisplayGeometryGraph.cs

示例13: SimulationInitialize

        private void SimulationInitialize(bool moveFirsStep)
        {
            //clear the trace and visited table
            Traces.Clear();
            visited.Clear();
            ListView_Trace.Items.Clear();

            //get the starting process

            //create the initial step
            EventStepSim initialStep = new EventStepSim(Spec.SimulationInitialization(this.ComboBox_Process.Text));
            //new EventStepSim(startingProcess, Common.Ultility.Constants.INITIAL_EVENT, null, SpecProcess.GetEnvironment()));

            //use the process string as the definition ref string, this is the only special case needs to be taken care of
            //initialStep.ProcessToString = startingProcess.Def.ToString();
            //todo: tobe checked
            //initialStep.ProcessToString = startingProcess.ToString();

            InitialState = initialStep.StepID;

            //string initialLabel = initialStep.ToFullString();

            AddToTrace("0", initialStep, "1", InitialState);

            CurrentEnableEventList.Clear();

            if (moveFirsStep)
            {
                //try
                //{
                List<EventStepSim> list = initialStep.MakeOneMove(HideTauTransition);

                for (int i = 0; i < list.Count; i++)
                {
                    EventStepSim step = list[i];
                    step.SourceProcess = InitialState;
                    step.IsUnvisitedStep = true;
                    list[i] = step;
                }

                CurrentEnableEventList.AddRange(list);
                //}
                //catch (Exception ex)
                //{

                //}
            }

            visited.Add(InitialState, null);

            g = new Graph("Graph");
            //g.GraphAttr.Orientation = System.Windows.Forms.Orientation.Landscape;
            g.Attr.LayerDirection = Direction;
            Node n = g.AddNode(InitialState);
            n.Attr.FillColor = Color.Red;
            n.LabelText = "1";
            n.UserData = initialStep; //initialLabel;

            Node tempN = g.AddNode(INITIAL_STATE);
            tempN.Attr.LineWidth = 0;
            tempN.Attr.Color = Color.White;
            tempN.LabelText = "";
            tempN.UserData = "";
            g.AddEdge(INITIAL_STATE, InitialState);

            //clear the mapping table
            Mapping.Clear();
            Mapping.Add(GetTraceEvent(this.ListView_Trace.Items.Count) + InitialState,
                        new ProcessData(initialStep, CloneGraph(g), CloneEnabledEvent()));

            SimulatorViewer.Graph = g;
            SimulatorViewer.Validate();

            FillCurrentEnabledList();
            UpdateStore(initialStep);

            WarningFlag = false;
        }
开发者ID:nhannhan159,项目名称:PAT,代码行数:78,代码来源:SimulationForm.cs

示例14: CreateWideGraph

 void CreateWideGraph()
 {
     graph = new Graph();
     for (int i = 0; i < 100; i++)
         graph.AddEdge("A", i.ToString());
 }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:6,代码来源:Form1.cs

示例15: InitGraph

        private void InitGraph()
        {
            Graph drawingGraph = new Graph();

            drawingGraph.AddEdge(leavesId, creekId);
            drawingGraph.AddEdge(leavesId, treeId);
            drawingGraph.AddEdge(leavesId, wId);

            drawingGraph.AddEdge("uno", "otro");
            foreach (DrawingNode node in drawingGraph.Nodes)
            {
                if (!node.Id.Equals("uno"))
                {
                    node.Attr.Shape = Shape.DrawFromGeometry;
                    node.DrawNodeDelegate = new DelegateToOverrideNodeRendering(DrawNode);
                    node.NodeBoundaryDelegate = new DelegateToSetNodeBoundary(GetNodeBoundary);
                }
                else
                {
                    node.LabelText = "node with a diamond shape";
                    node.Attr.Shape = Shape.Diamond;
                }

            }

            double width = leaves.Width;
            double height = leaves.Height;

            drawingGraph.Attr.LayerSeparation = height / 2;
            drawingGraph.Attr.NodeSeparation = width / 2;
            double arrowHeadLenght = width / 10;
            foreach (Microsoft.Msagl.Drawing.Edge e in drawingGraph.Edges)
                e.Attr.ArrowheadLength = (float)arrowHeadLenght;
            drawingGraph.LayoutAlgorithmSettings = new SugiyamaLayoutSettings();
            viewer.Graph = drawingGraph;
        }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:36,代码来源:Form1.cs


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