コード例 #1
0
        public static void Main()
        {
            Console.WriteLine("Data Structure Practice");

            DisplayGraph.DisplayKruskalSpanningTree();

            Console.ReadLine();
        }
コード例 #2
0
        /// <summary>
        /// Erzeugt ein neues Fenster für die Bild- und Tondarstellung.
        /// </summary>
        public BDAWindow()
        {
            // Startup
            InitializeComponent();

            // Finish
            Graph = new DisplayGraph();
        }
コード例 #3
0
ファイル: BDAWindow.cs プロジェクト: davinx/DVB.NET---VCR.NET
        /// <summary>
        /// Erzeugt ein neues Fenster für die Bild- und Tondarstellung.
        /// </summary>
        public BDAWindow()
        {
            // Startup
            InitializeComponent();

            // Finish
            Graph = new DisplayGraph();
        }
コード例 #4
0
        /// <summary>
        /// Erzeugt einen neuen Filter.
        /// </summary>
        /// <param name="graph">Optional für den Fall, dass der Filter als
        /// Datenstromquelle genutzt wird.</param>
        public TSFilter(DisplayGraph graph)
        {
            // Remember
            DisplayGraph = graph;

            // Create pin helper
            m_Pin = new InputPin(this, false);

            // Create injectors
            m_TSInjector = new Injector(50, 512 * TS.Manager.FullSize, m_Pin.Receive);
        }
コード例 #5
0
 internal FlowGraphView(Document document, MethodLocation location, FlowGraph flowGraph, DisplayGraph displayGraph)
 {
     this.Document     = document;
     this.Location     = location;
     this.FlowGraph    = flowGraph;
     this.DisplayGraph = displayGraph;
 }
コード例 #6
0
        private void ProcessStatements(
            SourceText text,
            DisplayGraph displayGraph,
            ExecutionModel executionModel,
            int nodeIndex,
            MethodFlowView calledMethod = null)
        {
            var  modelManager    = this.PathView.ToolView.GraphProvider.ModelManager;
            var  flowNode        = executionModel.PathNodes[nodeIndex];
            bool isLastInnerNode =
                (nodeIndex == executionModel.PathNodes.Length - 1) &&
                flowNode is InnerFlowNode;
            var nodeInterpretations = executionModel.NodeInterpretations[nodeIndex];
            var heapLocations       = executionModel.HeapLocations[nodeIndex];

            // TODO: Consider optimizing
            // TODO: Group the records by their display nodes
            var displayRecords = new List <DisplayNodeRecord>();

            foreach (var displayNode in displayGraph.Nodes)
            {
                displayRecords.AddRange(displayNode.Records.Where(record => record.FlowNode == flowNode));

                // Temporary: Replace by this if only the last result of a DisplayNode is important
                // (Behaves weirdly in case of methods and their arguments, as they are distributed between
                //  two FlowNodes)
                ////var displayRecord = displayNode.Records.LastOrDefault(record => record.FlowNode == flowNode);
                ////if (displayRecord != null)
                ////{
                ////    displayRecords.Add(displayRecord);
                ////}
            }

            foreach (var displayRecord in displayRecords)
            {
                Contract.Assert(displayRecord != null);
                string            statement    = text.ToString(displayRecord.Span);
                string            value        = null;
                string            type         = null;
                HeapModelLocation?heapLocation = null;
                if (displayRecord.Type != null)
                {
                    var modelFactory = modelManager.TryGetFactory(displayRecord.Type);
                    if (modelFactory.ValueKind == ValueModelKind.Interpretation)
                    {
                        // Hide the remaining portion of the inner CFG node where the exploration started from
                        if (isLastInnerNode && displayRecord.FirstVariableIndex >= nodeInterpretations.Length)
                        {
                            continue;
                        }

                        var sortRequirements = modelFactory.GetExpressionSortRequirements(displayRecord.Type);
                        var interpretations  = nodeInterpretations
                                               .Skip(displayRecord.FirstVariableIndex)
                                               .Take(sortRequirements.Count)
                                               .ToArray();

                        if (interpretations.Length != 0 &&
                            interpretations.All(interpretation => interpretation != null))
                        {
                            var valueModel = modelFactory.GetValueModel(displayRecord.Type, interpretations);

                            value = valueModel.ValueText;
                            type  = displayRecord.Type.Name;
                        }
                    }
                    else
                    {
                        Contract.Assert(modelFactory.ValueKind == ValueModelKind.Reference);

                        bool locationExists = displayRecord.FirstVariableIndex < heapLocations.Length;

                        // Hide the remaining portion of the inner CFG node where the exploration started from
                        if (isLastInnerNode && !locationExists)
                        {
                            continue;
                        }

                        if (locationExists)
                        {
                            heapLocation = heapLocations[displayRecord.FirstVariableIndex];
                            var valueModel = modelFactory.GetValueModel(
                                displayRecord.Type,
                                heapLocation.Value,
                                executionModel.HeapModel);

                            value = valueModel.ValueText;
                            type  = displayRecord.Type.Name;
                        }
                    }
                }

                // Display a call only on the last statement of a call node
                // (In future, display node records concerning argument evaluation might be added)
                var called = (calledMethod != null && displayRecord == displayRecords.Last()) ? calledMethod : null;

                var statementFlow = new StatementFlowView(
                    this,
                    this.statementFlows.Count,
                    displayRecord,
                    !string.IsNullOrEmpty(statement) ? statement : displayRecord.VariableName,
                    value,
                    type,
                    heapLocation,
                    called);
                this.statementFlows.Add(statementFlow);
            }
        }