/// <summary>
 /// Registers the predecessors handler
 /// </summary>
 /// <param name="vis"></param>
 public void RegisterPredecessorRecorderHandlers(IPredecessorRecorderVisitor vis)
 {
     if (vis == null)
     {
         throw new ArgumentNullException("visitor");
     }
     InitializeVertex += new VertexHandler(vis.InitializeVertex);
     TreeEdge         += new EdgeHandler(vis.TreeEdge);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="vis"></param>
        public void RegisterTreeEdgeBuilderHandlers(ITreeEdgeBuilderVisitor vis)
        {
            if (vis == null)
            {
                throw new ArgumentNullException("visitor");
            }

            TreeEdge += new EdgeHandler(vis.TreeEdge);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="vis"></param>
        public void RegisterDistanceRecorderHandlers(IDistanceRecorderVisitor vis)
        {
            if (vis == null)
            {
                throw new ArgumentNullException("visitor");
            }

            InitializeVertex += new VertexHandler(vis.InitializeVertex);
            DiscoverVertex   += new VertexHandler(vis.DiscoverVertex);
            TreeEdge         += new EdgeHandler(vis.TreeEdge);
        }
Example #4
0
 public GraphCreatorWindow(Action <string> graphPathChosen, Brush nodeBrush, Brush numBrush, Brush lineBrush, PenLineCap penLineCap)
 {
     InitializeComponent();
     this.MinWidth                       = this.MaxWidth = this.Width;
     this.MinHeight                      = this.MaxHeight = this.Height;
     GraphPathChosen                     = graphPathChosen;
     this.GraphVisual                    = GraphVisual.Create(GraphCanvas, nodeBrush, numBrush, lineBrush, penLineCap);
     this.EdgeHandler                    = EdgesHandler.Create(EdgesScrollViewer, GraphVisual.UpdateWeight, _ => GraphUpdated());
     GraphVisual.EdgeAddedEvent         += (sender, args) => EdgeHandler.AddEdge(args.AddedEdge);
     GraphVisual.EdgeRemovedEvent       += (sender, args) => EdgeHandler.RemoveEdge(args.RemovedEdge);
     GraphVisual.EdgeAddedEvent         += (sender, args) => this.GraphUpdated();
     GraphVisual.EdgeRemovedEvent       += (sender, args) => this.GraphUpdated();
     GraphVisual.NodeAmountChangedEvent += (sender, args) => this.GraphUpdated();
     this.StateController                = new IdleState(GraphVisual);
     this.WeightsHandler                 = WeightsHandler.Create(this.ThicknessDictionaryStackPanel,
                                                                 nodeBrush, lineBrush, GraphVisual.NodeWidth, GraphVisual.MinLineThickness, GraphVisual.MaxLineThickness, 0.0, 2.0);
 }
 /// <summary>
 /// Registers the predecessors handler
 /// </summary>
 /// <param name="vis"></param>
 public void RegisterPredecessorRecorderHandlers(IPredecessorRecorderVisitor vis)
 {
     if (vis == null)
         throw new ArgumentNullException("visitor");
     InitializeVertex += new VertexHandler(vis.InitializeVertex);
     TreeEdge += new EdgeHandler(vis.TreeEdge);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="vis"></param>
        public void RegisterTreeEdgeBuilderHandlers(ITreeEdgeBuilderVisitor vis)
        {
            if (vis == null)
                throw new ArgumentNullException("visitor");

            TreeEdge += new EdgeHandler(vis.TreeEdge);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="vis"></param>
 public void RegisterVisitor(IGraphvizVisitor vis)
 {
     WriteGraph  += new EventHandler(vis.WriteGraph);
     WriteVertex += new VertexHandler(vis.WriteVertex);
     WriteEdge   += new EdgeHandler(vis.WriteEdge);
 }
Example #8
0
    void proc(Cell[] cells, int dimensionMap, EdgeHandler handler, int level)
    {
        foreach (Cell cell in cells)
        {
            if (!cell.signed)
            {
                return;
            }
        }

        if (cells.Length == children.Length / 2) //only edges
        {
            if (level == maxLevel)
            {
                handler(cells, dimensionMap);
            }
        }

        foreach (Cell cell in cells)
        {
            if (cell.children == null)
            {
                return;
            }
        }

        //get "block"
        Cell[] block = new Cell[children.Length];
        for (int i = 0; i < block.Length; i++)
        {
            var cellToPickFrom = i & dimensionMap;
            var cellToPick     = i ^ dimensionMap;

            int actualCellToPickFrom = BitHelper.ReduceDims(cellToPickFrom, dimensionMap, Dimensions);

            block[i] = cells[actualCellToPickFrom].children[cellToPick];
        }

        for (int dimMap = 0; dimMap < children.Length - 1; dimMap++)
        {
            if ((dimMap & dimensionMap) != dimensionMap)
            {
                continue;
            }

            int activeDimensions = 0;
            for (int i = 0; i < Dimensions; i++)
            {
                if (BitHelper.Get(dimMap, i))
                {
                    activeDimensions++;
                }
            }

            for (int i = 0; i < children.Length; i++)
            {
                if ((dimMap & i) > 0)
                {
                    continue;
                }
                Cell[] pickedCells = new Cell[(int)Math.Pow(2, activeDimensions)];
                for (int j = 0; j < children.Length; j++)
                {
                    if ((~dimMap & j) > 0)
                    {
                        continue;
                    }
                    pickedCells[BitHelper.ReduceDims(j, dimMap, Dimensions)] = block[i | j];
                }
                proc(pickedCells, dimMap, handler, level + 1);
            }
        }
    }
Example #9
0
 public void EnumerateEdges(EdgeHandler handler)
 {
     proc(new Cell[] { this }, 0, handler, 1);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="vis"></param>
        public void RegisterDistanceRecorderHandlers(IDistanceRecorderVisitor vis)
        {
            if (vis == null)
                throw new ArgumentNullException("visitor");

            InitializeVertex += new VertexHandler(vis.InitializeVertex);
            DiscoverVertex += new VertexHandler(vis.DiscoverVertex);
            TreeEdge += new EdgeHandler(vis.TreeEdge);
        }
Example #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="vis"></param>
 public void RegisterVisitor(IGraphvizVisitor vis)
 {
     WriteGraph += new EventHandler(vis.WriteGraph);
     WriteVertex += new VertexHandler(vis.WriteVertex);
     WriteEdge += new EdgeHandler(vis.WriteEdge);
 }