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


C# IGraph.ContainsKey方法代码示例

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


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

示例1: GraphHasBeenLaidOut

        //*************************************************************************
        //  Method: GraphHasBeenLaidOut()
        //
        /// <summary>
        /// Gets a flag indicating whether a graph has been laid out.
        /// </summary>
        ///
        /// <param name="graph">
        /// The graph to check.
        /// </param>
        ///
        /// <returns>
        /// true if the graph has been laid out.
        /// </returns>
        //*************************************************************************
        public static Boolean GraphHasBeenLaidOut(
            IGraph graph
            )
        {
            Debug.Assert(graph != null);

            return ( graph.ContainsKey(
            ReservedMetadataKeys.LayoutBaseLayoutComplete) );
        }
开发者ID:haisreekanth,项目名称:NetMap,代码行数:24,代码来源:LayoutMetadataUtil.cs

示例2: SortStronglyConnectedComponents

        //*************************************************************************
        //  Method: SortStronglyConnectedComponents()
        //
        /// <summary>
        /// Sorts the strongly connected components.
        /// </summary>
        ///
        /// <param name="oStronglyConnectedComponents">
        /// Unsorted List of strongly connected components.
        /// </param>
        ///
        /// <param name="oGraph">
        /// The graph the vertices belong to.
        /// </param>
        ///
        /// <param name="bSortAscending">
        /// true to sort the components by increasing vertex count, false to sort
        /// them by decreasing vertex count.
        /// </param>
        ///
        /// <remarks>
        /// See the remarks in the calling method for details on how the sort is
        /// performed.
        /// </remarks>
        //*************************************************************************
        protected void SortStronglyConnectedComponents(
            List< LinkedList<IVertex> > oStronglyConnectedComponents,
            IGraph oGraph,
            Boolean bSortAscending
            )
        {
            Debug.Assert(oStronglyConnectedComponents != null);
            Debug.Assert(oGraph != null);

            // The key is a strongly connected component and the value is the
            // smallest vertex layout sort order within the component.

            Dictionary<LinkedList<IVertex>, Single>
            oSmallestSortableLayoutOrder = null;

            if ( oGraph.ContainsKey(ReservedMetadataKeys.SortableLayoutOrderSet) )
            {
            // The vertex layout sort orders have been set on the vertices.
            // Populate the dictionary.

            oSmallestSortableLayoutOrder =
                new Dictionary<LinkedList<IVertex>, Single>();

            foreach (LinkedList<IVertex> oStronglyConnectedComponent in
                oStronglyConnectedComponents)
            {
                oSmallestSortableLayoutOrder.Add(
                    oStronglyConnectedComponent,
                    GetSmallestSortableLayoutOrder(oStronglyConnectedComponent)
                    );
            }
            }

            oStronglyConnectedComponents.Sort(
            delegate
            (
                LinkedList<IVertex> oStronglyConnectedComponent1,
                LinkedList<IVertex> oStronglyConnectedComponent2
            )
            {
                // Sort the components first by increasing vertex count.

                Int32 iCompareTo =
                    oStronglyConnectedComponent1.Count.CompareTo(
                        oStronglyConnectedComponent2.Count);

                if (!bSortAscending)
                {
                    iCompareTo *= -1;
                }

                if (iCompareTo == 0 && oSmallestSortableLayoutOrder != null)
                {
                    // Sub-sort components with the same vertex count by the
                    // smallest layout order within the component.

                    iCompareTo = oSmallestSortableLayoutOrder[
                        oStronglyConnectedComponent1].CompareTo(
                            oSmallestSortableLayoutOrder[
                                oStronglyConnectedComponent2] );
                }

                return (iCompareTo);
            }
            );
        }
开发者ID:haisreekanth,项目名称:NetMap,代码行数:91,代码来源:ConnectedComponentCalculator.cs

示例3:

    UseMetadataVertexSorter
    (
        IGraph graph
    )
    {
        Debug.Assert(graph != null);

        this.VertexSorter =

            graph.ContainsKey(ReservedMetadataKeys.SortableLayoutAndZOrderSet)
            ? 
            new ByMetadataVertexSorter<Single>(
                ReservedMetadataKeys.SortableLayoutAndZOrder)
            :
            null;
    }
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:16,代码来源:SortableLayoutBase.cs

示例4: VerifyOriginalEdgeMetadata

    VerifyOriginalMetadata
    (
        IGraph oGraph,
        IEdge oEdge1,
        IEdge oEdge2,
        IEdge oEdge3,
        IEdge oEdge4
    )
    {
        GroupLayoutDrawingInfo oGroupLayoutDrawingInfo;

        Assert.IsFalse( GroupMetadataManager.TryGetGroupLayoutDrawingInfo(
            oGraph, out oGroupLayoutDrawingInfo) );

        Assert.IsFalse( oGraph.ContainsKey(
            ReservedMetadataKeys.IntergroupEdgesHidden) );

        VerifyOriginalEdgeMetadata(oEdge1, oEdge2, oEdge3, oEdge4);
    }
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:19,代码来源:GroupMetadataManagerTest.cs

示例5: return

    GetVerticesToDraw
    (
        IGraph oGraph
    )
    {
        Debug.Assert(oGraph != null);

        // Note that the ReservedMetadataKeys.SortableLayoutAndZOrderSet key is
        // used for two purposes:
        //
        // 1. It tells SortableLayoutBase to lay out the graph's vertices in a
        //    specified order.
        //
        // 2. It tells this GraphDrawer to draw the graph's vertices in the
        //    same order.

        if ( oGraph.ContainsKey(
            ReservedMetadataKeys.SortableLayoutAndZOrderSet) )
        {
            return ( ( new ByMetadataVertexSorter<Single>(
                ReservedMetadataKeys.SortableLayoutAndZOrder) ).Sort(
                    oGraph.Vertices) );
        }

        return (oGraph.Vertices);
    }
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:26,代码来源:GraphDrawer.cs

示例6: GetAdjustedLayoutContext

        //*************************************************************************
        //  Method: GetAdjustedLayoutContext()
        //
        /// <summary>
        /// Gets an adjusted layout context object to use when laying out the
        /// graph.
        /// </summary>
        ///
        /// <param name="oGraph">
        /// The graph being laid out.
        /// </param>
        ///
        /// <param name="oOriginalLayoutContext">
        /// The original layout context passed to the layout method.
        /// </param>
        ///
        /// <param name="oAdjustedLayoutContext">
        /// If true is returned, this gets set to a copy of <paramref
        /// name="oOriginalLayoutContext" /> that has been adjusted.
        /// </param>
        ///
        /// <returns>
        /// true if the graph can be laid out, false if it can't be.
        /// </returns>
        ///
        /// <remarks>
        /// This method adjusts the graph rectangle stored in <paramref
        /// name="oOriginalLayoutContext" /> according to the <see
        /// cref="LayoutBase.Margin" /> setting and the presence of a <see
        /// cref="ReservedMetadataKeys.LayOutTheseVerticesWithinBounds" /> key on
        /// the graph.  If subtracting the margin results in a non-positive width
        /// or height, false is returned.
        /// </remarks>
        //*************************************************************************
        protected Boolean GetAdjustedLayoutContext(
            IGraph oGraph,
            LayoutContext oOriginalLayoutContext,
            out LayoutContext oAdjustedLayoutContext
            )
        {
            Debug.Assert(oGraph != null);
            Debug.Assert(oOriginalLayoutContext != null);
            AssertValid();

            oAdjustedLayoutContext = null;
            Rectangle oAdjustedRectangle = oOriginalLayoutContext.GraphRectangle;

            if (
            oGraph.ContainsKey(
                ReservedMetadataKeys.LayOutTheseVerticesWithinBounds)
            &&
            oGraph.ContainsKey(
                ReservedMetadataKeys.LayOutTheseVerticesOnly)
            )
            {
            // Get the bounding rectangle of the specified vertices.

            Single fMinimumX = Single.MaxValue;
            Single fMaximumX = Single.MinValue;
            Single fMinimumY = Single.MaxValue;
            Single fMaximumY = Single.MinValue;

            foreach ( IVertex oVertex in GetVerticesToLayOut(oGraph) )
            {
                PointF oLocation = oVertex.Location;
                Single fX = oLocation.X;
                Single fY = oLocation.Y;

                fMinimumX = Math.Min(fX, fMinimumX);
                fMaximumX = Math.Max(fX, fMaximumX);
                fMinimumY = Math.Min(fY, fMinimumY);
                fMaximumY = Math.Max(fY, fMaximumY);
            }

            if (fMinimumX != Single.MaxValue)
            {
                oAdjustedRectangle = Rectangle.FromLTRB(
                    (Int32)Math.Ceiling(fMinimumX),
                    (Int32)Math.Ceiling(fMinimumY),
                    (Int32)Math.Floor(fMaximumX),
                    (Int32)Math.Floor(fMaximumY) );
            }
            }
            else
            {
            oAdjustedRectangle.Inflate(-m_iMargin, -m_iMargin);
            }

            if (oAdjustedRectangle.Width > 0 && oAdjustedRectangle.Height > 0)
            {
            oAdjustedLayoutContext = new LayoutContext(oAdjustedRectangle);
            return (true);
            }

            return (false);
        }
开发者ID:haisreekanth,项目名称:NetMap,代码行数:96,代码来源:LayoutBase.cs

示例7: AssertValid

    TransformLayoutCore
    (
        IGraph graph,
        LayoutContext originalLayoutContext,
        LayoutContext newLayoutContext
    )
    {
        Debug.Assert(graph != null);
        Debug.Assert(originalLayoutContext != null);
        Debug.Assert(newLayoutContext != null);
        AssertValid();

        Matrix oTransformationMatrix = LayoutUtil.GetRectangleTransformation(
            originalLayoutContext.GraphRectangle,
            newLayoutContext.GraphRectangle
            );

        LayoutUtil.TransformVertexLocations(graph, oTransformationMatrix);

        if ( graph.ContainsKey(
            ReservedMetadataKeys.GraphHasEdgeIntermediateCurvePoints) )
        {
            TransformIntermediateCurvePoints(graph, oTransformationMatrix);
        }

        GroupMetadataManager.TransformGroupRectangles(
            graph, originalLayoutContext, newLayoutContext);
    }
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:28,代码来源:LayoutBase.cs

示例8: LayOutGraphCore

        //*************************************************************************
        //  Method: LayOutGraphCore()
        //
        /// <summary>
        /// Lays out a graph synchronously or asynchronously.
        /// </summary>
        ///
        /// <param name="graph">
        /// Graph to lay out.  The graph is guaranteed to have at least one vertex.
        /// </param>
        ///
        /// <param name="verticesToLayOut">
        /// Vertices to lay out.  The collection is guaranteed to have at least one
        /// vertex.
        /// </param>
        ///
        /// <param name="layoutContext">
        /// Provides access to objects needed to lay out the graph.  The <see
        /// cref="LayoutContext.GraphRectangle" /> is guaranteed to have non-zero
        /// width and height.
        /// </param>
        ///
        /// <param name="backgroundWorker">
        /// <see cref="BackgroundWorker" /> whose worker thread called this method
        /// if the graph is being laid out asynchronously, or null if the graph is
        /// being laid out synchronously.
        /// </param>
        ///
        /// <returns>
        /// true if the layout was successfully completed, false if the layout was
        /// cancelled.  The layout can be cancelled only if the graph is being laid
        /// out asynchronously.
        /// </returns>
        ///
        /// <remarks>
        /// This method lays out the graph <paramref name="graph" /> either
        /// synchronously (if <paramref name="backgroundWorker" /> is null) or
        /// asynchronously (if (<paramref name="backgroundWorker" /> is not null)
        /// by setting the the <see cref="IVertex.Location" /> property on the
        /// vertices in <paramref name="verticesToLayOut" /> and optionally adding
        /// geometry metadata to the graph, vertices, or edges.
        ///
        /// <para>
        /// In the asynchronous case, the <see
        /// cref="BackgroundWorker.CancellationPending" /> property on the
        /// <paramref name="backgroundWorker" /> object should be checked before
        /// each layout iteration.  If it's true, the method should immediately
        /// return false.  Also, <see
        /// cref="AsyncLayoutBase.FireLayOutGraphIterationCompleted()" /> should be
        /// called after each iteration.
        /// </para>
        ///
        /// <para>
        /// The arguments have already been checked for validity.
        /// </para>
        ///
        /// </remarks>
        //*************************************************************************
        protected override Boolean LayOutGraphCore(
            IGraph graph,
            ICollection<IVertex> verticesToLayOut,
            LayoutContext layoutContext,
            BackgroundWorker backgroundWorker
            )
        {
            Debug.Assert(graph != null);
            Debug.Assert(verticesToLayOut != null);
            Debug.Assert(verticesToLayOut.Count > 0);
            Debug.Assert(layoutContext != null);
            AssertValid();

            Int32 iVertices = verticesToLayOut.Count;

            ICollection<IEdge> oEdgesToLayOut =
            GetEdgesToLayOut(graph, verticesToLayOut);

            // If the graph has already been laid out, use the current vertex
            // locations as initial values.

            if ( !LayoutMetadataUtil.GraphHasBeenLaidOut(graph) )
            {
            // The graph has not been laid out.  By default, randomize the
            // locations of those vertices that are not locked.  If the graph
            // has the FruchtermanReingoldLayoutSelectivelyRandomize key,
            // however, randomize the locations of those vertices that have
            // IVertex.Location set to LayoutBase.RandomizeThisLocation and are
            // not locked.

            Boolean bSelectivelyRandomize = graph.ContainsKey(
                ReservedMetadataKeys.
                    FruchtermanReingoldLayoutSelectivelyRandomize);

            RandomizeVertexLocations(verticesToLayOut, layoutContext,
                new Random(1), bSelectivelyRandomize);
            }

            // Store required metadata on the graph's vertices.

            InitializeMetadata(verticesToLayOut);

//.........这里部分代码省略.........
开发者ID:haisreekanth,项目名称:NetMap,代码行数:101,代码来源:FruchtermanReingoldLayout.cs


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