private void RestoreDefaults()
 {
     transitionLabels                 = TransitionLabel.Action;
     nodeLabelsVisible                = true;
     initialStateColor                = Color.LightGray;
     hoverColor                       = Color.Lime;
     selectionColor                   = System.Drawing.Color.Blue;
     livenessCheckIsOn                = false;
     deadStateColor                   = Color.Yellow;
     safetyCheckIsOn                  = false;
     unsafeStateColor                 = Color.Red;
     maxTransitions                   = 100;
     loopsVisible                     = true;
     mergeLabels                      = true;
     acceptingStatesMarked            = true;
     stateShape                       = StateShape.Ellipse;
     direction                        = GraphDirection.TopToBottom;
     combineActions                   = false;
     excludeIsomorphicStates          = false;
     collapseExcludedIsomorphicStates = false;
     if (this.finiteAutomatonContext != null)
     {
         graphChanged = true;
         PerformLayout();
     }
 }
        public static void BFS_VLevels(
            DAG dag,
            GraphDirection dir,
            SortedDictionary <long, SortedSet <long> > nodeVLevels,
            long currentLevel,
            Func <DAGNode, bool> nodeAction,
            Func <long, bool> levelAction)
        {
            SortedDictionary <long, DAGNode> nodeEnumeration = dag.NodeEnumeration;

            foreach (KeyValuePair <long, SortedSet <long> > currentLevelNodes in
                     (dir == GraphDirection.Forward ? nodeVLevels : nodeVLevels.Reverse()))
            {
                if (currentLevel > currentLevelNodes.Key)
                {
                    continue;
                }

                foreach (long vNodeId in currentLevelNodes.Value)
                {
                    if (nodeEnumeration.TryGetValue(vNodeId, out DAGNode? vNode))
                    {
                        nodeAction(vNode);
                    }
                }

                levelAction(currentLevelNodes.Key);
            }
        }
 public NavSegmentOverlap(int plane, int depth, GraphDirection dir, NavSegment seg)
 {
     this.plane     = plane;
     this.depth     = depth;
     this.direction = dir;
     this.segment   = seg;
 }
    /// <summary>
    /// Sets the position fo the neighbouting vertex based on the direction in which it lies
    /// </summary>
    /// <param name="vertexIndex"> Index of current vertex</param>
    /// <param name="neighbourVertex"> Neighbouring LevelGraphVertex object</param>
    /// <param name="direction"> Direction in which the neighbouring vertex lies in reference to current vertex </param>
    /// <param name="roomSpawnInfo">List of RoomSpawnParameters</param>
    private void Setposition(int vertexIndex, LevelGraphVertex neighbourVertex, GraphDirection direction, List <RoomSpawnParameters> roomSpawnInfo)
    {
        switch (direction)
        {
        case GraphDirection.North:
            roomSpawnInfo[neighbourVertex.ID].X = roomSpawnInfo[vertexIndex].X;
            roomSpawnInfo[neighbourVertex.ID].Y = roomSpawnInfo[vertexIndex].Y + _settings.roomSize;
            break;

        case GraphDirection.South:
            roomSpawnInfo[neighbourVertex.ID].X = roomSpawnInfo[vertexIndex].X;
            roomSpawnInfo[neighbourVertex.ID].Y = roomSpawnInfo[vertexIndex].Y - _settings.roomSize;
            break;

        case GraphDirection.East:
            roomSpawnInfo[neighbourVertex.ID].X = roomSpawnInfo[vertexIndex].X + _settings.roomSize;
            roomSpawnInfo[neighbourVertex.ID].Y = roomSpawnInfo[vertexIndex].Y;
            break;

        case GraphDirection.West:
            roomSpawnInfo[neighbourVertex.ID].X = roomSpawnInfo[vertexIndex].X - _settings.roomSize;
            roomSpawnInfo[neighbourVertex.ID].Y = roomSpawnInfo[vertexIndex].Y;
            break;
        }
    }
Exemple #5
0
        public static (List <long>, bool) FindPath_Greedy(
            DAGNode s,
            DAGNode t,
            GraphDirection direction,
            Predicate <DAGNode> nodeFilter,
            Predicate <DAGEdge> edgeFilter,
            Action <DAGNode> nodeAction,
            Action <DAGEdge> edgeAction)
        {
            List <long> path      = new();
            bool        pathFound = false;

            SortedSet <long> processedNodes = new();
            DAGNode          currentNode    = (direction == GraphDirection.Forward ? s : t);

            if (!nodeFilter(currentNode))
            {
                pathFound = false;

                return(path, pathFound);
            }

            while (true)
            {
                processedNodes.Add(currentNode.Id);
                bool nextNodeFound = false;

                path.Add(currentNode.Id);
                nodeAction(currentNode);

                if (currentNode == (direction == GraphDirection.Forward ? t : s))
                {
                    pathFound = true;

                    return(path, pathFound);
                }

                List <DAGEdge> nextEdges = (direction == GraphDirection.Forward ?
                                            currentNode.OutEdges : currentNode.InEdges);

                foreach (DAGEdge e in nextEdges)
                {
                    DAGNode v = (direction == GraphDirection.Forward ? e.ToNode : e.FromNode);
                    if (edgeFilter(e) && nodeFilter(v))
                    {
                        currentNode = v;
                        edgeAction(e);

                        nextNodeFound = true;

                        break;
                    }
                }

                if (!nextNodeFound)
                {
                    return(path, pathFound);
                }
            }
        }
Exemple #6
0
        public static bool FindPath_DFS(
            DAG dag,
            DAGNode s,
            GraphDirection direction,
            Predicate <DAGNode> nodeFilter,
            Predicate <DAGEdge> edgeFilter,
            Action <DAGNode, long> nodeAction,
            Action <DAGEdge, long> edgeAction,
            List <long> path)
        {
            SortedSet <long> processedNodes = new();

            bool pathFound = FindPath_DFS(
                s,
                dag.t,
                processedNodes,
                direction,
                0,
                nodeFilter,
                edgeFilter,
                nodeAction,
                edgeAction,
                path);

            return(pathFound);
        }
    /// <summary>
    /// Sets the position of the doors to block unconnected exits. This method adds new item to the SpawnParametersList.
    /// </summary>
    /// <param name="vertexIndex"> Index of current vertex</param>
    /// <param name="direction"> Direction in which the neighbouring vertex lies in reference to current vertex </param>
    /// <param name="doorSpawnInfo">List of RoomSpawnParameters</param>
    private void SetDoorPosition(int vertexIndex, GraphDirection direction, List <RoomSpawnParameters> roomSpawnInfo, List <DoorSpawnParameters> doorSpawnInfo)
    {
        float X = 0, Y = 0;
        bool  isHorizontal = true;

        switch (direction)
        {
        case GraphDirection.North:
            X            = roomSpawnInfo[vertexIndex].X;
            Y            = roomSpawnInfo[vertexIndex].Y + _settings.roomSize / 2f - 0.5f;
            isHorizontal = false;
            break;

        case GraphDirection.South:
            X            = roomSpawnInfo[vertexIndex].X;
            Y            = roomSpawnInfo[vertexIndex].Y - _settings.roomSize / 2f + 0.5f;
            isHorizontal = false;
            break;

        case GraphDirection.East:
            X            = roomSpawnInfo[vertexIndex].X + _settings.roomSize / 2f - 0.5f;
            Y            = roomSpawnInfo[vertexIndex].Y;
            isHorizontal = true;
            break;

        case GraphDirection.West:
            X            = roomSpawnInfo[vertexIndex].X - _settings.roomSize / 2f + 0.5f;
            Y            = roomSpawnInfo[vertexIndex].Y;
            isHorizontal = true;
            break;
        }

        doorSpawnInfo.Add(new DoorSpawnParameters(X, Y, isHorizontal));
    }
Exemple #8
0
        public static void DFS(
            DAGNode s,
            GraphDirection direction,
            Action <DAGNode, long> nodeAction,
            Action <DAGEdge, long> edgeAction)
        {
            SortedSet <long> processedNodes = new();

            DFS(s, processedNodes, direction, 0, nodeAction, edgeAction);
        }
Exemple #9
0
    public void AddEdge(int fromId, int toId, GraphDirection direction)
    {
        var from = nodes[fromId];
        var to   = nodes[toId];

        from.AddNeighbour(toId, direction);
        GraphDirection reversedDirection = (GraphDirection)(3 - (int)direction);

        to.AddNeighbour(fromId, reversedDirection);
    }
Exemple #10
0
            static private IVertexBase GetNextVertex(IEdgeBase edge, GraphDirection direction)
            {
                switch (direction)
                {
                case GraphDirection.Successors: return(edge.End);

                case GraphDirection.Predecessors: return(edge.Start);

                default: throw new NotSupportedException();
                }
            }
Exemple #11
0
            private TValue Transform(ITransformer transformer, TValue value, GraphDirection direction)
            {
                switch (direction)
                {
                case GraphDirection.Successors: return(_transform(transformer, value));

                case GraphDirection.Predecessors: return(_inverseTransform(transformer, value));

                default: throw new NotSupportedException();
                }
            }
Exemple #12
0
        public static bool PropagateProperties(
            DAG dag,
            long fromNodeId,
            GraphDirection direction,
            Predicate <DAGNode> nodeFilter,
            Predicate <DAGEdge> edgeFilter,
            Predicate <DAGNode> nodeAction,
            Predicate <DAGEdge> edgeAction)
        {
            QueueWithIdSet <DAGNode> nodeQueue = new();
            bool             status            = false;
            SortedSet <long> processedNodes    = new();
            DAGNode          s = dag.NodeEnumeration[fromNodeId];

            if (nodeFilter(s))
            {
                nodeQueue.Enqueue(s);
            }

            while (nodeQueue.Any())
            {
                DAGNode u = nodeQueue.Dequeue();
                if (processedNodes.Contains(u.Id))
                {
                    continue;
                }

                processedNodes.Add(u.Id);

                bool nodeActionStatus = nodeAction(u);
                status = status || nodeActionStatus;

                foreach (DAGEdge e in (direction == GraphDirection.Forward ?
                                       u.OutEdges : u.InEdges))
                {
                    DAGNode v = (direction == GraphDirection.Forward ? e.ToNode : e.FromNode);

                    if (!edgeFilter(e))
                    {
                        continue;
                    }

                    bool edgeActionStatus = edgeAction(e);
                    status = status || edgeActionStatus;

                    if (nodeFilter(v) && (!nodeQueue.Contains(v)))
                    {
                        nodeQueue.Enqueue((direction == GraphDirection.Forward ? e.ToNode : e.FromNode));
                    }
                }
            }

            return(status);
        }
 private void RestoreDefaults()
 {
     transitionLabels                 = TransitionLabel.Action;
     nodeLabelsVisible                = true;
     initialStateColor                = new Color("LightGray");
     hoverColor                       = new Color("Lime");
     selectionColor                   = new Color("Blue");
     livenessCheckIsOn                = false;
     deadStateColor                   = new Color("Yellow");
     safetyCheckIsOn                  = false;
     unsafeStateColor                 = new Color("Red");
     maxTransitions                   = 100;
     loopsVisible                     = true;
     mergeLabels                      = true;
     acceptingStatesMarked            = true;
     stateShape                       = StateShape.Ellipse;
     direction                        = GraphDirection.TopToBottom;
     combineActions                   = false;
     excludeIsomorphicStates          = false;
     collapseExcludedIsomorphicStates = false;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Name of the factory</param>
        /// <param name="factory">Factory</param>
        /// <param name="direction">Direction of graph</param>        
        /// <param name="containerGraph">The parent graph</param>
        /// <param name="logger">The logger to use</param>
        /// <param name="stateDictionary">Forwarded state dictionary</param>
        /// <param name="linked">If true then we are creating a linked master node</param>
        public NetGraphContainerNode(string name, NetGraphFactory factory,  
            GraphDirection direction, NetGraph containerGraph, Logger logger, 
            Dictionary<string, object> stateDictionary, bool linked)
        {
            var clients = factory.GetNodes<ClientEndpointFactory>();
            var servers = factory.GetNodes<ServerEndpointFactory>();

            if ((clients.Length > 0) && (servers.Length > 0))
            {
                Guid outputNode = direction == GraphDirection.ClientToServer
                    ? servers[0].Id : clients[0].Id;
                Guid inputNode = direction == GraphDirection.ClientToServer
                    ? clients[0].Id : servers[0].Id;

                if (linked)
                {
                    _graph = factory.Create(name, logger, containerGraph, containerGraph.GlobalMeta,
                        containerGraph.Meta, containerGraph.ConnectionProperties);
                }
                else
                {
                    _graph = factory.CreateFiltered(name, logger, containerGraph, containerGraph.GlobalMeta,
                        containerGraph.Meta, inputNode, containerGraph.ConnectionProperties, stateDictionary);
                }

                _graph.BindEndpoint(outputNode, new EventDataAdapter(this));

                _inputNode = (PipelineEndpoint)_graph.Nodes[inputNode];
                _inputNode.Hidden = true;

                _outputNode = (PipelineEndpoint)_graph.Nodes[outputNode];
                _outputNode.Hidden = true;
            }
            else
            {
                throw new ArgumentException(CANAPE.Properties.Resources.NetGraphContainerNode_InvalidGraph);
            }
        }
Exemple #15
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Name of the factory</param>
        /// <param name="factory">Factory</param>
        /// <param name="direction">Direction of graph</param>
        /// <param name="containerGraph">The parent graph</param>
        /// <param name="logger">The logger to use</param>
        /// <param name="stateDictionary">Forwarded state dictionary</param>
        /// <param name="linked">If true then we are creating a linked master node</param>
        public NetGraphContainerNode(string name, NetGraphFactory factory,
                                     GraphDirection direction, NetGraph containerGraph, Logger logger,
                                     Dictionary <string, object> stateDictionary, bool linked)
        {
            var clients = factory.GetNodes <ClientEndpointFactory>();
            var servers = factory.GetNodes <ServerEndpointFactory>();

            if ((clients.Length > 0) && (servers.Length > 0))
            {
                Guid outputNode = direction == GraphDirection.ClientToServer
                    ? servers[0].Id : clients[0].Id;
                Guid inputNode = direction == GraphDirection.ClientToServer
                    ? clients[0].Id : servers[0].Id;

                if (linked)
                {
                    _graph = factory.Create(name, logger, containerGraph, containerGraph.GlobalMeta,
                                            containerGraph.Meta, containerGraph.ConnectionProperties);
                }
                else
                {
                    _graph = factory.CreateFiltered(name, logger, containerGraph, containerGraph.GlobalMeta,
                                                    containerGraph.Meta, inputNode, containerGraph.ConnectionProperties, stateDictionary);
                }

                _graph.BindEndpoint(outputNode, new EventDataAdapter(this));

                _inputNode        = (PipelineEndpoint)_graph.Nodes[inputNode];
                _inputNode.Hidden = true;

                _outputNode        = (PipelineEndpoint)_graph.Nodes[outputNode];
                _outputNode.Hidden = true;
            }
            else
            {
                throw new ArgumentException(CANAPE.Properties.Resources.NetGraphContainerNode_InvalidGraph);
            }
        }
Exemple #16
0
        private static void DFS(
            DAGNode u,
            SortedSet <long> processedNodes,
            GraphDirection direction,
            long level,
            Action <DAGNode, long> nodeAction,
            Action <DAGEdge, long> edgeAction)
        {
            if (processedNodes.Contains(u.Id))
            {
                return;
            }

            nodeAction(u, level);
            processedNodes.Add(u.Id);

            foreach (DAGEdge e in (direction == GraphDirection.Forward ? u.OutEdges : u.InEdges))
            {
                DFS((direction == GraphDirection.Forward ? e.ToNode : e.FromNode),
                    processedNodes, direction, level + 1, nodeAction, edgeAction);
                edgeAction(e, level);
            }
        }
Exemple #17
0
 private void RestoreDefaults()
 {
     transitionLabels = TransitionLabel.Action;
     nodeLabelsVisible = true;
     initialStateColor = Color.LightGray;
     hoverColor = Color.Lime;
     selectionColor = System.Drawing.Color.Blue;
     livenessCheckIsOn = false;
     deadStateColor = Color.Yellow;
     safetyCheckIsOn = false;
     unsafeStateColor = Color.Red;
     maxTransitions = 100;
     loopsVisible = true;
     mergeLabels = true;
     acceptingStatesMarked = true;
     stateShape = StateShape.Ellipse;
     direction = GraphDirection.TopToBottom;
     combineActions = false;
     excludeIsomorphicStates = false;
     collapseExcludedIsomorphicStates = false;
     if (this.finiteAutomatonContext != null)
     {
         graphChanged = true;
         PerformLayout();
     }
 }
Exemple #18
0
            public IEnumerable <Projection <TValue> > VisitDirection(IVertexBase vertex, Arguments args, GraphDirection direction)
            {
                IReadOnlyCollection <IEdgeBase> nextEdges = GetNextEdges(vertex, direction);

                if (args.Target == null && nextEdges.Count == 0)
                {
                    yield return(new Projection <TValue> {
                        Value = args.Value, TransformerPath = args.TransformerPath.ToArray()
                    });
                }
                else
                {
                    foreach (Projection <TValue> value in nextEdges.Where(x => GetNextVertex(x, direction) != vertex)
                             .OrderBy(x => (GetNextVertex(x, direction) as ViewVertex)?.View.GetSceneNode()?.Depth ?? 0)
                             .SelectMany(x => x.Accept(this, args, direction))
                             .Where(x => args.Target == null || x.TransformerPath[0] == args.Target.Transformer))
                    {
                        yield return(value);
                    }
                }
            }
Exemple #19
0
        private static bool FindPath_DFS(
            DAGNode u,
            DAGNode t,
            SortedSet <long> processedNodes,
            GraphDirection direction,
            long level,
            Predicate <DAGNode> nodeFilter,
            Predicate <DAGEdge> edgeFilter,
            Action <DAGNode, long> nodeAction,
            Action <DAGEdge, long> edgeAction,
            List <long> path)
        {
            if (!nodeFilter(u))
            {
                return(false);
            }

            if (processedNodes.Contains(u.Id))
            {
                return(false);
            }

            nodeAction(u, level);
            path.Add(u.Id);

            processedNodes.Add(u.Id);

            if (u.Id == t.Id)
            {
                return(true);
            }

            foreach (DAGEdge e in (direction == GraphDirection.Forward ? u.OutEdges : u.InEdges))
            {
                if (!edgeFilter(e))
                {
                    continue;
                }

                bool pathFound = FindPath_DFS(
                    (direction == GraphDirection.Forward ? e.ToNode : e.FromNode),
                    t,
                    processedNodes,
                    direction,
                    level + 1,
                    nodeFilter,
                    edgeFilter,
                    nodeAction,
                    edgeAction,
                    path);

                edgeAction(e, level);

                if (pathFound)
                {
                    return(true);
                }
            }

            path.RemoveAt(path.Count - 1);

            return(false);
        }
Exemple #20
0
            public IEnumerable <Projection <TValue> > Visit(IEdgeBase edge, Arguments args, GraphDirection direction)
            {
                args       = new Arguments(args);
                args.Value = Transform(edge, args.Value, direction);

                IVertexBase nextVertex = GetNextVertex(edge, direction);

                foreach (Projection <TValue> projection in nextVertex.Accept(this, args))
                {
                    yield return(projection);
                }
            }
Exemple #21
0
            static private IReadOnlyCollection <IEdgeBase> GetNextEdges(IVertexBase vertex, GraphDirection direction)
            {
                switch (direction)
                {
                case GraphDirection.Successors: return(vertex.Successors);

                case GraphDirection.Predecessors: return(vertex.Predecessors);

                default: throw new NotSupportedException();
                }
            }
Exemple #22
0
 public override IEnumerable <Projection <TValue> > Accept <TValue>(ProjectionVisitor <TValue> visitor, ProjectionVisitor <TValue> .Arguments args, GraphDirection direction) => visitor.Visit(this, args, direction);
 private void RestoreDefaults()
 {
     transitionLabels = TransitionLabel.Action;
     nodeLabelsVisible = true;
     initialStateColor = new Color("LightGray");
     hoverColor = new Color("Lime");
     selectionColor = new Color("Blue");
     livenessCheckIsOn = false;
     deadStateColor = new Color("Yellow");
     safetyCheckIsOn = false;
     unsafeStateColor = new Color("Red");
     maxTransitions = 100;
     loopsVisible = true;
     mergeLabels = true;
     acceptingStatesMarked = true;
     stateShape = StateShape.Ellipse;
     direction = GraphDirection.TopToBottom;
     combineActions = false;
     excludeIsomorphicStates = false;
     collapseExcludedIsomorphicStates = false;
 }
Exemple #24
0
        public static string GenerateDotGraph(GraphDirection direction, object root)
        {
            var dotGraph = Pooling.StringBuilderPool.Scoped(sb =>
            {
                var vb = Pooling.StringBuilderPool.Get();
                var nb = Pooling.StringBuilderPool.Get();
                var cb = Pooling.StringBuilderPool.Get();

                var clusters = 0;

                var dir = direction switch
                {
                    GraphDirection.LeftToRight => "LR",
                    GraphDirection.RightToLeft => "RL",
                    GraphDirection.TopToBottom => "TB",
                    GraphDirection.BottomToTop => "BT",
                    _ => throw new ArgumentOutOfRangeException(nameof(direction), direction, null)
                };

                try
                {
                    var rootType  = root.GetType();
                    var graphName = rootType.TryGetAttribute(true, out DisplayNameAttribute display)
                                                ? display.DisplayName
                                                : rootType.Name;

                    sb.AppendLine($"digraph \"{graphName}\" {{");
                    sb.AppendLine($"\trankdir=\"{dir}\"");
                    sb.AppendLine($"\tgraph[layout=dot,label=\"{graphName}\"];");
                    sb.AppendLine("\tnode[style=filled,shape=box];");

                    if (root is IEnumerable enumerable)
                    {
                        foreach (var item in enumerable)
                        {
                            WalkGraph(item, ref clusters, vb, nb, cb);
                        }
                    }
                    else
                    {
                        WalkGraph(root, ref clusters, vb, nb, cb);
                    }

                    if (nb.Length > 0)
                    {
                        sb.AppendLine();
                        sb.AppendLine("\t// nodes:");
                        sb.Append(nb.ToString());
                    }

                    if (cb.Length > 0)
                    {
                        sb.AppendLine();
                        sb.AppendLine("\t// clusters:");
                        sb.Append(cb.ToString());
                    }

                    if (vb.Length > 0)
                    {
                        sb.AppendLine();
                        sb.AppendLine("\t// vertices:");
                        sb.Append(vb.ToString());
                    }

                    sb.AppendLine("}");
                }
                finally
                {
                    Pooling.StringBuilderPool.Return(vb);
                    Pooling.StringBuilderPool.Return(nb);
                }
            });

            return(dotGraph);
        }
        private void buildGraph(int depth, GraphDirection dir, int index)
        {
            var iSize = world.mapWidth;
            var jSize = world.mapHeight;

            if (dir == GraphDirection.Y)
            {
                Utility.Swap(ref iSize, ref jSize);
            }

            var iStart = 0;

            if (index != -1)
            {
                iStart = index;
                iSize  = index + 1;
            }

            for (int i = iStart; i < iSize; i++)
            {
                if (dir == GraphDirection.X)
                {
                    navGraph[depth].ClearX(i);
                }
                else
                {
                    navGraph[depth].ClearY(i);
                }

                var hasUp   = false;
                var hasDown = false;
                var current = -1;
                for (int j = 0; j < jSize; j++)
                {
                    var block = dir == GraphDirection.X ? world.getTile(i, j, depth) : world.getTile(j, i, depth);
                    //var desc = block.wallDescriptor;
                    if (block.isWalkable)
                    {
                        //if(desc.AllowsMovementUp)
                        if (current == -1)
                        {
                            current = j;
                        }
                    }
                    else if (current != -1)
                    {
                        if (dir == GraphDirection.X)
                        {
                            navGraph[depth].AddSegmentX(current, new NavSegment(current, j - 1));
                        }
                        else
                        {
                            navGraph[depth].AddSegmentY(current, new NavSegment(current, j - 1));
                        }

                        current = -1;
                        hasUp   = false;
                        hasDown = false;
                    }
                }

                if (current != -1)
                {
                    if (dir == GraphDirection.X)
                    {
                        navGraph[depth].AddSegmentX(current, new NavSegment(current, jSize - 1));
                    }
                    else
                    {
                        navGraph[depth].AddSegmentY(current, new NavSegment(current, jSize - 1));
                    }
                }
            }
        }
        /// <summary>
        /// 根据指定的方向绘制一个箭头
        /// </summary>
        /// <param name="g"></param>
        /// <param name="brush"></param>
        /// <param name="point"></param>
        /// <param name="size"></param>
        /// <param name="direction"></param>
        public static void PaintTriangle(Graphics g, Brush brush, Point point, int size, GraphDirection direction)
        {
            Point[] points = new Point[4];
            if (direction == GraphDirection.Ledtward)
            {
                points[0] = new Point(point.X, point.Y - size);
                points[1] = new Point(point.X, point.Y + size);
                points[2] = new Point(point.X - 2 * size, point.Y);
            }
            else if (direction == GraphDirection.Rightward)
            {
                points[0] = new Point(point.X, point.Y - size);
                points[1] = new Point(point.X, point.Y + size);
                points[2] = new Point(point.X + 2 * size, point.Y);
            }
            else if (direction == GraphDirection.Upward)
            {
                points[0] = new Point(point.X - size, point.Y);
                points[1] = new Point(point.X + size, point.Y);
                points[2] = new Point(point.X, point.Y - 2 * size);
            }
            else
            {
                points[0] = new Point(point.X - size, point.Y);
                points[1] = new Point(point.X + size, point.Y);
                points[2] = new Point(point.X, point.Y + 2 * size);
            }

            points[3] = points[0];
            g.FillPolygon(brush, points);
        }
Exemple #27
0
 public abstract IEnumerable <Projection <TValue> > Accept <TValue>(ProjectionVisitor <TValue> visitor, ProjectionVisitor <TValue> .Arguments args, GraphDirection direction);
Exemple #28
0
 private GraphDirection GetReverseDirection(GraphDirection direction)
 {
     return((GraphDirection)(3 - (int)direction));
 }
    /// <summary>
    /// Add neighbours in a given direction
    /// </summary>
    /// <param name="id">Node id of the neighbour</param>
    /// <param name="direction">Direction in which the neighbour will be located</param>
    public void AddNeighbour(int id, GraphDirection direction)
    {
        int dir = (int)direction;

        neighbours[dir] = id;
    }
Exemple #30
0
        /// <summary>
        /// Paints the triangle.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="brush">The brush.</param>
        /// <param name="point">The point.</param>
        /// <param name="size">The size.</param>
        /// <param name="direction">The direction.</param>
        public static void PaintTriangle(Graphics g, System.Drawing.Brush brush, PointF point, int size, GraphDirection direction)
        {
            PointF[] array = new PointF[4];
            switch (direction)
            {
            case GraphDirection.Leftward:
                array[0] = new PointF(point.X, point.Y - (float)size);
                array[1] = new PointF(point.X, point.Y + (float)size);
                array[2] = new PointF(point.X - (float)(2 * size), point.Y);
                break;

            case GraphDirection.Rightward:
                array[0] = new PointF(point.X, point.Y - (float)size);
                array[1] = new PointF(point.X, point.Y + (float)size);
                array[2] = new PointF(point.X + (float)(2 * size), point.Y);
                break;

            case GraphDirection.Upward:
                array[0] = new PointF(point.X - (float)size, point.Y);
                array[1] = new PointF(point.X + (float)size, point.Y);
                array[2] = new PointF(point.X, point.Y - (float)(2 * size));
                break;

            default:
                array[0] = new PointF(point.X - (float)size, point.Y);
                array[1] = new PointF(point.X + (float)size, point.Y);
                array[2] = new PointF(point.X, point.Y + (float)(2 * size));
                break;
            }
            array[3] = array[0];
            g.FillPolygon(brush, array);
        }
 private void buildGraph(int depth, GraphDirection dir)
 {
     buildGraph(depth, dir, -1);
 }