當前位置: 首頁>>代碼示例>>C#>>正文


C# Layout.Node類代碼示例

本文整理匯總了C#中Microsoft.Msagl.Core.Layout.Node的典型用法代碼示例。如果您正苦於以下問題:C# Node類的具體用法?C# Node怎麽用?C# Node使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Node類屬於Microsoft.Msagl.Core.Layout命名空間,在下文中一共展示了Node類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CopyGraph

        public static GeometryGraph CopyGraph(GeometryGraph graph)
        {
            if (graph == null) return null;
            var copy = new GeometryGraph();

            Dictionary<Node,Node> nodeCopy=new Dictionary<Node, Node>(graph.Nodes.Count);

            foreach (Node node in graph.Nodes) {
                var c = new Node();
                copy.Nodes.Add(c);
                nodeCopy[node] = c;
                c.BoundaryCurve = node.BoundaryCurve.Clone();
            }

            foreach (Edge edge in graph.Edges) {
                var source = edge.Source;
                var target = edge.Target;
                var copySource = nodeCopy[source];
                var copyTarget = nodeCopy[target];
                Edge edgeCopy=new Edge(copySource,copyTarget);
                copy.Edges.Add(edgeCopy);
                StraightLineEdges.RouteEdge(edgeCopy,0);
            }

            return copy;
        }
開發者ID:mrkcass,項目名稱:SuffixTreeExplorer,代碼行數:26,代碼來源:Helper.cs

示例2: GetOrCreateNode

 private Node GetOrCreateNode(Port port, Dictionary<ICurve, Node> nodeDictionary) {
     var curve = GetPortCurve(port);
     Node node;
     if (!nodeDictionary.TryGetValue(curve, out node))
         nodeDictionary[curve] = node = new Node(curve);
     return node;
 }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:7,代碼來源:MultiEdgeRouter.cs

示例3: RunInternal

        /// <summary>
        /// Executes the algorithm.
        /// </summary>
        protected override void  RunInternal()
        {
            Result = new double[pivotArray.Length][];

            Node[] nodes = new Node[graph.Nodes.Count];
            graph.Nodes.CopyTo(nodes, 0);
            double[] min = new double[graph.Nodes.Count];
            for (int i = 0; i < min.Length; i++)
            {
                min[i] = Double.PositiveInfinity;
            }
            Node pivot = nodes[0];
            pivotArray[0] = 0;
            for (int i = 0; ; i++) {
                var ssd = new SingleSourceDistances(graph, pivot, directed);
                ssd.Run();
                Result[i] = ssd.Result;
                if (i + 1 < pivotArray.Length)
                {//looking for the next pivot
                    int argmax = 0;
                    for (int j = 0; j < Result[i].Length; j++)
                    {
                        min[j] = Math.Min(min[j], Result[i][j]);
                        if (min[j] > min[argmax])
                            argmax = j;
                    }
                    pivot = nodes[argmax];
                    pivotArray[i + 1] = argmax;
                }
                else
                    break;
            }

        }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:37,代碼來源:PivotDistances.cs

示例4: SimpleDeepTranslationTest

        public void SimpleDeepTranslationTest()
        {
            var graph = new GeometryGraph();
            var a = new Node(CurveFactory.CreateRectangle(30, 20, new Point()));
            var b = new Node(CurveFactory.CreateRectangle(30, 20, new Point(100, 0)));
            var e = new Edge(a, b);
            graph.Nodes.Add(a);
            graph.Nodes.Add(b);
            graph.Edges.Add(e);
            var c = CreateCluster(new Node[] { a, b }, 10);
            c.CalculateBoundsFromChildren(0);
            var originalClusterBounds = c.BoundingBox;
            RouteEdges(graph, 10);
            var edgeBounds = e.BoundingBox;

            Assert.AreEqual(c.BoundingBox.Width, 150, "Cluster has incorrect width");
            Assert.AreEqual(c.BoundingBox.Height, 40, "Cluster has incorrect width");

            var delta = new Point(10, 20);
            c.DeepTranslation(delta, true);
            Rectangle translatedClusterBounds = c.BoundingBox;

            Assert.IsTrue(ApproximateComparer.Close((translatedClusterBounds.LeftBottom - originalClusterBounds.LeftBottom), delta), "edge was not translated");

            c.CalculateBoundsFromChildren(0);

            Assert.IsTrue(ApproximateComparer.Close(translatedClusterBounds, c.BoundingBox), "translated bounds do not equal computed bounds of translated cluster");
            Assert.IsTrue(ApproximateComparer.Close((e.BoundingBox.LeftBottom - edgeBounds.LeftBottom), delta), "edge was not translated");
        }
開發者ID:WenzCao,項目名稱:automatic-graph-layout,代碼行數:29,代碼來源:ClusterTests.cs

示例5: HorizontalSeparationConstraint

 public HorizontalSeparationConstraint(Node u, Node v, double separation, bool equality)
 {
     this.equality = equality;
     this.u = u;
     this.v = v;
     this.separation = separation;
 }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:7,代碼來源:HorizontalSeparationConstraint.cs

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

示例7: ValidateNoNodeOverlapping

 /// <summary>
 /// Validate two nodes not overlapping with each other
 /// </summary>        
 internal static void ValidateNoNodeOverlapping(Node node, Node node2)
 {
     if (node == node2 || node is Cluster || node2 is Cluster)
     {
         return;
     }
     Assert.IsFalse(node.BoundingBox.Intersects(node2.BoundingBox), string.Format("Node (ID: {0}, BoundingBox: {1}) overlaps with Node (ID: {2}, BoundingBox: {3})", node.UserData, node.BoundingBox.ToString(), node2.UserData, node2.BoundingBox.ToString()));            
 }
開發者ID:WenzCao,項目名稱:automatic-graph-layout,代碼行數:11,代碼來源:SugiyamaValidation.cs

示例8: BumperPusher

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pushedNodes">nodes that are being pushed</param>
        /// <param name="separation"></param>
        /// <param name="pushingNodes"></param>
        public BumperPusher(IEnumerable<Node> pushedNodes, double separation, Node[] pushingNodes) {
            this.separation = separation;
            rtree = new RTree<Node>(RectangleNode<Node>.CreateRectangleNodeOnEnumeration(
                pushedNodes.Select(n => new RectangleNode<Node>(n, GetPaddedBoxOfNode(n)))));

            //LayoutAlgorithmSettings.ShowDebugCurvesEnumeration(rtree.GetAllLeaves().Select(n=>new DebugCurve(n.BoundaryCurve)));
            this.pushingNodes = pushingNodes;
        }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:14,代碼來源:BumperPusher.cs

示例9: Visit

  void Visit(Node u)
 {
     visited.Add(u);
     low[u] = depth[u] = visited.Count;
     foreach (var e in u.OutEdges.Concat(u.InEdges))
     {
         Visit(u, e);
     }
 }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:9,代碼來源:GraphConnectedComponents.cs

示例10: PositionLabels

 /// <summary>
 /// positions location nodes
 /// </summary>
 /// <param name="locationNodes">the nodes represent the labels and originally are positioned at locations</param>
 /// <param name="locationRadius">the minimum gap between a location and its label</param>
 /// <param name="removeCrossings">If set to true will remove intersections between line segments (location, locationLabel). 
 /// The result will be better but the calculation will take more time.
 /// </param>
 public static GeometryGraph PositionLabels(Node[] locationNodes, double locationRadius, bool routeEdges, double labelSeparation)
 {
     #if MYDEBUG
     Microsoft.Msagl.GraphViewerGdi.DisplayGeometryGraph.SetShowFunctions();
     #endif
     var labeler = new LocationLabeler(locationNodes, locationRadius, routeEdges, labelSeparation);
     labeler.Work();
     return labeler.graph;
 }
開發者ID:mrkcass,項目名稱:SuffixTreeExplorer,代碼行數:17,代碼來源:LocationLabeler.cs

示例11: ShortestPartRouterForLg

 public ShortestPartRouterForLg(Node source, Node target, Func<Node, LgNodeInfo> geomNodeToLgNode) {
     this.source = source;
     this.target = target;
     this.geomNodeToLgNode = geomNodeToLgNode;
     queue.Enqueue(source, 0);
     pathDirection = target.Center - source.Center;
     costToTarget = double.PositiveInfinity;
     EdgeIsInterestingFunc = MonotonicityFunc;
 }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:9,代碼來源:ShortestPartRouterForLg.cs

示例12: CreateShapeIfNeeeded

        static void CreateShapeIfNeeeded(Node n, Dictionary<Node, Shape> nodesToShapes) {
            if (nodesToShapes.ContainsKey(n)) return;
            nodesToShapes[n] = new RelativeShape(() => n.BoundaryCurve)
#if DEBUG
        {
                        UserData = n.ToString()
        }
#endif       
                ;
        }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:10,代碼來源:ShapeCreatorForRoutingToParents.cs

示例13: PushByNodeAndReportPushedAsFixed

 IEnumerable<Node> PushByNodeAndReportPushedAsFixed(Node pushingNode) {
     var ret = new List<Node>();
     var pushingNodeBox = GetPaddedBoxOfNode(pushingNode);
     foreach (var rectNode in rtree.GetAllLeavesIntersectingRectangle(pushingNodeBox)) {
         if (fixedNodes.Contains(rectNode.UserData)) continue;
         if (PushNodeAndUpdateRTree(pushingNode, rectNode))
             ret.Add(rectNode.UserData);
     }
     return ret;
 }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:10,代碼來源:BumperPusher.cs

示例14: IsDescendantOf_BasicTest

        public void IsDescendantOf_BasicTest()
        {
            Cluster cluster = new Cluster();
            Node node = new Node();
            Node node2 = new Node();
            cluster.AddChild(node);

            Assert.IsTrue(node.IsDescendantOf(cluster), "Node is a descendant of cluster but IsDescendantOf returns false.");
            Assert.IsFalse(node2.IsDescendantOf(cluster), "Node2 is not a descendant of cluster but IsDescendantOf returns true.");
            Assert.IsFalse(cluster.IsDescendantOf(cluster), "A cluster should not be considered a descendant of itself.");
        }
開發者ID:WenzCao,項目名稱:automatic-graph-layout,代碼行數:11,代碼來源:NodeTests.cs

示例15: ProcessAncestorDescendantCouple

 static void ProcessAncestorDescendantCouple(Cluster ancestor, Node node, Dictionary<Node, Shape> nodesToShapes) {
     Cluster parent=Parent(node);
     do {
         foreach (var n in Children(parent))
             CreateShapeIfNeeeded(n, nodesToShapes);
         if (parent == ancestor)
             break;
         parent = Parent(parent);                
     } while (true);
     CreateShapeIfNeeeded(parent, nodesToShapes);
 }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:11,代碼來源:ShapeCreatorForRoutingToParents.cs


注:本文中的Microsoft.Msagl.Core.Layout.Node類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。