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


C# Edge类代码示例

本文整理汇总了C#中Edge的典型用法代码示例。如果您正苦于以下问题:C# Edge类的具体用法?C# Edge怎么用?C# Edge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CreateAndLayoutGraph

        internal static GeometryGraph CreateAndLayoutGraph()
        {
            double w = 30;
            double h = 20;
            GeometryGraph graph = new GeometryGraph();
            Node a = new Node( new Ellipse(w, h, new P()),"a");
            Node b = new Node( CurveFactory.CreateRectangle(w, h, new P()),"b");
            Node c = new Node( CurveFactory.CreateRectangle(w, h, new P()),"c");
            Node d = new Node(CurveFactory.CreateRectangle(w, h, new P()), "d");

            graph.Nodes.Add(a);
            graph.Nodes.Add(b);
            graph.Nodes.Add(c);
            graph.Nodes.Add(d);
            Edge e = new Edge(a, b) { Length = 10 };
            graph.Edges.Add(e);
            graph.Edges.Add(new Edge(b, c) { Length = 3 });
            graph.Edges.Add(new Edge(b, d) { Length = 4 });

            //graph.Save("c:\\tmp\\saved.msagl");
            var settings = new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings();
            LayoutHelpers.CalculateLayout(graph, settings, null);

            return graph;
        }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:25,代码来源:Form1.cs

示例2: Edge

 private Edge(Edge prev)
 {
     qPrev = prev;
     prev.qNext = this;
     LFace = null;
     Token = 0;
 }
开发者ID:WCell,项目名称:WCell-Terrain,代码行数:7,代码来源:QuadEdge.cs

示例3: test3

        public void test3()
        {
            UndirectedGraph<int, Edge<int>> graph = new UndirectedGraph<int, Edge<int>>(true);

            // Add vertices to the graph
            graph.AddVertex(0);
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);
            graph.AddVertex(4);
            // Create the edges
            Edge<int> e0_1 = new Edge<int>(0, 1);
            Edge<int> e0_2 = new Edge<int>(0, 2);
            Edge<int> e1_4 = new Edge<int>(1, 4);
            Edge<int> e3_4 = new Edge<int>(3, 4);
            Edge<int> e0_3 = new Edge<int>(0, 3);
            Edge<int> e1_2 = new Edge<int>(1, 2);
            // Add the edges
            graph.AddEdge(e0_1);
            graph.AddEdge(e0_2);
            graph.AddEdge(e1_2);
            graph.AddEdge(e1_4);
            graph.AddEdge(e3_4);
            graph.AddEdge(e0_3);

            List<int> path = new List<int>();

            HamiltonianDefiner definer = new HamiltonianDefiner(graph);
            bool isHamiltonian = definer.isHamiltonianGraph(path);
            Assert.AreEqual(isHamiltonian, true);
        }
开发者ID:DmitriyChernov,项目名称:HomeWork,代码行数:31,代码来源:UnitTest1.cs

示例4: HalfEdge

        /// <summary>
        /// Class constructor.
        /// </summary>
        
        /// <date>2013-07-23</date>
        public HalfEdge(Edge objEdge, Point objSiteLeft, Point objSiteRight)
        {
            this.Site = objSiteLeft;
            this.Edge = objEdge;

            // 'angle' is a value to be used for properly sorting the
            // halfsegments counterclockwise. By convention, we will
            // use the angle of the line defined by the 'site to the left'
            // to the 'site to the right'.
            // However, border edges have no 'site to the right': thus we
            // use the angle of line perpendicular to the halfsegment (the
            // edge should have both end points defined in such case.)
            if (objSiteRight != null)
            {
                this.Angle = Math.Atan2(objSiteRight.y - objSiteLeft.y, objSiteRight.x - objSiteLeft.x);
            }
            else
            {
                if (objEdge.SiteLeft == objSiteLeft)
                {
                    this.Angle = Math.Atan2(objEdge.VertexB.x - objEdge.VertexA.x, objEdge.VertexA.y - objEdge.VertexB.y);
                }
                else
                {
                    this.Angle = Math.Atan2(objEdge.VertexA.x - objEdge.VertexB.x, objEdge.VertexB.y - objEdge.VertexA.y);
                }
            }
        }
开发者ID:Innominandum,项目名称:Voronoi,代码行数:33,代码来源:HalfEdge.cs

示例5: FindTourStartingFrom

        public IEnumerable<int> FindTourStartingFrom(Edge startEdge)
        {
            this.InitializeVisit();

            this.VisitNode(startEdge.Head);
            yield return startEdge.Head;

            this.VisitNode(startEdge.Tail);
            yield return startEdge.Tail;

            int currentNode = startEdge.Tail;

            TaskLogger.Text = "Computing nearest neighbor tour...";

            while (unvisitedNodes.ItemsCount > 0)
            {
                int nearestUnvisitedNode = this.FindNearestUnvisitedNode(currentNode);

                this.VisitNode(nearestUnvisitedNode);
                yield return nearestUnvisitedNode;

                currentNode = nearestUnvisitedNode;

                TaskLogger.Progress = 100.0 * visitedNodes.ItemsCount / nodes.Length;
            }
        }
开发者ID:IcyTotem,项目名称:TSP,代码行数:26,代码来源:NNTourFinder.cs

示例6: ComputeEdgeEnds

        /// <summary>
        /// Creates stub edges for all the intersections in this
        /// Edge (if any) and inserts them into the graph.
        /// </summary>
        /// <param name="edge"></param>
        /// <param name="l"></param>
        public virtual void ComputeEdgeEnds(Edge edge, IList l)
        {
            EdgeIntersectionList eiList = edge.EdgeIntersectionList;       
            // ensure that the list has entries for the first and last point of the edge
            eiList.AddEndpoints();

            IEnumerator it = eiList.GetEnumerator();
            EdgeIntersection eiPrev = null;
            EdgeIntersection eiCurr = null;
            // no intersections, so there is nothing to do
            if (! it.MoveNext()) return;
            EdgeIntersection eiNext = (EdgeIntersection) it.Current;
            do 
            {
                eiPrev = eiCurr;
                eiCurr = eiNext;
                eiNext = null;
                
                if (it.MoveNext())
                    eiNext = (EdgeIntersection)it.Current;                

                if (eiCurr != null) 
                {
                    CreateEdgeEndForPrev(edge, l, eiCurr, eiPrev);
                    CreateEdgeEndForNext(edge, l, eiCurr, eiNext);
                }
            } 
            while (eiCurr != null);
        }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:35,代码来源:EdgeEndBuilder.cs

示例7: EdgeViewModel

 public EdgeViewModel(int index, Edge edge, BoundaryCondition condition)
 {
     Index = index;
     Edge = edge;
     Condition = condition;
     Types = new ObservableCollection<BoundaryConditionsType>(getTypesOfBoundaryConditions());
 }
开发者ID:tarashor,项目名称:FEMLibrary.SolidMechanics,代码行数:7,代码来源:EdgeViewModel.cs

示例8: NeuralNetwork

        public NeuralNetwork(int countInputNodes, int countOutputNodes, int countHiddenNodes)
        {
            input_nodes = new List<Node>();
            hidden_nodes = new List<Node>();
            output_nodes = new List<Node>();

            // add input nodes
            for (int i = 0; i < countInputNodes; i++)
                input_nodes.Add(new Node());
            // add hidden nodes
            for (int i = 0; i < countHiddenNodes; i++)
                hidden_nodes.Add(new Node());
            // add output nodes
            for (int i = 0; i < countOutputNodes; i++)
                output_nodes.Add(new Node());

            // create edges from data to input
            for (int i = 0; i < input_nodes.Count; i++)
                input_nodes[i].AddEdge(true, new Edge(null, input_nodes[i], 0));

            // create edges from input to hidden
            Edge newEdge;
            for(int i  =0; i < input_nodes.Count; i++)
                for(int j = 0; j < hidden_nodes.Count; j++)
                {
                    newEdge = new Edge(input_nodes[i], hidden_nodes[j], 0);
                }

            // create edges from hidden to output

            // create edges from output to output data
        }
开发者ID:daan-leiva,项目名称:FirstNeuralNetwork,代码行数:32,代码来源:NeuralNetwork.cs

示例9: EdgeList

        public EdgeList(Edge edge)
        {
            _edges = new List<Edge>();
            _edges.Add(edge);

            _weight = edge.Weight;
        }
开发者ID:jorik041,项目名称:osmsharp,代码行数:7,代码来源:EdgeList.cs

示例10: Main

        public static void Main(string[] args)
        {
            Console.Title = "Graph";

            Vertex jana = new Vertex();
            Vertex philip = new Vertex();
            Vertex markus = new Vertex();

            Edge relMarkusPhilip = new Edge();
            Edge relJanaPhilip= new Edge();

            jana.Data.Add("Class", "Person");
            philip.Data.Add("Class", "Person");
            markus.Data.Add("Class", "Person");

            jana.Data.Add("Name", "Jana");
            philip.Data.Add("Name", "Philip");
            markus.Data.Add("Name", "Markus");

            relJanaPhilip.Data.Add("Class", "Friend");
            relMarkusPhilip.Data.Add("Class", "Friend");

            relMarkusPhilip.ConnectVertices(ref markus, ref philip);
            relJanaPhilip.ConnectVertices(ref jana, ref philip);

            List<Edge> results = markus.SearchVertices("Friend");

            foreach (Edge e in results)
                Console.WriteLine(e.Data["Class"]);

            Console.ReadLine();
        }
开发者ID:PJurke,项目名称:graph,代码行数:32,代码来源:Program.cs

示例11: Add

 public void Add( Edge edge )
 {
     if( !TryAdd( edge ) )
     {
         throw new ArgumentException( "Edge already exists: " + edge.Id );
     }
 }
开发者ID:JackWangCUMT,项目名称:Plainion.GraphViz,代码行数:7,代码来源:Graph.cs

示例12: FindShortestPathForSimpleUndirectedGraphUsingDijkstraAlgorithm

        public void FindShortestPathForSimpleUndirectedGraphUsingDijkstraAlgorithm()
        {
            var graph = new UndirectedGraph<object, Edge<object>>(true);
            object v1 = "vertex1";
            object v2 = "vertex2";
            object v3 = "vertex3";
            var e1 = new Edge<object>(v1, v2);
            var e2 = new Edge<object>(v2, v3);
            var e3 = new Edge<object>(v3, v1);
            graph.AddVertex(v1);
            graph.AddVertex(v2);
            graph.AddVertex(v3);
            graph.AddEdge(e1);
            graph.AddEdge(e2);
            graph.AddEdge(e3);

            var algorithm = new UndirectedDijkstraShortestPathAlgorithm<object, Edge<object>>(graph, edge => (double)1);
            var observer = new UndirectedVertexPredecessorRecorderObserver<object, Edge<object>>();
            using (observer.Attach(algorithm))
            {
                algorithm.Compute(v1);
            }

            IEnumerable<Edge<object>> path;
            observer.TryGetPath(v3, out path);

            foreach (var edge in path)
            {
                Console.WriteLine(edge);
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:31,代码来源:NetworkGraphAlgorithmTest.cs

示例13: Read

		public static Graph Read(StreamReader stream)
		{
			int.Parse(stream.ReadLine());
			int E = int.Parse(stream.ReadLine());

			var graph = new Graph();

			for(int i = 0; i < E; ++i)
			{
				string[] r = stream.ReadLine().Trim().Split(' ');
				r = r.Where (x => x.Length > 0).ToArray();

				var edge = new Edge()
				{
					From = int.Parse(r[0]),
					To = int.Parse(r[1]),
					Weight = float.Parse(r[2]),
				};

				if(!graph.Vertices.ContainsKey(edge.From))
				{
					graph.Vertices[edge.From] = new List<Edge>();
				}
				graph.Vertices[edge.From].Add(edge);
			}

			return graph;
		}
开发者ID:scoutsalwaysready,项目名称:toolbox,代码行数:28,代码来源:dijkstra.cs

示例14: CreateGeometryEdgeAndAddItToGeometryGraph

        /// <summary>
        /// create a geometry edge, the geometry source and target have to be set already
        /// </summary>
        /// <param name="drawingEdge"></param>
        /// <param name="msaglGraph"></param>
        /// <returns></returns>
        static Core.Layout.Edge CreateGeometryEdgeAndAddItToGeometryGraph(Edge drawingEdge, GeometryGraph msaglGraph) {
            var msaglEdge = CreateGeometryEdgeFromDrawingEdge(drawingEdge);

            msaglGraph.Edges.Add(msaglEdge);
            
            return msaglEdge;
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:13,代码来源:GeometryGraphCreator.cs

示例15: FisrstSampleInput

        public void FisrstSampleInput()
        {
            int nodesCount = 4;

            var edges = new List<Edge>
            {
                new Edge(0, 1, 9),
                new Edge(0, 3, 4),
                new Edge(3, 1, 6),
                new Edge(3, 2, 11),
                new Edge(1, 2, 5)
            };

            var expectedEdges = new Edge[]
            {
                edges[1],
                edges[4],
                edges[2]
            };

            var actualEdges = KruskalAlgorithm.Kruskal(nodesCount, edges);

            CollectionAssert.AreEqual(expectedEdges, actualEdges);
            Assert.AreEqual(15, actualEdges.Sum(e => e.Weight));
        }
开发者ID:SoftUniCourses,项目名称:Algorithms,代码行数:25,代码来源:ModifiedKruskalAlgorithmTests.cs


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