Smrf.NodeXL.ExcelTemplate.SubgraphImageCreator.CreateSubgraph C# (CSharp) Method

CreateSubgraph() protected method

protected CreateSubgraph ( IVertex oOriginalVertex, CreateSubgraphImagesAsyncArgs oCreateSubgraphImagesAsyncArgs ) : IGraph
oOriginalVertex IVertex
oCreateSubgraphImagesAsyncArgs CreateSubgraphImagesAsyncArgs
return IGraph
    CreateSubgraph
    (
        IVertex oOriginalVertex,
        CreateSubgraphImagesAsyncArgs oCreateSubgraphImagesAsyncArgs
    )
    {
        Debug.Assert(oOriginalVertex != null);
        Debug.Assert(oCreateSubgraphImagesAsyncArgs != null);
        AssertValid();

        // Create a new empty graph that will contain the vertex's subgraph.

        IGraph oSubgraph = new Graph();

        // Clone the original vertex, its adjacent vertices, and the connecting
        // edges into the subgraph.

        Decimal decLevels = oCreateSubgraphImagesAsyncArgs.Levels;

        IVertex oSubgraphVertex = CloneVertexIntoSubgraph(oOriginalVertex,
            oSubgraph, decLevels);

        if (oCreateSubgraphImagesAsyncArgs.SelectVertex)
        {
            // Select the vertex.

            oSubgraphVertex.SetValue(ReservedMetadataKeys.IsSelected, true);
        }

        if (oCreateSubgraphImagesAsyncArgs.SelectIncidentEdges)
        {
            // Select the vertex's incident edges.

            foreach (IEdge oIncidentEdge in oSubgraphVertex.IncidentEdges)
            {
                oIncidentEdge.SetValue(ReservedMetadataKeys.IsSelected, true);
            }
        }

        return (oSubgraph);
    }