Esempio n. 1
0
        public static WeightedAcyclicDirectedGraph <T> Create(
            WeightedDirectedGraph <T> digraph)
        {
            // Calc the depth of each node in the digraph.
            GraphDepthInfo depthInfo = AcyclicGraphDepthAnalysis.CalculateNodeDepths(digraph);

            return(CreateInner(digraph, depthInfo));
        }
        /// <summary>
        /// Create from the provided <see cref="WeightedDirectedGraph{T}"/>.
        /// </summary>
        /// <remarks>
        /// The provided graph is expected to describe an acyclic graph; this method asserts that is the case and builds
        /// a formal acyclic graph representation.
        /// </remarks>
        /// <param name="digraph">The directed graph.</param>
        /// <returns>A new instance of <see cref="WeightedDirectedGraphAcyclic{T}"/>.</returns>
        public static WeightedDirectedGraphAcyclic <T> Create(
            WeightedDirectedGraph <T> digraph)
        {
            // Calc the depth of each node in the digraph.
            // ENHANCEMENT: Use a re-usable instance of AcyclicGraphDepthAnalysis.
            GraphDepthInfo depthInfo = new AcyclicGraphDepthAnalysis().CalculateNodeDepths(digraph);

            return(CreateInner(digraph, depthInfo));
        }
Esempio n. 3
0
        public static WeightedAcyclicDirectedGraph <T> Create(
            WeightedDirectedGraph <T> digraph,
            GraphDepthInfo depthInfo)
        {
            // Assert that the passed in depth info is correct.
            // Note. This test is expensive because it invokes a graph traversal algorithm to determine node depths.
            Debug.Assert(depthInfo.Equals(AcyclicGraphDepthAnalysis.CalculateNodeDepths(digraph)));

            return(CreateInner(digraph, depthInfo));
        }